aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjgeboski <jgeboski@gmail.com>2016-01-07 14:06:04 -0500
committerjgeboski <jgeboski@gmail.com>2016-01-07 14:08:13 -0500
commit1952710b5c31c9e6a4c5f2e431e75db9ca5f9f0d (patch)
treefc22a6627664321c8fe25f64a05977bd411a80f1
parentccca2da9588ac6b9375ecbeef75af414948e7b4b (diff)
downloadbitlbee-facebook-1952710b5c31c9e6a4c5f2e431e75db9ca5f9f0d.tar.gz
bitlbee-facebook-1952710b5c31c9e6a4c5f2e431e75db9ca5f9f0d.tar.bz2
bitlbee-facebook-1952710b5c31c9e6a4c5f2e431e75db9ca5f9f0d.tar.xz
facebook-api: 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.
-rw-r--r--facebook/facebook-api.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/facebook/facebook-api.c b/facebook/facebook-api.c
index dc22bea..4344cf8 100644
--- a/facebook/facebook-api.c
+++ b/facebook/facebook-api.c
@@ -60,7 +60,7 @@ struct _FbApiPrivate
GQueue *msgs;
gboolean invisible;
guint unread;
-
+ FbId lastmid;
};
struct _FbApiData
@@ -1439,6 +1439,8 @@ fb_api_cb_publish_ms(FbApi *api, GByteArray *pload)
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"
@@ -1457,6 +1459,20 @@ fb_api_cb_publish_ms(FbApi *api, GByteArray *pload)
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);
@@ -1471,10 +1487,6 @@ fb_api_cb_publish_ms(FbApi *api, GByteArray *pload)
}
}
- if (msg.uid == 0) {
- continue;
- }
-
body = fb_json_values_next_str(values, NULL);
if (body != NULL) {