@dongdev/fca-unofficial 3.0.31 → 4.0.1
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/LICENSE +191 -0
- package/README.md +238 -398
- package/dist/cjs.cjs +9 -0
- package/dist/index.d.mts +1250 -0
- package/dist/index.d.ts +1250 -0
- package/dist/index.js +27772 -0
- package/dist/index.mjs +27735 -0
- package/docs/ARCHITECTURE.md +467 -0
- package/docs/DOCS.md +709 -0
- package/fca-config.example.json +33 -0
- package/package.json +32 -22
- package/test/fca.test.cjs +540 -0
- package/CHANGELOG.md +0 -296
- package/DOCS.md +0 -2712
- package/func/checkUpdate.js +0 -222
- package/func/logAdapter.js +0 -33
- package/func/logger.js +0 -48
- package/index.d.ts +0 -751
- package/index.js +0 -8
- package/module/config.js +0 -40
- package/module/login.js +0 -133
- package/module/loginHelper.js +0 -1296
- package/module/options.js +0 -44
- package/src/api/action/addExternalModule.js +0 -25
- package/src/api/action/changeAvatar.js +0 -137
- package/src/api/action/changeBio.js +0 -75
- package/src/api/action/enableAutoSaveAppState.js +0 -73
- package/src/api/action/getCurrentUserID.js +0 -7
- package/src/api/action/handleFriendRequest.js +0 -57
- package/src/api/action/logout.js +0 -76
- package/src/api/action/refreshFb_dtsg.js +0 -48
- package/src/api/action/setPostReaction.js +0 -106
- package/src/api/action/unfriend.js +0 -54
- package/src/api/http/httpGet.js +0 -46
- package/src/api/http/httpPost.js +0 -52
- package/src/api/http/postFormData.js +0 -47
- package/src/api/messaging/addUserToGroup.js +0 -68
- package/src/api/messaging/changeAdminStatus.js +0 -126
- package/src/api/messaging/changeArchivedStatus.js +0 -55
- package/src/api/messaging/changeBlockedStatus.js +0 -48
- package/src/api/messaging/changeGroupImage.js +0 -91
- package/src/api/messaging/changeNickname.js +0 -70
- package/src/api/messaging/changeThreadColor.js +0 -79
- package/src/api/messaging/changeThreadEmoji.js +0 -111
- package/src/api/messaging/createNewGroup.js +0 -88
- package/src/api/messaging/createPoll.js +0 -46
- package/src/api/messaging/createThemeAI.js +0 -98
- package/src/api/messaging/deleteMessage.js +0 -136
- package/src/api/messaging/deleteThread.js +0 -56
- package/src/api/messaging/editMessage.js +0 -68
- package/src/api/messaging/forwardAttachment.js +0 -57
- package/src/api/messaging/getEmojiUrl.js +0 -29
- package/src/api/messaging/getFriendsList.js +0 -82
- package/src/api/messaging/getMessage.js +0 -829
- package/src/api/messaging/getThemePictures.js +0 -62
- package/src/api/messaging/handleMessageRequest.js +0 -65
- package/src/api/messaging/markAsDelivered.js +0 -57
- package/src/api/messaging/markAsRead.js +0 -88
- package/src/api/messaging/markAsReadAll.js +0 -49
- package/src/api/messaging/markAsSeen.js +0 -61
- package/src/api/messaging/muteThread.js +0 -50
- package/src/api/messaging/removeUserFromGroup.js +0 -62
- package/src/api/messaging/resolvePhotoUrl.js +0 -43
- package/src/api/messaging/scheduler.js +0 -264
- package/src/api/messaging/searchForThread.js +0 -53
- package/src/api/messaging/sendMessage.js +0 -270
- package/src/api/messaging/sendTypingIndicator.js +0 -74
- package/src/api/messaging/setMessageReaction.js +0 -90
- package/src/api/messaging/setTitle.js +0 -124
- package/src/api/messaging/shareContact.js +0 -49
- package/src/api/messaging/threadColors.js +0 -128
- package/src/api/messaging/unsendMessage.js +0 -81
- package/src/api/messaging/uploadAttachment.js +0 -492
- package/src/api/socket/core/connectMqtt.js +0 -258
- package/src/api/socket/core/emitAuth.js +0 -103
- package/src/api/socket/core/getSeqID.js +0 -320
- package/src/api/socket/core/getTaskResponseData.js +0 -25
- package/src/api/socket/core/parseDelta.js +0 -377
- package/src/api/socket/detail/buildStream.js +0 -215
- package/src/api/socket/detail/constants.js +0 -28
- package/src/api/socket/listenMqtt.js +0 -377
- package/src/api/socket/middleware/index.js +0 -216
- package/src/api/threads/getThreadHistory.js +0 -664
- package/src/api/threads/getThreadInfo.js +0 -296
- package/src/api/threads/getThreadList.js +0 -293
- package/src/api/threads/getThreadPictures.js +0 -78
- package/src/api/users/getUserID.js +0 -65
- package/src/api/users/getUserInfo.js +0 -402
- package/src/api/users/getUserInfoV2.js +0 -134
- package/src/core/sendReqMqtt.js +0 -96
- package/src/database/helpers.js +0 -53
- package/src/database/models/index.js +0 -88
- package/src/database/models/thread.js +0 -50
- package/src/database/models/user.js +0 -46
- package/src/database/threadData.js +0 -94
- package/src/database/userData.js +0 -98
- package/src/remote/remoteClient.js +0 -123
- package/src/utils/broadcast.js +0 -51
- package/src/utils/client.js +0 -10
- package/src/utils/constants.js +0 -23
- package/src/utils/cookies.js +0 -68
- package/src/utils/format/attachment.js +0 -357
- package/src/utils/format/cookie.js +0 -9
- package/src/utils/format/date.js +0 -50
- package/src/utils/format/decode.js +0 -44
- package/src/utils/format/delta.js +0 -194
- package/src/utils/format/ids.js +0 -64
- package/src/utils/format/index.js +0 -64
- package/src/utils/format/message.js +0 -88
- package/src/utils/format/presence.js +0 -132
- package/src/utils/format/readTyp.js +0 -44
- package/src/utils/format/thread.js +0 -42
- package/src/utils/format/utils.js +0 -141
- package/src/utils/headers.js +0 -115
- package/src/utils/loginParser/autoLogin.js +0 -125
- package/src/utils/loginParser/helpers.js +0 -43
- package/src/utils/loginParser/index.js +0 -10
- package/src/utils/loginParser/parseAndCheckLogin.js +0 -220
- package/src/utils/loginParser/textUtils.js +0 -28
- package/src/utils/request/client.js +0 -26
- package/src/utils/request/config.js +0 -23
- package/src/utils/request/defaults.js +0 -46
- package/src/utils/request/helpers.js +0 -46
- package/src/utils/request/index.js +0 -17
- package/src/utils/request/methods.js +0 -163
- package/src/utils/request/proxy.js +0 -21
- package/src/utils/request/retry.js +0 -77
- package/src/utils/request/sanitize.js +0 -49
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { formatID } = require("./utils");
|
|
4
|
-
const { _formatAttachment } = require("./attachment");
|
|
5
|
-
|
|
6
|
-
function getAdminTextMessageType(m) {
|
|
7
|
-
const type = m && (m.type || m);
|
|
8
|
-
switch (type) {
|
|
9
|
-
case "joinable_group_link_mode_change":
|
|
10
|
-
return "log:link-status";
|
|
11
|
-
case "magic_words":
|
|
12
|
-
return "log:magic-words";
|
|
13
|
-
case "change_thread_theme":
|
|
14
|
-
return "log:thread-color";
|
|
15
|
-
case "change_thread_icon":
|
|
16
|
-
case "change_thread_quick_reaction":
|
|
17
|
-
return "log:thread-icon";
|
|
18
|
-
case "change_thread_nickname":
|
|
19
|
-
return "log:user-nickname";
|
|
20
|
-
case "change_thread_admins":
|
|
21
|
-
return "log:thread-admins";
|
|
22
|
-
case "group_poll":
|
|
23
|
-
return "log:thread-poll";
|
|
24
|
-
case "change_thread_approval_mode":
|
|
25
|
-
return "log:thread-approval-mode";
|
|
26
|
-
case "messenger_call_log":
|
|
27
|
-
case "participant_joined_group_call":
|
|
28
|
-
return "log:thread-call";
|
|
29
|
-
case "pin_messages_v2":
|
|
30
|
-
return "log:thread-pinned";
|
|
31
|
-
case "unpin_messages_v2":
|
|
32
|
-
return "log:unpin-message";
|
|
33
|
-
default:
|
|
34
|
-
return m && m.type != null ? m.type : type;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function formatDeltaEvent(m) {
|
|
39
|
-
var logMessageType;
|
|
40
|
-
var logMessageData;
|
|
41
|
-
switch (m.class) {
|
|
42
|
-
case "AdminTextMessage":
|
|
43
|
-
logMessageType = getAdminTextMessageType(m);
|
|
44
|
-
logMessageData = m.untypedData;
|
|
45
|
-
break;
|
|
46
|
-
case "ThreadName":
|
|
47
|
-
logMessageType = "log:thread-name";
|
|
48
|
-
logMessageData = { name: m.name };
|
|
49
|
-
break;
|
|
50
|
-
case "ParticipantsAddedToGroupThread":
|
|
51
|
-
logMessageType = "log:subscribe";
|
|
52
|
-
logMessageData = { addedParticipants: m.addedParticipants };
|
|
53
|
-
break;
|
|
54
|
-
case "ParticipantLeftGroupThread":
|
|
55
|
-
logMessageType = "log:unsubscribe";
|
|
56
|
-
logMessageData = { leftParticipantFbId: m.leftParticipantFbId };
|
|
57
|
-
break;
|
|
58
|
-
case "UserLocation": {
|
|
59
|
-
logMessageType = "log:user-location";
|
|
60
|
-
logMessageData = {
|
|
61
|
-
Image:
|
|
62
|
-
m.attachments[0].mercury.extensible_attachment.story_attachment.media
|
|
63
|
-
.image,
|
|
64
|
-
Location:
|
|
65
|
-
m.attachments[0].mercury.extensible_attachment.story_attachment.target
|
|
66
|
-
.location_title,
|
|
67
|
-
coordinates:
|
|
68
|
-
m.attachments[0].mercury.extensible_attachment.story_attachment.target
|
|
69
|
-
.coordinate,
|
|
70
|
-
url: m.attachments[0].mercury.extensible_attachment.story_attachment
|
|
71
|
-
.url,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
case "ApprovalQueue":
|
|
75
|
-
logMessageType = "log:approval-queue";
|
|
76
|
-
logMessageData = {
|
|
77
|
-
approvalQueue: {
|
|
78
|
-
action: m.action,
|
|
79
|
-
recipientFbId: m.recipientFbId,
|
|
80
|
-
requestSource: m.requestSource,
|
|
81
|
-
...m.messageMetadata,
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
type: "event",
|
|
87
|
-
threadID: formatID(
|
|
88
|
-
(
|
|
89
|
-
m.messageMetadata.threadKey.threadFbId ||
|
|
90
|
-
m.messageMetadata.threadKey.otherUserFbId
|
|
91
|
-
).toString(),
|
|
92
|
-
),
|
|
93
|
-
logMessageType: logMessageType,
|
|
94
|
-
logMessageData: logMessageData,
|
|
95
|
-
logMessageBody: m.messageMetadata.adminText,
|
|
96
|
-
author: m.messageMetadata.actorFbId,
|
|
97
|
-
participantIDs: (m?.participants || []).map((e) => e.toString()),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function getMentionsFromDeltaMessage(m) {
|
|
102
|
-
var body = m.body || "";
|
|
103
|
-
var mentions = {};
|
|
104
|
-
var mdata = [];
|
|
105
|
-
if (m.data && m.data.prng) {
|
|
106
|
-
try {
|
|
107
|
-
mdata = JSON.parse(m.data.prng);
|
|
108
|
-
} catch (e) {
|
|
109
|
-
mdata = [];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (mdata.length > 0) {
|
|
113
|
-
for (var i = 0; i < mdata.length; i++) {
|
|
114
|
-
var id = mdata[i].i;
|
|
115
|
-
var o = parseInt(mdata[i].o, 10) || 0;
|
|
116
|
-
var l = parseInt(mdata[i].l, 10) || 0;
|
|
117
|
-
mentions[String(id)] = body.substring(o, o + l);
|
|
118
|
-
}
|
|
119
|
-
return mentions;
|
|
120
|
-
}
|
|
121
|
-
var md = m.messageMetadata;
|
|
122
|
-
if (
|
|
123
|
-
md &&
|
|
124
|
-
md.data &&
|
|
125
|
-
md.data.data &&
|
|
126
|
-
md.data.data.Gb &&
|
|
127
|
-
md.data.data.Gb.asMap &&
|
|
128
|
-
md.data.data.Gb.asMap.data
|
|
129
|
-
) {
|
|
130
|
-
var gbData = md.data.data.Gb.asMap.data;
|
|
131
|
-
for (var key in gbData) {
|
|
132
|
-
if (!Object.prototype.hasOwnProperty.call(gbData, key)) continue;
|
|
133
|
-
var entry = gbData[key];
|
|
134
|
-
if (entry && entry.asMap && entry.asMap.data) {
|
|
135
|
-
var d = entry.asMap.data;
|
|
136
|
-
var id = d.id && d.id.asLong ? String(d.id.asLong) : null;
|
|
137
|
-
var offset = parseInt(
|
|
138
|
-
d.offset && d.offset.asLong ? d.offset.asLong : 0,
|
|
139
|
-
10,
|
|
140
|
-
);
|
|
141
|
-
var len = parseInt(
|
|
142
|
-
d.length && d.length.asLong ? d.length.asLong : 0,
|
|
143
|
-
10,
|
|
144
|
-
);
|
|
145
|
-
if (id != null) {
|
|
146
|
-
mentions[id] = body.substring(offset, offset + len);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return mentions;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function formatDeltaMessage(m) {
|
|
155
|
-
var md = m.messageMetadata;
|
|
156
|
-
var body = m.body || "";
|
|
157
|
-
var mentions = getMentionsFromDeltaMessage(m);
|
|
158
|
-
var args = body === "" ? [] : body.trim().split(/\s+/);
|
|
159
|
-
return {
|
|
160
|
-
type: "message",
|
|
161
|
-
senderID: formatID(md.actorFbId.toString()),
|
|
162
|
-
threadID: formatID(
|
|
163
|
-
(md.threadKey.threadFbId || md.threadKey.otherUserFbId).toString(),
|
|
164
|
-
),
|
|
165
|
-
messageID: md.messageId,
|
|
166
|
-
args: args,
|
|
167
|
-
body: body,
|
|
168
|
-
attachments: (m.attachments || []).map((v) => _formatAttachment(v)),
|
|
169
|
-
mentions: mentions,
|
|
170
|
-
timestamp: md.timestamp,
|
|
171
|
-
isGroup: !!md.threadKey.threadFbId,
|
|
172
|
-
participantIDs: (m.participants || []).map((p) => formatID(p.toString())),
|
|
173
|
-
isUnread: md.isUnread !== undefined ? md.isUnread : false,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function formatDeltaReadReceipt(delta) {
|
|
178
|
-
return {
|
|
179
|
-
reader: (delta.threadKey.otherUserFbId || delta.actorFbId).toString(),
|
|
180
|
-
time: delta.actionTimestampMs,
|
|
181
|
-
threadID: formatID(
|
|
182
|
-
(delta.threadKey.otherUserFbId || delta.threadKey.threadFbId).toString(),
|
|
183
|
-
),
|
|
184
|
-
type: "read_receipt",
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
module.exports = {
|
|
189
|
-
getAdminTextMessageType,
|
|
190
|
-
formatDeltaEvent,
|
|
191
|
-
formatDeltaMessage,
|
|
192
|
-
getMentionsFromDeltaMessage,
|
|
193
|
-
formatDeltaReadReceipt,
|
|
194
|
-
};
|
package/src/utils/format/ids.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { padZeros } = require("./utils");
|
|
4
|
-
|
|
5
|
-
function binaryToDecimal(data) {
|
|
6
|
-
var ret = "";
|
|
7
|
-
while (data !== "0") {
|
|
8
|
-
var end = 0;
|
|
9
|
-
var fullName = "";
|
|
10
|
-
var i = 0;
|
|
11
|
-
for (; i < data.length; i++) {
|
|
12
|
-
end = 2 * end + parseInt(data[i], 10);
|
|
13
|
-
if (end >= 10) {
|
|
14
|
-
fullName += "1";
|
|
15
|
-
end -= 10;
|
|
16
|
-
} else fullName += "0";
|
|
17
|
-
}
|
|
18
|
-
ret = end.toString() + ret;
|
|
19
|
-
data = fullName.slice(fullName.indexOf("1"));
|
|
20
|
-
}
|
|
21
|
-
return ret;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function generateOfflineThreadingID() {
|
|
25
|
-
var ret = Date.now();
|
|
26
|
-
var value = Math.floor(Math.random() * 4294967295);
|
|
27
|
-
var str = ("0000000000000000000000" + value.toString(2)).slice(-22);
|
|
28
|
-
var msgs = ret.toString(2) + str;
|
|
29
|
-
return binaryToDecimal(msgs);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function generateThreadingID(clientID) {
|
|
33
|
-
var k = Date.now();
|
|
34
|
-
var l = Math.floor(Math.random() * 4294967295);
|
|
35
|
-
var m = clientID;
|
|
36
|
-
return "<" + k + ":" + l + "-" + m + "@mail.projektitan.com>";
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function getGUID() {
|
|
40
|
-
var sectionLength = Date.now();
|
|
41
|
-
var id = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
|
|
42
|
-
/[xy]/g,
|
|
43
|
-
function (c) {
|
|
44
|
-
var r = Math.floor((sectionLength + Math.random() * 16) % 16);
|
|
45
|
-
sectionLength = Math.floor(sectionLength / 16);
|
|
46
|
-
var _guid = (c == "x" ? r : (r & 7) | 8).toString(16);
|
|
47
|
-
return _guid;
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
return id;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function generateTimestampRelative() {
|
|
54
|
-
var d = new Date();
|
|
55
|
-
return d.getHours() + ":" + padZeros(d.getMinutes());
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
module.exports = {
|
|
59
|
-
binaryToDecimal,
|
|
60
|
-
generateOfflineThreadingID,
|
|
61
|
-
generateThreadingID,
|
|
62
|
-
getGUID,
|
|
63
|
-
generateTimestampRelative,
|
|
64
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const utils = require("./utils");
|
|
4
|
-
const ids = require("./ids");
|
|
5
|
-
const date = require("./date");
|
|
6
|
-
const presence = require("./presence");
|
|
7
|
-
const attachment = require("./attachment");
|
|
8
|
-
const delta = require("./delta");
|
|
9
|
-
const message = require("./message");
|
|
10
|
-
const readTyp = require("./readTyp");
|
|
11
|
-
const thread = require("./thread");
|
|
12
|
-
const decode = require("./decode");
|
|
13
|
-
const cookie = require("./cookie");
|
|
14
|
-
|
|
15
|
-
module.exports = {
|
|
16
|
-
getType: utils.getType,
|
|
17
|
-
formatID: utils.formatID,
|
|
18
|
-
padZeros: utils.padZeros,
|
|
19
|
-
arrayToObject: utils.arrayToObject,
|
|
20
|
-
arrToForm: utils.arrToForm,
|
|
21
|
-
getData_Path: utils.getData_Path,
|
|
22
|
-
setData_Path: utils.setData_Path,
|
|
23
|
-
getPaths: utils.getPaths,
|
|
24
|
-
cleanHTML: utils.cleanHTML,
|
|
25
|
-
getCurrentTimestamp: utils.getCurrentTimestamp,
|
|
26
|
-
getSignatureID: utils.getSignatureID,
|
|
27
|
-
|
|
28
|
-
generateOfflineThreadingID: ids.generateOfflineThreadingID,
|
|
29
|
-
generateThreadingID: ids.generateThreadingID,
|
|
30
|
-
getGUID: ids.getGUID,
|
|
31
|
-
generateTimestampRelative: ids.generateTimestampRelative,
|
|
32
|
-
|
|
33
|
-
formatDate: date.formatDate,
|
|
34
|
-
|
|
35
|
-
presenceEncode: presence.presenceEncode,
|
|
36
|
-
presenceDecode: presence.presenceDecode,
|
|
37
|
-
generatePresence: presence.generatePresence,
|
|
38
|
-
generateAccessiblityCookie: presence.generateAccessiblityCookie,
|
|
39
|
-
formatProxyPresence: presence.formatProxyPresence,
|
|
40
|
-
formatPresence: presence.formatPresence,
|
|
41
|
-
|
|
42
|
-
_formatAttachment: attachment._formatAttachment,
|
|
43
|
-
formatAttachment: attachment.formatAttachment,
|
|
44
|
-
|
|
45
|
-
getAdminTextMessageType: delta.getAdminTextMessageType,
|
|
46
|
-
formatDeltaEvent: delta.formatDeltaEvent,
|
|
47
|
-
formatDeltaMessage: delta.formatDeltaMessage,
|
|
48
|
-
getMentionsFromDeltaMessage: delta.getMentionsFromDeltaMessage,
|
|
49
|
-
formatDeltaReadReceipt: delta.formatDeltaReadReceipt,
|
|
50
|
-
|
|
51
|
-
formatMessage: message.formatMessage,
|
|
52
|
-
formatEvent: message.formatEvent,
|
|
53
|
-
formatHistoryMessage: message.formatHistoryMessage,
|
|
54
|
-
|
|
55
|
-
formatReadReceipt: readTyp.formatReadReceipt,
|
|
56
|
-
formatRead: readTyp.formatRead,
|
|
57
|
-
formatTyp: readTyp.formatTyp,
|
|
58
|
-
|
|
59
|
-
formatThread: thread.formatThread,
|
|
60
|
-
|
|
61
|
-
decodeClientPayload: decode.decodeClientPayload,
|
|
62
|
-
|
|
63
|
-
formatCookie: cookie.formatCookie,
|
|
64
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { formatID } = require("./utils");
|
|
4
|
-
const { formatAttachment } = require("./attachment");
|
|
5
|
-
const { getAdminTextMessageType } = require("./delta");
|
|
6
|
-
|
|
7
|
-
function formatMessage(m) {
|
|
8
|
-
var originalMessage = m.message ? m.message : m;
|
|
9
|
-
var body = originalMessage.body || "";
|
|
10
|
-
var args = body == "" ? [] : body.trim().split(/\s+/);
|
|
11
|
-
var obj = {
|
|
12
|
-
type: "message",
|
|
13
|
-
senderName: originalMessage.sender_name,
|
|
14
|
-
senderID: formatID(originalMessage.sender_fbid.toString()),
|
|
15
|
-
participantNames: originalMessage.group_thread_info
|
|
16
|
-
? originalMessage.group_thread_info.participant_names
|
|
17
|
-
: [originalMessage.sender_name.split(" ")[0]],
|
|
18
|
-
participantIDs: originalMessage.group_thread_info
|
|
19
|
-
? originalMessage.group_thread_info.participant_ids.map(function (v) {
|
|
20
|
-
return formatID(v.toString());
|
|
21
|
-
})
|
|
22
|
-
: [formatID(originalMessage.sender_fbid)],
|
|
23
|
-
body: body,
|
|
24
|
-
args: args,
|
|
25
|
-
threadID: formatID(
|
|
26
|
-
(
|
|
27
|
-
originalMessage.thread_fbid || originalMessage.other_user_fbid
|
|
28
|
-
).toString(),
|
|
29
|
-
),
|
|
30
|
-
threadName: originalMessage.group_thread_info
|
|
31
|
-
? originalMessage.group_thread_info.name
|
|
32
|
-
: originalMessage.sender_name,
|
|
33
|
-
location: originalMessage.coordinates ? originalMessage.coordinates : null,
|
|
34
|
-
messageID: originalMessage.mid
|
|
35
|
-
? originalMessage.mid.toString()
|
|
36
|
-
: originalMessage.message_id,
|
|
37
|
-
attachments: formatAttachment(
|
|
38
|
-
originalMessage.attachments,
|
|
39
|
-
originalMessage.attachmentIds,
|
|
40
|
-
originalMessage.attachment_map,
|
|
41
|
-
originalMessage.share_map,
|
|
42
|
-
),
|
|
43
|
-
timestamp: originalMessage.timestamp,
|
|
44
|
-
timestampAbsolute: originalMessage.timestamp_absolute,
|
|
45
|
-
timestampRelative: originalMessage.timestamp_relative,
|
|
46
|
-
timestampDatetime: originalMessage.timestamp_datetime,
|
|
47
|
-
tags: originalMessage.tags,
|
|
48
|
-
reactions: originalMessage.reactions ? originalMessage.reactions : [],
|
|
49
|
-
isUnread: originalMessage.is_unread,
|
|
50
|
-
};
|
|
51
|
-
if (m.type === "pages_messaging")
|
|
52
|
-
obj.pageID = m.realtime_viewer_fbid.toString();
|
|
53
|
-
obj.isGroup = obj.participantIDs.length > 2;
|
|
54
|
-
return obj;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function formatEvent(m) {
|
|
58
|
-
var originalMessage = m.message ? m.message : m;
|
|
59
|
-
var logMessageType = originalMessage.log_message_type;
|
|
60
|
-
var logMessageData;
|
|
61
|
-
if (logMessageType === "log:generic-admin-text") {
|
|
62
|
-
logMessageData = originalMessage.log_message_data.untypedData;
|
|
63
|
-
logMessageType = getAdminTextMessageType(
|
|
64
|
-
originalMessage.log_message_data.message_type,
|
|
65
|
-
);
|
|
66
|
-
} else logMessageData = originalMessage.log_message_data;
|
|
67
|
-
return Object.assign(formatMessage(originalMessage), {
|
|
68
|
-
type: "event",
|
|
69
|
-
logMessageType: logMessageType,
|
|
70
|
-
logMessageData: logMessageData,
|
|
71
|
-
logMessageBody: originalMessage.log_message_body,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function formatHistoryMessage(m) {
|
|
76
|
-
switch (m.action_type) {
|
|
77
|
-
case "ma-type:log-message":
|
|
78
|
-
return formatEvent(m);
|
|
79
|
-
default:
|
|
80
|
-
return formatMessage(m);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
module.exports = {
|
|
85
|
-
formatMessage,
|
|
86
|
-
formatEvent,
|
|
87
|
-
formatHistoryMessage,
|
|
88
|
-
};
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var PRESENCE_MAP = {
|
|
4
|
-
_: "%",
|
|
5
|
-
A: "%2",
|
|
6
|
-
B: "000",
|
|
7
|
-
C: "%7d",
|
|
8
|
-
D: "%7b%22",
|
|
9
|
-
E: "%2c%22",
|
|
10
|
-
F: "%22%3a",
|
|
11
|
-
G: "%2c%22ut%22%3a1",
|
|
12
|
-
H: "%2c%22bls%22%3a",
|
|
13
|
-
I: "%2c%22n%22%3a%22%",
|
|
14
|
-
J: "%22%3a%7b%22i%22%3a0%7d",
|
|
15
|
-
K: "%2c%22pt%22%3a0%2c%22vis%22%3a",
|
|
16
|
-
L: "%2c%22ch%22%3a%7b%22h%22%3a%22",
|
|
17
|
-
M: "%7b%22v%22%3a2%2c%22time%22%3a1",
|
|
18
|
-
N: ".channel%22%2c%22sub%22%3a%5b",
|
|
19
|
-
O: "%2c%22sb%22%3a1%2c%22t%22%3a%5b",
|
|
20
|
-
P: "%2c%22ud%22%3a100%2c%22lc%22%3a0",
|
|
21
|
-
Q: "%5d%2c%22f%22%3anull%2c%22uct%22%3a",
|
|
22
|
-
R: ".channel%22%2c%22sub%22%3a%5b1%5d",
|
|
23
|
-
S: "%22%2c%22m%22%3a0%7d%2c%7b%22i%22%3a",
|
|
24
|
-
T: "%2c%22blc%22%3a1%2c%22snd%22%3a1%2c%22ct%22%3a",
|
|
25
|
-
U: "%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",
|
|
26
|
-
V: "%2c%22blc%22%3a0%2c%22snd%22%3a0%2c%22ct%22%3a",
|
|
27
|
-
W: "%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a",
|
|
28
|
-
X: "%2c%22ri%22%3a0%7d%2c%22state%22%3a%7b%22p%22%3a0%2c%22ut%22%3a1",
|
|
29
|
-
Y: "%2c%22pt%22%3a0%2c%22vis%22%3a1%2c%22bls%22%3a0%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",
|
|
30
|
-
Z: "%2c%22sb%22%3a1%2c%22t%22%3a%5b%5d%2c%22f%22%3anull%2c%22uct%22%3a0%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a",
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
var PRESENCE_REVERSE = {};
|
|
34
|
-
var PRESENCE_REGEX;
|
|
35
|
-
(function () {
|
|
36
|
-
var l = [];
|
|
37
|
-
for (var m in PRESENCE_MAP) {
|
|
38
|
-
PRESENCE_REVERSE[PRESENCE_MAP[m]] = m;
|
|
39
|
-
l.push(PRESENCE_MAP[m]);
|
|
40
|
-
}
|
|
41
|
-
l.reverse();
|
|
42
|
-
PRESENCE_REGEX = new RegExp(l.join("|"), "g");
|
|
43
|
-
})();
|
|
44
|
-
|
|
45
|
-
function presenceEncode(str) {
|
|
46
|
-
return encodeURIComponent(str)
|
|
47
|
-
.replace(/([_A-Z])|%../g, function (m, n) {
|
|
48
|
-
return n ? "%" + n.charCodeAt(0).toString(16) : m;
|
|
49
|
-
})
|
|
50
|
-
.toLowerCase()
|
|
51
|
-
.replace(PRESENCE_REGEX, function (m) {
|
|
52
|
-
return PRESENCE_REVERSE[m];
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function presenceDecode(str) {
|
|
57
|
-
return decodeURIComponent(
|
|
58
|
-
str.replace(/[_A-Z]/g, function (m) {
|
|
59
|
-
return PRESENCE_MAP[m];
|
|
60
|
-
}),
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function generatePresence(userID) {
|
|
65
|
-
var time = Date.now();
|
|
66
|
-
return (
|
|
67
|
-
"E" +
|
|
68
|
-
presenceEncode(
|
|
69
|
-
JSON.stringify({
|
|
70
|
-
v: 3,
|
|
71
|
-
time: parseInt(time / 1000, 10),
|
|
72
|
-
user: userID,
|
|
73
|
-
state: {
|
|
74
|
-
ut: 0,
|
|
75
|
-
t2: [],
|
|
76
|
-
lm2: null,
|
|
77
|
-
uct2: time,
|
|
78
|
-
tr: null,
|
|
79
|
-
tw: Math.floor(Math.random() * 4294967295) + 1,
|
|
80
|
-
at: time,
|
|
81
|
-
},
|
|
82
|
-
ch: {
|
|
83
|
-
["p_" + userID]: 0,
|
|
84
|
-
},
|
|
85
|
-
}),
|
|
86
|
-
)
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function generateAccessiblityCookie() {
|
|
91
|
-
var time = Date.now();
|
|
92
|
-
return encodeURIComponent(
|
|
93
|
-
JSON.stringify({
|
|
94
|
-
sr: 0,
|
|
95
|
-
"sr-ts": time,
|
|
96
|
-
jk: 0,
|
|
97
|
-
"jk-ts": time,
|
|
98
|
-
kb: 0,
|
|
99
|
-
"kb-ts": time,
|
|
100
|
-
hcm: 0,
|
|
101
|
-
"hcm-ts": time,
|
|
102
|
-
}),
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function formatProxyPresence(presence, userID) {
|
|
107
|
-
if (presence.lat === undefined || presence.p === undefined) return null;
|
|
108
|
-
return {
|
|
109
|
-
type: "presence",
|
|
110
|
-
timestamp: presence.lat * 1000,
|
|
111
|
-
userID: userID || "",
|
|
112
|
-
statuses: presence.p,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function formatPresence(presence, userID) {
|
|
117
|
-
return {
|
|
118
|
-
type: "presence",
|
|
119
|
-
timestamp: presence.la * 1000,
|
|
120
|
-
userID: userID || "",
|
|
121
|
-
statuses: presence.a,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
module.exports = {
|
|
126
|
-
presenceEncode,
|
|
127
|
-
presenceDecode,
|
|
128
|
-
generatePresence,
|
|
129
|
-
generateAccessiblityCookie,
|
|
130
|
-
formatProxyPresence,
|
|
131
|
-
formatPresence,
|
|
132
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { formatID } = require("./utils");
|
|
4
|
-
|
|
5
|
-
function formatReadReceipt(event) {
|
|
6
|
-
return {
|
|
7
|
-
reader: event.reader.toString(),
|
|
8
|
-
time: event.time,
|
|
9
|
-
threadID: formatID((event.thread_fbid || event.reader).toString()),
|
|
10
|
-
type: "read_receipt",
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function formatRead(event) {
|
|
15
|
-
return {
|
|
16
|
-
threadID: formatID(
|
|
17
|
-
(
|
|
18
|
-
(event.chat_ids && event.chat_ids[0]) ||
|
|
19
|
-
(event.thread_fbids && event.thread_fbids[0])
|
|
20
|
-
).toString(),
|
|
21
|
-
),
|
|
22
|
-
time: event.timestamp,
|
|
23
|
-
type: "read",
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function formatTyp(event) {
|
|
28
|
-
return {
|
|
29
|
-
isTyping: !!event.st,
|
|
30
|
-
from: event.from.toString(),
|
|
31
|
-
threadID: formatID(
|
|
32
|
-
(event.to || event.thread_fbid || event.from).toString(),
|
|
33
|
-
),
|
|
34
|
-
fromMobile: event.hasOwnProperty("from_mobile") ? event.from_mobile : true,
|
|
35
|
-
userID: (event.realtime_viewer_fbid || event.from).toString(),
|
|
36
|
-
type: "typ",
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = {
|
|
41
|
-
formatReadReceipt,
|
|
42
|
-
formatRead,
|
|
43
|
-
formatTyp,
|
|
44
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { formatID } = require("./utils");
|
|
4
|
-
|
|
5
|
-
function formatThread(data) {
|
|
6
|
-
return {
|
|
7
|
-
threadID: formatID(data.thread_fbid.toString()),
|
|
8
|
-
participants: data.participants.map(formatID),
|
|
9
|
-
participantIDs: data.participants.map(formatID),
|
|
10
|
-
name: data.name,
|
|
11
|
-
nicknames: data.custom_nickname,
|
|
12
|
-
snippet: data.snippet,
|
|
13
|
-
snippetAttachments: data.snippet_attachments,
|
|
14
|
-
snippetSender: formatID((data.snippet_sender || "").toString()),
|
|
15
|
-
unreadCount: data.unread_count,
|
|
16
|
-
messageCount: data.message_count,
|
|
17
|
-
imageSrc: data.image_src,
|
|
18
|
-
timestamp: data.timestamp,
|
|
19
|
-
muteUntil: data.mute_until,
|
|
20
|
-
isCanonicalUser: data.is_canonical_user,
|
|
21
|
-
isCanonical: data.is_canonical,
|
|
22
|
-
isSubscribed: data.is_subscribed,
|
|
23
|
-
folder: data.folder,
|
|
24
|
-
isArchived: data.is_archived,
|
|
25
|
-
recipientsLoadable: data.recipients_loadable,
|
|
26
|
-
hasEmailParticipant: data.has_email_participant,
|
|
27
|
-
readOnly: data.read_only,
|
|
28
|
-
canReply: data.can_reply,
|
|
29
|
-
cannotReplyReason: data.cannot_reply_reason,
|
|
30
|
-
lastMessageTimestamp: data.last_message_timestamp,
|
|
31
|
-
lastReadTimestamp: data.last_read_timestamp,
|
|
32
|
-
lastMessageType: data.last_message_type,
|
|
33
|
-
emoji: data.custom_like_icon,
|
|
34
|
-
color: data.custom_color,
|
|
35
|
-
adminIDs: data.admin_ids,
|
|
36
|
-
threadType: data.thread_type,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = {
|
|
41
|
-
formatThread,
|
|
42
|
-
};
|