fca-nx 6.8.8 → 7.0.5
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/README.md +24 -10
- package/func/checkUpdate.js +1 -1
- package/func/logAdapter.js +2 -0
- package/index.js +3 -0
- package/module/config.js +5 -2
- package/module/login.js +38 -13
- package/module/loginHelper.js +164 -127
- package/module/options.js +7 -1
- package/package.json +2 -2
- package/src/api/action/addfriend.js +9 -3
- package/src/api/action/changeAvatar.js +1 -0
- package/src/api/action/changeCover.js +3 -1
- package/src/api/action/enableAutoSaveAppState.js +18 -5
- package/src/api/action/refreshFb_dtsg.js +18 -76
- package/src/api/http/httpGet.js +6 -2
- package/src/api/http/httpPost.js +7 -2
- package/src/api/messaging/createNewGroup.js +1 -1
- package/src/api/messaging/deleteMessage.js +1 -1
- package/src/api/messaging/forwardMessage.js +9 -1
- package/src/api/messaging/getEmojiUrl.js +5 -1
- package/src/api/messaging/getMessage.js +4 -2
- package/src/api/messaging/getThemePictures.js +21 -28
- package/src/api/messaging/markAsRead.js +1 -0
- package/src/api/messaging/muteThread.js +1 -1
- package/src/api/messaging/pinMessage.js +10 -1
- package/src/api/messaging/scheduler.js +71 -4
- package/src/api/messaging/sendBroadcast.js +15 -0
- package/src/api/messaging/sendMessage.js +23 -1
- package/src/api/messaging/sendTypingIndicator.js +0 -15
- package/src/api/messaging/sessionGuard.js +45 -9
- package/src/api/messaging/setMessageReaction.js +2 -1
- package/src/api/messaging/threadColors.js +45 -12
- package/src/api/messaging/uploadAttachment.js +37 -3
- package/src/api/socket/OldMessage.js +7 -2
- package/src/api/socket/core/connectMqtt.js +68 -81
- package/src/api/socket/core/emitAuth.js +11 -2
- package/src/api/socket/core/getSeqID.js +28 -36
- package/src/api/socket/core/getTaskResponseData.js +3 -1
- package/src/api/socket/core/parseDelta.js +1 -1
- package/src/api/socket/detail/buildStream.js +4 -1
- package/src/api/socket/detail/constants.js +4 -1
- package/src/api/socket/e2ee/crypto.js +40 -2
- package/src/api/socket/e2ee/index.js +124 -73
- package/src/api/socket/e2ee/protocol.js +40 -32
- package/src/api/socket/e2ee/ratchet.js +43 -37
- package/src/api/socket/e2ee/store.js +47 -133
- package/src/api/socket/e2ee/vendor/fb-e2ee.cjs +18 -140
- package/src/api/socket/listenE2EE.js +23 -12
- package/src/api/socket/listenMqtt.js +94 -110
- package/src/api/socket/middleware/index.js +61 -7
- package/src/api/socket/sendMessage.js +78 -170
- package/src/api/socket/sendMessageMqtt.js +6 -0
- package/src/api/threads/getThreadHistory.js +68 -38
- package/src/api/threads/getThreadInfo.js +4 -3
- package/src/api/threads/getThreadList.js +34 -31
- package/src/api/threads/getThreadPictures.js +1 -1
- package/src/api/users/getUserInfo.js +5 -2
- package/src/api/users/getUserInfoV2.js +65 -59
- package/src/app/createFcaClient.js +2 -2
- package/src/core/sendReqMqtt.js +2 -1
- package/src/database/helpers.js +12 -0
- package/src/database/models/index.js +8 -9
- package/src/utils/broadcast.js +1 -1
- package/src/utils/clientIdentity.js +50 -3
- package/src/utils/cookies.js +4 -2
- package/src/utils/format/utils.js +10 -0
- package/src/utils/headers.js +26 -12
- package/src/utils/loginParser/autoLogin.js +12 -0
- package/src/utils/loginParser/parseAndCheckLogin.js +7 -0
- package/src/utils/loginParser/textUtils.js +6 -0
- package/src/utils/request/config.js +4 -1
- package/src/utils/request/methods.js +0 -13
- package/src/utils/request/proxy.js +13 -0
- package/src/utils/request/retry.js +0 -10
- package/src/utils/request/sanitize.js +1 -1
- package/src/utils/textEffects.js +85 -0
- package/src/utils/utils.js +17 -3
- package/src/utils/instanceLock.js +0 -35
- package/src/utils/ipGuard.js +0 -58
- package/src/utils/sendThrottle.js +0 -51
|
@@ -37,11 +37,13 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
37
37
|
largePreviewHeight: attachment.large_preview.height,
|
|
38
38
|
largePreviewWidth: attachment.large_preview.width,
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
44
45
|
|
|
46
|
+
// @Undocumented
|
|
45
47
|
attributionApp: attachment.attribution_app
|
|
46
48
|
? {
|
|
47
49
|
attributionAppID: attachment.attribution_app.id,
|
|
@@ -68,15 +70,16 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
68
70
|
width: attachment.animated_image.width,
|
|
69
71
|
height: attachment.animated_image.height,
|
|
70
72
|
|
|
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,
|
|
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
|
|
79
81
|
|
|
82
|
+
// @Undocumented
|
|
80
83
|
attributionApp: attachment.attribution_app
|
|
81
84
|
? {
|
|
82
85
|
attributionAppID: attachment.attribution_app.id,
|
|
@@ -96,7 +99,7 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
96
99
|
),
|
|
97
100
|
duration: attachment.playable_duration_in_ms,
|
|
98
101
|
|
|
99
|
-
thumbnailUrl: attachment.large_image.uri,
|
|
102
|
+
thumbnailUrl: attachment.large_image.uri, // @Legacy
|
|
100
103
|
|
|
101
104
|
previewUrl: attachment.large_image.uri,
|
|
102
105
|
previewWidth: attachment.large_image.width,
|
|
@@ -122,14 +125,14 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
|
122
125
|
isMalicious: attachment.is_malicious,
|
|
123
126
|
contentType: attachment.content_type,
|
|
124
127
|
|
|
125
|
-
name: attachment.filename,
|
|
126
|
-
mimeType: "",
|
|
127
|
-
fileSize: -1
|
|
128
|
+
name: attachment.filename, // @Legacy
|
|
129
|
+
mimeType: "", // @Legacy
|
|
130
|
+
fileSize: -1 // @Legacy
|
|
128
131
|
};
|
|
129
132
|
case "MessageAudio":
|
|
130
133
|
return {
|
|
131
134
|
type: "audio",
|
|
132
|
-
ID: attachment.url_shimhash,
|
|
135
|
+
ID: attachment.url_shimhash, // Not fowardable
|
|
133
136
|
filename: attachment.filename,
|
|
134
137
|
original_extension: getExtension(
|
|
135
138
|
attachment.original_extension,
|
|
@@ -210,6 +213,19 @@ function formatExtensibleAttachment(attachment) {
|
|
|
210
213
|
|
|
211
214
|
subattachments: attachment.story_attachment.subattachments,
|
|
212
215
|
|
|
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
|
+
//
|
|
213
229
|
properties: attachment.story_attachment.properties.reduce(function(
|
|
214
230
|
obj,
|
|
215
231
|
cur
|
|
@@ -219,10 +235,11 @@ function formatExtensibleAttachment(attachment) {
|
|
|
219
235
|
},
|
|
220
236
|
{}),
|
|
221
237
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
238
|
+
// Deprecated fields
|
|
239
|
+
animatedImageSize: "", // @Legacy
|
|
240
|
+
facebookUrl: "", // @Legacy
|
|
241
|
+
styleList: "", // @Legacy
|
|
242
|
+
target: "", // @Legacy
|
|
226
243
|
thumbnailUrl:
|
|
227
244
|
attachment.story_attachment.media == null
|
|
228
245
|
? null
|
|
@@ -232,7 +249,7 @@ function formatExtensibleAttachment(attachment) {
|
|
|
232
249
|
: (
|
|
233
250
|
attachment.story_attachment.media.animated_image ||
|
|
234
251
|
attachment.story_attachment.media.image
|
|
235
|
-
).uri,
|
|
252
|
+
).uri, // @Legacy
|
|
236
253
|
thumbnailWidth:
|
|
237
254
|
attachment.story_attachment.media == null
|
|
238
255
|
? null
|
|
@@ -242,7 +259,7 @@ function formatExtensibleAttachment(attachment) {
|
|
|
242
259
|
: (
|
|
243
260
|
attachment.story_attachment.media.animated_image ||
|
|
244
261
|
attachment.story_attachment.media.image
|
|
245
|
-
).width,
|
|
262
|
+
).width, // @Legacy
|
|
246
263
|
thumbnailHeight:
|
|
247
264
|
attachment.story_attachment.media == null
|
|
248
265
|
? null
|
|
@@ -252,7 +269,7 @@ function formatExtensibleAttachment(attachment) {
|
|
|
252
269
|
: (
|
|
253
270
|
attachment.story_attachment.media.animated_image ||
|
|
254
271
|
attachment.story_attachment.media.image
|
|
255
|
-
).height
|
|
272
|
+
).height // @Legacy
|
|
256
273
|
};
|
|
257
274
|
} else {
|
|
258
275
|
return { error: "Don't know what to do with extensible_attachment." };
|
|
@@ -331,7 +348,7 @@ function formatEventData(event) {
|
|
|
331
348
|
ad_preferences_link: event.ad_preferences_link,
|
|
332
349
|
ad_properties: event.ad_properties
|
|
333
350
|
};
|
|
334
|
-
|
|
351
|
+
// never data
|
|
335
352
|
case "ParticipantJoinedGroupCallExtensibleMessageAdminText":
|
|
336
353
|
case "ThreadEphemeralTtlModeExtensibleMessageAdminText":
|
|
337
354
|
case "StartedSharingVideoExtensibleMessageAdminText":
|
|
@@ -359,7 +376,8 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
359
376
|
const messages = messageThread.messages.nodes.map(function(d) {
|
|
360
377
|
switch (d.__typename) {
|
|
361
378
|
case "UserMessage":
|
|
362
|
-
|
|
379
|
+
// Give priority to stickers. They're seen as normal messages but we've
|
|
380
|
+
// been considering them as attachments.
|
|
363
381
|
var maybeStickerAttachment;
|
|
364
382
|
if (d.sticker) {
|
|
365
383
|
maybeStickerAttachment = [
|
|
@@ -374,17 +392,17 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
374
392
|
width: d.sticker.width,
|
|
375
393
|
height: d.sticker.height,
|
|
376
394
|
|
|
377
|
-
caption: d.snippet,
|
|
378
|
-
description: d.sticker.label,
|
|
395
|
+
caption: d.snippet, // Not sure what the heck caption was.
|
|
396
|
+
description: d.sticker.label, // Not sure about this one either.
|
|
379
397
|
|
|
380
398
|
frameCount: d.sticker.frame_count,
|
|
381
399
|
frameRate: d.sticker.frame_rate,
|
|
382
400
|
framesPerRow: d.sticker.frames_per_row,
|
|
383
401
|
framesPerCol: d.sticker.frames_per_col,
|
|
384
402
|
|
|
385
|
-
stickerID: d.sticker.id,
|
|
386
|
-
spriteURI: d.sticker.sprite_image,
|
|
387
|
-
spriteURI2x: d.sticker.sprite_image_2x
|
|
403
|
+
stickerID: d.sticker.id, // @Legacy
|
|
404
|
+
spriteURI: d.sticker.sprite_image, // @Legacy
|
|
405
|
+
spriteURI2x: d.sticker.sprite_image_2x // @Legacy
|
|
388
406
|
}
|
|
389
407
|
];
|
|
390
408
|
}
|
|
@@ -418,6 +436,7 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
418
436
|
mentions: mentionsObj,
|
|
419
437
|
isUnread: d.unread,
|
|
420
438
|
|
|
439
|
+
// New
|
|
421
440
|
messageReactions: d.message_reactions
|
|
422
441
|
? d.message_reactions.map(formatReactionsGraphQL)
|
|
423
442
|
: null,
|
|
@@ -438,6 +457,7 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
438
457
|
threadName: d.thread_name
|
|
439
458
|
},
|
|
440
459
|
|
|
460
|
+
// @Legacy
|
|
441
461
|
author: d.message_sender.id,
|
|
442
462
|
logMessageType: "log:thread-name",
|
|
443
463
|
logMessageData: { name: d.thread_name }
|
|
@@ -454,9 +474,9 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
454
474
|
snippet: d.snippet,
|
|
455
475
|
eventData:
|
|
456
476
|
d.image_with_metadata == null
|
|
457
|
-
? {}
|
|
477
|
+
? {} /* removed image */
|
|
458
478
|
: {
|
|
459
|
-
|
|
479
|
+
/* image added */
|
|
460
480
|
threadImage: {
|
|
461
481
|
attachmentID: d.image_with_metadata.legacy_attachment_id,
|
|
462
482
|
width: d.image_with_metadata.original_dimensions.x,
|
|
@@ -465,6 +485,7 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
465
485
|
}
|
|
466
486
|
},
|
|
467
487
|
|
|
488
|
+
// @Legacy
|
|
468
489
|
logMessageType: "log:thread-icon",
|
|
469
490
|
logMessageData: {
|
|
470
491
|
thread_icon: d.image_with_metadata
|
|
@@ -483,12 +504,13 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
483
504
|
eventType: "remove_participants",
|
|
484
505
|
snippet: d.snippet,
|
|
485
506
|
eventData: {
|
|
486
|
-
|
|
507
|
+
// Array of IDs.
|
|
487
508
|
participantsRemoved: d.participants_removed.map(function(p) {
|
|
488
509
|
return p.id;
|
|
489
510
|
})
|
|
490
511
|
},
|
|
491
512
|
|
|
513
|
+
// @Legacy
|
|
492
514
|
logMessageType: "log:unsubscribe",
|
|
493
515
|
logMessageData: {
|
|
494
516
|
leftParticipantFbId: d.participants_removed.map(function(p) {
|
|
@@ -507,12 +529,13 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
507
529
|
eventType: "add_participants",
|
|
508
530
|
snippet: d.snippet,
|
|
509
531
|
eventData: {
|
|
510
|
-
|
|
532
|
+
// Array of IDs.
|
|
511
533
|
participantsAdded: d.participants_added.map(function(p) {
|
|
512
534
|
return p.id;
|
|
513
535
|
})
|
|
514
536
|
},
|
|
515
537
|
|
|
538
|
+
// @Legacy
|
|
516
539
|
logMessageType: "log:subscribe",
|
|
517
540
|
logMessageData: {
|
|
518
541
|
addedParticipants: d.participants_added.map(function(p) {
|
|
@@ -531,6 +554,7 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
531
554
|
eventType: "video_call",
|
|
532
555
|
snippet: d.snippet,
|
|
533
556
|
|
|
557
|
+
// @Legacy
|
|
534
558
|
logMessageType: "other"
|
|
535
559
|
};
|
|
536
560
|
case "VoiceCallMessage":
|
|
@@ -544,6 +568,7 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
544
568
|
eventType: "voice_call",
|
|
545
569
|
snippet: d.snippet,
|
|
546
570
|
|
|
571
|
+
// @Legacy
|
|
547
572
|
logMessageType: "other"
|
|
548
573
|
};
|
|
549
574
|
case "GenericAdminTextMessage":
|
|
@@ -558,10 +583,11 @@ function formatMessagesGraphQLResponse(data) {
|
|
|
558
583
|
eventType: d.extensible_message_admin_text_type.toLowerCase(),
|
|
559
584
|
eventData: formatEventData(d.extensible_message_admin_text),
|
|
560
585
|
|
|
586
|
+
// @Legacy
|
|
561
587
|
logMessageType: getAdminTextMessageType(
|
|
562
588
|
d.extensible_message_admin_text_type
|
|
563
589
|
),
|
|
564
|
-
logMessageData: d.extensible_message_admin_text
|
|
590
|
+
logMessageData: d.extensible_message_admin_text // Maybe different?
|
|
565
591
|
};
|
|
566
592
|
default:
|
|
567
593
|
return { error: "Don't know about message type " + d.__typename };
|
|
@@ -593,11 +619,13 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
|
593
619
|
};
|
|
594
620
|
}
|
|
595
621
|
|
|
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.
|
|
596
624
|
const form = {
|
|
597
625
|
av: ctx.userID,
|
|
598
626
|
queries: JSON.stringify({
|
|
599
627
|
o0: {
|
|
600
|
-
|
|
628
|
+
// This doc_id was valid on February 2nd 2017.
|
|
601
629
|
doc_id: "1498317363570230",
|
|
602
630
|
query_params: {
|
|
603
631
|
id: threadID,
|
|
@@ -617,7 +645,9 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
|
617
645
|
if (resData.error) {
|
|
618
646
|
throw resData;
|
|
619
647
|
}
|
|
620
|
-
|
|
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?
|
|
621
651
|
if (resData[resData.length - 1].error_results !== 0) {
|
|
622
652
|
throw new Error("There was an error_result.");
|
|
623
653
|
}
|
|
@@ -233,7 +233,7 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
233
233
|
out[info.threadID] = info;
|
|
234
234
|
}
|
|
235
235
|
} catch (e) {
|
|
236
|
-
|
|
236
|
+
// Skip malformed entries but continue processing others
|
|
237
237
|
log.error("getThreadInfoGraphQL", e && e.message ? e.message : String(e));
|
|
238
238
|
}
|
|
239
239
|
}
|
|
@@ -248,6 +248,7 @@ 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
|
|
251
252
|
if (threadData && (typeof create === "function" || typeof update === "function")) {
|
|
252
253
|
const tasks = [];
|
|
253
254
|
for (const id of stale) {
|
|
@@ -264,7 +265,7 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
264
265
|
try {
|
|
265
266
|
await Promise.all(tasks);
|
|
266
267
|
} catch {
|
|
267
|
-
|
|
268
|
+
// Swallow DB errors – not critical for API behavior
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
271
|
}
|
|
@@ -281,7 +282,7 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
281
282
|
|
|
282
283
|
return callback(null, result);
|
|
283
284
|
} catch (err) {
|
|
284
|
-
|
|
285
|
+
// Horizon-style anti-get-info message to hint possible spam/limit
|
|
285
286
|
log.error(
|
|
286
287
|
"getThreadInfoGraphQL",
|
|
287
288
|
"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()),
|
|
20
|
+
userID: formatID(p.id.toString()), // do we need .toString()? when it is not a string?
|
|
21
21
|
name: p.name,
|
|
22
22
|
shortName: p.short_name,
|
|
23
23
|
gender: p.gender,
|
|
24
|
-
url: p.url,
|
|
24
|
+
url: p.url, // how about making it profileURL
|
|
25
25
|
profilePicture: p.big_image_src.uri,
|
|
26
26
|
username: p.username || null,
|
|
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
|
|
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?
|
|
34
34
|
};
|
|
35
35
|
case "Page":
|
|
36
36
|
return {
|
|
37
37
|
accountType: p["__typename"],
|
|
38
|
-
userID: formatID(p.id.toString()),
|
|
38
|
+
userID: formatID(p.id.toString()), // or maybe... pageID?
|
|
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
|
-
|
|
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
|
|
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
|
|
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),
|
|
57
|
-
profilePicture: p.big_image_src.uri,
|
|
58
|
-
username: p.username || null,
|
|
59
|
-
isMessageBlockedByViewer: p.is_message_blocked_by_viewer
|
|
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
|
|
60
60
|
};
|
|
61
61
|
default:
|
|
62
62
|
log.warn(
|
|
@@ -67,12 +67,13 @@ 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"]}]`
|
|
70
|
+
name: p.name || `[unknown ${p["__typename"]}]` // probably it will always be something... but fallback to [unknown], just in case
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
// "FF8C0077" -> "8C0077"
|
|
76
77
|
function formatColor(color) {
|
|
77
78
|
if (color && color.match(/^(?:[0-9a-fA-F]{8})$/g)) return color.slice(2);
|
|
78
79
|
return color;
|
|
@@ -108,7 +109,7 @@ function formatThreadList(data) {
|
|
|
108
109
|
return {
|
|
109
110
|
threadID: t.thread_key
|
|
110
111
|
? formatID(t.thread_key.thread_fbid || t.thread_key.other_user_id)
|
|
111
|
-
: null,
|
|
112
|
+
: null, // shall never be null
|
|
112
113
|
name: getThreadName(t),
|
|
113
114
|
unreadCount: t.unread_count,
|
|
114
115
|
messageCount: t.messages_count,
|
|
@@ -124,20 +125,20 @@ function formatThreadList(data) {
|
|
|
124
125
|
adminIDs: t.thread_admins.map(a => a.id),
|
|
125
126
|
folder: t.folder,
|
|
126
127
|
isGroup: t.thread_type === "GROUP",
|
|
127
|
-
customizationEnabled: t.customization_enabled,
|
|
128
|
-
participantAddMode: t.participant_add_mode_as_string,
|
|
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"
|
|
129
130
|
montageThread: t.montage_thread
|
|
130
131
|
? Buffer.from(t.montage_thread.id, "base64").toString()
|
|
131
|
-
: null,
|
|
132
|
+
: null, // base64 encoded string "message_thread:0000000000000000"
|
|
132
133
|
reactionsMuteMode: t.reactions_mute_mode,
|
|
133
134
|
mentionsMuteMode: t.mentions_mute_mode,
|
|
134
135
|
isArchived: t.has_viewer_archived,
|
|
135
136
|
isSubscribed: t.is_viewer_subscribed,
|
|
136
|
-
timestamp: t.updated_time_precise,
|
|
137
|
+
timestamp: t.updated_time_precise, // in miliseconds
|
|
137
138
|
snippet: lastMessageNode ? lastMessageNode.snippet : null,
|
|
138
139
|
snippetAttachments: lastMessageNode
|
|
139
140
|
? lastMessageNode.extensible_attachment
|
|
140
|
-
: null,
|
|
141
|
+
: null, // TODO: not sure if it works
|
|
141
142
|
snippetSender: lastMessageNode
|
|
142
143
|
? formatID(
|
|
143
144
|
(lastMessageNode.message_sender.messaging_actor.id || "").toString()
|
|
@@ -145,7 +146,7 @@ function formatThreadList(data) {
|
|
|
145
146
|
: null,
|
|
146
147
|
lastMessageTimestamp: lastMessageNode
|
|
147
148
|
? lastMessageNode.timestamp_precise
|
|
148
|
-
: null,
|
|
149
|
+
: null, // timestamp in miliseconds
|
|
149
150
|
lastReadTimestamp:
|
|
150
151
|
t.last_read_receipt && t.last_read_receipt.nodes.length > 0
|
|
151
152
|
? t.last_read_receipt.nodes[0]
|
|
@@ -157,7 +158,7 @@ function formatThreadList(data) {
|
|
|
157
158
|
participantIDs: formatParticipants(t.all_participants).map(
|
|
158
159
|
participant => participant.userID
|
|
159
160
|
),
|
|
160
|
-
threadType: t.thread_type === "GROUP" ? 2 : 1,
|
|
161
|
+
threadType: t.thread_type === "GROUP" ? 2 : 1, // "GROUP" or "ONE_TO_ONE"
|
|
161
162
|
inviteLink: {
|
|
162
163
|
enable: t.joinable_mode ? t.joinable_mode.mode == 1 : false,
|
|
163
164
|
link: t.joinable_mode ? t.joinable_mode.link : null
|
|
@@ -225,7 +226,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
|
225
226
|
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
|
226
227
|
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
227
228
|
.then(resData => {
|
|
228
|
-
|
|
229
|
+
// Validate resData is an array and has elements
|
|
229
230
|
if (!resData || !Array.isArray(resData) || resData.length === 0) {
|
|
230
231
|
throw {
|
|
231
232
|
error: "getThreadList: Invalid response data - resData is not a valid array",
|
|
@@ -233,6 +234,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
|
233
234
|
};
|
|
234
235
|
}
|
|
235
236
|
|
|
237
|
+
// Validate last element exists and has required properties
|
|
236
238
|
const lastElement = resData[resData.length - 1];
|
|
237
239
|
if (!lastElement || typeof lastElement !== "object") {
|
|
238
240
|
throw {
|
|
@@ -242,7 +244,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
|
242
244
|
}
|
|
243
245
|
|
|
244
246
|
if (lastElement.error_results > 0) {
|
|
245
|
-
|
|
247
|
+
// Check if first element and o0 exist before accessing errors
|
|
246
248
|
if (resData[0] && resData[0].o0 && resData[0].o0.errors) {
|
|
247
249
|
throw resData[0].o0.errors;
|
|
248
250
|
} else {
|
|
@@ -260,6 +262,7 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
|
260
262
|
};
|
|
261
263
|
}
|
|
262
264
|
|
|
265
|
+
// Validate first element and nested data structure
|
|
263
266
|
if (!resData[0] || !resData[0].o0 || !resData[0].o0.data ||
|
|
264
267
|
!resData[0].o0.data.viewer || !resData[0].o0.data.viewer.message_threads ||
|
|
265
268
|
!Array.isArray(resData[0].o0.data.viewer.message_threads.nodes)) {
|
|
@@ -119,11 +119,12 @@ function mergeUserEntry(a, b) {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
module.exports = function (defaultFuncs, api, ctx) {
|
|
122
|
-
|
|
122
|
+
// Read FastConfig-style anti-get-info flag from global config (if available)
|
|
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
|
|
127
128
|
if (disableAntiUserInfo) {
|
|
128
129
|
function formatLegacyData(data) {
|
|
129
130
|
const retObj = {};
|
|
@@ -338,11 +339,13 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
338
339
|
isProcessingQueue = false;
|
|
339
340
|
}
|
|
340
341
|
|
|
342
|
+
// Store interval reference for cleanup
|
|
341
343
|
const updateInterval = setInterval(() => {
|
|
342
344
|
checkAndUpdateUsers();
|
|
343
345
|
processQueue();
|
|
344
346
|
}, 10000);
|
|
345
347
|
|
|
348
|
+
// Store interval in ctx for cleanup on logout/stop
|
|
346
349
|
if (!ctx._userInfoIntervals) {
|
|
347
350
|
ctx._userInfoIntervals = [];
|
|
348
351
|
}
|
|
@@ -387,7 +390,7 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
387
390
|
}
|
|
388
391
|
return callback(null, ret);
|
|
389
392
|
}).catch(err => {
|
|
390
|
-
|
|
393
|
+
// Horizon-style anti-get-info message to hint rate limiting / spam block
|
|
391
394
|
log.error(
|
|
392
395
|
"getUserInfo",
|
|
393
396
|
"Lỗi: getUserInfo Có Thể Do Bạn Spam Quá Nhiều !,Hãy Thử Lại !"
|