fca-kzii 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.gitattributes +2 -0
- package/Extra/Bypass/956/index.js +234 -0
- package/Extra/Bypass/test/aaaa.json +170 -0
- package/Extra/Bypass/test/index.js +188 -0
- package/Extra/Database/index.js +469 -0
- package/Extra/ExtraAddons.js +82 -0
- package/Extra/ExtraFindUID.js +62 -0
- package/Extra/ExtraGetThread.js +365 -0
- package/Extra/ExtraScreenShot.js +430 -0
- package/Extra/ExtraUptimeRobot.js +38 -0
- package/Extra/Html/Classic/script.js +119 -0
- package/Extra/Html/Classic/style.css +8 -0
- package/Extra/Security/AES_256_GCM/index.js +0 -0
- package/Extra/Security/Base/Step_1.js +6 -0
- package/Extra/Security/Base/Step_2.js +22 -0
- package/Extra/Security/Base/Step_3.js +22 -0
- package/Extra/Security/Base/index.js +191 -0
- package/Extra/Security/Index.js +5 -0
- package/Extra/Security/Step_1.js +6 -0
- package/Extra/Security/Step_2.js +22 -0
- package/Extra/Security/Step_3.js +22 -0
- package/Extra/Src/Change_Environment.js +24 -0
- package/Extra/Src/Check_Update.js +67 -0
- package/Extra/Src/History.js +115 -0
- package/Extra/Src/Instant_Update.js +65 -0
- package/Extra/Src/Last-Run.js +65 -0
- package/Extra/Src/Premium.js +81 -0
- package/Extra/Src/Release_Memory.js +160 -0
- package/Extra/Src/Websocket.js +213 -0
- package/Extra/Src/image/checkmate.jpg +0 -0
- package/Extra/Src/test.js +28 -0
- package/Extra/Src/uuid.js +137 -0
- package/Func/AcceptAgreement.js +31 -0
- package/Func/ClearCache.js +64 -0
- package/Func/ReportV1.js +54 -0
- package/LICENSE +21 -0
- package/Language/index.json +222 -0
- package/Main.js +1266 -0
- package/README.md +152 -0
- package/SECURITY.md +18 -0
- package/broadcast.js +44 -0
- package/index.js +448 -0
- package/logger.js +66 -0
- package/package.json +97 -0
- package/src/Dev_Horizon_Data.js +125 -0
- package/src/Dev_getThreadInfoOLD.js +422 -0
- package/src/Dev_shareTest2.js +68 -0
- package/src/Dev_shareTest3.js +71 -0
- package/src/Premium.js +25 -0
- package/src/Screenshot.js +83 -0
- package/src/addExternalModule.js +16 -0
- package/src/addUserToGroup.js +79 -0
- package/src/changeAdminStatus.js +79 -0
- package/src/changeArchivedStatus.js +41 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +65 -0
- package/src/changeBlockedStatus.js +36 -0
- package/src/changeGroupImage.js +106 -0
- package/src/changeNickname.js +45 -0
- package/src/changeThreadColor.js +62 -0
- package/src/changeThreadEmoji.js +42 -0
- package/src/createNewGroup.js +70 -0
- package/src/createPoll.js +60 -0
- package/src/deleteMessage.js +45 -0
- package/src/deleteThread.js +43 -0
- package/src/editMessage.js +53 -0
- package/src/forwardAttachment.js +48 -0
- package/src/getAccessToken.js +28 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +27 -0
- package/src/getFriendsList.js +73 -0
- package/src/getMessage.js +103 -0
- package/src/getThreadHistory.js +537 -0
- package/src/getThreadInfo.js +424 -0
- package/src/getThreadInfoOLD.js +422 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadMain.js +220 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +59 -0
- package/src/getUserID.js +62 -0
- package/src/getUserInfo.js +112 -0
- package/src/getUserInfoMain.js +65 -0
- package/src/getUserInfoV2.js +32 -0
- package/src/getUserInfoV3.js +63 -0
- package/src/getUserInfoV4.js +55 -0
- package/src/getUserInfoV5.js +61 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +49 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/httpPostFormData.js +41 -0
- package/src/listenMqtt.js +930 -0
- package/src/listenMqttV1.js +846 -0
- package/src/logout.js +68 -0
- package/src/markAsDelivered.js +48 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +43 -0
- package/src/markAsSeen.js +51 -0
- package/src/muteThread.js +47 -0
- package/src/removeUserFromGroup.js +49 -0
- package/src/resolvePhotoUrl.js +37 -0
- package/src/searchForThread.js +43 -0
- package/src/sendMessage.js +386 -0
- package/src/sendMqttMessage.js +71 -0
- package/src/sendTypingIndicator.js +80 -0
- package/src/setMessageReaction.js +109 -0
- package/src/setPostReaction.js +102 -0
- package/src/setTitle.js +74 -0
- package/src/shareContact.js +55 -0
- package/src/shareLink.js +58 -0
- package/src/threadColors.js +39 -0
- package/src/unfriend.js +43 -0
- package/src/unsendMessage.js +40 -0
- package/test/Database_Test.js +4 -0
- package/test/Db2.js +530 -0
- package/test/Horizon_Database/A_README.md +1 -0
- package/test/Horizon_Database/Database.db +0 -0
- package/test/data/shareAttach.js +146 -0
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +7 -0
- package/test/env/.env +0 -0
- package/test/example-config.json +18 -0
- package/test/example-db.db +0 -0
- package/test/memoryleak.js +18 -0
- package/test/test-page.js +140 -0
- package/test/test.js +385 -0
- package/test/testname.js +1342 -0
- package/test/testv2.js +3 -0
- package/utils.js +3038 -0
@@ -0,0 +1,424 @@
|
|
1
|
+
/* eslint-disable linebreak-style */
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var utils = require("../utils");
|
5
|
+
// tương lai đi rồi fix ahahha
|
6
|
+
function formatEventReminders(reminder) {
|
7
|
+
return {
|
8
|
+
reminderID: reminder.id,
|
9
|
+
eventCreatorID: reminder.lightweight_event_creator.id,
|
10
|
+
time: reminder.time,
|
11
|
+
eventType: reminder.lightweight_event_type.toLowerCase(),
|
12
|
+
locationName: reminder.location_name,
|
13
|
+
// @TODO verify this
|
14
|
+
locationCoordinates: reminder.location_coordinates,
|
15
|
+
locationPage: reminder.location_page,
|
16
|
+
eventStatus: reminder.lightweight_event_status.toLowerCase(),
|
17
|
+
note: reminder.note,
|
18
|
+
repeatMode: reminder.repeat_mode.toLowerCase(),
|
19
|
+
eventTitle: reminder.event_title,
|
20
|
+
triggerMessage: reminder.trigger_message,
|
21
|
+
secondsToNotifyBefore: reminder.seconds_to_notify_before,
|
22
|
+
allowsRsvp: reminder.allows_rsvp,
|
23
|
+
relatedEvent: reminder.related_event,
|
24
|
+
members: reminder.event_reminder_members.edges.map(function(member) {
|
25
|
+
return {
|
26
|
+
memberID: member.node.id,
|
27
|
+
state: member.guest_list_state.toLowerCase()
|
28
|
+
};
|
29
|
+
})
|
30
|
+
};
|
31
|
+
}
|
32
|
+
|
33
|
+
function formatThreadGraphQLResponse(data) {
|
34
|
+
try{
|
35
|
+
var messageThread = data.message_thread;
|
36
|
+
} catch (err){
|
37
|
+
console.error("GetThreadInfoGraphQL", "Can't get this thread info!");
|
38
|
+
return {err: err};
|
39
|
+
}
|
40
|
+
var threadID = messageThread.thread_key.thread_fbid
|
41
|
+
? messageThread.thread_key.thread_fbid
|
42
|
+
: messageThread.thread_key.other_user_id;
|
43
|
+
|
44
|
+
// Remove me
|
45
|
+
var lastM = messageThread.last_message;
|
46
|
+
var snippetID =
|
47
|
+
lastM &&
|
48
|
+
lastM.nodes &&
|
49
|
+
lastM.nodes[0] &&
|
50
|
+
lastM.nodes[0].message_sender &&
|
51
|
+
lastM.nodes[0].message_sender.messaging_actor
|
52
|
+
? lastM.nodes[0].message_sender.messaging_actor.id
|
53
|
+
: null;
|
54
|
+
var snippetText =
|
55
|
+
lastM && lastM.nodes && lastM.nodes[0] ? lastM.nodes[0].snippet : null;
|
56
|
+
var lastR = messageThread.last_read_receipt;
|
57
|
+
var lastReadTimestamp =
|
58
|
+
lastR && lastR.nodes && lastR.nodes[0] && lastR.nodes[0].timestamp_precise
|
59
|
+
? lastR.nodes[0].timestamp_precise
|
60
|
+
: null;
|
61
|
+
|
62
|
+
return {
|
63
|
+
threadID: threadID,
|
64
|
+
threadName: messageThread.name,
|
65
|
+
participantIDs: messageThread.all_participants.edges.map(d => d.node.messaging_actor.id),
|
66
|
+
userInfo: messageThread.all_participants.edges.map(d => ({
|
67
|
+
id: d.node.messaging_actor.id,
|
68
|
+
name: d.node.messaging_actor.name,
|
69
|
+
firstName: d.node.messaging_actor.short_name,
|
70
|
+
vanity: d.node.messaging_actor.username,
|
71
|
+
thumbSrc: d.node.messaging_actor.big_image_src.uri,
|
72
|
+
profileUrl: d.node.messaging_actor.big_image_src.uri,
|
73
|
+
gender: d.node.messaging_actor.gender,
|
74
|
+
type: d.node.messaging_actor.__typename,
|
75
|
+
isFriend: d.node.messaging_actor.is_viewer_friend,
|
76
|
+
isBirthday: !!d.node.messaging_actor.is_birthday //not sure?
|
77
|
+
})),
|
78
|
+
unreadCount: messageThread.unread_count,
|
79
|
+
messageCount: messageThread.messages_count,
|
80
|
+
timestamp: messageThread.updated_time_precise,
|
81
|
+
muteUntil: messageThread.mute_until,
|
82
|
+
isGroup: messageThread.thread_type == "GROUP",
|
83
|
+
isSubscribed: messageThread.is_viewer_subscribed,
|
84
|
+
isArchived: messageThread.has_viewer_archived,
|
85
|
+
folder: messageThread.folder,
|
86
|
+
cannotReplyReason: messageThread.cannot_reply_reason,
|
87
|
+
eventReminders: messageThread.event_reminders
|
88
|
+
? messageThread.event_reminders.nodes.map(formatEventReminders)
|
89
|
+
: null,
|
90
|
+
emoji: messageThread.customization_info
|
91
|
+
? messageThread.customization_info.emoji
|
92
|
+
: null,
|
93
|
+
color:
|
94
|
+
messageThread.customization_info &&
|
95
|
+
messageThread.customization_info.outgoing_bubble_color
|
96
|
+
? messageThread.customization_info.outgoing_bubble_color.slice(2)
|
97
|
+
: null,
|
98
|
+
nicknames:
|
99
|
+
messageThread.customization_info &&
|
100
|
+
messageThread.customization_info.participant_customizations
|
101
|
+
? messageThread.customization_info.participant_customizations.reduce(
|
102
|
+
function(res, val) {
|
103
|
+
if (val.nickname) res[val.participant_id] = val.nickname;
|
104
|
+
return res;
|
105
|
+
},
|
106
|
+
{}
|
107
|
+
)
|
108
|
+
: {},
|
109
|
+
adminIDs: messageThread.thread_admins,
|
110
|
+
approvalMode: Boolean(messageThread.approval_mode),
|
111
|
+
approvalQueue: messageThread.group_approval_queue.nodes.map(a => ({
|
112
|
+
inviterID: a.inviter.id,
|
113
|
+
requesterID: a.requester.id,
|
114
|
+
timestamp: a.request_timestamp,
|
115
|
+
request_source: a.request_source // @Undocumented
|
116
|
+
})),
|
117
|
+
|
118
|
+
// @Undocumented
|
119
|
+
reactionsMuteMode: messageThread.reactions_mute_mode.toLowerCase(),
|
120
|
+
mentionsMuteMode: messageThread.mentions_mute_mode.toLowerCase(),
|
121
|
+
isPinProtected: messageThread.is_pin_protected,
|
122
|
+
relatedPageThread: messageThread.related_page_thread,
|
123
|
+
|
124
|
+
// @Legacy
|
125
|
+
name: messageThread.name,
|
126
|
+
snippet: snippetText,
|
127
|
+
snippetSender: snippetID,
|
128
|
+
snippetAttachments: [],
|
129
|
+
serverTimestamp: messageThread.updated_time_precise,
|
130
|
+
imageSrc: messageThread.image ? messageThread.image.uri : null,
|
131
|
+
isCanonicalUser: messageThread.is_canonical_neo_user,
|
132
|
+
isCanonical: messageThread.thread_type != "GROUP",
|
133
|
+
recipientsLoadable: true,
|
134
|
+
hasEmailParticipant: false,
|
135
|
+
readOnly: false,
|
136
|
+
canReply: messageThread.cannot_reply_reason == null,
|
137
|
+
lastMessageTimestamp: messageThread.last_message
|
138
|
+
? messageThread.last_message.timestamp_precise
|
139
|
+
: null,
|
140
|
+
lastMessageType: "message",
|
141
|
+
lastReadTimestamp: lastReadTimestamp,
|
142
|
+
threadType: messageThread.thread_type == "GROUP" ? 2 : 1,
|
143
|
+
TimeCreate: Date.now(),
|
144
|
+
TimeUpdate: Date.now()
|
145
|
+
};
|
146
|
+
}
|
147
|
+
|
148
|
+
const MAX_ARRAY_LENGTH = 6; //safe
|
149
|
+
var Request_Update_Time = 0;
|
150
|
+
var updateInterval;
|
151
|
+
var updateTimeout;
|
152
|
+
let Queues = [];
|
153
|
+
|
154
|
+
let onetimecook = false
|
155
|
+
|
156
|
+
function addToQueues(num) {
|
157
|
+
const existingArray = Queues.some(subArr => subArr.some(obj => obj.threadID == num.threadID));
|
158
|
+
|
159
|
+
if (!existingArray) {
|
160
|
+
if (Queues.length > 0 && Queues[Queues.length - 1].length === MAX_ARRAY_LENGTH) {
|
161
|
+
Queues.push([num]);
|
162
|
+
} else {
|
163
|
+
const lastArray = Queues.length > 0 ? Queues[Queues.length - 1] : [];
|
164
|
+
lastArray.push(num);
|
165
|
+
|
166
|
+
if (Queues.length === 0) {
|
167
|
+
Queues.push(lastArray);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
175
|
+
|
176
|
+
var { createData,getData,hasData,updateData, getAll } = require('../Extra/ExtraGetThread');
|
177
|
+
var Database = require('../Extra/Database');
|
178
|
+
|
179
|
+
return async function getThreadInfoGraphQL(threadID, callback) {
|
180
|
+
var resolveFunc = function(){};
|
181
|
+
var rejectFunc = function(){};
|
182
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
183
|
+
resolveFunc = resolve;
|
184
|
+
rejectFunc = reject;
|
185
|
+
});
|
186
|
+
|
187
|
+
if (utils.getType(callback) != "Function" && utils.getType(callback) != "AsyncFunction") {
|
188
|
+
callback = function (err, data) {
|
189
|
+
if (err) {
|
190
|
+
return rejectFunc(err);
|
191
|
+
}
|
192
|
+
resolveFunc(data);
|
193
|
+
};
|
194
|
+
}
|
195
|
+
|
196
|
+
if (utils.getType(threadID) !== "Array") threadID = [threadID];
|
197
|
+
|
198
|
+
|
199
|
+
if (utils.getType(global.Fca.Data.Userinfo) == "Array" || global.Fca.Data.Userinfo == undefined) global.Fca.Data.Userinfo = new Map();
|
200
|
+
|
201
|
+
const updateUserInfo = (threadInfo) => {
|
202
|
+
if (!global.Fca.Data.Userinfo) {
|
203
|
+
global.Fca.Data.Userinfo = new Map();
|
204
|
+
}
|
205
|
+
|
206
|
+
threadInfo.forEach(thread => {
|
207
|
+
const userInfo = thread.userInfo;
|
208
|
+
|
209
|
+
if (Array.isArray(userInfo)) {
|
210
|
+
const userInfoMap = new Map(userInfo.map(user => [user.id, user]));
|
211
|
+
for (const [id, user] of userInfoMap) {
|
212
|
+
global.Fca.Data.Userinfo.set(id, user);
|
213
|
+
}
|
214
|
+
}
|
215
|
+
});
|
216
|
+
};
|
217
|
+
|
218
|
+
const getMultiInfo = async function (threadIDs) {
|
219
|
+
let form = {};
|
220
|
+
let tempThreadInf = [];
|
221
|
+
threadIDs.forEach((x,y) => {
|
222
|
+
form["o" + y] = {
|
223
|
+
doc_id: "3449967031715030",
|
224
|
+
query_params: { id: x, message_limit: 0, load_messages: false, load_read_receipts: false, before: null }
|
225
|
+
};
|
226
|
+
});
|
227
|
+
let Submit = { queries: JSON.stringify(form), batch_name: "MessengerGraphQLThreadFetcher" };
|
228
|
+
|
229
|
+
const promise = new Promise((resolve, reject) => {
|
230
|
+
defaultFuncs.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, Submit)
|
231
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
232
|
+
.then(resData => {
|
233
|
+
if (resData.error || resData[resData.length - 1].error_results !== 0) throw "Lỗi: getThreadInfoGraphQL Có Thể Do Bạn Spam Quá Nhiều";
|
234
|
+
resData = resData.slice(0, -1).sort((a, b) => Object.keys(a)[0].localeCompare(Object.keys(b)[0]));
|
235
|
+
resData.forEach((x, y) => tempThreadInf.push(formatThreadGraphQLResponse(x["o" + y].data)));
|
236
|
+
return resolve({
|
237
|
+
Success: true,
|
238
|
+
Data: tempThreadInf
|
239
|
+
});
|
240
|
+
})
|
241
|
+
.catch(() => {
|
242
|
+
reject({ Success: false, Data: '' })
|
243
|
+
});
|
244
|
+
})
|
245
|
+
|
246
|
+
return await promise;
|
247
|
+
}
|
248
|
+
|
249
|
+
const formatAndUpdateData = (AllThreadInfo) => {
|
250
|
+
try {
|
251
|
+
AllThreadInfo.forEach(threadInf => { updateData(threadInf.threadID, threadInf); })
|
252
|
+
updateUserInfo(AllThreadInfo) // [ {}, {} ]
|
253
|
+
|
254
|
+
} catch (e) {
|
255
|
+
console.log(e);
|
256
|
+
}
|
257
|
+
}
|
258
|
+
|
259
|
+
const formatAndCreateData = (AllThreadInfo) => {
|
260
|
+
try {
|
261
|
+
AllThreadInfo.forEach(threadInf => { createData(threadInf.threadID, threadInf); })
|
262
|
+
updateUserInfo(AllThreadInfo) // [ {}, {} ]
|
263
|
+
|
264
|
+
} catch (e) {
|
265
|
+
console.log(e);
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
const checkAverageStaticTimestamp = function (avgTimeStamp) {
|
270
|
+
const DEFAULT_UPDATE_TIME = 900 * 1000; //thời gian cập nhật tối đa + với thời gian trung bình của tổng request 1 mảng
|
271
|
+
//khi request phút thứ 3, 1 req ở phút thứ 7, 1 req ở phút thứ 10, vậy trung bình là (3+7+1) / time.length (3) + với 15p = tg trung bình để cập nhật 1 mảng
|
272
|
+
const MAXIMUM_ERROR_TIME = 10 * 1000;
|
273
|
+
return { //khi check = false thì cần cập nhật vì đã hơn thời gian tb + 15p
|
274
|
+
Check: (parseInt(avgTimeStamp) + parseInt(DEFAULT_UPDATE_TIME)) + parseInt(MAXIMUM_ERROR_TIME) >= Date.now(), // ở đây avgTimeStamp là thời gian cố định của 1 mảng queue khi đầy
|
275
|
+
timeLeft: (parseInt(avgTimeStamp) + parseInt(DEFAULT_UPDATE_TIME)) - Date.now() + parseInt(MAXIMUM_ERROR_TIME)
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
const autoCheckAndUpdateRecallTime = () => {
|
280
|
+
let holdTime = [];
|
281
|
+
let oneTimeCall = false;
|
282
|
+
//lấy tất cả trung bình thời gian của tất cả mảng và tìm thời gian còn lại ngắn nhất, nếu có sẵn id cần cập nhật thì cập nhật ngày lập tức
|
283
|
+
Queues.forEach((i, index) => {
|
284
|
+
// [ { threadID, TimeCreate }, {} ]
|
285
|
+
const averageTimestamp = Math.round(i.reduce((acc, obj) => acc + obj.TimeCreate, 0) / i.length);
|
286
|
+
const DataAvg = checkAverageStaticTimestamp(averageTimestamp);
|
287
|
+
if (DataAvg.Check) {
|
288
|
+
//cần chờ
|
289
|
+
// holdTime.push(DataAvg.timeLeft);
|
290
|
+
//cho thi cho 10s sau check lai roi cho tiep nhe =))
|
291
|
+
}
|
292
|
+
else {
|
293
|
+
oneTimeCall = true;
|
294
|
+
}
|
295
|
+
});
|
296
|
+
|
297
|
+
if (oneTimeCall) autoUpdateData(); // cập nhật ngay, nhin la biet tot hon hold roi =))
|
298
|
+
|
299
|
+
// if (holdTime.length >= 1) {
|
300
|
+
// holdTime.sort((a,b) => a - b) //low to high time
|
301
|
+
// if (holdTime[0] > Request_Update_Time) {
|
302
|
+
// Request_Update_Time = holdTime[0];
|
303
|
+
// clearInterval(updateInterval);
|
304
|
+
// updateInterval = setInterval(() => { autoUpdateData(); }, holdTime[0])
|
305
|
+
// }
|
306
|
+
// }
|
307
|
+
|
308
|
+
//hold lam cai cho gi khi ta co check lien tuc 10s 1 lan 😔
|
309
|
+
|
310
|
+
const MAXIMUM_RECALL_TIME = 30 * 1000;
|
311
|
+
clearTimeout(updateTimeout);
|
312
|
+
updateTimeout = setTimeout(() => { autoCheckAndUpdateRecallTime(); }, MAXIMUM_RECALL_TIME)
|
313
|
+
}
|
314
|
+
|
315
|
+
const autoUpdateData = async function() {
|
316
|
+
//[ [ {}, {} ], [ {}, {} ] ]
|
317
|
+
let doUpdate = [];
|
318
|
+
let holdTime = [];
|
319
|
+
|
320
|
+
Queues.forEach((i, index) => {
|
321
|
+
// [ {}, {} ]
|
322
|
+
const averageTimestamp = Math.round(i.reduce((acc, obj) => acc + obj.TimeCreate, 0) / i.length);
|
323
|
+
// thời gian trung bình của 1 mảng từ lúc bắt đầu request lần đầu, cần + thêm thời gian cố định là 15p !
|
324
|
+
|
325
|
+
const DataAvg = checkAverageStaticTimestamp(averageTimestamp)
|
326
|
+
if (DataAvg.Check) {
|
327
|
+
// chờ tiếp
|
328
|
+
}
|
329
|
+
else {
|
330
|
+
// đã hơn thời gian 15p
|
331
|
+
doUpdate.push(i) // [ {}, {} ]
|
332
|
+
Queues.splice(index, 1); //đạt điều kiện nên xoá để tý nó tự thêm 💀
|
333
|
+
}
|
334
|
+
|
335
|
+
});
|
336
|
+
|
337
|
+
if (doUpdate.length >= 1) {
|
338
|
+
// maybe [ [ {}, {} ] [ {}, {} ] ]
|
339
|
+
let ids = []; // [ id, id ]
|
340
|
+
doUpdate.forEach(i => {
|
341
|
+
//[ {} {} ]
|
342
|
+
const onlyThreadID = [...new Set(i.map(obj => obj.threadID))]; // [ id1, id2 ]
|
343
|
+
ids.push(onlyThreadID) //[ [ id1, id2 ] ]
|
344
|
+
})
|
345
|
+
|
346
|
+
// [ [ id1, id2 ],[ id1, id2 ] ] 5 per arr
|
347
|
+
|
348
|
+
ids.forEach(async function(i) {
|
349
|
+
const dataResp = await getMultiInfo(i);
|
350
|
+
if (dataResp.Success == true) {
|
351
|
+
let MultiThread = dataResp.Data;
|
352
|
+
formatAndUpdateData(MultiThread)
|
353
|
+
}
|
354
|
+
else {
|
355
|
+
global.Fca.Require.logger.Warning('CANT NOT GET THREADINFO 💀 MAYBE U HAS BEEN BLOCKED FROM FACEBOOK');
|
356
|
+
}
|
357
|
+
})
|
358
|
+
}
|
359
|
+
}
|
360
|
+
|
361
|
+
const createOrTakeDataFromDatabase = async (threadIDs) => {
|
362
|
+
let inDb = []; //NOTE: xử lý resp thành 1 mảng nếu có nhiều hơn 1 threadID và obj nếu 1 threadID
|
363
|
+
let inFastArr = [];
|
364
|
+
let createNow = [];
|
365
|
+
let cbThreadInfos = [];
|
366
|
+
// kiểm tra và phân ra 2 loại 1 là chưa có 2 là có =))
|
367
|
+
// kiểm tra
|
368
|
+
|
369
|
+
threadIDs.forEach(id => {
|
370
|
+
// id, id ,id
|
371
|
+
hasData(id) == true ? inDb.push(id) : createNow.push(id)
|
372
|
+
});
|
373
|
+
|
374
|
+
if (inDb.length >= 1) {
|
375
|
+
let threadInfos = inDb.map(id => getData(id));
|
376
|
+
cbThreadInfos = cbThreadInfos.concat(threadInfos);
|
377
|
+
updateUserInfo(threadInfos);
|
378
|
+
|
379
|
+
//request update queue
|
380
|
+
threadInfos.forEach(i => addToQueues({ threadID: i.threadID, TimeCreate: Date.now() }));
|
381
|
+
}
|
382
|
+
if (createNow.length >= 1) {
|
383
|
+
//5 data per chunk []
|
384
|
+
const chunkSize = 5;
|
385
|
+
const totalChunk = []; // [ [ id, id ], [ id,id ] ]
|
386
|
+
|
387
|
+
for (let i = 0; i < createNow.length; i += chunkSize) {
|
388
|
+
const chunk = createNow.slice(i, i + chunkSize);
|
389
|
+
totalChunk.push(chunk);
|
390
|
+
}
|
391
|
+
|
392
|
+
for (let i of totalChunk) {
|
393
|
+
//i = [ id,id ]
|
394
|
+
const newThreadInf = await getMultiInfo(i); // always [ {} ] or [ {}, {} ]
|
395
|
+
if (newThreadInf.Success == true) {
|
396
|
+
let MultiThread = newThreadInf.Data;
|
397
|
+
formatAndCreateData(MultiThread)
|
398
|
+
cbThreadInfos = cbThreadInfos.concat(MultiThread)
|
399
|
+
|
400
|
+
//request update queue
|
401
|
+
MultiThread.forEach(i => addToQueues({ threadID: i.threadID, TimeCreate: Date.now() }));
|
402
|
+
}
|
403
|
+
else {
|
404
|
+
global.Fca.Require.logger.Warning('CANT NOT GET THREADINFO 💀 MAYBE U HAS BEEN BLOCKED FROM FACEBOOK');
|
405
|
+
}
|
406
|
+
}
|
407
|
+
}
|
408
|
+
return cbThreadInfos.length == 1 ? callback(null, cbThreadInfos[0]) : callback(null, cbThreadInfos)
|
409
|
+
}
|
410
|
+
|
411
|
+
if (global.Fca.Data.Already != true) {
|
412
|
+
global.Fca.Data.Already = true;
|
413
|
+
autoCheckAndUpdateRecallTime();
|
414
|
+
setInterval(function(){
|
415
|
+
const MapToArray = Array.from(global.Fca.Data.Userinfo, ([name, value]) => (value));
|
416
|
+
Database(true).set('UserInfo', MapToArray);
|
417
|
+
}, 420 * 1000);
|
418
|
+
}
|
419
|
+
|
420
|
+
await createOrTakeDataFromDatabase(threadID);
|
421
|
+
|
422
|
+
return returnPromise;
|
423
|
+
};
|
424
|
+
};
|