bitlbee-facebook
bitlbee-facebook copied to clipboard
Only fetch unread messages when connecting
Currently unread messages will be fetched when connecting and when changing to/from away when show_unread
is true
. This can lead to duplicate messages being delivered if messages are not automatically marked as read.
With this patch unread messages are only fetched when connecting when show_unread
is true
.
The variable should be better named now.
I think this might be a bad idea. If a user is silently reconnected (the only time this patch is useful), and a message is received while being reconnected, the message is lost. This patch really needs to factor in the current value of the mark_read
set. This is also a bug in the current code as well, as it does not factor in the value of mark_read
.
You have a point about reconnects, I didn't think about silent reconnects for other reasons than changing from available to away and back.
Maybe there somewhere I can store a flag to be used when reconnecting because of changing to/from away? It's not perfect, but it's a lot easier than keeping track of the last message received.
I'm not sure how you mean I should take the value of mark_read
into account here, the only way I can imagine is to only "mask out" these messages when mark_read
is false
. I don't know if that's what you meant though.
Maybe there somewhere I can store a flag to be used when reconnecting because of changing to/from away? It's not perfect, but it's a lot easier than keeping track of the last message received.
If you only want this functionality as a result of switching the away state, then I would just wait for the protocol update. Facebook has added a way to switch the visibility state without having to reconnect the MQTT stream. See purple-facebook/issues#227 (patches are cross applied to this plugin).
But to answer the question, you could add a fb_api_is_retrying()
function which returns priv->retrying
, then factor that into the conditional expression. The value of priv->retrying
will be TRUE
in the fb_cb_api_connect()
function if the call is the result of a silent reconnect.
I'm not sure how you mean I should take the value of mark_read into account here, the only way I can imagine is to only "mask out" these messages when mark_read is false. I don't know if that's what you meant though.
Disregard. I think the best solution here is to just have the set values check the other set values, and ensure that if show_unread
is true
that mark_read
is not false
. I mentioned this in #69, but again, outside the scope of both of the PRs.