fca-nx 6.8.6 → 6.8.8

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 (74) hide show
  1. package/func/checkUpdate.js +1 -1
  2. package/func/logAdapter.js +0 -2
  3. package/index.js +0 -3
  4. package/module/config.js +2 -7
  5. package/module/login.js +10 -38
  6. package/module/loginHelper.js +94 -163
  7. package/module/options.js +1 -7
  8. package/package.json +2 -2
  9. package/src/api/action/addfriend.js +3 -9
  10. package/src/api/action/changeAvatar.js +0 -1
  11. package/src/api/action/changeCover.js +1 -3
  12. package/src/api/action/enableAutoSaveAppState.js +5 -18
  13. package/src/api/action/refreshFb_dtsg.js +2 -2
  14. package/src/api/http/httpGet.js +2 -6
  15. package/src/api/http/httpPost.js +2 -7
  16. package/src/api/messaging/createNewGroup.js +1 -1
  17. package/src/api/messaging/deleteMessage.js +1 -1
  18. package/src/api/messaging/forwardMessage.js +1 -9
  19. package/src/api/messaging/getEmojiUrl.js +1 -5
  20. package/src/api/messaging/getMessage.js +2 -4
  21. package/src/api/messaging/getThemePictures.js +0 -7
  22. package/src/api/messaging/markAsRead.js +0 -1
  23. package/src/api/messaging/muteThread.js +1 -1
  24. package/src/api/messaging/pinMessage.js +1 -10
  25. package/src/api/messaging/scheduler.js +4 -71
  26. package/src/api/messaging/sendBroadcast.js +0 -15
  27. package/src/api/messaging/sendMessage.js +1 -10
  28. package/src/api/messaging/sendTypingIndicator.js +2 -2
  29. package/src/api/messaging/sessionGuard.js +9 -45
  30. package/src/api/messaging/setMessageReaction.js +1 -2
  31. package/src/api/messaging/threadColors.js +12 -45
  32. package/src/api/messaging/uploadAttachment.js +3 -37
  33. package/src/api/socket/core/connectMqtt.js +17 -60
  34. package/src/api/socket/core/emitAuth.js +2 -14
  35. package/src/api/socket/core/getSeqID.js +23 -29
  36. package/src/api/socket/core/getTaskResponseData.js +1 -3
  37. package/src/api/socket/core/parseDelta.js +1 -1
  38. package/src/api/socket/detail/buildStream.js +1 -4
  39. package/src/api/socket/detail/constants.js +1 -4
  40. package/src/api/socket/e2ee/crypto.js +2 -40
  41. package/src/api/socket/e2ee/index.js +10 -123
  42. package/src/api/socket/e2ee/protocol.js +1 -32
  43. package/src/api/socket/e2ee/ratchet.js +10 -44
  44. package/src/api/socket/e2ee/store.js +1 -13
  45. package/src/api/socket/listenE2EE.js +1 -25
  46. package/src/api/socket/listenMqtt.js +13 -29
  47. package/src/api/socket/middleware/index.js +7 -61
  48. package/src/api/socket/sendMessage.js +2 -19
  49. package/src/api/threads/getThreadHistory.js +38 -68
  50. package/src/api/threads/getThreadInfo.js +3 -4
  51. package/src/api/threads/getThreadList.js +31 -34
  52. package/src/api/threads/getThreadPictures.js +1 -1
  53. package/src/api/users/getUserInfo.js +2 -5
  54. package/src/api/users/getUserInfoV2.js +3 -9
  55. package/src/core/sendReqMqtt.js +1 -2
  56. package/src/database/helpers.js +0 -12
  57. package/src/database/models/index.js +1 -3
  58. package/src/utils/broadcast.js +1 -1
  59. package/src/utils/clientIdentity.js +3 -50
  60. package/src/utils/cookies.js +2 -4
  61. package/src/utils/format/utils.js +0 -10
  62. package/src/utils/headers.js +12 -26
  63. package/src/utils/instanceLock.js +3 -9
  64. package/src/utils/ipGuard.js +1 -15
  65. package/src/utils/loginParser/autoLogin.js +0 -12
  66. package/src/utils/loginParser/parseAndCheckLogin.js +0 -7
  67. package/src/utils/loginParser/textUtils.js +0 -6
  68. package/src/utils/request/config.js +1 -4
  69. package/src/utils/request/methods.js +1 -4
  70. package/src/utils/request/proxy.js +0 -13
  71. package/src/utils/request/retry.js +0 -1
  72. package/src/utils/request/sanitize.js +1 -1
  73. package/src/utils/sendThrottle.js +1 -14
  74. package/src/utils/utils.js +3 -17
@@ -37,13 +37,11 @@ function formatAttachmentsGraphQLResponse(attachment) {
37
37
  largePreviewHeight: attachment.large_preview.height,
38
38
  largePreviewWidth: attachment.large_preview.width,
39
39
 
40
- // You have to query for the real image. See below.
41
- url: attachment.large_preview.uri, // @Legacy
42
- width: attachment.large_preview.width, // @Legacy
43
- height: attachment.large_preview.height, // @Legacy
44
- name: attachment.filename, // @Legacy
40
+ url: attachment.large_preview.uri,
41
+ width: attachment.large_preview.width,
42
+ height: attachment.large_preview.height,
43
+ name: attachment.filename,
45
44
 
46
- // @Undocumented
47
45
  attributionApp: attachment.attribution_app
48
46
  ? {
49
47
  attributionAppID: attachment.attribution_app.id,
@@ -70,16 +68,15 @@ function formatAttachmentsGraphQLResponse(attachment) {
70
68
  width: attachment.animated_image.width,
71
69
  height: attachment.animated_image.height,
72
70
 
73
- thumbnailUrl: attachment.preview_image.uri, // @Legacy
74
- name: attachment.filename, // @Legacy
75
- facebookUrl: attachment.animated_image.uri, // @Legacy
76
- rawGifImage: attachment.animated_image.uri, // @Legacy
77
- animatedGifUrl: attachment.animated_image.uri, // @Legacy
78
- animatedGifPreviewUrl: attachment.preview_image.uri, // @Legacy
79
- animatedWebpUrl: attachment.animated_image.uri, // @Legacy
80
- animatedWebpPreviewUrl: attachment.preview_image.uri, // @Legacy
71
+ thumbnailUrl: attachment.preview_image.uri,
72
+ name: attachment.filename,
73
+ facebookUrl: attachment.animated_image.uri,
74
+ rawGifImage: attachment.animated_image.uri,
75
+ animatedGifUrl: attachment.animated_image.uri,
76
+ animatedGifPreviewUrl: attachment.preview_image.uri,
77
+ animatedWebpUrl: attachment.animated_image.uri,
78
+ animatedWebpPreviewUrl: attachment.preview_image.uri,
81
79
 
82
- // @Undocumented
83
80
  attributionApp: attachment.attribution_app
84
81
  ? {
85
82
  attributionAppID: attachment.attribution_app.id,
@@ -99,7 +96,7 @@ function formatAttachmentsGraphQLResponse(attachment) {
99
96
  ),
100
97
  duration: attachment.playable_duration_in_ms,
101
98
 
102
- thumbnailUrl: attachment.large_image.uri, // @Legacy
99
+ thumbnailUrl: attachment.large_image.uri,
103
100
 
104
101
  previewUrl: attachment.large_image.uri,
105
102
  previewWidth: attachment.large_image.width,
@@ -125,14 +122,14 @@ function formatAttachmentsGraphQLResponse(attachment) {
125
122
  isMalicious: attachment.is_malicious,
126
123
  contentType: attachment.content_type,
127
124
 
128
- name: attachment.filename, // @Legacy
129
- mimeType: "", // @Legacy
130
- fileSize: -1 // @Legacy
125
+ name: attachment.filename,
126
+ mimeType: "",
127
+ fileSize: -1
131
128
  };
132
129
  case "MessageAudio":
133
130
  return {
134
131
  type: "audio",
135
- ID: attachment.url_shimhash, // Not fowardable
132
+ ID: attachment.url_shimhash,
136
133
  filename: attachment.filename,
137
134
  original_extension: getExtension(
138
135
  attachment.original_extension,
@@ -213,19 +210,6 @@ function formatExtensibleAttachment(attachment) {
213
210
 
214
211
  subattachments: attachment.story_attachment.subattachments,
215
212
 
216
- // Format example:
217
- //
218
- // [{
219
- // key: "width",
220
- // value: { text: "1280" }
221
- // }]
222
- //
223
- // That we turn into:
224
- //
225
- // {
226
- // width: "1280"
227
- // }
228
- //
229
213
  properties: attachment.story_attachment.properties.reduce(function(
230
214
  obj,
231
215
  cur
@@ -235,11 +219,10 @@ function formatExtensibleAttachment(attachment) {
235
219
  },
236
220
  {}),
237
221
 
238
- // Deprecated fields
239
- animatedImageSize: "", // @Legacy
240
- facebookUrl: "", // @Legacy
241
- styleList: "", // @Legacy
242
- target: "", // @Legacy
222
+ animatedImageSize: "",
223
+ facebookUrl: "",
224
+ styleList: "",
225
+ target: "",
243
226
  thumbnailUrl:
244
227
  attachment.story_attachment.media == null
245
228
  ? null
@@ -249,7 +232,7 @@ function formatExtensibleAttachment(attachment) {
249
232
  : (
250
233
  attachment.story_attachment.media.animated_image ||
251
234
  attachment.story_attachment.media.image
252
- ).uri, // @Legacy
235
+ ).uri,
253
236
  thumbnailWidth:
254
237
  attachment.story_attachment.media == null
255
238
  ? null
@@ -259,7 +242,7 @@ function formatExtensibleAttachment(attachment) {
259
242
  : (
260
243
  attachment.story_attachment.media.animated_image ||
261
244
  attachment.story_attachment.media.image
262
- ).width, // @Legacy
245
+ ).width,
263
246
  thumbnailHeight:
264
247
  attachment.story_attachment.media == null
265
248
  ? null
@@ -269,7 +252,7 @@ function formatExtensibleAttachment(attachment) {
269
252
  : (
270
253
  attachment.story_attachment.media.animated_image ||
271
254
  attachment.story_attachment.media.image
272
- ).height // @Legacy
255
+ ).height
273
256
  };
274
257
  } else {
275
258
  return { error: "Don't know what to do with extensible_attachment." };
@@ -348,7 +331,7 @@ function formatEventData(event) {
348
331
  ad_preferences_link: event.ad_preferences_link,
349
332
  ad_properties: event.ad_properties
350
333
  };
351
- // never data
334
+
352
335
  case "ParticipantJoinedGroupCallExtensibleMessageAdminText":
353
336
  case "ThreadEphemeralTtlModeExtensibleMessageAdminText":
354
337
  case "StartedSharingVideoExtensibleMessageAdminText":
@@ -376,8 +359,7 @@ function formatMessagesGraphQLResponse(data) {
376
359
  const messages = messageThread.messages.nodes.map(function(d) {
377
360
  switch (d.__typename) {
378
361
  case "UserMessage":
379
- // Give priority to stickers. They're seen as normal messages but we've
380
- // been considering them as attachments.
362
+
381
363
  var maybeStickerAttachment;
382
364
  if (d.sticker) {
383
365
  maybeStickerAttachment = [
@@ -392,17 +374,17 @@ function formatMessagesGraphQLResponse(data) {
392
374
  width: d.sticker.width,
393
375
  height: d.sticker.height,
394
376
 
395
- caption: d.snippet, // Not sure what the heck caption was.
396
- description: d.sticker.label, // Not sure about this one either.
377
+ caption: d.snippet,
378
+ description: d.sticker.label,
397
379
 
398
380
  frameCount: d.sticker.frame_count,
399
381
  frameRate: d.sticker.frame_rate,
400
382
  framesPerRow: d.sticker.frames_per_row,
401
383
  framesPerCol: d.sticker.frames_per_col,
402
384
 
403
- stickerID: d.sticker.id, // @Legacy
404
- spriteURI: d.sticker.sprite_image, // @Legacy
405
- spriteURI2x: d.sticker.sprite_image_2x // @Legacy
385
+ stickerID: d.sticker.id,
386
+ spriteURI: d.sticker.sprite_image,
387
+ spriteURI2x: d.sticker.sprite_image_2x
406
388
  }
407
389
  ];
408
390
  }
@@ -436,7 +418,6 @@ function formatMessagesGraphQLResponse(data) {
436
418
  mentions: mentionsObj,
437
419
  isUnread: d.unread,
438
420
 
439
- // New
440
421
  messageReactions: d.message_reactions
441
422
  ? d.message_reactions.map(formatReactionsGraphQL)
442
423
  : null,
@@ -457,7 +438,6 @@ function formatMessagesGraphQLResponse(data) {
457
438
  threadName: d.thread_name
458
439
  },
459
440
 
460
- // @Legacy
461
441
  author: d.message_sender.id,
462
442
  logMessageType: "log:thread-name",
463
443
  logMessageData: { name: d.thread_name }
@@ -474,9 +454,9 @@ function formatMessagesGraphQLResponse(data) {
474
454
  snippet: d.snippet,
475
455
  eventData:
476
456
  d.image_with_metadata == null
477
- ? {} /* removed image */
457
+ ? {}
478
458
  : {
479
- /* image added */
459
+
480
460
  threadImage: {
481
461
  attachmentID: d.image_with_metadata.legacy_attachment_id,
482
462
  width: d.image_with_metadata.original_dimensions.x,
@@ -485,7 +465,6 @@ function formatMessagesGraphQLResponse(data) {
485
465
  }
486
466
  },
487
467
 
488
- // @Legacy
489
468
  logMessageType: "log:thread-icon",
490
469
  logMessageData: {
491
470
  thread_icon: d.image_with_metadata
@@ -504,13 +483,12 @@ function formatMessagesGraphQLResponse(data) {
504
483
  eventType: "remove_participants",
505
484
  snippet: d.snippet,
506
485
  eventData: {
507
- // Array of IDs.
486
+
508
487
  participantsRemoved: d.participants_removed.map(function(p) {
509
488
  return p.id;
510
489
  })
511
490
  },
512
491
 
513
- // @Legacy
514
492
  logMessageType: "log:unsubscribe",
515
493
  logMessageData: {
516
494
  leftParticipantFbId: d.participants_removed.map(function(p) {
@@ -529,13 +507,12 @@ function formatMessagesGraphQLResponse(data) {
529
507
  eventType: "add_participants",
530
508
  snippet: d.snippet,
531
509
  eventData: {
532
- // Array of IDs.
510
+
533
511
  participantsAdded: d.participants_added.map(function(p) {
534
512
  return p.id;
535
513
  })
536
514
  },
537
515
 
538
- // @Legacy
539
516
  logMessageType: "log:subscribe",
540
517
  logMessageData: {
541
518
  addedParticipants: d.participants_added.map(function(p) {
@@ -554,7 +531,6 @@ function formatMessagesGraphQLResponse(data) {
554
531
  eventType: "video_call",
555
532
  snippet: d.snippet,
556
533
 
557
- // @Legacy
558
534
  logMessageType: "other"
559
535
  };
560
536
  case "VoiceCallMessage":
@@ -568,7 +544,6 @@ function formatMessagesGraphQLResponse(data) {
568
544
  eventType: "voice_call",
569
545
  snippet: d.snippet,
570
546
 
571
- // @Legacy
572
547
  logMessageType: "other"
573
548
  };
574
549
  case "GenericAdminTextMessage":
@@ -583,11 +558,10 @@ function formatMessagesGraphQLResponse(data) {
583
558
  eventType: d.extensible_message_admin_text_type.toLowerCase(),
584
559
  eventData: formatEventData(d.extensible_message_admin_text),
585
560
 
586
- // @Legacy
587
561
  logMessageType: getAdminTextMessageType(
588
562
  d.extensible_message_admin_text_type
589
563
  ),
590
- logMessageData: d.extensible_message_admin_text // Maybe different?
564
+ logMessageData: d.extensible_message_admin_text
591
565
  };
592
566
  default:
593
567
  return { error: "Don't know about message type " + d.__typename };
@@ -619,13 +593,11 @@ module.exports = function(defaultFuncs, api, ctx) {
619
593
  };
620
594
  }
621
595
 
622
- // `queries` has to be a string. I couldn't tell from the dev console. This
623
- // took me a really long time to figure out. I deserve a cookie for this.
624
596
  const form = {
625
597
  av: ctx.userID,
626
598
  queries: JSON.stringify({
627
599
  o0: {
628
- // This doc_id was valid on February 2nd 2017.
600
+
629
601
  doc_id: "1498317363570230",
630
602
  query_params: {
631
603
  id: threadID,
@@ -645,9 +617,7 @@ module.exports = function(defaultFuncs, api, ctx) {
645
617
  if (resData.error) {
646
618
  throw resData;
647
619
  }
648
- // This returns us an array of things. The last one is the success /
649
- // failure one.
650
- // @TODO What do we do in this case?
620
+
651
621
  if (resData[resData.length - 1].error_results !== 0) {
652
622
  throw new Error("There was an error_result.");
653
623
  }
@@ -233,7 +233,7 @@ module.exports = function (defaultFuncs, api, ctx) {
233
233
  out[info.threadID] = info;
234
234
  }
235
235
  } catch (e) {
236
- // Skip malformed entries but continue processing others
236
+
237
237
  log.error("getThreadInfoGraphQL", e && e.message ? e.message : String(e));
238
238
  }
239
239
  }
@@ -248,7 +248,6 @@ module.exports = function (defaultFuncs, api, ctx) {
248
248
  if (stale.length) {
249
249
  fetched = await fetchFromGraphQL(stale);
250
250
 
251
- // Persist fetched data back to DB
252
251
  if (threadData && (typeof create === "function" || typeof update === "function")) {
253
252
  const tasks = [];
254
253
  for (const id of stale) {
@@ -265,7 +264,7 @@ module.exports = function (defaultFuncs, api, ctx) {
265
264
  try {
266
265
  await Promise.all(tasks);
267
266
  } catch {
268
- // Swallow DB errors – not critical for API behavior
267
+
269
268
  }
270
269
  }
271
270
  }
@@ -282,7 +281,7 @@ module.exports = function (defaultFuncs, api, ctx) {
282
281
 
283
282
  return callback(null, result);
284
283
  } catch (err) {
285
- // Horizon-style anti-get-info message to hint possible spam/limit
284
+
286
285
  log.error(
287
286
  "getThreadInfoGraphQL",
288
287
  "Lỗi: getThreadInfoGraphQL Có Thể Do Bạn Spam Quá Nhiều, Hãy Thử Lại !"
@@ -17,35 +17,35 @@ function formatParticipants(participants) {
17
17
  case "User":
18
18
  return {
19
19
  accountType: p["__typename"],
20
- userID: formatID(p.id.toString()), // do we need .toString()? when it is not a string?
20
+ userID: formatID(p.id.toString()),
21
21
  name: p.name,
22
22
  shortName: p.short_name,
23
23
  gender: p.gender,
24
- url: p.url, // how about making it profileURL
24
+ url: p.url,
25
25
  profilePicture: p.big_image_src.uri,
26
26
  username: p.username || null,
27
- // TODO: maybe better names for these?
28
- isViewerFriend: p.is_viewer_friend, // true/false
29
- isMessengerUser: p.is_messenger_user, // true/false
30
- isVerified: p.is_verified, // true/false
31
- isMessageBlockedByViewer: p.is_message_blocked_by_viewer, // true/false
32
- isViewerCoworker: p.is_viewer_coworker, // true/false
33
- isEmployee: p.is_employee // null? when it is something other? can someone check?
27
+
28
+ isViewerFriend: p.is_viewer_friend,
29
+ isMessengerUser: p.is_messenger_user,
30
+ isVerified: p.is_verified,
31
+ isMessageBlockedByViewer: p.is_message_blocked_by_viewer,
32
+ isViewerCoworker: p.is_viewer_coworker,
33
+ isEmployee: p.is_employee
34
34
  };
35
35
  case "Page":
36
36
  return {
37
37
  accountType: p["__typename"],
38
- userID: formatID(p.id.toString()), // or maybe... pageID?
38
+ userID: formatID(p.id.toString()),
39
39
  name: p.name,
40
40
  url: p.url,
41
41
  profilePicture: p.big_image_src.uri,
42
42
  username: p.username || null,
43
- // uhm... better names maybe?
44
- acceptsMessengerUserFeedback: p.accepts_messenger_user_feedback, // true/false
45
- isMessengerUser: p.is_messenger_user, // true/false
46
- isVerified: p.is_verified, // true/false
47
- isMessengerPlatformBot: p.is_messenger_platform_bot, // true/false
48
- isMessageBlockedByViewer: p.is_message_blocked_by_viewer // true/false
43
+
44
+ acceptsMessengerUserFeedback: p.accepts_messenger_user_feedback,
45
+ isMessengerUser: p.is_messenger_user,
46
+ isVerified: p.is_verified,
47
+ isMessengerPlatformBot: p.is_messenger_platform_bot,
48
+ isMessageBlockedByViewer: p.is_message_blocked_by_viewer
49
49
  };
50
50
  case "ReducedMessagingActor":
51
51
  case "UnavailableMessagingActor":
@@ -53,10 +53,10 @@ function formatParticipants(participants) {
53
53
  accountType: p["__typename"],
54
54
  userID: formatID(p.id.toString()),
55
55
  name: p.name,
56
- url: createProfileUrl(p.url, p.username, p.id), // in this case p.url is null all the time
57
- profilePicture: p.big_image_src.uri, // in this case it is default facebook photo, we could determine gender using it
58
- username: p.username || null, // maybe we could use it to generate profile URL?
59
- isMessageBlockedByViewer: p.is_message_blocked_by_viewer // true/false
56
+ url: createProfileUrl(p.url, p.username, p.id),
57
+ profilePicture: p.big_image_src.uri,
58
+ username: p.username || null,
59
+ isMessageBlockedByViewer: p.is_message_blocked_by_viewer
60
60
  };
61
61
  default:
62
62
  log.warn(
@@ -67,13 +67,12 @@ function formatParticipants(participants) {
67
67
  return {
68
68
  accountType: p["__typename"],
69
69
  userID: formatID(p.id.toString()),
70
- name: p.name || `[unknown ${p["__typename"]}]` // probably it will always be something... but fallback to [unknown], just in case
70
+ name: p.name || `[unknown ${p["__typename"]}]`
71
71
  };
72
72
  }
73
73
  });
74
74
  }
75
75
 
76
- // "FF8C0077" -> "8C0077"
77
76
  function formatColor(color) {
78
77
  if (color && color.match(/^(?:[0-9a-fA-F]{8})$/g)) return color.slice(2);
79
78
  return color;
@@ -109,7 +108,7 @@ function formatThreadList(data) {
109
108
  return {
110
109
  threadID: t.thread_key
111
110
  ? formatID(t.thread_key.thread_fbid || t.thread_key.other_user_id)
112
- : null, // shall never be null
111
+ : null,
113
112
  name: getThreadName(t),
114
113
  unreadCount: t.unread_count,
115
114
  messageCount: t.messages_count,
@@ -125,20 +124,20 @@ function formatThreadList(data) {
125
124
  adminIDs: t.thread_admins.map(a => a.id),
126
125
  folder: t.folder,
127
126
  isGroup: t.thread_type === "GROUP",
128
- customizationEnabled: t.customization_enabled, // false for ONE_TO_ONE with Page or ReducedMessagingActor
129
- participantAddMode: t.participant_add_mode_as_string, // "ADD" if "GROUP" and null if "ONE_TO_ONE"
127
+ customizationEnabled: t.customization_enabled,
128
+ participantAddMode: t.participant_add_mode_as_string,
130
129
  montageThread: t.montage_thread
131
130
  ? Buffer.from(t.montage_thread.id, "base64").toString()
132
- : null, // base64 encoded string "message_thread:0000000000000000"
131
+ : null,
133
132
  reactionsMuteMode: t.reactions_mute_mode,
134
133
  mentionsMuteMode: t.mentions_mute_mode,
135
134
  isArchived: t.has_viewer_archived,
136
135
  isSubscribed: t.is_viewer_subscribed,
137
- timestamp: t.updated_time_precise, // in miliseconds
136
+ timestamp: t.updated_time_precise,
138
137
  snippet: lastMessageNode ? lastMessageNode.snippet : null,
139
138
  snippetAttachments: lastMessageNode
140
139
  ? lastMessageNode.extensible_attachment
141
- : null, // TODO: not sure if it works
140
+ : null,
142
141
  snippetSender: lastMessageNode
143
142
  ? formatID(
144
143
  (lastMessageNode.message_sender.messaging_actor.id || "").toString()
@@ -146,7 +145,7 @@ function formatThreadList(data) {
146
145
  : null,
147
146
  lastMessageTimestamp: lastMessageNode
148
147
  ? lastMessageNode.timestamp_precise
149
- : null, // timestamp in miliseconds
148
+ : null,
150
149
  lastReadTimestamp:
151
150
  t.last_read_receipt && t.last_read_receipt.nodes.length > 0
152
151
  ? t.last_read_receipt.nodes[0]
@@ -158,7 +157,7 @@ function formatThreadList(data) {
158
157
  participantIDs: formatParticipants(t.all_participants).map(
159
158
  participant => participant.userID
160
159
  ),
161
- threadType: t.thread_type === "GROUP" ? 2 : 1, // "GROUP" or "ONE_TO_ONE"
160
+ threadType: t.thread_type === "GROUP" ? 2 : 1,
162
161
  inviteLink: {
163
162
  enable: t.joinable_mode ? t.joinable_mode.mode == 1 : false,
164
163
  link: t.joinable_mode ? t.joinable_mode.link : null
@@ -226,7 +225,7 @@ module.exports = function(defaultFuncs, api, ctx) {
226
225
  .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
227
226
  .then(parseAndCheckLogin(ctx, defaultFuncs))
228
227
  .then(resData => {
229
- // Validate resData is an array and has elements
228
+
230
229
  if (!resData || !Array.isArray(resData) || resData.length === 0) {
231
230
  throw {
232
231
  error: "getThreadList: Invalid response data - resData is not a valid array",
@@ -234,7 +233,6 @@ module.exports = function(defaultFuncs, api, ctx) {
234
233
  };
235
234
  }
236
235
 
237
- // Validate last element exists and has required properties
238
236
  const lastElement = resData[resData.length - 1];
239
237
  if (!lastElement || typeof lastElement !== "object") {
240
238
  throw {
@@ -244,7 +242,7 @@ module.exports = function(defaultFuncs, api, ctx) {
244
242
  }
245
243
 
246
244
  if (lastElement.error_results > 0) {
247
- // Check if first element and o0 exist before accessing errors
245
+
248
246
  if (resData[0] && resData[0].o0 && resData[0].o0.errors) {
249
247
  throw resData[0].o0.errors;
250
248
  } else {
@@ -262,7 +260,6 @@ module.exports = function(defaultFuncs, api, ctx) {
262
260
  };
263
261
  }
264
262
 
265
- // Validate first element and nested data structure
266
263
  if (!resData[0] || !resData[0].o0 || !resData[0].o0.data ||
267
264
  !resData[0].o0.data.viewer || !resData[0].o0.data.viewer.message_threads ||
268
265
  !Array.isArray(resData[0].o0.data.viewer.message_threads.nodes)) {
@@ -54,7 +54,7 @@ module.exports = function(defaultFuncs, api, ctx) {
54
54
  if (resData.error) {
55
55
  throw resData;
56
56
  }
57
- // the response is pretty messy
57
+
58
58
  const queryThreadID =
59
59
  resData.jsmods.require[0][3][1].query_metadata.query_path[0]
60
60
  .message_thread;
@@ -119,12 +119,11 @@ function mergeUserEntry(a, b) {
119
119
  }
120
120
 
121
121
  module.exports = function (defaultFuncs, api, ctx) {
122
- // Read FastConfig-style anti-get-info flag from global config (if available)
122
+
123
123
  const cfg = global.fca && global.fca.config;
124
124
  const antiCfg = cfg && cfg.antiGetInfo;
125
125
  const disableAntiUserInfo = !!(antiCfg && antiCfg.AntiGetUserInfo === true);
126
126
 
127
- // Lightweight, Horizon-style implementation without database/queue
128
127
  if (disableAntiUserInfo) {
129
128
  function formatLegacyData(data) {
130
129
  const retObj = {};
@@ -339,13 +338,11 @@ module.exports = function (defaultFuncs, api, ctx) {
339
338
  isProcessingQueue = false;
340
339
  }
341
340
 
342
- // Store interval reference for cleanup
343
341
  const updateInterval = setInterval(() => {
344
342
  checkAndUpdateUsers();
345
343
  processQueue();
346
344
  }, 10000);
347
345
 
348
- // Store interval in ctx for cleanup on logout/stop
349
346
  if (!ctx._userInfoIntervals) {
350
347
  ctx._userInfoIntervals = [];
351
348
  }
@@ -390,7 +387,7 @@ module.exports = function (defaultFuncs, api, ctx) {
390
387
  }
391
388
  return callback(null, ret);
392
389
  }).catch(err => {
393
- // Horizon-style anti-get-info message to hint rate limiting / spam block
390
+
394
391
  log.error(
395
392
  "getUserInfo",
396
393
  "Lỗi: getUserInfo Có Thể Do Bạn Spam Quá Nhiều !,Hãy Thử Lại !"
@@ -71,9 +71,6 @@ function extractPhotoUrl(photo, depth = 0) {
71
71
  }
72
72
  if (typeof photo !== "object") return null;
73
73
 
74
- // Facebook has returned direct URLs as well as nested image/photo objects
75
- // from Comet hovercards. Walk only the known media keys and prefer direct
76
- // URL fields before descending into nested containers.
77
74
  for (const key of [
78
75
  "source",
79
76
  "uri",
@@ -92,9 +89,6 @@ function extractPhotoUrl(photo, depth = 0) {
92
89
  return null;
93
90
  }
94
91
 
95
-
96
- // [Hardened] Fallback: read the cover photo straight from the profile page HTML,
97
- // used when none of the GraphQL doc_ids returned a cover (doc_ids rotate often).
98
92
  function decodeJsonString(raw) {
99
93
  try { return JSON.parse('"' + raw + '"'); } catch { return String(raw).replace(/\\\//g, "/"); }
100
94
  }
@@ -196,7 +190,7 @@ function createDefaultUser(id) {
196
190
  vanity: String(id),
197
191
  thumbSrc: `https://graph.facebook.com/${id}/picture?width=720&height=720`,
198
192
  profilePicUrl: `https://graph.facebook.com/${id}/picture?width=720&height=720`,
199
- coverPhoto: null, // FIX: default e null
193
+ coverPhoto: null,
200
194
  profileUrl: `https://www.facebook.com/profile.php?id=${id}`,
201
195
  gender: "no specific gender",
202
196
  type: "User",
@@ -223,7 +217,7 @@ function formatUser(user, id) {
223
217
  lastName: nameParts.length > 1? nameParts.slice(1).join(" ") : null,
224
218
  vanity: user.vanity || String(id),
225
219
  profilePicUrl: user.thumbSrc || `https://graph.facebook.com/${id}/picture?width=720&height=720`,
226
- coverPhoto: user.coverPhoto || null, // FIX: cover photo pass
220
+ coverPhoto: user.coverPhoto || null,
227
221
  profileUrl: user.profileUrl || `https://www.facebook.com/profile.php?id=${id}`,
228
222
  gender: user.gender || "no specific gender",
229
223
  type: user.type || "User",
@@ -281,7 +275,7 @@ module.exports = function (defaultFuncs, api, ctx) {
281
275
  logger(`getUserInfoV2 ${doc.id}: ${error.message || error}`, "warn");
282
276
  }
283
277
  }
284
- // [Hardened] GraphQL often omits cover; scrape profile HTML as last resort
278
+
285
279
  if (bestUser && !bestUser.coverPhoto) {
286
280
  const pages = [`https://www.facebook.com/profile.php?id=${id}`];
287
281
  if (bestUser.vanity && bestUser.vanity !== id) {
@@ -25,7 +25,6 @@ function sendReqMqtt(ctx, payload, options, callback) {
25
25
  let timer = null;
26
26
  let cleaned = false;
27
27
 
28
- // Cleanup function to ensure listeners and timers are always removed
29
28
  const cleanup = () => {
30
29
  if (cleaned) return;
31
30
  cleaned = true;
@@ -38,7 +37,7 @@ function sendReqMqtt(ctx, payload, options, callback) {
38
37
  ctx.mqttClient.removeListener("message", handleRes);
39
38
  }
40
39
  } catch (err) {
41
- // Ignore cleanup errors
40
+
42
41
  }
43
42
  };
44
43
 
@@ -1,10 +1,5 @@
1
1
  "use strict";
2
2
 
3
- /**
4
- * Shared helpers for database layer (userData, threadData).
5
- * Keeps validation and payload normalization in one place.
6
- */
7
-
8
3
  const DB_NOT_INIT = "Database not initialized";
9
4
 
10
5
  function validateId(value, fieldName = "id") {
@@ -23,18 +18,11 @@ function validateData(data) {
23
18
  }
24
19
  }
25
20
 
26
- /**
27
- * @param {string|string[]|null} keys - "userID" | ["userID","data"] | null
28
- * @returns {string[]|undefined}
29
- */
30
21
  function normalizeAttributes(keys) {
31
22
  if (keys == null) return undefined;
32
23
  return typeof keys === "string" ? [keys] : Array.isArray(keys) ? keys : undefined;
33
24
  }
34
25
 
35
- /**
36
- * Normalize payload: accept either { data } or raw object.
37
- */
38
26
  function normalizePayload(data, key = "data") {
39
27
  return Object.prototype.hasOwnProperty.call(data, key) ? data : { [key]: data };
40
28
  }
@@ -30,7 +30,6 @@ try {
30
30
  isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.READ_COMMITTED
31
31
  });
32
32
 
33
- // Load models with error handling
34
33
  try {
35
34
  const modelFiles = fs.readdirSync(__dirname)
36
35
  .filter(file => file.endsWith(".js") && file !== "index.js");
@@ -42,12 +41,11 @@ try {
42
41
  models[model.name] = model;
43
42
  }
44
43
  } catch (modelError) {
45
- // Log but continue loading other models
44
+
46
45
  console.error(`Failed to load model ${file}:`, modelError && modelError.message ? modelError.message : String(modelError));
47
46
  }
48
47
  }
49
48
 
50
- // Associate models
51
49
  Object.keys(models).forEach(modelName => {
52
50
  try {
53
51
  if (models[modelName].associate) {
@@ -36,7 +36,7 @@ async function broadcast(api, threadIDs, message, options) {
36
36
  skipBlocked &&
37
37
  /permission|blocked|not allowed|cannot send message|not authorized/i.test(msg)
38
38
  ) {
39
- // Skip only this target, continue with others
39
+
40
40
  }
41
41
  }
42
42
  if (delayMs > 0) {