fca-arif-babu 1.0.21 → 8.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.
Files changed (152) hide show
  1. package/Extra/Balancer.js +49 -0
  2. package/Extra/Bypass/956/index.js +234 -0
  3. package/Extra/Bypass/test/aaaa.json +169 -0
  4. package/Extra/Bypass/test/index.js +188 -0
  5. package/Extra/Database/index.js +469 -0
  6. package/Extra/ExtraAddons.js +82 -0
  7. package/Extra/ExtraFindUID.js +62 -0
  8. package/Extra/ExtraGetThread.js +365 -0
  9. package/Extra/ExtraScreenShot.js +430 -0
  10. package/Extra/ExtraUptimeRobot.js +38 -0
  11. package/Extra/Html/Classic/script.js +119 -0
  12. package/Extra/Html/Classic/style.css +8 -0
  13. package/Extra/Security/AES_256_GCM/index.js +1 -0
  14. package/Extra/Security/Base/Step_1.js +6 -0
  15. package/Extra/Security/Base/Step_2.js +22 -0
  16. package/Extra/Security/Base/Step_3.js +22 -0
  17. package/Extra/Security/Base/index.js +191 -0
  18. package/Extra/Security/Step_1.js +6 -0
  19. package/Extra/Security/Step_2.js +22 -0
  20. package/Extra/Security/Step_3.js +22 -0
  21. package/Extra/Security/index.js +5 -0
  22. package/Extra/Src/Change_Environment.js +24 -0
  23. package/Extra/Src/Check_Update.js +67 -0
  24. package/Extra/Src/History.js +115 -0
  25. package/Extra/Src/Instant_Update.js +65 -0
  26. package/Extra/Src/Last-Run.js +65 -0
  27. package/Extra/Src/Premium.js +81 -0
  28. package/Extra/Src/Release_Memory.js +160 -0
  29. package/Extra/Src/Websocket.js +213 -0
  30. package/Extra/Src/image/62518eafb0670b697788ce4f9a4f71d1.jpg +0 -0
  31. package/Extra/Src/test.js +28 -0
  32. package/Extra/Src/uuid.js +137 -0
  33. package/Func/AcceptAgreement.js +31 -0
  34. package/Func/ClearCache.js +64 -0
  35. package/Func/ReportV1.js +54 -0
  36. package/{LICENSE-MIT → LICENSE.txt} +6 -6
  37. package/Language/index.json +228 -0
  38. package/Main.js +1290 -0
  39. package/README.md +8 -6
  40. package/SECURITY.md +17 -0
  41. package/broadcast.js +44 -0
  42. package/index.js +424 -465
  43. package/logger.js +66 -0
  44. package/package.json +91 -42
  45. package/src/Dev_Horizon_Data.js +125 -0
  46. package/src/Dev_getThreadInfoOLD.js +422 -0
  47. package/src/Dev_shareTest2.js +68 -0
  48. package/src/Dev_shareTest3.js +71 -0
  49. package/src/Premium.js +25 -0
  50. package/src/Screenshot.js +83 -0
  51. package/src/addExternalModule.js +5 -14
  52. package/src/addUserToGroup.js +21 -57
  53. package/src/changeAdminStatus.js +22 -46
  54. package/src/changeArchivedStatus.js +12 -26
  55. package/src/{changeAvatarV2.js → changeAvt.js} +2 -3
  56. package/src/changeBio.js +15 -26
  57. package/src/changeBlockedStatus.js +9 -22
  58. package/src/changeGroupImage.js +26 -55
  59. package/src/changeNickname.js +14 -28
  60. package/src/changeThreadColor.js +19 -22
  61. package/src/changeThreadEmoji.js +12 -25
  62. package/src/createNewGroup.js +18 -36
  63. package/src/createPoll.js +17 -28
  64. package/src/deleteMessage.js +14 -25
  65. package/src/deleteThread.js +13 -26
  66. package/src/editMessage.js +50 -56
  67. package/src/forwardAttachment.js +16 -28
  68. package/src/getAccessToken.js +28 -0
  69. package/src/getCurrentUserID.js +3 -3
  70. package/src/getEmojiUrl.js +8 -10
  71. package/src/getFriendsList.js +15 -25
  72. package/src/getMessage.js +81 -813
  73. package/src/getThreadHistory.js +98 -241
  74. package/src/getThreadInfo.js +286 -89
  75. package/src/getThreadInfoOLD.js +422 -0
  76. package/src/getThreadList.js +158 -215
  77. package/src/getThreadMain.js +220 -0
  78. package/src/getThreadPictures.js +20 -40
  79. package/src/getUID.js +49 -112
  80. package/src/getUserID.js +14 -18
  81. package/src/getUserInfo.js +75 -34
  82. package/src/getUserInfoMain.js +65 -0
  83. package/src/getUserInfoV2.js +32 -0
  84. package/src/getUserInfoV3.js +63 -0
  85. package/src/getUserInfoV4.js +55 -0
  86. package/src/getUserInfoV5.js +61 -0
  87. package/src/handleFriendRequest.js +14 -25
  88. package/src/handleMessageRequest.js +21 -37
  89. package/src/httpGet.js +22 -37
  90. package/src/httpPost.js +20 -36
  91. package/src/httpPostFormData.js +23 -52
  92. package/src/listenMqtt.js +667 -414
  93. package/src/listenMqttV1.js +846 -0
  94. package/src/logout.js +17 -24
  95. package/src/markAsDelivered.js +16 -23
  96. package/src/markAsRead.js +28 -43
  97. package/src/markAsReadAll.js +14 -21
  98. package/src/markAsSeen.js +19 -29
  99. package/src/muteThread.js +13 -18
  100. package/src/removeUserFromGroup.js +18 -48
  101. package/src/resolvePhotoUrl.js +14 -22
  102. package/src/searchForThread.js +13 -23
  103. package/src/sendMessage.js +125 -181
  104. package/src/sendMqttMessage.js +71 -0
  105. package/src/sendTypingIndicator.js +80 -28
  106. package/src/setMessageReaction.js +20 -33
  107. package/src/setPostReaction.js +95 -105
  108. package/src/setTitle.js +19 -35
  109. package/src/shareContact.js +37 -92
  110. package/src/shareLink.js +5 -6
  111. package/src/threadColors.js +17 -109
  112. package/src/unfriend.js +11 -20
  113. package/src/unsendMessage.js +33 -30
  114. package/src/unsendMqttMessage.js +66 -0
  115. package/test/data/shareAttach.js +146 -0
  116. package/test/data/something.mov +1 -0
  117. package/test/data/test.png +1 -0
  118. package/test/data/test.txt +1 -0
  119. package/test/env/.env +1 -0
  120. package/test/example-config.json +18 -0
  121. package/test/test-page.js +140 -0
  122. package/test/test.js +385 -0
  123. package/test/testv2.js +3 -0
  124. package/utils.js +2908 -1247
  125. package/replit.nix +0 -3
  126. package/src/changeAvatar.js +0 -136
  127. package/src/changeBlockedStatusMqtt.js +0 -80
  128. package/src/changeCover.js +0 -72
  129. package/src/changeName.js +0 -78
  130. package/src/changeUsername.js +0 -58
  131. package/src/createCommentPost.js +0 -229
  132. package/src/createPost.js +0 -275
  133. package/src/data/getThreadInfo.json +0 -1
  134. package/src/editMessageOld.js +0 -67
  135. package/src/follow.js +0 -74
  136. package/src/getAccess.js +0 -112
  137. package/src/getAvatarUser.js +0 -78
  138. package/src/getBotInitialData.js +0 -42
  139. package/src/getRegion.js +0 -7
  140. package/src/getThreadHistoryDeprecated.js +0 -93
  141. package/src/getThreadInfoDeprecated.js +0 -80
  142. package/src/getThreadListDeprecated.js +0 -75
  143. package/src/listenNotification.js +0 -85
  144. package/src/pinMessage.js +0 -59
  145. package/src/refreshFb_dtsg.js +0 -89
  146. package/src/searchStickers.js +0 -53
  147. package/src/sendMessageMqtt.js +0 -316
  148. package/src/setMessageReactionMqtt.js +0 -62
  149. package/src/setProfileGuard.js +0 -44
  150. package/src/setStoryReaction.js +0 -64
  151. package/src/stopListenMqtt.js +0 -23
  152. package/src/uploadAttachment.js +0 -94
@@ -1,20 +1,7 @@
1
1
  "use strict";
2
2
 
3
- const utils = require("../utils");
4
- // @NethWs3Dev
5
-
6
- function getExtension(original_extension, filename = "") {
7
- if (original_extension) {
8
- return original_extension;
9
- } else {
10
- const extension = filename.split(".").pop();
11
- if (extension === filename) {
12
- return "";
13
- } else {
14
- return extension;
15
- }
16
- }
17
- }
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
18
5
 
19
6
  function formatAttachmentsGraphQLResponse(attachment) {
20
7
  switch (attachment.__typename) {
@@ -23,10 +10,6 @@ function formatAttachmentsGraphQLResponse(attachment) {
23
10
  type: "photo",
24
11
  ID: attachment.legacy_attachment_id,
25
12
  filename: attachment.filename,
26
- original_extension: getExtension(
27
- attachment.original_extension,
28
- attachment.filename,
29
- ),
30
13
  thumbnailUrl: attachment.thumbnail.uri,
31
14
 
32
15
  previewUrl: attachment.preview.uri,
@@ -46,11 +29,11 @@ function formatAttachmentsGraphQLResponse(attachment) {
46
29
  // @Undocumented
47
30
  attributionApp: attachment.attribution_app
48
31
  ? {
49
- attributionAppID: attachment.attribution_app.id,
50
- name: attachment.attribution_app.name,
51
- logo: attachment.attribution_app.square_logo,
52
- }
53
- : null,
32
+ attributionAppID: attachment.attribution_app.id,
33
+ name: attachment.attribution_app.name,
34
+ logo: attachment.attribution_app.square_logo
35
+ }
36
+ : null
54
37
 
55
38
  // @TODO No idea what this is, should we expose it?
56
39
  // Ben - July 15th 2017
@@ -74,10 +57,6 @@ function formatAttachmentsGraphQLResponse(attachment) {
74
57
  type: "animated_image",
75
58
  ID: attachment.legacy_attachment_id,
76
59
  filename: attachment.filename,
77
- original_extension: getExtension(
78
- attachment.original_extension,
79
- attachment.filename,
80
- ),
81
60
 
82
61
  previewUrl: attachment.preview_image.uri,
83
62
  previewWidth: attachment.preview_image.width,
@@ -99,22 +78,17 @@ function formatAttachmentsGraphQLResponse(attachment) {
99
78
  // @Undocumented
100
79
  attributionApp: attachment.attribution_app
101
80
  ? {
102
- attributionAppID: attachment.attribution_app.id,
103
- name: attachment.attribution_app.name,
104
- logo: attachment.attribution_app.square_logo,
105
- }
106
- : null,
81
+ attributionAppID: attachment.attribution_app.id,
82
+ name: attachment.attribution_app.name,
83
+ logo: attachment.attribution_app.square_logo
84
+ }
85
+ : null
107
86
  };
108
87
  case "MessageVideo":
109
88
  return {
110
89
  type: "video",
111
- ID: attachment.legacy_attachment_id,
112
90
  filename: attachment.filename,
113
- original_extension: getExtension(
114
- attachment.original_extension,
115
- attachment.filename,
116
- ),
117
- duration: attachment.playable_duration_in_ms,
91
+ ID: attachment.legacy_attachment_id,
118
92
 
119
93
  thumbnailUrl: attachment.large_image.uri, // @Legacy
120
94
 
@@ -126,17 +100,14 @@ function formatAttachmentsGraphQLResponse(attachment) {
126
100
  width: attachment.original_dimensions.x,
127
101
  height: attachment.original_dimensions.y,
128
102
 
129
- videoType: attachment.video_type.toLowerCase(),
103
+ duration: attachment.playable_duration_in_ms,
104
+ videoType: attachment.video_type.toLowerCase()
130
105
  };
131
106
  case "MessageFile":
132
107
  return {
133
108
  type: "file",
134
- ID: attachment.message_file_fbid,
135
109
  filename: attachment.filename,
136
- original_extension: getExtension(
137
- attachment.original_extension,
138
- attachment.filename,
139
- ),
110
+ ID: attachment.message_file_fbid,
140
111
 
141
112
  url: attachment.url,
142
113
  isMalicious: attachment.is_malicious,
@@ -144,27 +115,23 @@ function formatAttachmentsGraphQLResponse(attachment) {
144
115
 
145
116
  name: attachment.filename, // @Legacy
146
117
  mimeType: "", // @Legacy
147
- fileSize: -1, // @Legacy
118
+ fileSize: -1 // @Legacy
148
119
  };
149
120
  case "MessageAudio":
150
121
  return {
151
122
  type: "audio",
152
- ID: attachment.url_shimhash, // Not fowardable
153
123
  filename: attachment.filename,
154
- original_extension: getExtension(
155
- attachment.original_extension,
156
- attachment.filename,
157
- ),
124
+ ID: attachment.url_shimhash, // Not fowardable
158
125
 
159
- duration: attachment.playable_duration_in_ms,
160
126
  audioType: attachment.audio_type,
127
+ duration: attachment.playable_duration_in_ms,
161
128
  url: attachment.playable_url,
162
129
 
163
- isVoiceMail: attachment.is_voicemail,
130
+ isVoiceMail: attachment.is_voicemail
164
131
  };
165
132
  default:
166
133
  return {
167
- error: "Don't know about attachment type " + attachment.__typename,
134
+ error: "Don't know about attachment type " + attachment.__typename
168
135
  };
169
136
  }
170
137
  }
@@ -177,56 +144,15 @@ function formatExtensibleAttachment(attachment) {
177
144
  url: attachment.story_attachment.url,
178
145
 
179
146
  title: attachment.story_attachment.title_with_entities.text,
180
- description:
181
- attachment.story_attachment.description &&
182
- attachment.story_attachment.description.text,
183
- source:
184
- attachment.story_attachment.source == null
185
- ? null
186
- : attachment.story_attachment.source.text,
187
-
188
- image:
189
- attachment.story_attachment.media == null
190
- ? null
191
- : attachment.story_attachment.media.animated_image == null &&
192
- attachment.story_attachment.media.image == null
193
- ? null
194
- : (
195
- attachment.story_attachment.media.animated_image ||
196
- attachment.story_attachment.media.image
197
- ).uri,
198
- width:
199
- attachment.story_attachment.media == null
200
- ? null
201
- : attachment.story_attachment.media.animated_image == null &&
202
- attachment.story_attachment.media.image == null
203
- ? null
204
- : (
205
- attachment.story_attachment.media.animated_image ||
206
- attachment.story_attachment.media.image
207
- ).width,
208
- height:
209
- attachment.story_attachment.media == null
210
- ? null
211
- : attachment.story_attachment.media.animated_image == null &&
212
- attachment.story_attachment.media.image == null
213
- ? null
214
- : (
215
- attachment.story_attachment.media.animated_image ||
216
- attachment.story_attachment.media.image
217
- ).height,
218
- playable:
219
- attachment.story_attachment.media == null
220
- ? null
221
- : attachment.story_attachment.media.is_playable,
222
- duration:
223
- attachment.story_attachment.media == null
224
- ? null
225
- : attachment.story_attachment.media.playable_duration_in_ms,
226
- playableUrl:
227
- attachment.story_attachment.media == null
228
- ? null
229
- : attachment.story_attachment.media.playable_url,
147
+ description: attachment.story_attachment.description && attachment.story_attachment.description.text,
148
+ source: attachment.story_attachment.source == null ? null : attachment.story_attachment.source.text,
149
+
150
+ image: attachment.story_attachment.media == null ? null : attachment.story_attachment.media.animated_image == null && attachment.story_attachment.media.image == null ? null : (attachment.story_attachment.media.animated_image || attachment.story_attachment.media.image).uri,
151
+ width: attachment.story_attachment.media == null ? null : attachment.story_attachment.media.animated_image == null && attachment.story_attachment.media.image == null ? null : (attachment.story_attachment.media.animated_image || attachment.story_attachment.media.image).width,
152
+ height: attachment.story_attachment.media == null ? null : attachment.story_attachment.media.animated_image == null && attachment.story_attachment.media.image == null ? null : (attachment.story_attachment.media.animated_image || attachment.story_attachment.media.image).height,
153
+ playable: attachment.story_attachment.media == null ? null : attachment.story_attachment.media.is_playable,
154
+ duration: attachment.story_attachment.media == null ? null : attachment.story_attachment.media.playable_duration_in_ms,
155
+ playableUrl: attachment.story_attachment.media == null ? null : attachment.story_attachment.media.playable_url,
230
156
 
231
157
  subattachments: attachment.story_attachment.subattachments,
232
158
 
@@ -243,10 +169,7 @@ function formatExtensibleAttachment(attachment) {
243
169
  // width: "1280"
244
170
  // }
245
171
  //
246
- properties: attachment.story_attachment.properties.reduce(function (
247
- obj,
248
- cur,
249
- ) {
172
+ properties: attachment.story_attachment.properties.reduce(function (obj, cur) {
250
173
  obj[cur.key] = cur.value.text;
251
174
  return obj;
252
175
  }, {}),
@@ -256,113 +179,77 @@ function formatExtensibleAttachment(attachment) {
256
179
  facebookUrl: "", // @Legacy
257
180
  styleList: "", // @Legacy
258
181
  target: "", // @Legacy
259
- thumbnailUrl:
260
- attachment.story_attachment.media == null
261
- ? null
262
- : attachment.story_attachment.media.animated_image == null &&
263
- attachment.story_attachment.media.image == null
264
- ? null
265
- : (
266
- attachment.story_attachment.media.animated_image ||
267
- attachment.story_attachment.media.image
268
- ).uri, // @Legacy
269
- thumbnailWidth:
270
- attachment.story_attachment.media == null
271
- ? null
272
- : attachment.story_attachment.media.animated_image == null &&
273
- attachment.story_attachment.media.image == null
274
- ? null
275
- : (
276
- attachment.story_attachment.media.animated_image ||
277
- attachment.story_attachment.media.image
278
- ).width, // @Legacy
279
- thumbnailHeight:
280
- attachment.story_attachment.media == null
281
- ? null
282
- : attachment.story_attachment.media.animated_image == null &&
283
- attachment.story_attachment.media.image == null
284
- ? null
285
- : (
286
- attachment.story_attachment.media.animated_image ||
287
- attachment.story_attachment.media.image
288
- ).height, // @Legacy
182
+ thumbnailUrl: attachment.story_attachment.media == null ? null : attachment.story_attachment.media.animated_image == null && attachment.story_attachment.media.image == null ? null : (attachment.story_attachment.media.animated_image || attachment.story_attachment.media.image).uri, // @Legacy
183
+ thumbnailWidth: attachment.story_attachment.media == null ? null : attachment.story_attachment.media.animated_image == null && attachment.story_attachment.media.image == null ? null : (attachment.story_attachment.media.animated_image || attachment.story_attachment.media.image).width, // @Legacy
184
+ thumbnailHeight: attachment.story_attachment.media == null ? null : attachment.story_attachment.media.animated_image == null && attachment.story_attachment.media.image == null ? null : (attachment.story_attachment.media.animated_image || attachment.story_attachment.media.image).height // @Legacy
289
185
  };
290
- } else {
291
- return { error: "Don't know what to do with extensible_attachment." };
292
186
  }
187
+ else return { error: "Don't know what to do with extensible_attachment." };
293
188
  }
294
189
 
295
190
  function formatReactionsGraphQL(reaction) {
296
191
  return {
297
192
  reaction: reaction.reaction,
298
- userID: reaction.user.id,
193
+ userID: reaction.user.id
299
194
  };
300
195
  }
301
196
 
302
197
  function formatEventData(event) {
303
- if (event == null) {
304
- return {};
305
- }
198
+ if (event == null) return {};
306
199
 
307
200
  switch (event.__typename) {
308
201
  case "ThemeColorExtensibleMessageAdminText":
309
- return {
310
- color: event.theme_color,
311
- };
202
+ return { color: event.theme_color };
312
203
  case "ThreadNicknameExtensibleMessageAdminText":
313
204
  return {
314
205
  nickname: event.nickname,
315
- participantID: event.participant_id,
206
+ participantID: event.participant_id
316
207
  };
317
208
  case "ThreadIconExtensibleMessageAdminText":
318
- return {
319
- threadIcon: event.thread_icon,
320
- };
209
+ return { threadIcon: event.thread_icon };
321
210
  case "InstantGameUpdateExtensibleMessageAdminText":
322
211
  return {
323
- gameID: event.game == null ? null : event.game.id,
212
+ gameID: (event.game == null ? null : event.game.id),
324
213
  update_type: event.update_type,
325
214
  collapsed_text: event.collapsed_text,
326
215
  expanded_text: event.expanded_text,
327
- instant_game_update_data: event.instant_game_update_data,
216
+ instant_game_update_data: event.instant_game_update_data
328
217
  };
329
218
  case "GameScoreExtensibleMessageAdminText":
330
- return {
331
- game_type: event.game_type,
332
- };
219
+ return { game_type: event.game_type };
333
220
  case "RtcCallLogExtensibleMessageAdminText":
334
221
  return {
335
222
  event: event.event,
336
223
  is_video_call: event.is_video_call,
337
- server_info_data: event.server_info_data,
224
+ server_info_data: event.server_info_data
338
225
  };
339
226
  case "GroupPollExtensibleMessageAdminText":
340
227
  return {
341
228
  event_type: event.event_type,
342
229
  total_count: event.total_count,
343
- question: event.question,
230
+ question: event.question
344
231
  };
345
232
  case "AcceptPendingThreadExtensibleMessageAdminText":
346
233
  return {
347
234
  accepter_id: event.accepter_id,
348
- requester_id: event.requester_id,
235
+ requester_id: event.requester_id
349
236
  };
350
237
  case "ConfirmFriendRequestExtensibleMessageAdminText":
351
238
  return {
352
239
  friend_request_recipient: event.friend_request_recipient,
353
- friend_request_sender: event.friend_request_sender,
240
+ friend_request_sender: event.friend_request_sender
354
241
  };
355
242
  case "AddContactExtensibleMessageAdminText":
356
243
  return {
357
244
  contact_added_id: event.contact_added_id,
358
- contact_adder_id: event.contact_adder_id,
245
+ contact_adder_id: event.contact_adder_id
359
246
  };
360
247
  case "AdExtensibleMessageAdminText":
361
248
  return {
362
249
  ad_client_token: event.ad_client_token,
363
250
  ad_id: event.ad_id,
364
251
  ad_preferences_link: event.ad_preferences_link,
365
- ad_properties: event.ad_properties,
252
+ ad_properties: event.ad_properties
366
253
  };
367
254
  // never data
368
255
  case "ParticipantJoinedGroupCallExtensibleMessageAdminText":
@@ -377,19 +264,15 @@ function formatEventData(event) {
377
264
  case "LightweightEventDeleteExtensibleMessageAdminText":
378
265
  return {};
379
266
  default:
380
- return {
381
- error: "Don't know what to with event data type " + event.__typename,
382
- };
267
+ return { error: "Don't know what to with event data type " + event.__typename };
383
268
  }
384
269
  }
385
270
 
386
271
  function formatMessagesGraphQLResponse(data) {
387
- const messageThread = data.o0.data.message_thread;
388
- const threadID = messageThread.thread_key.thread_fbid
389
- ? messageThread.thread_key.thread_fbid
390
- : messageThread.thread_key.other_user_id;
272
+ var messageThread = data.o0.data.message_thread;
273
+ var threadID = messageThread.thread_key.thread_fbid ? messageThread.thread_key.thread_fbid : messageThread.thread_key.other_user_id;
391
274
 
392
- const messages = messageThread.messages.nodes.map(function (d) {
275
+ var messages = messageThread.messages.nodes.map(function (d) {
393
276
  switch (d.__typename) {
394
277
  case "UserMessage":
395
278
  // Give priority to stickers. They're seen as normal messages but we've
@@ -402,7 +285,7 @@ function formatMessagesGraphQLResponse(data) {
402
285
  ID: d.sticker.id,
403
286
  url: d.sticker.url,
404
287
 
405
- packID: d.sticker.pack ? d.sticker.pack.id : null,
288
+ packID: d.sticker.pack.id,
406
289
  spriteUrl: d.sticker.sprite_image,
407
290
  spriteUrl2x: d.sticker.sprite_image_2x,
408
291
  width: d.sticker.width,
@@ -418,19 +301,14 @@ function formatMessagesGraphQLResponse(data) {
418
301
 
419
302
  stickerID: d.sticker.id, // @Legacy
420
303
  spriteURI: d.sticker.sprite_image, // @Legacy
421
- spriteURI2x: d.sticker.sprite_image_2x, // @Legacy
422
- },
304
+ spriteURI2x: d.sticker.sprite_image_2x // @Legacy
305
+ }
423
306
  ];
424
307
  }
425
308
 
426
309
  var mentionsObj = {};
427
310
  if (d.message !== null) {
428
- d.message.ranges.forEach((e) => {
429
- mentionsObj[e.entity.id] = d.message.text.substr(
430
- e.offset,
431
- e.length,
432
- );
433
- });
311
+ d.message.ranges.forEach(e => mentionsObj[e.entity.id] = d.message.text.substr(e.offset, e.length));
434
312
  }
435
313
 
436
314
  return {
@@ -442,7 +320,7 @@ function formatMessagesGraphQLResponse(data) {
442
320
  : d.extensible_attachment
443
321
  ? [formatExtensibleAttachment(d.extensible_attachment)]
444
322
  : [],
445
- body: d.message !== null ? d.message.text : "",
323
+ body: d.message !== null ? d.message.text : '',
446
324
  isGroup: messageThread.thread_type === "GROUP",
447
325
  messageID: d.message_id,
448
326
  senderID: d.message_sender.id,
@@ -453,11 +331,9 @@ function formatMessagesGraphQLResponse(data) {
453
331
  isUnread: d.unread,
454
332
 
455
333
  // New
456
- messageReactions: d.message_reactions
457
- ? d.message_reactions.map(formatReactionsGraphQL)
458
- : null,
334
+ messageReactions: d.message_reactions ? d.message_reactions.map(formatReactionsGraphQL) : null,
459
335
  isSponsored: d.is_sponsored,
460
- snippet: d.snippet,
336
+ snippet: d.snippet
461
337
  };
462
338
  case "ThreadNameMessage":
463
339
  return {
@@ -469,14 +345,12 @@ function formatMessagesGraphQLResponse(data) {
469
345
  timestamp: d.timestamp_precise,
470
346
  eventType: "change_thread_name",
471
347
  snippet: d.snippet,
472
- eventData: {
473
- threadName: d.thread_name,
474
- },
348
+ eventData: { threadName: d.thread_name },
475
349
 
476
350
  // @Legacy
477
351
  author: d.message_sender.id,
478
352
  logMessageType: "log:thread-name",
479
- logMessageData: { name: d.thread_name },
353
+ logMessageData: { name: d.thread_name }
480
354
  };
481
355
  case "ThreadImageMessage":
482
356
  return {
@@ -488,26 +362,21 @@ function formatMessagesGraphQLResponse(data) {
488
362
  timestamp: d.timestamp_precise,
489
363
  eventType: "change_thread_image",
490
364
  snippet: d.snippet,
491
- eventData:
492
- d.image_with_metadata == null
493
- ? {} /* removed image */
494
- : {
495
- /* image added */
496
- threadImage: {
497
- attachmentID: d.image_with_metadata.legacy_attachment_id,
498
- width: d.image_with_metadata.original_dimensions.x,
499
- height: d.image_with_metadata.original_dimensions.y,
500
- url: d.image_with_metadata.preview.uri,
501
- },
502
- },
365
+ eventData: d.image_with_metadata == null
366
+ ? {} /* removed image */
367
+ : {
368
+ /* image added */
369
+ threadImage: {
370
+ attachmentID: d.image_with_metadata.legacy_attachment_id,
371
+ width: d.image_with_metadata.original_dimensions.x,
372
+ height: d.image_with_metadata.original_dimensions.y,
373
+ url: d.image_with_metadata.preview.uri
374
+ }
375
+ },
503
376
 
504
377
  // @Legacy
505
378
  logMessageType: "log:thread-icon",
506
- logMessageData: {
507
- thread_icon: d.image_with_metadata
508
- ? d.image_with_metadata.preview.uri
509
- : null,
510
- },
379
+ logMessageData: { thread_icon: d.image_with_metadata ? d.image_with_metadata.preview.uri : null }
511
380
  };
512
381
  case "ParticipantLeftMessage":
513
382
  return {
@@ -523,7 +392,7 @@ function formatMessagesGraphQLResponse(data) {
523
392
  // Array of IDs.
524
393
  participantsRemoved: d.participants_removed.map(function (p) {
525
394
  return p.id;
526
- }),
395
+ })
527
396
  },
528
397
 
529
398
  // @Legacy
@@ -531,8 +400,8 @@ function formatMessagesGraphQLResponse(data) {
531
400
  logMessageData: {
532
401
  leftParticipantFbId: d.participants_removed.map(function (p) {
533
402
  return p.id;
534
- }),
535
- },
403
+ })
404
+ }
536
405
  };
537
406
  case "ParticipantsAddedMessage":
538
407
  return {
@@ -548,7 +417,7 @@ function formatMessagesGraphQLResponse(data) {
548
417
  // Array of IDs.
549
418
  participantsAdded: d.participants_added.map(function (p) {
550
419
  return p.id;
551
- }),
420
+ })
552
421
  },
553
422
 
554
423
  // @Legacy
@@ -556,8 +425,8 @@ function formatMessagesGraphQLResponse(data) {
556
425
  logMessageData: {
557
426
  addedParticipants: d.participants_added.map(function (p) {
558
427
  return p.id;
559
- }),
560
- },
428
+ })
429
+ }
561
430
  };
562
431
  case "VideoCallMessage":
563
432
  return {
@@ -571,7 +440,7 @@ function formatMessagesGraphQLResponse(data) {
571
440
  snippet: d.snippet,
572
441
 
573
442
  // @Legacy
574
- logMessageType: "other",
443
+ logMessageType: "other"
575
444
  };
576
445
  case "VoiceCallMessage":
577
446
  return {
@@ -585,7 +454,7 @@ function formatMessagesGraphQLResponse(data) {
585
454
  snippet: d.snippet,
586
455
 
587
456
  // @Legacy
588
- logMessageType: "other",
457
+ logMessageType: "other"
589
458
  };
590
459
  case "GenericAdminTextMessage":
591
460
  return {
@@ -601,9 +470,9 @@ function formatMessagesGraphQLResponse(data) {
601
470
 
602
471
  // @Legacy
603
472
  logMessageType: utils.getAdminTextMessageType(
604
- d.extensible_message_admin_text_type,
473
+ d.extensible_message_admin_text_type
605
474
  ),
606
- logMessageData: d.extensible_message_admin_text, // Maybe different?
475
+ logMessageData: d.extensible_message_admin_text // Maybe different?
607
476
  };
608
477
  default:
609
478
  return { error: "Don't know about message type " + d.__typename };
@@ -613,32 +482,25 @@ function formatMessagesGraphQLResponse(data) {
613
482
  }
614
483
 
615
484
  module.exports = function (defaultFuncs, api, ctx) {
616
- return function getThreadHistoryGraphQL(
617
- threadID,
618
- amount,
619
- timestamp,
620
- callback,
621
- ) {
622
- let resolveFunc = function () {};
623
- let rejectFunc = function () {};
624
- const returnPromise = new Promise(function (resolve, reject) {
485
+ return function getThreadHistoryGraphQL(threadID, amount, timestamp, callback) {
486
+ var resolveFunc = function () { };
487
+ var rejectFunc = function () { };
488
+ var returnPromise = new Promise(function (resolve, reject) {
625
489
  resolveFunc = resolve;
626
490
  rejectFunc = reject;
627
491
  });
628
492
 
629
493
  if (!callback) {
630
494
  callback = function (err, data) {
631
- if (err) {
632
- return rejectFunc(err);
633
- }
495
+ if (err) return rejectFunc(err);
634
496
  resolveFunc(data);
635
497
  };
636
498
  }
637
499
 
638
500
  // `queries` has to be a string. I couldn't tell from the dev console. This
639
501
  // took me a really long time to figure out. I deserve a cookie for this.
640
- const form = {
641
- av: ctx.globalOptions.pageID,
502
+ var form = {
503
+ "av": ctx.globalOptions.pageID,
642
504
  queries: JSON.stringify({
643
505
  o0: {
644
506
  // This doc_id was valid on February 2nd 2017.
@@ -648,30 +510,25 @@ module.exports = function (defaultFuncs, api, ctx) {
648
510
  message_limit: amount,
649
511
  load_messages: 1,
650
512
  load_read_receipts: false,
651
- before: timestamp,
652
- },
653
- },
654
- }),
513
+ before: timestamp
514
+ }
515
+ }
516
+ })
655
517
  };
656
518
 
657
519
  defaultFuncs
658
520
  .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
659
521
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
660
522
  .then(function (resData) {
661
- if (resData.error) {
662
- throw resData;
663
- }
523
+ if (resData.error) throw resData;
664
524
  // This returns us an array of things. The last one is the success /
665
525
  // failure one.
666
526
  // @TODO What do we do in this case?
667
- if (resData[resData.length - 1].error_results !== 0) {
668
- throw new Error("There was an error_result.");
669
- }
670
-
527
+ if (resData[resData.length - 1].error_results !== 0) throw new Error("There was an error_result.");
671
528
  callback(null, formatMessagesGraphQLResponse(resData[0]));
672
529
  })
673
530
  .catch(function (err) {
674
- console.error("getThreadHistoryGraphQL", err);
531
+ log.error("getThreadHistoryGraphQL", "Lỗi getThreadHistoryGraphQL Có Thể Do Bạn Spam Quá Nhiều, Hãy Thử Lại !");
675
532
  return callback(err);
676
533
  });
677
534