@dongdev/fca-unofficial 3.0.31 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/README.md +224 -406
- package/dist/index.d.mts +1241 -0
- package/dist/index.d.ts +1241 -0
- package/dist/index.js +27749 -0
- package/dist/index.mjs +27713 -0
- package/docs/ARCHITECTURE.md +467 -0
- package/docs/DOCS.md +686 -0
- package/fca-config.example.json +33 -0
- package/package.json +32 -22
- package/test/fca.test.cjs +533 -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
package/src/utils/cookies.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// Cookie helpers extracted from client.js
|
|
4
|
-
|
|
5
|
-
function saveCookies(jar) {
|
|
6
|
-
return res => {
|
|
7
|
-
try {
|
|
8
|
-
const setCookie = res?.headers?.["set-cookie"];
|
|
9
|
-
if (Array.isArray(setCookie) && setCookie.length) {
|
|
10
|
-
const url =
|
|
11
|
-
res?.request?.res?.responseUrl ||
|
|
12
|
-
(res?.config?.baseURL
|
|
13
|
-
? new URL(res.config.url || "/", res.config.baseURL).toString()
|
|
14
|
-
: res?.config?.url || "https://www.facebook.com");
|
|
15
|
-
for (const c of setCookie) {
|
|
16
|
-
try {
|
|
17
|
-
jar.setCookieSync(c, url);
|
|
18
|
-
} catch {
|
|
19
|
-
// ignore per-cookie errors
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
} catch {
|
|
24
|
-
// ignore unexpected cookie parsing errors
|
|
25
|
-
}
|
|
26
|
-
return res;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function getAppState(jar) {
|
|
31
|
-
if (!jar || typeof jar.getCookiesSync !== "function") return [];
|
|
32
|
-
const urls = ["https://www.facebook.com"];
|
|
33
|
-
const all = urls.flatMap(u => {
|
|
34
|
-
try {
|
|
35
|
-
return jar.getCookiesSync(u) || [];
|
|
36
|
-
} catch {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
const seen = new Set();
|
|
41
|
-
const out = [];
|
|
42
|
-
for (const c of all) {
|
|
43
|
-
const key = c.key || c.name;
|
|
44
|
-
if (!key) continue;
|
|
45
|
-
const id = key + "|" + (c.domain || "") + "|" + (c.path || "/");
|
|
46
|
-
if (seen.has(id)) continue;
|
|
47
|
-
seen.add(id);
|
|
48
|
-
out.push({
|
|
49
|
-
key,
|
|
50
|
-
value: c.value,
|
|
51
|
-
domain: c.domain || ".facebook.com",
|
|
52
|
-
path: c.path || "/",
|
|
53
|
-
hostOnly: !!c.hostOnly,
|
|
54
|
-
creation: c.creation || new Date(),
|
|
55
|
-
lastAccessed: c.lastAccessed || new Date(),
|
|
56
|
-
secure: !!c.secure,
|
|
57
|
-
httpOnly: !!c.httpOnly,
|
|
58
|
-
expires: c.expires && c.expires !== "Infinity" ? c.expires : "Infinity"
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return out;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
module.exports = {
|
|
65
|
-
saveCookies,
|
|
66
|
-
getAppState
|
|
67
|
-
};
|
|
68
|
-
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var url = require("url");
|
|
4
|
-
const querystring = require("querystring");
|
|
5
|
-
|
|
6
|
-
function _formatAttachment(attachment1, attachment2) {
|
|
7
|
-
attachment2 = attachment2 || { id: "", image_data: {} };
|
|
8
|
-
attachment1 = attachment1.mercury ? attachment1.mercury : attachment1;
|
|
9
|
-
var blob = attachment1.blob_attachment;
|
|
10
|
-
var type =
|
|
11
|
-
blob && blob.__typename ? blob.__typename : attachment1.attach_type;
|
|
12
|
-
if (!type && attachment1.sticker_attachment) {
|
|
13
|
-
type = "StickerAttachment";
|
|
14
|
-
blob = attachment1.sticker_attachment;
|
|
15
|
-
} else if (!type && attachment1.extensible_attachment) {
|
|
16
|
-
if (
|
|
17
|
-
attachment1.extensible_attachment.story_attachment &&
|
|
18
|
-
attachment1.extensible_attachment.story_attachment.target &&
|
|
19
|
-
attachment1.extensible_attachment.story_attachment.target.__typename &&
|
|
20
|
-
attachment1.extensible_attachment.story_attachment.target.__typename ===
|
|
21
|
-
"MessageLocation"
|
|
22
|
-
)
|
|
23
|
-
type = "MessageLocation";
|
|
24
|
-
else type = "ExtensibleAttachment";
|
|
25
|
-
|
|
26
|
-
blob = attachment1.extensible_attachment;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (blob && blob.real_metadata) {
|
|
30
|
-
const realMetadata = blob.real_metadata;
|
|
31
|
-
if (realMetadata.Src) {
|
|
32
|
-
attachment2.src = realMetadata.Src;
|
|
33
|
-
}
|
|
34
|
-
if (realMetadata.ThumbnailSrc) {
|
|
35
|
-
attachment2.thumbnailSrc = realMetadata.ThumbnailSrc;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
switch (type) {
|
|
40
|
-
case "sticker":
|
|
41
|
-
return {
|
|
42
|
-
type: "sticker",
|
|
43
|
-
ID: attachment1.metadata.stickerID.toString(),
|
|
44
|
-
url: attachment1.url,
|
|
45
|
-
packID: attachment1.metadata.packID.toString(),
|
|
46
|
-
spriteUrl: attachment1.metadata.spriteURI,
|
|
47
|
-
spriteUrl2x: attachment1.metadata.spriteURI2x,
|
|
48
|
-
width: attachment1.metadata.width,
|
|
49
|
-
height: attachment1.metadata.height,
|
|
50
|
-
caption: attachment2.caption,
|
|
51
|
-
description: attachment2.description,
|
|
52
|
-
frameCount: attachment1.metadata.frameCount,
|
|
53
|
-
frameRate: attachment1.metadata.frameRate,
|
|
54
|
-
framesPerRow: attachment1.metadata.framesPerRow,
|
|
55
|
-
framesPerCol: attachment1.metadata.framesPerCol,
|
|
56
|
-
stickerID: attachment1.metadata.stickerID.toString(),
|
|
57
|
-
spriteURI: attachment1.metadata.spriteURI,
|
|
58
|
-
spriteURI2x: attachment1.metadata.spriteURI2x,
|
|
59
|
-
};
|
|
60
|
-
case "file":
|
|
61
|
-
return {
|
|
62
|
-
type: "file",
|
|
63
|
-
filename: attachment1.name,
|
|
64
|
-
ID: attachment2.id.toString(),
|
|
65
|
-
url: attachment1.url,
|
|
66
|
-
isMalicious: attachment2.is_malicious,
|
|
67
|
-
contentType: attachment2.mime_type,
|
|
68
|
-
name: attachment1.name,
|
|
69
|
-
mimeType: attachment2.mime_type,
|
|
70
|
-
fileSize: attachment2.file_size,
|
|
71
|
-
};
|
|
72
|
-
case "photo":
|
|
73
|
-
return {
|
|
74
|
-
type: "photo",
|
|
75
|
-
ID: attachment1.metadata.fbid.toString(),
|
|
76
|
-
filename: attachment1.fileName,
|
|
77
|
-
thumbnailUrl: attachment1.thumbnail_url,
|
|
78
|
-
previewUrl: attachment1.preview_url,
|
|
79
|
-
previewWidth: attachment1.preview_width,
|
|
80
|
-
previewHeight: attachment1.preview_height,
|
|
81
|
-
largePreviewUrl: attachment1.large_preview_url,
|
|
82
|
-
largePreviewWidth: attachment1.large_preview_width,
|
|
83
|
-
largePreviewHeight: attachment1.large_preview_height,
|
|
84
|
-
url: attachment1.metadata.url,
|
|
85
|
-
width: attachment1.metadata.dimensions.split(",")[0],
|
|
86
|
-
height: attachment1.metadata.dimensions.split(",")[1],
|
|
87
|
-
name: attachment1.fileName,
|
|
88
|
-
};
|
|
89
|
-
case "animated_image":
|
|
90
|
-
return {
|
|
91
|
-
type: "animated_image",
|
|
92
|
-
ID: attachment2.id.toString(),
|
|
93
|
-
filename: attachment2.filename,
|
|
94
|
-
previewUrl: attachment1.preview_url,
|
|
95
|
-
previewWidth: attachment1.preview_width,
|
|
96
|
-
previewHeight: attachment1.preview_height,
|
|
97
|
-
url: attachment2.image_data.url,
|
|
98
|
-
width: attachment2.image_data.width,
|
|
99
|
-
height: attachment2.image_data.height,
|
|
100
|
-
name: attachment1.name,
|
|
101
|
-
facebookUrl: attachment1.url,
|
|
102
|
-
thumbnailUrl: attachment1.thumbnail_url,
|
|
103
|
-
mimeType: attachment2.mime_type,
|
|
104
|
-
rawGifImage: attachment2.image_data.raw_gif_image,
|
|
105
|
-
rawWebpImage: attachment2.image_data.raw_webp_image,
|
|
106
|
-
animatedGifUrl: attachment2.image_data.animated_gif_url,
|
|
107
|
-
animatedGifPreviewUrl: attachment2.image_data.animated_gif_preview_url,
|
|
108
|
-
animatedWebpUrl: attachment2.image_data.animated_webp_url,
|
|
109
|
-
animatedWebpPreviewUrl:
|
|
110
|
-
attachment2.image_data.animated_webp_preview_url,
|
|
111
|
-
};
|
|
112
|
-
case "share":
|
|
113
|
-
return {
|
|
114
|
-
type: "share",
|
|
115
|
-
ID: attachment1.share.share_id.toString(),
|
|
116
|
-
url: attachment2.href,
|
|
117
|
-
title: attachment1.share.title,
|
|
118
|
-
description: attachment1.share.description,
|
|
119
|
-
source: attachment1.share.source,
|
|
120
|
-
image: attachment1.share.media.image,
|
|
121
|
-
width: attachment1.share.media.image_size.width,
|
|
122
|
-
height: attachment1.share.media.image_size.height,
|
|
123
|
-
playable: attachment1.share.media.playable,
|
|
124
|
-
duration: attachment1.share.media.duration,
|
|
125
|
-
subattachments: attachment1.share.subattachments,
|
|
126
|
-
properties: {},
|
|
127
|
-
animatedImageSize: attachment1.share.media.animated_image_size,
|
|
128
|
-
facebookUrl: attachment1.share.uri,
|
|
129
|
-
target: attachment1.share.target,
|
|
130
|
-
styleList: attachment1.share.style_list,
|
|
131
|
-
};
|
|
132
|
-
case "video":
|
|
133
|
-
return {
|
|
134
|
-
type: "video",
|
|
135
|
-
ID: attachment1.metadata.fbid.toString(),
|
|
136
|
-
filename: attachment1.name,
|
|
137
|
-
previewUrl: attachment1.preview_url,
|
|
138
|
-
previewWidth: attachment1.preview_width,
|
|
139
|
-
previewHeight: attachment1.preview_height,
|
|
140
|
-
url: attachment1.url,
|
|
141
|
-
width: attachment1.metadata.dimensions.width,
|
|
142
|
-
height: attachment1.metadata.dimensions.height,
|
|
143
|
-
duration: attachment1.metadata.duration,
|
|
144
|
-
videoType: "unknown",
|
|
145
|
-
thumbnailUrl: attachment1.thumbnail_url,
|
|
146
|
-
};
|
|
147
|
-
case "error":
|
|
148
|
-
return {
|
|
149
|
-
type: "error",
|
|
150
|
-
attachment1: attachment1,
|
|
151
|
-
attachment2: attachment2,
|
|
152
|
-
};
|
|
153
|
-
case "MessageImage":
|
|
154
|
-
return {
|
|
155
|
-
type: "photo",
|
|
156
|
-
ID: blob.legacy_attachment_id,
|
|
157
|
-
filename: blob.filename,
|
|
158
|
-
thumbnailUrl: blob.thumbnail.uri,
|
|
159
|
-
previewUrl: blob.preview.uri,
|
|
160
|
-
previewWidth: blob.preview.width,
|
|
161
|
-
previewHeight: blob.preview.height,
|
|
162
|
-
largePreviewUrl: blob.large_preview.uri,
|
|
163
|
-
largePreviewWidth: blob.large_preview.width,
|
|
164
|
-
largePreviewHeight: blob.large_preview.height,
|
|
165
|
-
url: blob.large_preview.uri,
|
|
166
|
-
width: blob.original_dimensions.x,
|
|
167
|
-
height: blob.original_dimensions.y,
|
|
168
|
-
name: blob.filename,
|
|
169
|
-
};
|
|
170
|
-
case "MessageAnimatedImage":
|
|
171
|
-
return {
|
|
172
|
-
type: "animated_image",
|
|
173
|
-
ID: blob.legacy_attachment_id,
|
|
174
|
-
filename: blob.filename,
|
|
175
|
-
previewUrl: blob.preview_image.uri,
|
|
176
|
-
previewWidth: blob.preview_image.width,
|
|
177
|
-
previewHeight: blob.preview_image.height,
|
|
178
|
-
url: blob.animated_image.uri,
|
|
179
|
-
width: blob.animated_image.width,
|
|
180
|
-
height: blob.animated_image.height,
|
|
181
|
-
thumbnailUrl: blob.preview_image.uri,
|
|
182
|
-
name: blob.filename,
|
|
183
|
-
facebookUrl: blob.animated_image.uri,
|
|
184
|
-
rawGifImage: blob.animated_image.uri,
|
|
185
|
-
animatedGifUrl: blob.animated_image.uri,
|
|
186
|
-
animatedGifPreviewUrl: blob.preview_image.uri,
|
|
187
|
-
animatedWebpUrl: blob.animated_image.uri,
|
|
188
|
-
animatedWebpPreviewUrl: blob.preview_image.uri,
|
|
189
|
-
};
|
|
190
|
-
case "MessageVideo":
|
|
191
|
-
return {
|
|
192
|
-
type: "video",
|
|
193
|
-
filename: blob.filename,
|
|
194
|
-
ID: blob.legacy_attachment_id,
|
|
195
|
-
previewUrl: blob.large_image.uri,
|
|
196
|
-
previewWidth: blob.large_image.width,
|
|
197
|
-
previewHeight: blob.large_image.height,
|
|
198
|
-
url: blob.playable_url,
|
|
199
|
-
width: blob.original_dimensions.x,
|
|
200
|
-
height: blob.original_dimensions.y,
|
|
201
|
-
duration: blob.playable_duration_in_ms,
|
|
202
|
-
videoType: blob.video_type.toLowerCase(),
|
|
203
|
-
thumbnailUrl: blob.large_image.uri,
|
|
204
|
-
};
|
|
205
|
-
case "MessageAudio":
|
|
206
|
-
return {
|
|
207
|
-
type: "audio",
|
|
208
|
-
filename: blob.filename,
|
|
209
|
-
ID: blob.url_shimhash,
|
|
210
|
-
audioType: blob.audio_type,
|
|
211
|
-
duration: blob.playable_duration_in_ms,
|
|
212
|
-
url: blob.playable_url,
|
|
213
|
-
isVoiceMail: blob.is_voicemail,
|
|
214
|
-
};
|
|
215
|
-
case "StickerAttachment":
|
|
216
|
-
return {
|
|
217
|
-
type: "sticker",
|
|
218
|
-
ID: blob.id,
|
|
219
|
-
url: blob.url,
|
|
220
|
-
packID: blob.pack ? blob.pack.id : null,
|
|
221
|
-
spriteUrl: blob.sprite_image,
|
|
222
|
-
spriteUrl2x: blob.sprite_image_2x,
|
|
223
|
-
width: blob.width,
|
|
224
|
-
height: blob.height,
|
|
225
|
-
caption: blob.label,
|
|
226
|
-
description: blob.label,
|
|
227
|
-
frameCount: blob.frame_count,
|
|
228
|
-
frameRate: blob.frame_rate,
|
|
229
|
-
framesPerRow: blob.frames_per_row,
|
|
230
|
-
framesPerCol: blob.frames_per_column,
|
|
231
|
-
stickerID: blob.id,
|
|
232
|
-
spriteURI: blob.sprite_image,
|
|
233
|
-
spriteURI2x: blob.sprite_image_2x,
|
|
234
|
-
};
|
|
235
|
-
case "MessageLocation": {
|
|
236
|
-
var urlAttach = blob.story_attachment.url;
|
|
237
|
-
var mediaAttach = blob.story_attachment.media;
|
|
238
|
-
var u = querystring.parse(url.parse(urlAttach).query).u;
|
|
239
|
-
var where1 = querystring.parse(url.parse(u).query).where1;
|
|
240
|
-
var address = where1.split(", ");
|
|
241
|
-
var latitude;
|
|
242
|
-
var longitude;
|
|
243
|
-
try {
|
|
244
|
-
latitude = Number.parseFloat(address[0]);
|
|
245
|
-
longitude = Number.parseFloat(address[1]);
|
|
246
|
-
} catch (err) {}
|
|
247
|
-
var imageUrl;
|
|
248
|
-
var width;
|
|
249
|
-
var height;
|
|
250
|
-
if (mediaAttach && mediaAttach.image) {
|
|
251
|
-
imageUrl = mediaAttach.image.uri;
|
|
252
|
-
width = mediaAttach.image.width;
|
|
253
|
-
height = mediaAttach.image.height;
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
type: "location",
|
|
257
|
-
ID: blob.legacy_attachment_id,
|
|
258
|
-
latitude: latitude,
|
|
259
|
-
longitude: longitude,
|
|
260
|
-
image: imageUrl,
|
|
261
|
-
width: width,
|
|
262
|
-
height: height,
|
|
263
|
-
url: u || urlAttach,
|
|
264
|
-
address: where1,
|
|
265
|
-
facebookUrl: blob.story_attachment.url,
|
|
266
|
-
target: blob.story_attachment.target,
|
|
267
|
-
styleList: blob.story_attachment.style_list,
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
case "ExtensibleAttachment":
|
|
271
|
-
return {
|
|
272
|
-
type: "share",
|
|
273
|
-
ID: blob.legacy_attachment_id,
|
|
274
|
-
url: blob.story_attachment.url,
|
|
275
|
-
title: blob.story_attachment.title_with_entities.text,
|
|
276
|
-
description:
|
|
277
|
-
blob.story_attachment.description &&
|
|
278
|
-
blob.story_attachment.description.text,
|
|
279
|
-
source: blob.story_attachment.source
|
|
280
|
-
? blob.story_attachment.source.text
|
|
281
|
-
: null,
|
|
282
|
-
image:
|
|
283
|
-
blob.story_attachment.media &&
|
|
284
|
-
blob.story_attachment.media.image &&
|
|
285
|
-
blob.story_attachment.media.image.uri,
|
|
286
|
-
width:
|
|
287
|
-
blob.story_attachment.media &&
|
|
288
|
-
blob.story_attachment.media.image &&
|
|
289
|
-
blob.story_attachment.media.image.width,
|
|
290
|
-
height:
|
|
291
|
-
blob.story_attachment.media &&
|
|
292
|
-
blob.story_attachment.media.image &&
|
|
293
|
-
blob.story_attachment.media.image.height,
|
|
294
|
-
playable:
|
|
295
|
-
blob.story_attachment.media &&
|
|
296
|
-
blob.story_attachment.media.is_playable,
|
|
297
|
-
duration:
|
|
298
|
-
blob.story_attachment.media &&
|
|
299
|
-
blob.story_attachment.media.playable_duration_in_ms,
|
|
300
|
-
playableUrl:
|
|
301
|
-
blob.story_attachment.media == null
|
|
302
|
-
? null
|
|
303
|
-
: blob.story_attachment.media.playable_url,
|
|
304
|
-
subattachments: blob.story_attachment.subattachments,
|
|
305
|
-
properties: blob.story_attachment.properties.reduce(function (obj, cur) {
|
|
306
|
-
obj[cur.key] = cur.value.text;
|
|
307
|
-
return obj;
|
|
308
|
-
}, {}),
|
|
309
|
-
facebookUrl: blob.story_attachment.url,
|
|
310
|
-
target: blob.story_attachment.target,
|
|
311
|
-
styleList: blob.story_attachment.style_list,
|
|
312
|
-
};
|
|
313
|
-
case "MessageFile":
|
|
314
|
-
return {
|
|
315
|
-
type: "file",
|
|
316
|
-
filename: blob.filename,
|
|
317
|
-
ID: blob.message_file_fbid,
|
|
318
|
-
url: blob.url,
|
|
319
|
-
isMalicious: blob.is_malicious,
|
|
320
|
-
contentType: blob.content_type,
|
|
321
|
-
name: blob.filename,
|
|
322
|
-
mimeType: "",
|
|
323
|
-
fileSize: -1,
|
|
324
|
-
};
|
|
325
|
-
default:
|
|
326
|
-
throw new Error(
|
|
327
|
-
"unrecognized attach_file of type " +
|
|
328
|
-
type +
|
|
329
|
-
"`" +
|
|
330
|
-
JSON.stringify(attachment1, null, 4) +
|
|
331
|
-
" attachment2: " +
|
|
332
|
-
JSON.stringify(attachment2, null, 4) +
|
|
333
|
-
"`",
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
function formatAttachment(attachments, attachmentIds, attachmentMap, shareMap) {
|
|
339
|
-
attachmentMap = shareMap || attachmentMap;
|
|
340
|
-
return attachments
|
|
341
|
-
? attachments.map(function (att, idx) {
|
|
342
|
-
if (
|
|
343
|
-
!attachmentMap ||
|
|
344
|
-
!attachmentIds ||
|
|
345
|
-
!attachmentMap[attachmentIds[idx]]
|
|
346
|
-
) {
|
|
347
|
-
return _formatAttachment(att);
|
|
348
|
-
}
|
|
349
|
-
return _formatAttachment(att, attachmentMap[attachmentIds[idx]]);
|
|
350
|
-
})
|
|
351
|
-
: [];
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
module.exports = {
|
|
355
|
-
_formatAttachment,
|
|
356
|
-
formatAttachment,
|
|
357
|
-
};
|
package/src/utils/format/date.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var NUM_TO_MONTH = [
|
|
4
|
-
"Jan",
|
|
5
|
-
"Feb",
|
|
6
|
-
"Mar",
|
|
7
|
-
"Apr",
|
|
8
|
-
"May",
|
|
9
|
-
"Jun",
|
|
10
|
-
"Jul",
|
|
11
|
-
"Aug",
|
|
12
|
-
"Sep",
|
|
13
|
-
"Oct",
|
|
14
|
-
"Nov",
|
|
15
|
-
"Dec",
|
|
16
|
-
];
|
|
17
|
-
var NUM_TO_DAY = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
18
|
-
|
|
19
|
-
function formatDate(date) {
|
|
20
|
-
var d = date.getUTCDate();
|
|
21
|
-
d = d >= 10 ? d : "0" + d;
|
|
22
|
-
var h = date.getUTCHours();
|
|
23
|
-
h = h >= 10 ? h : "0" + h;
|
|
24
|
-
var m = date.getUTCMinutes();
|
|
25
|
-
m = m >= 10 ? m : "0" + m;
|
|
26
|
-
var s = date.getUTCSeconds();
|
|
27
|
-
s = s >= 10 ? s : "0" + s;
|
|
28
|
-
return (
|
|
29
|
-
NUM_TO_DAY[date.getUTCDay()] +
|
|
30
|
-
", " +
|
|
31
|
-
d +
|
|
32
|
-
" " +
|
|
33
|
-
NUM_TO_MONTH[date.getUTCMonth()] +
|
|
34
|
-
" " +
|
|
35
|
-
date.getUTCFullYear() +
|
|
36
|
-
" " +
|
|
37
|
-
h +
|
|
38
|
-
":" +
|
|
39
|
-
m +
|
|
40
|
-
":" +
|
|
41
|
-
s +
|
|
42
|
-
" GMT"
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = {
|
|
47
|
-
NUM_TO_MONTH,
|
|
48
|
-
NUM_TO_DAY,
|
|
49
|
-
formatDate,
|
|
50
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function decodeClientPayload(payload) {
|
|
4
|
-
function Utf8ArrayToStr(array) {
|
|
5
|
-
var out, i, len, c;
|
|
6
|
-
var char2, char3;
|
|
7
|
-
out = "";
|
|
8
|
-
len = array.length;
|
|
9
|
-
i = 0;
|
|
10
|
-
while (i < len) {
|
|
11
|
-
c = array[i++];
|
|
12
|
-
switch (c >> 4) {
|
|
13
|
-
case 0:
|
|
14
|
-
case 1:
|
|
15
|
-
case 2:
|
|
16
|
-
case 3:
|
|
17
|
-
case 4:
|
|
18
|
-
case 5:
|
|
19
|
-
case 6:
|
|
20
|
-
case 7:
|
|
21
|
-
out += String.fromCharCode(c);
|
|
22
|
-
break;
|
|
23
|
-
case 12:
|
|
24
|
-
case 13:
|
|
25
|
-
char2 = array[i++];
|
|
26
|
-
out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f));
|
|
27
|
-
break;
|
|
28
|
-
case 14:
|
|
29
|
-
char2 = array[i++];
|
|
30
|
-
char3 = array[i++];
|
|
31
|
-
out += String.fromCharCode(
|
|
32
|
-
((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0),
|
|
33
|
-
);
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return out;
|
|
38
|
-
}
|
|
39
|
-
return JSON.parse(Utf8ArrayToStr(payload));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = {
|
|
43
|
-
decodeClientPayload,
|
|
44
|
-
};
|