From dfd5141e73ea838b09d671efba06f7554cff567d Mon Sep 17 00:00:00 2001 From: Winston Ametsitsi Date: Mon, 19 Mar 2018 20:29:29 -0700 Subject: [PATCH 1/3] fix showing messages correctly when messages include attachment/photo --- scripts/pull.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/pull.js b/scripts/pull.js index 3fe2c07..d1e50ec 100644 --- a/scripts/pull.js +++ b/scripts/pull.js @@ -153,6 +153,15 @@ class Pull extends EventEmitter { }); } } + } else if (att.mercury.blob_attachment.__typename === 'MessageImage') { + this.emit('message', { + type: 'msg', + author: ms.delta.messageMetadata.actorFbId, + otherUserId: ms.delta.messageMetadata.threadKey.otherUserFbId, + threadId: ms.delta.messageMetadata.threadKey.threadFbId, + timestamp: ms.delta.messageMetadata.timestamp, + attachment: att.mercury.blob_attachment + }); } } } else if (ms.delta.class === 'AdminTextMessage') { From 660f80257ef487c917482ef9f55f8d003006de96 Mon Sep 17 00:00:00 2001 From: Winston Ametsitsi Date: Mon, 19 Mar 2018 20:47:14 -0700 Subject: [PATCH 2/3] fix handling animated images sent in messages --- scripts/pull.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/pull.js b/scripts/pull.js index d1e50ec..802c320 100644 --- a/scripts/pull.js +++ b/scripts/pull.js @@ -157,6 +157,17 @@ class Pull extends EventEmitter { this.emit('message', { type: 'msg', author: ms.delta.messageMetadata.actorFbId, + body: 'sent an image ', + otherUserId: ms.delta.messageMetadata.threadKey.otherUserFbId, + threadId: ms.delta.messageMetadata.threadKey.threadFbId, + timestamp: ms.delta.messageMetadata.timestamp, + attachment: att.mercury.blob_attachment + }); + } else if (att.mercury.blob_attachment.__typename === 'MessageAnimatedImage') { + this.emit('message', { + type: 'msg', + author: ms.delta.messageMetadata.actorFbId, + body: 'sent a gif ', otherUserId: ms.delta.messageMetadata.threadKey.otherUserFbId, threadId: ms.delta.messageMetadata.threadKey.threadFbId, timestamp: ms.delta.messageMetadata.timestamp, From 67d65ad59447503236042bd2e8f5ead9de283b4c Mon Sep 17 00:00:00 2001 From: Winston Ametsitsi Date: Thu, 22 Mar 2018 00:57:27 -0700 Subject: [PATCH 3/3] show image, gif, and stickers on initial thread load the same as live show sent stickers in live view properly with link --- scripts/messenger.js | 12 ++++++++++++ scripts/pull.js | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/scripts/messenger.js b/scripts/messenger.js index abef6da..94b3e94 100644 --- a/scripts/messenger.js +++ b/scripts/messenger.js @@ -342,6 +342,18 @@ class Messenger { if (m.blob_attachments) { obj.attachment = m.blob_attachments[0]; + + if (obj.body == "" && m.blob_attachments[0]) { + if (m.blob_attachments[0].__typename === "MessageImage") { + obj.body = 'sent an image '; + } else if (m.blob_attachments[0].__typename === "MessageAnimatedImage") { + obj.body = 'sent a gif '; + } + } + } + if (m.sticker) { + obj.body += 'sent a sticker: ' + m.sticker.label + ' '; + obj.attachment = m.sticker; } data.push(obj); } diff --git a/scripts/pull.js b/scripts/pull.js index 802c320..3542bf2 100644 --- a/scripts/pull.js +++ b/scripts/pull.js @@ -116,6 +116,18 @@ class Pull extends EventEmitter { }); } else if (ms.delta.attachments !== undefined) { const att = ms.delta.attachments[0]; + if (att.mercury.sticker_attachment !== undefined) { + this.emit('message', { + type: 'msg', + author: ms.delta.messageMetadata.actorFbId, + body: 'sent a sticker: ' + att.mercury.sticker_attachment.label + ' ', + otherUserId: ms.delta.messageMetadata.threadKey.otherUserFbId, + threadId: ms.delta.messageMetadata.threadKey.threadFbId, + timestamp: ms.delta.messageMetadata.timestamp, + attachment: att.mercury.sticker_attachment + }); + } + if (att.mercury.attach_type === 'animated_image') { this.emit('message', { type: 'msg',