/pidgin/main: ad2ee74b913a: facebook: ignore messages which are ...
James Geboski <[email protected]>
| Newsgroups | gmane.comp.gnome.gaim.cvs |
|---|---|
| Message-ID | <[email protected]> |
Changeset: ad2ee74b913ae50e170b1d06413fa2a494a9ee76 Author: James Geboski <[email protected]> Date: 2016-01-07 14:06 -0500 Branch: default URL: https://hg.pidgin.im/pidgin/main/rev/ad2ee74b913a Description: facebook: ignore messages which are sequentially duplicated Sometimes Facebook will sent a batch of duplicated messages over the MQTT stream. There are occasions where Facebook will send duplicated messages which are not sequential, however, it does not occur at the rete of the sequential duplication. This is likely due to the fact that the plugin is using an older revision of the Messenger protocol. For now, we should attempt to ignore sequential duplicates from being from being display. This fix is not bullet proof, but it is simple, and should cut down on the duplicated message spam. The proper fix is likely going to be to update the plugin to use a more recent Messenger protocol revision. diffstat: libpurple/protocols/facebook/api.c | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diffs (53 lines): diff --git a/libpurple/protocols/facebook/api.c b/libpurple/protocols/facebook/api.c --- a/libpurple/protocols/facebook/api.c +++ b/libpurple/protocols/facebook/api.c @@ -67,7 +67,7 @@ struct _FbApiPrivate GQueue *msgs; gboolean invisible; guint unread; - + FbId lastmid; }; struct _FbApiData @@ -1493,6 +1493,8 @@ fb_api_cb_publish_ms(FbApi *api, GByteAr values = fb_json_values_new(root); fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE, + "$.deltaNewMessage.messageMetadata.offlineThreadingId"); + fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE, "$.deltaNewMessage.messageMetadata.actorFbId"); fb_json_values_add(values, FB_JSON_TYPE_INT, FALSE, "$.deltaNewMessage.messageMetadata" @@ -1511,6 +1513,20 @@ fb_api_cb_publish_ms(FbApi *api, GByteAr fb_json_values_set_array(values, TRUE, "$.deltas"); while (fb_json_values_update(values, &err)) { + id = fb_json_values_next_int(values, 0); + + /* Ignore everything but new messages */ + if (id == 0) { + continue; + } + + /* Ignore sequential duplicates */ + if (id == priv->lastmid) { + fb_util_debug_info("Ignoring duplicate %" FB_ID_FORMAT, id); + continue; + } + + priv->lastmid = id; fb_api_message_reset(&msg, FALSE); msg.uid = fb_json_values_next_int(values, 0); oid = fb_json_values_next_int(values, 0); @@ -1525,10 +1541,6 @@ fb_api_cb_publish_ms(FbApi *api, GByteAr } } - if (msg.uid == 0) { - continue; - } - body = fb_json_values_next_str(values, NULL); if (body != NULL) { _______________________________________________ Commits mailing list [email protected] https://pidgin.im/cgi-bin/mailman/listinfo/commits