hridoy-ultimate 8.0.2 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -40
- package/LICENSE +23 -0
- package/MERGE_REPORT.md +54 -0
- package/README.md +158 -113
- package/THIRD_PARTY_NOTICES.md +36 -0
- package/docs/TEST_RESULTS.md +68 -0
- package/docs/UPSTREAM_API_DOCS.md +2712 -0
- package/func/checkUpdate.js +6 -0
- package/func/logAdapter.js +33 -0
- package/func/logger.js +48 -0
- package/index.d.ts +812 -0
- package/index.js +30 -824
- package/module/config.js +46 -0
- package/module/login.js +136 -0
- package/module/loginHelper.js +1413 -0
- package/module/options.js +55 -0
- package/package.json +75 -22
- package/scripts/run-tests.js +19 -0
- package/scripts/syntax-check.js +22 -0
- package/src/{addExternalModule.js → api/action/addExternalModule.js} +8 -8
- package/src/{changeAvatar.js → api/action/changeAvatar.js} +32 -33
- package/src/{changeBio.js → api/action/changeBio.js} +19 -22
- package/src/api/action/dismissScrapingWarning.js +50 -0
- package/src/api/action/enableAutoSaveAppState.js +73 -0
- package/src/{getCurrentUserID.js → api/action/getCurrentUserID.js} +1 -1
- package/src/api/action/handleFriendRequest.js +57 -0
- package/src/api/action/logout.js +95 -0
- package/src/api/action/refreshFb_dtsg.js +47 -0
- package/src/{setPostReaction.js → api/action/setPostReaction.js} +23 -31
- package/src/{unfriend.js → api/action/unfriend.js} +14 -14
- package/src/api/http/httpGet.js +46 -0
- package/src/api/http/httpPost.js +52 -0
- package/src/api/http/postFormData.js +47 -0
- package/src/api/messaging/addUserToGroup.js +68 -0
- package/src/api/messaging/changeAdminStatus.js +126 -0
- package/src/{changeArchivedStatus.js → api/messaging/changeArchivedStatus.js} +15 -17
- package/src/{changeBlockedStatus.js → api/messaging/changeBlockedStatus.js} +13 -16
- package/src/api/messaging/changeGroupImage.js +91 -0
- package/src/api/messaging/changeNickname.js +70 -0
- package/src/api/messaging/changeThreadColor.js +79 -0
- package/src/api/messaging/changeThreadEmoji.js +111 -0
- package/src/{createNewGroup.js → api/messaging/createNewGroup.js} +24 -26
- package/src/api/messaging/createPoll.js +46 -0
- package/src/api/messaging/createThemeAI.js +98 -0
- package/src/api/messaging/deleteMessage.js +136 -0
- package/src/{deleteThread.js → api/messaging/deleteThread.js} +14 -16
- package/src/api/messaging/editMessage.js +105 -0
- package/src/api/messaging/forwardAttachment.js +57 -0
- package/src/api/messaging/forwardMessage.js +134 -0
- package/src/{getEmojiUrl.js → api/messaging/getEmojiUrl.js} +2 -2
- package/src/{getFriendsList.js → api/messaging/getFriendsList.js} +16 -19
- package/src/{getMessage.js → api/messaging/getMessage.js} +160 -180
- package/src/api/messaging/getThemePictures.js +62 -0
- package/src/api/messaging/handleMessageRequest.js +65 -0
- package/src/api/messaging/markAsDelivered.js +69 -0
- package/src/api/messaging/markAsRead.js +110 -0
- package/src/api/messaging/markAsReadAll.js +56 -0
- package/src/api/messaging/markAsSeen.js +68 -0
- package/src/api/messaging/muteThread.js +50 -0
- package/src/api/messaging/pinMessage.js +115 -0
- package/src/api/messaging/removeUserFromGroup.js +62 -0
- package/src/{resolvePhotoUrl.js → api/messaging/resolvePhotoUrl.js} +11 -15
- package/src/api/messaging/scheduler.js +264 -0
- package/src/{searchForThread.js → api/messaging/searchForThread.js} +12 -12
- package/src/api/messaging/sendBroadcast.js +93 -0
- package/src/api/messaging/sendMessage.js +269 -0
- package/src/api/messaging/sendTypingIndicator.js +90 -0
- package/src/api/messaging/sessionGuard.js +130 -0
- package/src/api/messaging/setMessageReaction.js +114 -0
- package/src/api/messaging/setTitle.js +124 -0
- package/src/api/messaging/shareContact.js +98 -0
- package/src/{threadColors.js → api/messaging/threadColors.js} +2 -5
- package/src/api/messaging/unsendMessage.js +105 -0
- package/src/api/messaging/uploadAttachment.js +493 -0
- package/src/api/socket/OldMessage.js +199 -0
- package/src/api/socket/core/connectMqtt.js +304 -0
- package/src/api/socket/core/emitAuth.js +95 -0
- package/src/api/socket/core/getSeqID.js +331 -0
- package/src/api/socket/core/getTaskResponseData.js +25 -0
- package/src/api/socket/core/lifecycle.js +117 -0
- package/src/api/socket/core/parseDelta.js +387 -0
- package/src/api/socket/detail/buildStream.js +215 -0
- package/src/api/socket/detail/constants.js +28 -0
- package/src/api/socket/e2ee/crypto.js +173 -0
- package/src/api/socket/e2ee/index.js +977 -0
- package/src/api/socket/e2ee/localMediaServer.js +59 -0
- package/src/api/socket/e2ee/mediaDecode.js +155 -0
- package/src/api/socket/e2ee/native/NOTICE.md +29 -0
- package/{lib → src/api/socket/e2ee/native/lib}/index.mjs +109 -66
- package/src/api/socket/e2ee/native/nativeMediaBridge.js +273 -0
- package/src/api/socket/e2ee/proto/ArmadilloApplication.proto +281 -0
- package/src/api/socket/e2ee/proto/ArmadilloICDC.proto +14 -0
- package/src/api/socket/e2ee/proto/ConsumerApplication.proto +232 -0
- package/src/api/socket/e2ee/proto/MessageApplication.proto +82 -0
- package/src/api/socket/e2ee/proto/MessageTransport.proto +77 -0
- package/src/api/socket/e2ee/proto/WACommon.proto +66 -0
- package/src/api/socket/e2ee/proto/WAMediaTransport.proto +176 -0
- package/src/api/socket/e2ee/proto/proto-writer.ts +76 -0
- package/src/api/socket/e2ee/protocol.js +196 -0
- package/src/api/socket/e2ee/ratchet.js +219 -0
- package/src/api/socket/e2ee/store.js +182 -0
- package/src/api/socket/e2ee/vendor/fme/dist/index.cjs +6477 -0
- package/src/api/socket/e2ee/vendor/fme/proto/ArmadilloApplication.proto +281 -0
- package/src/api/socket/e2ee/vendor/fme/proto/ArmadilloICDC.proto +14 -0
- package/src/api/socket/e2ee/vendor/fme/proto/ConsumerApplication.proto +232 -0
- package/src/api/socket/e2ee/vendor/fme/proto/MessageApplication.proto +82 -0
- package/src/api/socket/e2ee/vendor/fme/proto/MessageTransport.proto +77 -0
- package/src/api/socket/e2ee/vendor/fme/proto/WACommon.proto +66 -0
- package/src/api/socket/e2ee/vendor/fme/proto/WAMediaTransport.proto +176 -0
- package/src/api/socket/listenE2EE.js +87 -0
- package/src/api/socket/listenMqtt.js +499 -0
- package/src/api/socket/middleware/index.js +216 -0
- package/src/api/socket/sendMessage.js +331 -0
- package/src/api/socket/sendMessageMqtt.js +69 -0
- package/src/{getThreadHistory.js → api/threads/getThreadHistory.js} +114 -132
- package/src/api/threads/getThreadInfo.js +329 -0
- package/src/api/threads/getThreadList.js +293 -0
- package/src/api/threads/getThreadPictures.js +78 -0
- package/src/{getUserID.js → api/users/getUserID.js} +22 -18
- package/src/api/users/getUserInfo.js +402 -0
- package/src/api/users/getUserInfoV2.js +134 -0
- package/src/app/MessengerBot.js +209 -0
- package/src/app/MessengerContext.js +32 -0
- package/src/app/createFcaClient.js +136 -0
- package/src/app/threadInfoRealtimeSync.js +284 -0
- package/src/core/sendReqMqtt.js +96 -0
- package/src/database/helpers.js +53 -0
- package/src/database/models/index.js +88 -0
- package/src/database/models/thread.js +50 -0
- package/src/database/models/user.js +46 -0
- package/src/database/threadData.js +94 -0
- package/src/database/userData.js +98 -0
- package/src/remote/remoteClient.js +123 -0
- package/src/utils/antiSuspension.js +219 -0
- package/src/utils/broadcast.js +51 -0
- package/src/utils/client.js +10 -0
- package/src/utils/constants.js +23 -0
- package/src/utils/cookies.js +85 -0
- package/src/utils/fingerprint.js +110 -0
- package/src/utils/format/attachment.js +357 -0
- package/src/utils/format/cookie.js +9 -0
- package/src/utils/format/date.js +50 -0
- package/src/utils/format/decode.js +44 -0
- package/src/utils/format/delta.js +195 -0
- package/src/utils/format/ids.js +64 -0
- package/src/utils/format/index.js +64 -0
- package/src/utils/format/message.js +88 -0
- package/src/utils/format/presence.js +132 -0
- package/src/utils/format/readTyp.js +44 -0
- package/src/utils/format/thread.js +42 -0
- package/src/utils/format/utils.js +141 -0
- package/src/utils/headers.js +125 -0
- package/src/utils/humanizer.js +256 -0
- package/src/utils/loginParser/autoLogin.js +125 -0
- package/src/utils/loginParser/extractDtsg.js +44 -0
- package/src/utils/loginParser/helpers.js +43 -0
- package/src/utils/loginParser/index.js +10 -0
- package/src/utils/loginParser/parseAndCheckLogin.js +241 -0
- package/src/utils/loginParser/textUtils.js +28 -0
- package/src/utils/nexca-logger.js +144 -0
- package/src/utils/nexca-utils.js +687 -0
- package/src/utils/request/client.js +26 -0
- package/src/utils/request/config.js +23 -0
- package/src/utils/request/defaults.js +46 -0
- package/src/utils/request/helpers.js +46 -0
- package/src/utils/request/index.js +17 -0
- package/src/utils/request/methods.js +163 -0
- package/src/utils/request/proxy.js +21 -0
- package/src/utils/request/retry.js +77 -0
- package/src/utils/request/sanitize.js +49 -0
- package/src/utils/typingIndicator.js +202 -0
- package/test/helpers/stub-modules.js +122 -0
- package/test/integration/logout.test.js +69 -0
- package/test/integration/mqtt-lifecycle.test.js +195 -0
- package/test/integration/package.test.js +116 -0
- package/test/integration/typing-wiring.test.js +71 -0
- package/test/unit/fingerprint.test.js +19 -0
- package/test/unit/humanizer.test.js +32 -0
- package/test/unit/lifecycle.test.js +92 -0
- package/test/unit/parsers.test.js +43 -0
- package/test/unit/typing.test.js +136 -0
- package/ANALYSIS.md +0 -31
- package/AUDIT_REPORT.md +0 -57
- package/advancedSystem.js +0 -95
- package/checkUpdate.js +0 -47
- package/config.json +0 -51
- package/e2ee.js +0 -738
- package/examples/basic-bot.js +0 -122
- package/examples/e2ee-bot.js +0 -141
- package/fca-config.example.json +0 -73
- package/scripts/check.js +0 -38
- package/src/OldMessage.js +0 -357
- package/src/addUserToGroup.js +0 -117
- package/src/changeAdminStatus.js +0 -105
- package/src/changeAvatarV2.js +0 -86
- package/src/changeAvt.js +0 -85
- package/src/changeBlockedStatusMqtt.js +0 -75
- package/src/changeCover.js +0 -73
- package/src/changeGroupImage.js +0 -137
- package/src/changeName.js +0 -79
- package/src/changeNickname.js +0 -61
- package/src/changeThreadColor.js +0 -67
- package/src/changeThreadEmoji.js +0 -57
- package/src/changeUsername.js +0 -59
- package/src/createCommentPost.js +0 -232
- package/src/createPoll.js +0 -73
- package/src/createPost.js +0 -276
- package/src/deleteMessage.js +0 -58
- package/src/editMessage.js +0 -76
- package/src/editMessageOld.js +0 -62
- package/src/follow.js +0 -74
- package/src/forwardAttachment.js +0 -62
- package/src/friendList.js +0 -104
- package/src/getAccess.js +0 -112
- package/src/getAvatarUser.js +0 -78
- package/src/getBotInitialData.js +0 -42
- package/src/getCtx.js +0 -5
- package/src/getOptions.js +0 -5
- package/src/getRegion.js +0 -7
- package/src/getThreadHistoryDeprecated.js +0 -71
- package/src/getThreadInfo.js +0 -232
- package/src/getThreadInfoDeprecated.js +0 -56
- package/src/getThreadList.js +0 -213
- package/src/getThreadListDeprecated.js +0 -46
- package/src/getThreadPictures.js +0 -59
- package/src/getThreadTheme.js +0 -81
- package/src/getUID.js +0 -119
- package/src/getUserInfo.js +0 -66
- package/src/handleFriendRequest.js +0 -46
- package/src/handleMessageRequest.js +0 -47
- package/src/httpGet.js +0 -49
- package/src/httpPost.js +0 -48
- package/src/httpPostFormData.js +0 -70
- package/src/listenMqtt.js +0 -1081
- package/src/listenNotification.js +0 -85
- package/src/logout.js +0 -18
- package/src/markAsDelivered.js +0 -47
- package/src/markAsRead.js +0 -72
- package/src/markAsReadAll.js +0 -40
- package/src/markAsSeen.js +0 -48
- package/src/metaTheme.js +0 -189
- package/src/muteThread.js +0 -45
- package/src/note.js +0 -228
- package/src/pinMessage.js +0 -54
- package/src/refreshFb_dtsg.js +0 -49
- package/src/removeSuspiciousAccount.js +0 -78
- package/src/removeUserFromGroup.js +0 -81
- package/src/reply.js +0 -442
- package/src/searchFriends.js +0 -140
- package/src/searchStickers.js +0 -53
- package/src/send.js +0 -46
- package/src/sendButtons.js +0 -163
- package/src/sendComment.js +0 -159
- package/src/sendFriendRequest.js +0 -112
- package/src/sendMessage.js +0 -441
- package/src/sendMessageMqtt.js +0 -323
- package/src/sendTypingIndicator.js +0 -68
- package/src/sendTypingIndicatorV2.js +0 -22
- package/src/setActiveStatus.js +0 -92
- package/src/setMessageReaction.js +0 -150
- package/src/setMessageReactionMqtt.js +0 -104
- package/src/setMessageReactionSafe.js +0 -44
- package/src/setProfileGuard.js +0 -44
- package/src/setProfileLock.js +0 -97
- package/src/setStoryReaction.js +0 -133
- package/src/setStorySeen.js +0 -108
- package/src/setThreadTheme.js +0 -102
- package/src/setTitle.js +0 -92
- package/src/shareContact.js +0 -110
- package/src/shareLink.js +0 -59
- package/src/stopListenMqtt.js +0 -60
- package/src/storyManager.js +0 -357
- package/src/suggestFriend.js +0 -132
- package/src/unsendMessage.js +0 -68
- package/src/uploadAttachment.js +0 -115
- package/test/fixes-1_2_4.test.js +0 -118
- package/test/mqtt-stop.test.js +0 -32
- package/test/reaction-mqtt.test.js +0 -57
- package/utils.js +0 -3056
- /package/{build → src/api/socket/e2ee/native/build}/messagix.dll +0 -0
- /package/{build → src/api/socket/e2ee/native/build}/messagix.so +0 -0
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
// @NethWs3Dev
|
|
7
|
-
|
|
3
|
+
const log = require("../../../func/logAdapter");
|
|
4
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
|
5
|
+
const { getAdminTextMessageType } = require("../../utils/format");
|
|
8
6
|
function getExtension(original_extension, filename = "") {
|
|
9
7
|
if (original_extension) {
|
|
10
8
|
return original_extension;
|
|
@@ -27,7 +25,7 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
27
25
|
filename: attachment.filename,
|
|
28
26
|
original_extension: getExtension(
|
|
29
27
|
attachment.original_extension,
|
|
30
|
-
attachment.filename
|
|
28
|
+
attachment.filename
|
|
31
29
|
),
|
|
32
30
|
thumbnailUrl: attachment.thumbnail.uri,
|
|
33
31
|
|
|
@@ -50,26 +48,9 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
50
48
|
? {
|
|
51
49
|
attributionAppID: attachment.attribution_app.id,
|
|
52
50
|
name: attachment.attribution_app.name,
|
|
53
|
-
logo: attachment.attribution_app.square_logo
|
|
51
|
+
logo: attachment.attribution_app.square_logo
|
|
54
52
|
}
|
|
55
|
-
: null
|
|
56
|
-
|
|
57
|
-
// @TODO No idea what this is, should we expose it?
|
|
58
|
-
// Ben - July 15th 2017
|
|
59
|
-
// renderAsSticker: attachment.render_as_sticker,
|
|
60
|
-
|
|
61
|
-
// This is _not_ the real URI, this is still just a large preview.
|
|
62
|
-
// To get the URL we'll need to support a POST query to
|
|
63
|
-
//
|
|
64
|
-
// https://www.facebook.com/webgraphql/query/
|
|
65
|
-
//
|
|
66
|
-
// With the following query params:
|
|
67
|
-
//
|
|
68
|
-
// query_id:728987990612546
|
|
69
|
-
// variables:{"id":"100009069356507","photoID":"10213724771692996"}
|
|
70
|
-
// dpr:1
|
|
71
|
-
//
|
|
72
|
-
// No special form though.
|
|
53
|
+
: null
|
|
73
54
|
};
|
|
74
55
|
case "MessageAnimatedImage":
|
|
75
56
|
return {
|
|
@@ -78,7 +59,7 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
78
59
|
filename: attachment.filename,
|
|
79
60
|
original_extension: getExtension(
|
|
80
61
|
attachment.original_extension,
|
|
81
|
-
attachment.filename
|
|
62
|
+
attachment.filename
|
|
82
63
|
),
|
|
83
64
|
|
|
84
65
|
previewUrl: attachment.preview_image.uri,
|
|
@@ -103,9 +84,9 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
103
84
|
? {
|
|
104
85
|
attributionAppID: attachment.attribution_app.id,
|
|
105
86
|
name: attachment.attribution_app.name,
|
|
106
|
-
logo: attachment.attribution_app.square_logo
|
|
87
|
+
logo: attachment.attribution_app.square_logo
|
|
107
88
|
}
|
|
108
|
-
: null
|
|
89
|
+
: null
|
|
109
90
|
};
|
|
110
91
|
case "MessageVideo":
|
|
111
92
|
return {
|
|
@@ -114,7 +95,7 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
114
95
|
filename: attachment.filename,
|
|
115
96
|
original_extension: getExtension(
|
|
116
97
|
attachment.original_extension,
|
|
117
|
-
attachment.filename
|
|
98
|
+
attachment.filename
|
|
118
99
|
),
|
|
119
100
|
duration: attachment.playable_duration_in_ms,
|
|
120
101
|
|
|
@@ -128,7 +109,7 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
128
109
|
width: attachment.original_dimensions.x,
|
|
129
110
|
height: attachment.original_dimensions.y,
|
|
130
111
|
|
|
131
|
-
videoType: attachment.video_type.toLowerCase()
|
|
112
|
+
videoType: attachment.video_type.toLowerCase()
|
|
132
113
|
};
|
|
133
114
|
case "MessageFile":
|
|
134
115
|
return {
|
|
@@ -137,7 +118,7 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
137
118
|
filename: attachment.filename,
|
|
138
119
|
original_extension: getExtension(
|
|
139
120
|
attachment.original_extension,
|
|
140
|
-
attachment.filename
|
|
121
|
+
attachment.filename
|
|
141
122
|
),
|
|
142
123
|
|
|
143
124
|
url: attachment.url,
|
|
@@ -146,7 +127,7 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
146
127
|
|
|
147
128
|
name: attachment.filename, // @Legacy
|
|
148
129
|
mimeType: "", // @Legacy
|
|
149
|
-
fileSize: -1
|
|
130
|
+
fileSize: -1 // @Legacy
|
|
150
131
|
};
|
|
151
132
|
case "MessageAudio":
|
|
152
133
|
return {
|
|
@@ -155,18 +136,18 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
155
136
|
filename: attachment.filename,
|
|
156
137
|
original_extension: getExtension(
|
|
157
138
|
attachment.original_extension,
|
|
158
|
-
attachment.filename
|
|
139
|
+
attachment.filename
|
|
159
140
|
),
|
|
160
141
|
|
|
161
142
|
duration: attachment.playable_duration_in_ms,
|
|
162
143
|
audioType: attachment.audio_type,
|
|
163
144
|
url: attachment.playable_url,
|
|
164
145
|
|
|
165
|
-
isVoiceMail: attachment.is_voicemail
|
|
146
|
+
isVoiceMail: attachment.is_voicemail
|
|
166
147
|
};
|
|
167
148
|
default:
|
|
168
149
|
return {
|
|
169
|
-
error: "Don't know about attachment type " + attachment.__typename
|
|
150
|
+
error: "Don't know about attachment type " + attachment.__typename
|
|
170
151
|
};
|
|
171
152
|
}
|
|
172
153
|
}
|
|
@@ -191,32 +172,32 @@ function formatExtensibleAttachment(attachment) {
|
|
|
191
172
|
attachment.story_attachment.media == null
|
|
192
173
|
? null
|
|
193
174
|
: attachment.story_attachment.media.animated_image == null &&
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
175
|
+
attachment.story_attachment.media.image == null
|
|
176
|
+
? null
|
|
177
|
+
: (
|
|
178
|
+
attachment.story_attachment.media.animated_image ||
|
|
179
|
+
attachment.story_attachment.media.image
|
|
180
|
+
).uri,
|
|
200
181
|
width:
|
|
201
182
|
attachment.story_attachment.media == null
|
|
202
183
|
? null
|
|
203
184
|
: attachment.story_attachment.media.animated_image == null &&
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
185
|
+
attachment.story_attachment.media.image == null
|
|
186
|
+
? null
|
|
187
|
+
: (
|
|
188
|
+
attachment.story_attachment.media.animated_image ||
|
|
189
|
+
attachment.story_attachment.media.image
|
|
190
|
+
).width,
|
|
210
191
|
height:
|
|
211
192
|
attachment.story_attachment.media == null
|
|
212
193
|
? null
|
|
213
194
|
: attachment.story_attachment.media.animated_image == null &&
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
195
|
+
attachment.story_attachment.media.image == null
|
|
196
|
+
? null
|
|
197
|
+
: (
|
|
198
|
+
attachment.story_attachment.media.animated_image ||
|
|
199
|
+
attachment.story_attachment.media.image
|
|
200
|
+
).height,
|
|
220
201
|
playable:
|
|
221
202
|
attachment.story_attachment.media == null
|
|
222
203
|
? null
|
|
@@ -245,13 +226,14 @@ function formatExtensibleAttachment(attachment) {
|
|
|
245
226
|
// width: "1280"
|
|
246
227
|
// }
|
|
247
228
|
//
|
|
248
|
-
properties: attachment.story_attachment.properties.reduce(function
|
|
229
|
+
properties: attachment.story_attachment.properties.reduce(function(
|
|
249
230
|
obj,
|
|
250
|
-
cur
|
|
231
|
+
cur
|
|
251
232
|
) {
|
|
252
233
|
obj[cur.key] = cur.value.text;
|
|
253
234
|
return obj;
|
|
254
|
-
},
|
|
235
|
+
},
|
|
236
|
+
{}),
|
|
255
237
|
|
|
256
238
|
// Deprecated fields
|
|
257
239
|
animatedImageSize: "", // @Legacy
|
|
@@ -262,32 +244,32 @@ function formatExtensibleAttachment(attachment) {
|
|
|
262
244
|
attachment.story_attachment.media == null
|
|
263
245
|
? null
|
|
264
246
|
: attachment.story_attachment.media.animated_image == null &&
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
247
|
+
attachment.story_attachment.media.image == null
|
|
248
|
+
? null
|
|
249
|
+
: (
|
|
250
|
+
attachment.story_attachment.media.animated_image ||
|
|
251
|
+
attachment.story_attachment.media.image
|
|
252
|
+
).uri, // @Legacy
|
|
271
253
|
thumbnailWidth:
|
|
272
254
|
attachment.story_attachment.media == null
|
|
273
255
|
? null
|
|
274
256
|
: attachment.story_attachment.media.animated_image == null &&
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
257
|
+
attachment.story_attachment.media.image == null
|
|
258
|
+
? null
|
|
259
|
+
: (
|
|
260
|
+
attachment.story_attachment.media.animated_image ||
|
|
261
|
+
attachment.story_attachment.media.image
|
|
262
|
+
).width, // @Legacy
|
|
281
263
|
thumbnailHeight:
|
|
282
264
|
attachment.story_attachment.media == null
|
|
283
265
|
? null
|
|
284
266
|
: attachment.story_attachment.media.animated_image == null &&
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
267
|
+
attachment.story_attachment.media.image == null
|
|
268
|
+
? null
|
|
269
|
+
: (
|
|
270
|
+
attachment.story_attachment.media.animated_image ||
|
|
271
|
+
attachment.story_attachment.media.image
|
|
272
|
+
).height // @Legacy
|
|
291
273
|
};
|
|
292
274
|
} else {
|
|
293
275
|
return { error: "Don't know what to do with extensible_attachment." };
|
|
@@ -297,7 +279,7 @@ function formatExtensibleAttachment(attachment) {
|
|
|
297
279
|
function formatReactionsGraphQL(reaction) {
|
|
298
280
|
return {
|
|
299
281
|
reaction: reaction.reaction,
|
|
300
|
-
userID: reaction.user.id
|
|
282
|
+
userID: reaction.user.id
|
|
301
283
|
};
|
|
302
284
|
}
|
|
303
285
|
|
|
@@ -309,16 +291,16 @@ function formatEventData(event) {
|
|
|
309
291
|
switch (event.__typename) {
|
|
310
292
|
case "ThemeColorExtensibleMessageAdminText":
|
|
311
293
|
return {
|
|
312
|
-
color: event.theme_color
|
|
294
|
+
color: event.theme_color
|
|
313
295
|
};
|
|
314
296
|
case "ThreadNicknameExtensibleMessageAdminText":
|
|
315
297
|
return {
|
|
316
298
|
nickname: event.nickname,
|
|
317
|
-
participantID: event.participant_id
|
|
299
|
+
participantID: event.participant_id
|
|
318
300
|
};
|
|
319
301
|
case "ThreadIconExtensibleMessageAdminText":
|
|
320
302
|
return {
|
|
321
|
-
threadIcon: event.thread_icon
|
|
303
|
+
threadIcon: event.thread_icon
|
|
322
304
|
};
|
|
323
305
|
case "InstantGameUpdateExtensibleMessageAdminText":
|
|
324
306
|
return {
|
|
@@ -326,45 +308,45 @@ function formatEventData(event) {
|
|
|
326
308
|
update_type: event.update_type,
|
|
327
309
|
collapsed_text: event.collapsed_text,
|
|
328
310
|
expanded_text: event.expanded_text,
|
|
329
|
-
instant_game_update_data: event.instant_game_update_data
|
|
311
|
+
instant_game_update_data: event.instant_game_update_data
|
|
330
312
|
};
|
|
331
313
|
case "GameScoreExtensibleMessageAdminText":
|
|
332
314
|
return {
|
|
333
|
-
game_type: event.game_type
|
|
315
|
+
game_type: event.game_type
|
|
334
316
|
};
|
|
335
317
|
case "RtcCallLogExtensibleMessageAdminText":
|
|
336
318
|
return {
|
|
337
319
|
event: event.event,
|
|
338
320
|
is_video_call: event.is_video_call,
|
|
339
|
-
server_info_data: event.server_info_data
|
|
321
|
+
server_info_data: event.server_info_data
|
|
340
322
|
};
|
|
341
323
|
case "GroupPollExtensibleMessageAdminText":
|
|
342
324
|
return {
|
|
343
325
|
event_type: event.event_type,
|
|
344
326
|
total_count: event.total_count,
|
|
345
|
-
question: event.question
|
|
327
|
+
question: event.question
|
|
346
328
|
};
|
|
347
329
|
case "AcceptPendingThreadExtensibleMessageAdminText":
|
|
348
330
|
return {
|
|
349
331
|
accepter_id: event.accepter_id,
|
|
350
|
-
requester_id: event.requester_id
|
|
332
|
+
requester_id: event.requester_id
|
|
351
333
|
};
|
|
352
334
|
case "ConfirmFriendRequestExtensibleMessageAdminText":
|
|
353
335
|
return {
|
|
354
336
|
friend_request_recipient: event.friend_request_recipient,
|
|
355
|
-
friend_request_sender: event.friend_request_sender
|
|
337
|
+
friend_request_sender: event.friend_request_sender
|
|
356
338
|
};
|
|
357
339
|
case "AddContactExtensibleMessageAdminText":
|
|
358
340
|
return {
|
|
359
341
|
contact_added_id: event.contact_added_id,
|
|
360
|
-
contact_adder_id: event.contact_adder_id
|
|
342
|
+
contact_adder_id: event.contact_adder_id
|
|
361
343
|
};
|
|
362
344
|
case "AdExtensibleMessageAdminText":
|
|
363
345
|
return {
|
|
364
346
|
ad_client_token: event.ad_client_token,
|
|
365
347
|
ad_id: event.ad_id,
|
|
366
348
|
ad_preferences_link: event.ad_preferences_link,
|
|
367
|
-
ad_properties: event.ad_properties
|
|
349
|
+
ad_properties: event.ad_properties
|
|
368
350
|
};
|
|
369
351
|
// never data
|
|
370
352
|
case "ParticipantJoinedGroupCallExtensibleMessageAdminText":
|
|
@@ -380,7 +362,7 @@ function formatEventData(event) {
|
|
|
380
362
|
return {};
|
|
381
363
|
default:
|
|
382
364
|
return {
|
|
383
|
-
error: "Don't know what to with event data type " + event.__typename
|
|
365
|
+
error: "Don't know what to with event data type " + event.__typename
|
|
384
366
|
};
|
|
385
367
|
}
|
|
386
368
|
}
|
|
@@ -391,7 +373,7 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
391
373
|
? messageThread.thread_key.thread_fbid
|
|
392
374
|
: messageThread.thread_key.other_user_id;
|
|
393
375
|
|
|
394
|
-
const messages = messageThread.messages.nodes.map(function
|
|
376
|
+
const messages = messageThread.messages.nodes.map(function(d) {
|
|
395
377
|
switch (d.__typename) {
|
|
396
378
|
case "UserMessage":
|
|
397
379
|
// Give priority to stickers. They're seen as normal messages but we've
|
|
@@ -420,17 +402,17 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
420
402
|
|
|
421
403
|
stickerID: d.sticker.id, // @Legacy
|
|
422
404
|
spriteURI: d.sticker.sprite_image, // @Legacy
|
|
423
|
-
spriteURI2x: d.sticker.sprite_image_2x
|
|
424
|
-
}
|
|
405
|
+
spriteURI2x: d.sticker.sprite_image_2x // @Legacy
|
|
406
|
+
}
|
|
425
407
|
];
|
|
426
408
|
}
|
|
427
409
|
|
|
428
410
|
var mentionsObj = {};
|
|
429
411
|
if (d.message !== null) {
|
|
430
|
-
d.message.ranges.forEach(
|
|
412
|
+
d.message.ranges.forEach(e => {
|
|
431
413
|
mentionsObj[e.entity.id] = d.message.text.substr(
|
|
432
414
|
e.offset,
|
|
433
|
-
e.length
|
|
415
|
+
e.length
|
|
434
416
|
);
|
|
435
417
|
});
|
|
436
418
|
}
|
|
@@ -440,10 +422,10 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
440
422
|
attachments: maybeStickerAttachment
|
|
441
423
|
? maybeStickerAttachment
|
|
442
424
|
: d.blob_attachments && d.blob_attachments.length > 0
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
425
|
+
? d.blob_attachments.map(formatAttachmentsGraphQLResponse)
|
|
426
|
+
: d.extensible_attachment
|
|
427
|
+
? [formatExtensibleAttachment(d.extensible_attachment)]
|
|
428
|
+
: [],
|
|
447
429
|
body: d.message !== null ? d.message.text : "",
|
|
448
430
|
isGroup: messageThread.thread_type === "GROUP",
|
|
449
431
|
messageID: d.message_id,
|
|
@@ -459,7 +441,7 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
459
441
|
? d.message_reactions.map(formatReactionsGraphQL)
|
|
460
442
|
: null,
|
|
461
443
|
isSponsored: d.is_sponsored,
|
|
462
|
-
snippet: d.snippet
|
|
444
|
+
snippet: d.snippet
|
|
463
445
|
};
|
|
464
446
|
case "ThreadNameMessage":
|
|
465
447
|
return {
|
|
@@ -472,13 +454,13 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
472
454
|
eventType: "change_thread_name",
|
|
473
455
|
snippet: d.snippet,
|
|
474
456
|
eventData: {
|
|
475
|
-
threadName: d.thread_name
|
|
457
|
+
threadName: d.thread_name
|
|
476
458
|
},
|
|
477
459
|
|
|
478
460
|
// @Legacy
|
|
479
461
|
author: d.message_sender.id,
|
|
480
462
|
logMessageType: "log:thread-name",
|
|
481
|
-
logMessageData: { name: d.thread_name }
|
|
463
|
+
logMessageData: { name: d.thread_name }
|
|
482
464
|
};
|
|
483
465
|
case "ThreadImageMessage":
|
|
484
466
|
return {
|
|
@@ -499,8 +481,8 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
499
481
|
attachmentID: d.image_with_metadata.legacy_attachment_id,
|
|
500
482
|
width: d.image_with_metadata.original_dimensions.x,
|
|
501
483
|
height: d.image_with_metadata.original_dimensions.y,
|
|
502
|
-
url: d.image_with_metadata.preview.uri
|
|
503
|
-
}
|
|
484
|
+
url: d.image_with_metadata.preview.uri
|
|
485
|
+
}
|
|
504
486
|
},
|
|
505
487
|
|
|
506
488
|
// @Legacy
|
|
@@ -508,8 +490,8 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
508
490
|
logMessageData: {
|
|
509
491
|
thread_icon: d.image_with_metadata
|
|
510
492
|
? d.image_with_metadata.preview.uri
|
|
511
|
-
: null
|
|
512
|
-
}
|
|
493
|
+
: null
|
|
494
|
+
}
|
|
513
495
|
};
|
|
514
496
|
case "ParticipantLeftMessage":
|
|
515
497
|
return {
|
|
@@ -523,18 +505,18 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
523
505
|
snippet: d.snippet,
|
|
524
506
|
eventData: {
|
|
525
507
|
// Array of IDs.
|
|
526
|
-
participantsRemoved: d.participants_removed.map(function
|
|
508
|
+
participantsRemoved: d.participants_removed.map(function(p) {
|
|
527
509
|
return p.id;
|
|
528
|
-
})
|
|
510
|
+
})
|
|
529
511
|
},
|
|
530
512
|
|
|
531
513
|
// @Legacy
|
|
532
514
|
logMessageType: "log:unsubscribe",
|
|
533
515
|
logMessageData: {
|
|
534
|
-
leftParticipantFbId: d.participants_removed.map(function
|
|
516
|
+
leftParticipantFbId: d.participants_removed.map(function(p) {
|
|
535
517
|
return p.id;
|
|
536
|
-
})
|
|
537
|
-
}
|
|
518
|
+
})
|
|
519
|
+
}
|
|
538
520
|
};
|
|
539
521
|
case "ParticipantsAddedMessage":
|
|
540
522
|
return {
|
|
@@ -548,18 +530,18 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
548
530
|
snippet: d.snippet,
|
|
549
531
|
eventData: {
|
|
550
532
|
// Array of IDs.
|
|
551
|
-
participantsAdded: d.participants_added.map(function
|
|
533
|
+
participantsAdded: d.participants_added.map(function(p) {
|
|
552
534
|
return p.id;
|
|
553
|
-
})
|
|
535
|
+
})
|
|
554
536
|
},
|
|
555
537
|
|
|
556
538
|
// @Legacy
|
|
557
539
|
logMessageType: "log:subscribe",
|
|
558
540
|
logMessageData: {
|
|
559
|
-
addedParticipants: d.participants_added.map(function
|
|
541
|
+
addedParticipants: d.participants_added.map(function(p) {
|
|
560
542
|
return p.id;
|
|
561
|
-
})
|
|
562
|
-
}
|
|
543
|
+
})
|
|
544
|
+
}
|
|
563
545
|
};
|
|
564
546
|
case "VideoCallMessage":
|
|
565
547
|
return {
|
|
@@ -573,7 +555,7 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
573
555
|
snippet: d.snippet,
|
|
574
556
|
|
|
575
557
|
// @Legacy
|
|
576
|
-
logMessageType: "other"
|
|
558
|
+
logMessageType: "other"
|
|
577
559
|
};
|
|
578
560
|
case "VoiceCallMessage":
|
|
579
561
|
return {
|
|
@@ -587,7 +569,7 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
587
569
|
snippet: d.snippet,
|
|
588
570
|
|
|
589
571
|
// @Legacy
|
|
590
|
-
logMessageType: "other"
|
|
572
|
+
logMessageType: "other"
|
|
591
573
|
};
|
|
592
574
|
case "GenericAdminTextMessage":
|
|
593
575
|
return {
|
|
@@ -602,10 +584,10 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
602
584
|
eventData: formatEventData(d.extensible_message_admin_text),
|
|
603
585
|
|
|
604
586
|
// @Legacy
|
|
605
|
-
logMessageType:
|
|
606
|
-
d.extensible_message_admin_text_type
|
|
587
|
+
logMessageType: getAdminTextMessageType(
|
|
588
|
+
d.extensible_message_admin_text_type
|
|
607
589
|
),
|
|
608
|
-
logMessageData: d.extensible_message_admin_text
|
|
590
|
+
logMessageData: d.extensible_message_admin_text // Maybe different?
|
|
609
591
|
};
|
|
610
592
|
default:
|
|
611
593
|
return { error: "Don't know about message type " + d.__typename };
|
|
@@ -614,22 +596,22 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
614
596
|
return messages;
|
|
615
597
|
}
|
|
616
598
|
|
|
617
|
-
module.exports = function
|
|
599
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
618
600
|
return function getThreadHistoryGraphQL(
|
|
619
601
|
threadID,
|
|
620
602
|
amount,
|
|
621
603
|
timestamp,
|
|
622
|
-
callback
|
|
604
|
+
callback
|
|
623
605
|
) {
|
|
624
|
-
let resolveFunc = function
|
|
625
|
-
let rejectFunc = function
|
|
626
|
-
const returnPromise = new Promise(function
|
|
606
|
+
let resolveFunc = function() {};
|
|
607
|
+
let rejectFunc = function() {};
|
|
608
|
+
const returnPromise = new Promise(function(resolve, reject) {
|
|
627
609
|
resolveFunc = resolve;
|
|
628
610
|
rejectFunc = reject;
|
|
629
611
|
});
|
|
630
612
|
|
|
631
613
|
if (!callback) {
|
|
632
|
-
callback = function
|
|
614
|
+
callback = function(err, data) {
|
|
633
615
|
if (err) {
|
|
634
616
|
return rejectFunc(err);
|
|
635
617
|
}
|
|
@@ -640,7 +622,7 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
640
622
|
// `queries` has to be a string. I couldn't tell from the dev console. This
|
|
641
623
|
// took me a really long time to figure out. I deserve a cookie for this.
|
|
642
624
|
const form = {
|
|
643
|
-
av: ctx.
|
|
625
|
+
av: ctx.userID,
|
|
644
626
|
queries: JSON.stringify({
|
|
645
627
|
o0: {
|
|
646
628
|
// This doc_id was valid on February 2nd 2017.
|
|
@@ -650,16 +632,16 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
650
632
|
message_limit: amount,
|
|
651
633
|
load_messages: 1,
|
|
652
634
|
load_read_receipts: false,
|
|
653
|
-
before: timestamp
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
})
|
|
635
|
+
before: timestamp
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
})
|
|
657
639
|
};
|
|
658
640
|
|
|
659
641
|
defaultFuncs
|
|
660
642
|
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
|
661
|
-
.then(
|
|
662
|
-
.then(function
|
|
643
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
644
|
+
.then(function(resData) {
|
|
663
645
|
if (resData.error) {
|
|
664
646
|
throw resData;
|
|
665
647
|
}
|
|
@@ -672,7 +654,7 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
672
654
|
|
|
673
655
|
callback(null, formatMessagesGraphQLResponse(resData[0]));
|
|
674
656
|
})
|
|
675
|
-
.catch(function
|
|
657
|
+
.catch(function(err) {
|
|
676
658
|
log.error("getThreadHistoryGraphQL", err);
|
|
677
659
|
return callback(err);
|
|
678
660
|
});
|