alicezetion 1.7.0 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/Extra/Database/index.js +399 -0
  4. package/Extra/Database/methods.js +286 -0
  5. package/Extra/ExtraAddons.js +213 -0
  6. package/Extra/ExtraGetThread.js +1 -0
  7. package/Extra/ExtraUptimeRobot.js +59 -0
  8. package/Extra/PM2/ecosystem.config.js +23 -0
  9. package/Extra/Src/Last-Run.js +48 -0
  10. package/Language/index.json +151 -0
  11. package/StateCrypt.js +22 -0
  12. package/broadcast.js +42 -0
  13. package/index.js +755 -533
  14. package/logger.js +21 -0
  15. package/package.json +35 -21
  16. package/replit.nix +0 -3
  17. package/src/addExternalModule.js +23 -0
  18. package/{leiamnash → src}/addUserToGroup.js +11 -23
  19. package/{leiamnash → src}/changeAdminStatus.js +32 -16
  20. package/{leiamnash → src}/changeArchivedStatus.js +9 -17
  21. package/src/changeAvt.js +91 -0
  22. package/{leiamnash → src}/changeBio.js +16 -24
  23. package/{leiamnash → src}/changeBlockedStatus.js +13 -18
  24. package/{leiamnash → src}/changeGroupImage.js +14 -23
  25. package/{leiamnash → src}/changeNickname.js +9 -14
  26. package/{leiamnash → src}/changeThreadColor.js +6 -10
  27. package/{leiamnash → src}/changeThreadEmoji.js +6 -11
  28. package/{leiamnash → src}/chat.js +116 -127
  29. package/{leiamnash → src}/createNewGroup.js +19 -27
  30. package/{leiamnash → src}/createPoll.js +6 -12
  31. package/{leiamnash → src}/deleteMessage.js +8 -13
  32. package/{leiamnash → src}/deleteThread.js +7 -14
  33. package/{leiamnash → src}/forwardAttachment.js +9 -16
  34. package/src/getAccessToken.js +32 -0
  35. package/{leiamnash → src}/getCurrentUserID.js +0 -0
  36. package/{leiamnash → src}/getEmojiUrl.js +1 -2
  37. package/{leiamnash → src}/getFriendsList.js +11 -14
  38. package/src/getMessage.js +84 -0
  39. package/{leiamnash → src}/getThreadHistory.js +27 -38
  40. package/{leiamnash → src}/getThreadHistoryDeprecated.js +14 -25
  41. package/src/getThreadInfo.js +197 -0
  42. package/{leiamnash → src}/getThreadInfoDeprecated.js +12 -24
  43. package/{leiamnash → src}/getThreadList.js +122 -88
  44. package/{leiamnash → src}/getThreadListDeprecated.js +9 -20
  45. package/{leiamnash → src}/getThreadPictures.js +9 -17
  46. package/{leiamnash → src}/getUserID.js +8 -11
  47. package/{leiamnash → src}/getUserInfo.js +12 -16
  48. package/src/getUserInfoV2.js +35 -0
  49. package/src/handleFriendRequest.js +47 -0
  50. package/{leiamnash → src}/handleMessageRequest.js +12 -22
  51. package/{leiamnash → src}/httpGet.js +15 -13
  52. package/{leiamnash → src}/httpPost.js +14 -13
  53. package/src/httpPostFormData.js +46 -0
  54. package/src/listenMqtt.js +1280 -0
  55. package/{leiamnash → src}/logout.js +7 -9
  56. package/{leiamnash → src}/markAsDelivered.js +14 -18
  57. package/{leiamnash → src}/markAsRead.js +30 -28
  58. package/{leiamnash → src}/markAsSeen.js +18 -19
  59. package/{leiamnash → src}/muteThread.js +7 -8
  60. package/{leiamnash/setMessageReaction.js → src/react.js} +15 -18
  61. package/{leiamnash → src}/removeUserFromGroup.js +13 -20
  62. package/{leiamnash → src}/resolvePhotoUrl.js +7 -13
  63. package/{leiamnash → src}/searchForThread.js +8 -13
  64. package/{leiamnash/markAsReadAll.js → src/seen.js} +10 -13
  65. package/{leiamnash → src}/sendTypingIndicator.js +23 -31
  66. package/src/setPostReaction.js +104 -0
  67. package/{leiamnash → src}/setTitle.js +15 -21
  68. package/src/threadColors.js +39 -0
  69. package/{leiamnash → src}/unfriend.js +9 -13
  70. package/{leiamnash/unsendMessage.js → src/unsend.js} +7 -16
  71. package/utils.js +1112 -1236
  72. package/leiamnash/addExternalModule.js +0 -19
  73. package/leiamnash/changeApprovalMode.js +0 -80
  74. package/leiamnash/getThreadInfo.js +0 -212
  75. package/leiamnash/handleFriendRequest.js +0 -61
  76. package/leiamnash/listenMqtt.js +0 -1129
  77. package/leiamnash/setPostReaction.js +0 -76
  78. package/leiamnash/threadColors.js +0 -57
package/utils.js CHANGED
@@ -1,6 +1,8 @@
1
+ /* eslint-disable no-undef */
2
+ /* eslint-disable no-prototype-builtins */
1
3
  "use strict";
2
4
 
3
- var bluebird = require("bluebird");
5
+ const bluebird = require("bluebird");
4
6
  var request = bluebird.promisify(require("request").defaults({ jar: true }));
5
7
  var stream = require("stream");
6
8
  var log = require("npmlog");
@@ -8,1400 +10,1274 @@ var querystring = require("querystring");
8
10
  var url = require("url");
9
11
 
10
12
  function setProxy(url) {
11
- if (typeof url == undefined)
12
- return request = bluebird.promisify(require("request").defaults({
13
- jar: true,
14
- }));
15
- return request = bluebird.promisify(require("request").defaults({
16
- jar: true,
17
- proxy: url
18
- }));
13
+ if (typeof url == undefined) return request = bluebird.promisify(require("request").defaults({ jar: true }));
14
+ return request = bluebird.promisify(require("request").defaults({ jar: true, proxy: url }));
19
15
  }
20
16
 
21
17
  function getHeaders(url, options, ctx, customHeader) {
22
- var headers = {
23
- "Content-Type": "application/x-www-form-urlencoded",
24
- Referer: "https://www.facebook.com/",
25
- Host: url.replace("https://", "").split("/")[0],
26
- Origin: "https://www.facebook.com",
27
- "User-Agent": options.userAgent,
28
- Connection: "keep-alive"
29
- };
30
- if (customHeader) {
31
- Object.assign(headers, customHeader);
32
- }
33
- if (ctx && ctx.region) {
34
- headers["X-MSGR-Region"] = ctx.region;
35
- }
18
+ var headers = {
19
+ "Content-Type": "application/x-www-form-urlencoded",
20
+ Referer: "https://www.facebook.com/",
21
+ Host: url.replace("https://", "").split("/")[0],
22
+ Origin: "https://www.facebook.com",
23
+ "User-Agent": options.userAgent,
24
+ Connection: "keep-alive",
25
+ "sec-fetch-site": 'same-origin',
26
+ "sec-fetch-mode": 'cors'
27
+ };
28
+ if (customHeader) Object.assign(headers, customHeader);
36
29
 
37
- return headers;
30
+ if (ctx && ctx.region) headers["X-MSGR-Region"] = ctx.region;
31
+
32
+ return headers;
38
33
  }
39
34
 
40
35
  function isReadableStream(obj) {
41
- return (
42
- obj instanceof stream.Stream &&
43
- (getType(obj._read) === "Function" ||
44
- getType(obj._read) === "AsyncFunction") &&
45
- getType(obj._readableState) === "Object"
46
- );
36
+ return (
37
+ obj instanceof stream.Stream &&
38
+ (getType(obj._read) === "Function" ||
39
+ getType(obj._read) === "AsyncFunction") &&
40
+ getType(obj._readableState) === "Object"
41
+ );
47
42
  }
48
43
 
49
44
  function get(url, jar, qs, options, ctx) {
50
- // I'm still confused about this
51
- if (getType(qs) === "Object") {
52
- for (var prop in qs) {
53
- if (qs.hasOwnProperty(prop) && getType(qs[prop]) === "Object") {
54
- qs[prop] = JSON.stringify(qs[prop]);
55
- }
56
- }
57
- }
58
- var op = {
59
- headers: getHeaders(url, options, ctx),
60
- timeout: 60000,
61
- qs: qs,
62
- url: url,
63
- method: "GET",
64
- jar: jar,
65
- gzip: true
66
- };
67
-
68
- return request(op).then(function (res) {
69
- return res[0];
70
- });
45
+ // I'm still confused about this
46
+ if (getType(qs) === "Object")
47
+ for (var prop in qs)
48
+ if (qs.hasOwnProperty(prop) && getType(qs[prop]) === "Object") qs[prop] = JSON.stringify(qs[prop]);
49
+ var op = {
50
+ headers: getHeaders(url, options, ctx),
51
+ timeout: 60000,
52
+ qs: qs,
53
+ url: url,
54
+ method: "GET",
55
+ jar: jar,
56
+ gzip: true
57
+ };
58
+
59
+ return request(op).then(function(res) {
60
+ return res[0];
61
+ });
71
62
  }
72
63
 
64
+ /*function getv2(url, jar, qs, options, ctx) {
65
+ // I'm still confused about this
66
+ if (getType(qs) === "Object")
67
+ for (var prop in qs)
68
+ if (qs.hasOwnProperty(prop) && getType(qs[prop]) === "Object") qs[prop] = JSON.stringify(qs[prop]);
69
+ var op = {
70
+ headers: getHeaders(url, options, ctx),
71
+ timeout: 60000,
72
+ qs: qs,
73
+ url: url,
74
+ method: "GET",
75
+ jar: jar,
76
+ gzip: true
77
+ };
78
+
79
+ return request(op).then(function(res) {
80
+ return res;
81
+ });
82
+ }*/
83
+
73
84
  function post(url, jar, form, options, ctx, customHeader) {
74
- var op = {
75
- headers: getHeaders(url, options, ctx, customHeader),
76
- timeout: 60000,
77
- url: url,
78
- method: "POST",
79
- form: form,
80
- jar: jar,
81
- gzip: true
82
- };
83
-
84
- return request(op).then(function (res) {
85
- return res[0];
86
- });
85
+ let headers = getHeaders(url, options);
86
+ headers['sec-fetch-site'] = 'same-origin';
87
+ var op = {
88
+ headers: headers,
89
+ timeout: 60000,
90
+ url: url,
91
+ method: "POST",
92
+ form: form,
93
+ jar: jar,
94
+ gzip: true
95
+ };
96
+
97
+ return request(op).then(function(res) {
98
+ return res[0];
99
+ });
87
100
  }
88
101
 
102
+ /*function postv2(url, jar, form, options, ctx, customHeader) {
103
+ let headers = getHeaders(url, options);
104
+ headers['sec-fetch-site'] = 'same-origin';
105
+ var op = {
106
+ headers: headers,
107
+ timeout: 60000,
108
+ url: url,
109
+ method: "POST",
110
+ form: form,
111
+ jar: jar,
112
+ gzip: true
113
+ };
114
+
115
+ return request(op).then(function(res) {
116
+ return res;
117
+ });
118
+ }*/
119
+
89
120
  function postFormData(url, jar, form, qs, options, ctx) {
90
- var headers = getHeaders(url, options, ctx);
91
- headers["Content-Type"] = "multipart/form-data";
92
- var op = {
93
- headers: headers,
94
- timeout: 60000,
95
- url: url,
96
- method: "POST",
97
- formData: form,
98
- qs: qs,
99
- jar: jar,
100
- gzip: true
101
- };
102
-
103
- return request(op).then(function (res) {
104
- return res[0];
105
- });
121
+ var headers = getHeaders(url, options, ctx);
122
+ headers["Content-Type"] = "multipart/form-data";
123
+ var op = {
124
+ headers: headers,
125
+ timeout: 60000,
126
+ url: url,
127
+ method: "POST",
128
+ formData: form,
129
+ qs: qs,
130
+ jar: jar,
131
+ gzip: true
132
+ };
133
+
134
+ return request(op).then(function(res) {
135
+ return res[0];
136
+ });
106
137
  }
107
138
 
108
139
  function padZeros(val, len) {
109
- val = String(val);
110
- len = len || 2;
111
- while (val.length < len) val = "0" + val;
112
- return val;
140
+ val = String(val);
141
+ len = len || 2;
142
+ while (val.length < len) val = "0" + val;
143
+ return val;
113
144
  }
114
145
 
115
146
  function generateThreadingID(clientID) {
116
- var k = Date.now();
117
- var l = Math.floor(Math.random() * 4294967295);
118
- var m = clientID;
119
- return "<" + k + ":" + l + "-" + m + "@mail.projektitan.com>";
147
+ var k = Date.now();
148
+ var l = Math.floor(Math.random() * 4294967295);
149
+ var m = clientID;
150
+ return "<" + k + ":" + l + "-" + m + "@mail.projektitan.com>";
120
151
  }
121
152
 
122
153
  function binaryToDecimal(data) {
123
- var ret = "";
124
- while (data !== "0") {
125
- var end = 0;
126
- var fullName = "";
127
- var i = 0;
128
- for (; i < data.length; i++) {
129
- end = 2 * end + parseInt(data[i], 10);
130
- if (end >= 10) {
131
- fullName += "1";
132
- end -= 10;
133
- } else {
134
- fullName += "0";
135
- }
154
+ var ret = "";
155
+ while (data !== "0") {
156
+ var end = 0;
157
+ var fullName = "";
158
+ var i = 0;
159
+ for (; i < data.length; i++) {
160
+ end = 2 * end + parseInt(data[i], 10);
161
+ if (end >= 10) {
162
+ fullName += "1";
163
+ end -= 10;
164
+ } else fullName += "0";
165
+ }
166
+ ret = end.toString() + ret;
167
+ data = fullName.slice(fullName.indexOf("1"));
136
168
  }
137
- ret = end.toString() + ret;
138
- data = fullName.slice(fullName.indexOf("1"));
139
- }
140
- return ret;
169
+ return ret;
141
170
  }
142
171
 
143
172
  function generateOfflineThreadingID() {
144
- var ret = Date.now();
145
- var value = Math.floor(Math.random() * 4294967295);
146
- var str = ("0000000000000000000000" + value.toString(2)).slice(-22);
147
- var msgs = ret.toString(2) + str;
148
- return binaryToDecimal(msgs);
173
+ var ret = Date.now();
174
+ var value = Math.floor(Math.random() * 4294967295);
175
+ var str = ("0000000000000000000000" + value.toString(2)).slice(-22);
176
+ var msgs = ret.toString(2) + str;
177
+ return binaryToDecimal(msgs);
149
178
  }
150
179
 
151
180
  var h;
152
181
  var i = {};
153
182
  var j = {
154
- _: "%",
155
- A: "%2",
156
- B: "000",
157
- C: "%7d",
158
- D: "%7b%22",
159
- E: "%2c%22",
160
- F: "%22%3a",
161
- G: "%2c%22ut%22%3a1",
162
- H: "%2c%22bls%22%3a",
163
- I: "%2c%22n%22%3a%22%",
164
- J: "%22%3a%7b%22i%22%3a0%7d",
165
- K: "%2c%22pt%22%3a0%2c%22vis%22%3a",
166
- L: "%2c%22ch%22%3a%7b%22h%22%3a%22",
167
- M: "%7b%22v%22%3a2%2c%22time%22%3a1",
168
- N: ".channel%22%2c%22sub%22%3a%5b",
169
- O: "%2c%22sb%22%3a1%2c%22t%22%3a%5b",
170
- P: "%2c%22ud%22%3a100%2c%22lc%22%3a0",
171
- Q: "%5d%2c%22f%22%3anull%2c%22uct%22%3a",
172
- R: ".channel%22%2c%22sub%22%3a%5b1%5d",
173
- S: "%22%2c%22m%22%3a0%7d%2c%7b%22i%22%3a",
174
- T: "%2c%22blc%22%3a1%2c%22snd%22%3a1%2c%22ct%22%3a",
175
- U: "%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",
176
- V: "%2c%22blc%22%3a0%2c%22snd%22%3a0%2c%22ct%22%3a",
177
- W: "%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a",
178
- X: "%2c%22ri%22%3a0%7d%2c%22state%22%3a%7b%22p%22%3a0%2c%22ut%22%3a1",
179
- Y:
180
- "%2c%22pt%22%3a0%2c%22vis%22%3a1%2c%22bls%22%3a0%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",
181
- Z:
182
- "%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"
183
+ _: "%",
184
+ A: "%2",
185
+ B: "000",
186
+ C: "%7d",
187
+ D: "%7b%22",
188
+ E: "%2c%22",
189
+ F: "%22%3a",
190
+ G: "%2c%22ut%22%3a1",
191
+ H: "%2c%22bls%22%3a",
192
+ I: "%2c%22n%22%3a%22%",
193
+ J: "%22%3a%7b%22i%22%3a0%7d",
194
+ K: "%2c%22pt%22%3a0%2c%22vis%22%3a",
195
+ L: "%2c%22ch%22%3a%7b%22h%22%3a%22",
196
+ M: "%7b%22v%22%3a2%2c%22time%22%3a1",
197
+ N: ".channel%22%2c%22sub%22%3a%5b",
198
+ O: "%2c%22sb%22%3a1%2c%22t%22%3a%5b",
199
+ P: "%2c%22ud%22%3a100%2c%22lc%22%3a0",
200
+ Q: "%5d%2c%22f%22%3anull%2c%22uct%22%3a",
201
+ R: ".channel%22%2c%22sub%22%3a%5b1%5d",
202
+ S: "%22%2c%22m%22%3a0%7d%2c%7b%22i%22%3a",
203
+ T: "%2c%22blc%22%3a1%2c%22snd%22%3a1%2c%22ct%22%3a",
204
+ U: "%2c%22blc%22%3a0%2c%22snd%22%3a1%2c%22ct%22%3a",
205
+ V: "%2c%22blc%22%3a0%2c%22snd%22%3a0%2c%22ct%22%3a",
206
+ W: "%2c%22s%22%3a0%2c%22blo%22%3a0%7d%2c%22bl%22%3a%7b%22ac%22%3a",
207
+ X: "%2c%22ri%22%3a0%7d%2c%22state%22%3a%7b%22p%22%3a0%2c%22ut%22%3a1",
208
+ 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",
209
+ 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"
183
210
  };
184
- (function () {
185
- var l = [];
186
- for (var m in j) {
187
- i[j[m]] = m;
188
- l.push(j[m]);
189
- }
190
- l.reverse();
191
- h = new RegExp(l.join("|"), "g");
211
+ (function() {
212
+ var l = [];
213
+ for (var m in j) {
214
+ i[j[m]] = m;
215
+ l.push(j[m]);
216
+ }
217
+ l.reverse();
218
+ h = new RegExp(l.join("|"), "g");
192
219
  })();
193
220
 
194
221
  function presenceEncode(str) {
195
- return encodeURIComponent(str)
196
- .replace(/([_A-Z])|%../g, function (m, n) {
197
- return n ? "%" + n.charCodeAt(0).toString(16) : m;
198
- })
199
- .toLowerCase()
200
- .replace(h, function (m) {
201
- return i[m];
202
- });
222
+ return encodeURIComponent(str)
223
+ .replace(/([_A-Z])|%../g, function(m, n) {
224
+ return n ? "%" + n.charCodeAt(0).toString(16) : m;
225
+ })
226
+ .toLowerCase()
227
+ .replace(h, function(m) {
228
+ return i[m];
229
+ });
203
230
  }
204
231
 
205
232
  // eslint-disable-next-line no-unused-vars
206
233
  function presenceDecode(str) {
207
- return decodeURIComponent(
208
- str.replace(/[_A-Z]/g, function (m) {
209
- return j[m];
210
- })
211
- );
234
+ return decodeURIComponent(
235
+ str.replace(/[_A-Z]/g, function(m) {
236
+ return j[m];
237
+ })
238
+ );
212
239
  }
213
240
 
214
241
  function generatePresence(userID) {
215
- var time = Date.now();
216
- return (
217
- "E" +
218
- presenceEncode(
219
- JSON.stringify({
220
- v: 3,
221
- time: parseInt(time / 1000, 10),
222
- user: userID,
223
- state: {
224
- ut: 0,
225
- t2: [],
226
- lm2: null,
227
- uct2: time,
228
- tr: null,
229
- tw: Math.floor(Math.random() * 4294967295) + 1,
230
- at: time
231
- },
232
- ch: {
233
- ["p_" + userID]: 0
234
- }
235
- })
236
- )
237
- );
242
+ var time = Date.now();
243
+ return (
244
+ "E" +
245
+ presenceEncode(
246
+ JSON.stringify({
247
+ v: 3,
248
+ time: parseInt(time / 1000, 10),
249
+ user: userID,
250
+ state: {
251
+ ut: 0,
252
+ t2: [],
253
+ lm2: null,
254
+ uct2: time,
255
+ tr: null,
256
+ tw: Math.floor(Math.random() * 4294967295) + 1,
257
+ at: time
258
+ },
259
+ ch: {
260
+ ["p_" + userID]: 0
261
+ }
262
+ })
263
+ )
264
+ );
238
265
  }
239
266
 
240
267
  function generateAccessiblityCookie() {
241
- var time = Date.now();
242
- return encodeURIComponent(
243
- JSON.stringify({
244
- sr: 0,
245
- "sr-ts": time,
246
- jk: 0,
247
- "jk-ts": time,
248
- kb: 0,
249
- "kb-ts": time,
250
- hcm: 0,
251
- "hcm-ts": time
252
- })
253
- );
268
+ var time = Date.now();
269
+ return encodeURIComponent(
270
+ JSON.stringify({
271
+ sr: 0,
272
+ "sr-ts": time,
273
+ jk: 0,
274
+ "jk-ts": time,
275
+ kb: 0,
276
+ "kb-ts": time,
277
+ hcm: 0,
278
+ "hcm-ts": time
279
+ })
280
+ );
254
281
  }
255
282
 
256
283
  function getGUID() {
257
- /** @type {number} */
258
- var sectionLength = Date.now();
259
- /** @type {string} */
260
- var id = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
261
- /** @type {number} */
262
- var r = Math.floor((sectionLength + Math.random() * 16) % 16);
263
284
  /** @type {number} */
264
- sectionLength = Math.floor(sectionLength / 16);
285
+ var sectionLength = Date.now();
265
286
  /** @type {string} */
266
- var _guid = (c == "x" ? r : (r & 7) | 8).toString(16);
267
- return _guid;
268
- });
269
- return id;
287
+ var id = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
288
+ /** @type {number} */
289
+ var r = Math.floor((sectionLength + Math.random() * 16) % 16);
290
+ /** @type {number} */
291
+ sectionLength = Math.floor(sectionLength / 16);
292
+ /** @type {string} */
293
+ var _guid = (c == "x" ? r : (r & 7) | 8).toString(16);
294
+ return _guid;
295
+ });
296
+ return id;
270
297
  }
271
298
 
272
299
  function _formatAttachment(attachment1, attachment2) {
273
- // TODO: THIS IS REALLY BAD
274
- // This is an attempt at fixing Facebook's inconsistencies. Sometimes they give us
275
- // two attachment objects, but sometimes only one. They each contain part of the
276
- // data that you'd want so we merge them for convenience.
277
- // Instead of having a bunch of if statements guarding every access to image_data,
278
- // we set it to empty object and use the fact that it'll return undefined.
279
- attachment2 = attachment2 || { id: "", image_data: {} };
280
- attachment1 = attachment1.mercury ? attachment1.mercury : attachment1;
281
- var blob = attachment1.blob_attachment;
282
- var type =
283
- blob && blob.__typename ? blob.__typename : attachment1.attach_type;
284
- if (!type && attachment1.sticker_attachment) {
285
- type = "StickerAttachment";
286
- blob = attachment1.sticker_attachment;
287
- } else if (!type && attachment1.extensible_attachment) {
288
- if (
289
- attachment1.extensible_attachment.story_attachment &&
290
- attachment1.extensible_attachment.story_attachment.target &&
291
- attachment1.extensible_attachment.story_attachment.target.__typename &&
292
- attachment1.extensible_attachment.story_attachment.target.__typename === "MessageLocation"
293
- ) {
294
- type = "MessageLocation";
295
- } else {
296
- type = "ExtensibleAttachment";
300
+ // TODO: THIS IS REALLY BAD
301
+ // This is an attempt at fixing Facebook's inconsistencies. Sometimes they give us
302
+ // two attachment objects, but sometimes only one. They each contain part of the
303
+ // data that you'd want so we merge them for convenience.
304
+ // Instead of having a bunch of if statements guarding every access to image_data,
305
+ // we set it to empty object and use the fact that it'll return undefined.
306
+ attachment2 = attachment2 || { id: "", image_data: {} };
307
+ attachment1 = attachment1.mercury ? attachment1.mercury : attachment1;
308
+ var blob = attachment1.blob_attachment;
309
+ var type =
310
+ blob && blob.__typename ? blob.__typename : attachment1.attach_type;
311
+ if (!type && attachment1.sticker_attachment) {
312
+ type = "StickerAttachment";
313
+ blob = attachment1.sticker_attachment;
314
+ } else if (!type && attachment1.extensible_attachment) {
315
+ if (
316
+ attachment1.extensible_attachment.story_attachment &&
317
+ attachment1.extensible_attachment.story_attachment.target &&
318
+ attachment1.extensible_attachment.story_attachment.target.__typename &&
319
+ attachment1.extensible_attachment.story_attachment.target.__typename === "MessageLocation"
320
+ ) type = "MessageLocation";
321
+ else type = "ExtensibleAttachment";
322
+
323
+ blob = attachment1.extensible_attachment;
297
324
  }
325
+ // TODO: Determine whether "sticker", "photo", "file" etc are still used
326
+ // KEEP IN SYNC WITH getThreadHistory
327
+ switch (type) {
328
+ case "sticker":
329
+ return {
330
+ type: "sticker",
331
+ ID: attachment1.metadata.stickerID.toString(),
332
+ url: attachment1.url,
333
+
334
+ packID: attachment1.metadata.packID.toString(),
335
+ spriteUrl: attachment1.metadata.spriteURI,
336
+ spriteUrl2x: attachment1.metadata.spriteURI2x,
337
+ width: attachment1.metadata.width,
338
+ height: attachment1.metadata.height,
339
+
340
+ caption: attachment2.caption,
341
+ description: attachment2.description,
342
+
343
+ frameCount: attachment1.metadata.frameCount,
344
+ frameRate: attachment1.metadata.frameRate,
345
+ framesPerRow: attachment1.metadata.framesPerRow,
346
+ framesPerCol: attachment1.metadata.framesPerCol,
347
+
348
+ stickerID: attachment1.metadata.stickerID.toString(), // @Legacy
349
+ spriteURI: attachment1.metadata.spriteURI, // @Legacy
350
+ spriteURI2x: attachment1.metadata.spriteURI2x // @Legacy
351
+ };
352
+ case "file":
353
+ return {
354
+ type: "file",
355
+ filename: attachment1.name,
356
+ ID: attachment2.id.toString(),
357
+ url: attachment1.url,
358
+
359
+ isMalicious: attachment2.is_malicious,
360
+ contentType: attachment2.mime_type,
361
+
362
+ name: attachment1.name, // @Legacy
363
+ mimeType: attachment2.mime_type, // @Legacy
364
+ fileSize: attachment2.file_size // @Legacy
365
+ };
366
+ case "photo":
367
+ return {
368
+ type: "photo",
369
+ ID: attachment1.metadata.fbid.toString(),
370
+ filename: attachment1.fileName,
371
+ thumbnailUrl: attachment1.thumbnail_url,
372
+
373
+ previewUrl: attachment1.preview_url,
374
+ previewWidth: attachment1.preview_width,
375
+ previewHeight: attachment1.preview_height,
376
+
377
+ largePreviewUrl: attachment1.large_preview_url,
378
+ largePreviewWidth: attachment1.large_preview_width,
379
+ largePreviewHeight: attachment1.large_preview_height,
380
+
381
+ url: attachment1.metadata.url, // @Legacy
382
+ width: attachment1.metadata.dimensions.split(",")[0], // @Legacy
383
+ height: attachment1.metadata.dimensions.split(",")[1], // @Legacy
384
+ name: attachment1.fileName // @Legacy
385
+ };
386
+ case "animated_image":
387
+ return {
388
+ type: "animated_image",
389
+ ID: attachment2.id.toString(),
390
+ filename: attachment2.filename,
391
+
392
+ previewUrl: attachment1.preview_url,
393
+ previewWidth: attachment1.preview_width,
394
+ previewHeight: attachment1.preview_height,
395
+
396
+ url: attachment2.image_data.url,
397
+ width: attachment2.image_data.width,
398
+ height: attachment2.image_data.height,
399
+
400
+ name: attachment1.name, // @Legacy
401
+ facebookUrl: attachment1.url, // @Legacy
402
+ thumbnailUrl: attachment1.thumbnail_url, // @Legacy
403
+ mimeType: attachment2.mime_type, // @Legacy
404
+ rawGifImage: attachment2.image_data.raw_gif_image, // @Legacy
405
+ rawWebpImage: attachment2.image_data.raw_webp_image, // @Legacy
406
+ animatedGifUrl: attachment2.image_data.animated_gif_url, // @Legacy
407
+ animatedGifPreviewUrl: attachment2.image_data.animated_gif_preview_url, // @Legacy
408
+ animatedWebpUrl: attachment2.image_data.animated_webp_url, // @Legacy
409
+ animatedWebpPreviewUrl: attachment2.image_data.animated_webp_preview_url // @Legacy
410
+ };
411
+ case "share":
412
+ return {
413
+ type: "share",
414
+ ID: attachment1.share.share_id.toString(),
415
+ url: attachment2.href,
416
+
417
+ title: attachment1.share.title,
418
+ description: attachment1.share.description,
419
+ source: attachment1.share.source,
420
+
421
+ image: attachment1.share.media.image,
422
+ width: attachment1.share.media.image_size.width,
423
+ height: attachment1.share.media.image_size.height,
424
+ playable: attachment1.share.media.playable,
425
+ duration: attachment1.share.media.duration,
426
+
427
+ subattachments: attachment1.share.subattachments,
428
+ properties: {},
429
+
430
+ animatedImageSize: attachment1.share.media.animated_image_size, // @Legacy
431
+ facebookUrl: attachment1.share.uri, // @Legacy
432
+ target: attachment1.share.target, // @Legacy
433
+ styleList: attachment1.share.style_list // @Legacy
434
+ };
435
+ case "video":
436
+ return {
437
+ type: "video",
438
+ ID: attachment1.metadata.fbid.toString(),
439
+ filename: attachment1.name,
440
+
441
+ previewUrl: attachment1.preview_url,
442
+ previewWidth: attachment1.preview_width,
443
+ previewHeight: attachment1.preview_height,
444
+
445
+ url: attachment1.url,
446
+ width: attachment1.metadata.dimensions.width,
447
+ height: attachment1.metadata.dimensions.height,
448
+
449
+ duration: attachment1.metadata.duration,
450
+ videoType: "unknown",
451
+
452
+ thumbnailUrl: attachment1.thumbnail_url // @Legacy
453
+ };
454
+ case "error":
455
+ return {
456
+ type: "error",
457
+
458
+ // Save error attachments because we're unsure of their format,
459
+ // and whether there are cases they contain something useful for debugging.
460
+ attachment1: attachment1,
461
+ attachment2: attachment2
462
+ };
463
+ case "MessageImage":
464
+ return {
465
+ type: "photo",
466
+ ID: blob.legacy_attachment_id,
467
+ filename: blob.filename,
468
+ thumbnailUrl: blob.thumbnail.uri,
469
+
470
+ previewUrl: blob.preview.uri,
471
+ previewWidth: blob.preview.width,
472
+ previewHeight: blob.preview.height,
473
+
474
+ largePreviewUrl: blob.large_preview.uri,
475
+ largePreviewWidth: blob.large_preview.width,
476
+ largePreviewHeight: blob.large_preview.height,
477
+
478
+ url: blob.large_preview.uri, // @Legacy
479
+ width: blob.original_dimensions.x, // @Legacy
480
+ height: blob.original_dimensions.y, // @Legacy
481
+ name: blob.filename // @Legacy
482
+ };
483
+ case "MessageAnimatedImage":
484
+ return {
485
+ type: "animated_image",
486
+ ID: blob.legacy_attachment_id,
487
+ filename: blob.filename,
488
+
489
+ previewUrl: blob.preview_image.uri,
490
+ previewWidth: blob.preview_image.width,
491
+ previewHeight: blob.preview_image.height,
492
+
493
+ url: blob.animated_image.uri,
494
+ width: blob.animated_image.width,
495
+ height: blob.animated_image.height,
496
+
497
+ thumbnailUrl: blob.preview_image.uri, // @Legacy
498
+ name: blob.filename, // @Legacy
499
+ facebookUrl: blob.animated_image.uri, // @Legacy
500
+ rawGifImage: blob.animated_image.uri, // @Legacy
501
+ animatedGifUrl: blob.animated_image.uri, // @Legacy
502
+ animatedGifPreviewUrl: blob.preview_image.uri, // @Legacy
503
+ animatedWebpUrl: blob.animated_image.uri, // @Legacy
504
+ animatedWebpPreviewUrl: blob.preview_image.uri // @Legacy
505
+ };
506
+ case "MessageVideo":
507
+ return {
508
+ type: "video",
509
+ filename: blob.filename,
510
+ ID: blob.legacy_attachment_id,
511
+
512
+ previewUrl: blob.large_image.uri,
513
+ previewWidth: blob.large_image.width,
514
+ previewHeight: blob.large_image.height,
515
+
516
+ url: blob.playable_url,
517
+ width: blob.original_dimensions.x,
518
+ height: blob.original_dimensions.y,
519
+
520
+ duration: blob.playable_duration_in_ms,
521
+ videoType: blob.video_type.toLowerCase(),
522
+
523
+ thumbnailUrl: blob.large_image.uri // @Legacy
524
+ };
525
+ case "MessageAudio":
526
+ return {
527
+ type: "audio",
528
+ filename: blob.filename,
529
+ ID: blob.url_shimhash,
530
+
531
+ audioType: blob.audio_type,
532
+ duration: blob.playable_duration_in_ms,
533
+ url: blob.playable_url,
534
+
535
+ isVoiceMail: blob.is_voicemail
536
+ };
537
+ case "StickerAttachment":
538
+ return {
539
+ type: "sticker",
540
+ ID: blob.id,
541
+ url: blob.url,
542
+
543
+ packID: blob.pack ? blob.pack.id : null,
544
+ spriteUrl: blob.sprite_image,
545
+ spriteUrl2x: blob.sprite_image_2x,
546
+ width: blob.width,
547
+ height: blob.height,
548
+
549
+ caption: blob.label,
550
+ description: blob.label,
551
+
552
+ frameCount: blob.frame_count,
553
+ frameRate: blob.frame_rate,
554
+ framesPerRow: blob.frames_per_row,
555
+ framesPerCol: blob.frames_per_column,
556
+
557
+ stickerID: blob.id, // @Legacy
558
+ spriteURI: blob.sprite_image, // @Legacy
559
+ spriteURI2x: blob.sprite_image_2x // @Legacy
560
+ };
561
+ case "MessageLocation":
562
+ var urlAttach = blob.story_attachment.url;
563
+ var mediaAttach = blob.story_attachment.media;
564
+
565
+ var u = querystring.parse(url.parse(urlAttach).query).u;
566
+ var where1 = querystring.parse(url.parse(u).query).where1;
567
+ var address = where1.split(", ");
568
+
569
+ var latitude;
570
+ var longitude;
571
+
572
+ try {
573
+ latitude = Number.parseFloat(address[0]);
574
+ longitude = Number.parseFloat(address[1]);
575
+ } catch (err) {
576
+ /* empty */
577
+ }
298
578
 
299
- blob = attachment1.extensible_attachment;
300
- }
301
- // TODO: Determine whether "sticker", "photo", "file" etc are still used
302
- // KEEP IN SYNC WITH getThreadHistory
303
- switch (type) {
304
- case "sticker":
305
- return {
306
- type: "sticker",
307
- ID: attachment1.metadata.stickerID.toString(),
308
- url: attachment1.url,
309
-
310
- packID: attachment1.metadata.packID.toString(),
311
- spriteUrl: attachment1.metadata.spriteURI,
312
- spriteUrl2x: attachment1.metadata.spriteURI2x,
313
- width: attachment1.metadata.width,
314
- height: attachment1.metadata.height,
315
-
316
- caption: attachment2.caption,
317
- description: attachment2.description,
318
-
319
- frameCount: attachment1.metadata.frameCount,
320
- frameRate: attachment1.metadata.frameRate,
321
- framesPerRow: attachment1.metadata.framesPerRow,
322
- framesPerCol: attachment1.metadata.framesPerCol,
323
-
324
- stickerID: attachment1.metadata.stickerID.toString(), // @Legacy
325
- spriteURI: attachment1.metadata.spriteURI, // @Legacy
326
- spriteURI2x: attachment1.metadata.spriteURI2x // @Legacy
327
- };
328
- case "file":
329
- return {
330
- type: "file",
331
- filename: attachment1.name,
332
- ID: attachment2.id.toString(),
333
- url: attachment1.url,
334
-
335
- isMalicious: attachment2.is_malicious,
336
- contentType: attachment2.mime_type,
337
-
338
- name: attachment1.name, // @Legacy
339
- mimeType: attachment2.mime_type, // @Legacy
340
- fileSize: attachment2.file_size // @Legacy
341
- };
342
- case "photo":
343
- return {
344
- type: "photo",
345
- ID: attachment1.metadata.fbid.toString(),
346
- filename: attachment1.fileName,
347
- thumbnailUrl: attachment1.thumbnail_url,
348
-
349
- previewUrl: attachment1.preview_url,
350
- previewWidth: attachment1.preview_width,
351
- previewHeight: attachment1.preview_height,
352
-
353
- largePreviewUrl: attachment1.large_preview_url,
354
- largePreviewWidth: attachment1.large_preview_width,
355
- largePreviewHeight: attachment1.large_preview_height,
356
-
357
- url: attachment1.metadata.url, // @Legacy
358
- width: attachment1.metadata.dimensions.split(",")[0], // @Legacy
359
- height: attachment1.metadata.dimensions.split(",")[1], // @Legacy
360
- name: attachment1.fileName // @Legacy
361
- };
362
- case "animated_image":
363
- return {
364
- type: "animated_image",
365
- ID: attachment2.id.toString(),
366
- filename: attachment2.filename,
367
-
368
- previewUrl: attachment1.preview_url,
369
- previewWidth: attachment1.preview_width,
370
- previewHeight: attachment1.preview_height,
371
-
372
- url: attachment2.image_data.url,
373
- width: attachment2.image_data.width,
374
- height: attachment2.image_data.height,
375
-
376
- name: attachment1.name, // @Legacy
377
- facebookUrl: attachment1.url, // @Legacy
378
- thumbnailUrl: attachment1.thumbnail_url, // @Legacy
379
- mimeType: attachment2.mime_type, // @Legacy
380
- rawGifImage: attachment2.image_data.raw_gif_image, // @Legacy
381
- rawWebpImage: attachment2.image_data.raw_webp_image, // @Legacy
382
- animatedGifUrl: attachment2.image_data.animated_gif_url, // @Legacy
383
- animatedGifPreviewUrl: attachment2.image_data.animated_gif_preview_url, // @Legacy
384
- animatedWebpUrl: attachment2.image_data.animated_webp_url, // @Legacy
385
- animatedWebpPreviewUrl: attachment2.image_data.animated_webp_preview_url // @Legacy
386
- };
387
- case "share":
388
- return {
389
- type: "share",
390
- ID: attachment1.share.share_id.toString(),
391
- url: attachment2.href,
392
-
393
- title: attachment1.share.title,
394
- description: attachment1.share.description,
395
- source: attachment1.share.source,
396
-
397
- image: attachment1.share.media.image,
398
- width: attachment1.share.media.image_size.width,
399
- height: attachment1.share.media.image_size.height,
400
- playable: attachment1.share.media.playable,
401
- duration: attachment1.share.media.duration,
402
-
403
- subattachments: attachment1.share.subattachments,
404
- properties: {},
405
-
406
- animatedImageSize: attachment1.share.media.animated_image_size, // @Legacy
407
- facebookUrl: attachment1.share.uri, // @Legacy
408
- target: attachment1.share.target, // @Legacy
409
- styleList: attachment1.share.style_list // @Legacy
410
- };
411
- case "video":
412
- return {
413
- type: "video",
414
- ID: attachment1.metadata.fbid.toString(),
415
- filename: attachment1.name,
416
-
417
- previewUrl: attachment1.preview_url,
418
- previewWidth: attachment1.preview_width,
419
- previewHeight: attachment1.preview_height,
420
-
421
- url: attachment1.url,
422
- width: attachment1.metadata.dimensions.width,
423
- height: attachment1.metadata.dimensions.height,
424
-
425
- duration: attachment1.metadata.duration,
426
- videoType: "unknown",
427
-
428
- thumbnailUrl: attachment1.thumbnail_url // @Legacy
429
- };
430
- case "error":
431
- return {
432
- type: "error",
433
-
434
- // Save error attachments because we're unsure of their format,
435
- // and whether there are cases they contain something useful for debugging.
436
- attachment1: attachment1,
437
- attachment2: attachment2
438
- };
439
- case "MessageImage":
440
- return {
441
- type: "photo",
442
- ID: blob.legacy_attachment_id,
443
- filename: blob.filename,
444
- thumbnailUrl: blob.thumbnail.uri,
445
-
446
- previewUrl: blob.preview.uri,
447
- previewWidth: blob.preview.width,
448
- previewHeight: blob.preview.height,
449
-
450
- largePreviewUrl: blob.large_preview.uri,
451
- largePreviewWidth: blob.large_preview.width,
452
- largePreviewHeight: blob.large_preview.height,
453
-
454
- url: blob.large_preview.uri, // @Legacy
455
- width: blob.original_dimensions.x, // @Legacy
456
- height: blob.original_dimensions.y, // @Legacy
457
- name: blob.filename // @Legacy
458
- };
459
- case "MessageAnimatedImage":
460
- return {
461
- type: "animated_image",
462
- ID: blob.legacy_attachment_id,
463
- filename: blob.filename,
464
-
465
- previewUrl: blob.preview_image.uri,
466
- previewWidth: blob.preview_image.width,
467
- previewHeight: blob.preview_image.height,
468
-
469
- url: blob.animated_image.uri,
470
- width: blob.animated_image.width,
471
- height: blob.animated_image.height,
472
-
473
- thumbnailUrl: blob.preview_image.uri, // @Legacy
474
- name: blob.filename, // @Legacy
475
- facebookUrl: blob.animated_image.uri, // @Legacy
476
- rawGifImage: blob.animated_image.uri, // @Legacy
477
- animatedGifUrl: blob.animated_image.uri, // @Legacy
478
- animatedGifPreviewUrl: blob.preview_image.uri, // @Legacy
479
- animatedWebpUrl: blob.animated_image.uri, // @Legacy
480
- animatedWebpPreviewUrl: blob.preview_image.uri // @Legacy
481
- };
482
- case "MessageVideo":
483
- return {
484
- type: "video",
485
- filename: blob.filename,
486
- ID: blob.legacy_attachment_id,
487
-
488
- previewUrl: blob.large_image.uri,
489
- previewWidth: blob.large_image.width,
490
- previewHeight: blob.large_image.height,
491
-
492
- url: blob.playable_url,
493
- width: blob.original_dimensions.x,
494
- height: blob.original_dimensions.y,
495
-
496
- duration: blob.playable_duration_in_ms,
497
- videoType: blob.video_type.toLowerCase(),
498
-
499
- thumbnailUrl: blob.large_image.uri // @Legacy
500
- };
501
- case "MessageAudio":
502
- return {
503
- type: "audio",
504
- filename: blob.filename,
505
- ID: blob.url_shimhash,
506
-
507
- audioType: blob.audio_type,
508
- duration: blob.playable_duration_in_ms,
509
- url: blob.playable_url,
510
-
511
- isVoiceMail: blob.is_voicemail
512
- };
513
- case "StickerAttachment":
514
- return {
515
- type: "sticker",
516
- ID: blob.id,
517
- url: blob.url,
518
-
519
- packID: blob.pack
520
- ? blob.pack.id
521
- : null,
522
- spriteUrl: blob.sprite_image,
523
- spriteUrl2x: blob.sprite_image_2x,
524
- width: blob.width,
525
- height: blob.height,
526
-
527
- caption: blob.label,
528
- description: blob.label,
529
-
530
- frameCount: blob.frame_count,
531
- frameRate: blob.frame_rate,
532
- framesPerRow: blob.frames_per_row,
533
- framesPerCol: blob.frames_per_column,
534
-
535
- stickerID: blob.id, // @Legacy
536
- spriteURI: blob.sprite_image, // @Legacy
537
- spriteURI2x: blob.sprite_image_2x // @Legacy
538
- };
539
- case "MessageLocation":
540
- var urlAttach = blob.story_attachment.url;
541
- var mediaAttach = blob.story_attachment.media;
542
-
543
- var u = querystring.parse(url.parse(urlAttach).query).u;
544
- var where1 = querystring.parse(url.parse(u).query).where1;
545
- var address = where1.split(", ");
546
-
547
- var latitude;
548
- var longitude;
549
-
550
- try {
551
- latitude = Number.parseFloat(address[0]);
552
- longitude = Number.parseFloat(address[1]);
553
- } catch (err) {
554
- /* empty */
555
- }
556
-
557
- var imageUrl;
558
- var width;
559
- var height;
560
-
561
- if (mediaAttach && mediaAttach.image) {
562
- imageUrl = mediaAttach.image.uri;
563
- width = mediaAttach.image.width;
564
- height = mediaAttach.image.height;
565
- }
566
-
567
- return {
568
- type: "location",
569
- ID: blob.legacy_attachment_id,
570
- latitude: latitude,
571
- longitude: longitude,
572
- image: imageUrl,
573
- width: width,
574
- height: height,
575
- url: u || urlAttach,
576
- address: where1,
577
-
578
- facebookUrl: blob.story_attachment.url, // @Legacy
579
- target: blob.story_attachment.target, // @Legacy
580
- styleList: blob.story_attachment.style_list // @Legacy
581
- };
582
- case "ExtensibleAttachment":
583
- return {
584
- type: "share",
585
- ID: blob.legacy_attachment_id,
586
- url: blob.story_attachment.url,
587
-
588
- title: blob.story_attachment.title_with_entities.text,
589
- description:
590
- blob.story_attachment.description &&
591
- blob.story_attachment.description.text,
592
- source: blob.story_attachment.source
593
- ? blob.story_attachment.source.text
594
- : null,
595
-
596
- image:
597
- blob.story_attachment.media &&
598
- blob.story_attachment.media.image &&
599
- blob.story_attachment.media.image.uri,
600
- width:
601
- blob.story_attachment.media &&
602
- blob.story_attachment.media.image &&
603
- blob.story_attachment.media.image.width,
604
- height:
605
- blob.story_attachment.media &&
606
- blob.story_attachment.media.image &&
607
- blob.story_attachment.media.image.height,
608
- playable:
609
- blob.story_attachment.media &&
610
- blob.story_attachment.media.is_playable,
611
- duration:
612
- blob.story_attachment.media &&
613
- blob.story_attachment.media.playable_duration_in_ms,
614
- playableUrl:
615
- blob.story_attachment.media == null
616
- ? null
617
- : blob.story_attachment.media.playable_url,
618
-
619
- subattachments: blob.story_attachment.subattachments,
620
- properties: blob.story_attachment.properties.reduce(function (obj, cur) {
621
- obj[cur.key] = cur.value.text;
622
- return obj;
623
- }, {}),
624
-
625
- facebookUrl: blob.story_attachment.url, // @Legacy
626
- target: blob.story_attachment.target, // @Legacy
627
- styleList: blob.story_attachment.style_list // @Legacy
628
- };
629
- case "MessageFile":
630
- return {
631
- type: "file",
632
- filename: blob.filename,
633
- ID: blob.message_file_fbid,
634
-
635
- url: blob.url,
636
- isMalicious: blob.is_malicious,
637
- contentType: blob.content_type,
638
-
639
- name: blob.filename,
640
- mimeType: "",
641
- fileSize: -1
642
- };
643
- default:
644
- throw new Error(
645
- "unrecognized attach_file of type " +
646
- type +
647
- "`" +
648
- JSON.stringify(attachment1, null, 4) +
649
- " attachment2: " +
650
- JSON.stringify(attachment2, null, 4) +
651
- "`"
652
- );
653
- }
579
+ var imageUrl;
580
+ var width;
581
+ var height;
582
+
583
+ if (mediaAttach && mediaAttach.image) {
584
+ imageUrl = mediaAttach.image.uri;
585
+ width = mediaAttach.image.width;
586
+ height = mediaAttach.image.height;
587
+ }
588
+
589
+ return {
590
+ type: "location",
591
+ ID: blob.legacy_attachment_id,
592
+ latitude: latitude,
593
+ longitude: longitude,
594
+ image: imageUrl,
595
+ width: width,
596
+ height: height,
597
+ url: u || urlAttach,
598
+ address: where1,
599
+
600
+ facebookUrl: blob.story_attachment.url, // @Legacy
601
+ target: blob.story_attachment.target, // @Legacy
602
+ styleList: blob.story_attachment.style_list // @Legacy
603
+ };
604
+ case "ExtensibleAttachment":
605
+ return {
606
+ type: "share",
607
+ ID: blob.legacy_attachment_id,
608
+ url: blob.story_attachment.url,
609
+
610
+ title: blob.story_attachment.title_with_entities.text,
611
+ description: blob.story_attachment.description &&
612
+ blob.story_attachment.description.text,
613
+ source: blob.story_attachment.source ? blob.story_attachment.source.text : null,
614
+
615
+ image: blob.story_attachment.media &&
616
+ blob.story_attachment.media.image &&
617
+ blob.story_attachment.media.image.uri,
618
+ width: blob.story_attachment.media &&
619
+ blob.story_attachment.media.image &&
620
+ blob.story_attachment.media.image.width,
621
+ height: blob.story_attachment.media &&
622
+ blob.story_attachment.media.image &&
623
+ blob.story_attachment.media.image.height,
624
+ playable: blob.story_attachment.media &&
625
+ blob.story_attachment.media.is_playable,
626
+ duration: blob.story_attachment.media &&
627
+ blob.story_attachment.media.playable_duration_in_ms,
628
+ playableUrl: blob.story_attachment.media == null ? null : blob.story_attachment.media.playable_url,
629
+
630
+ subattachments: blob.story_attachment.subattachments,
631
+ properties: blob.story_attachment.properties.reduce(function(obj, cur) {
632
+ obj[cur.key] = cur.value.text;
633
+ return obj;
634
+ }, {}),
635
+
636
+ facebookUrl: blob.story_attachment.url, // @Legacy
637
+ target: blob.story_attachment.target, // @Legacy
638
+ styleList: blob.story_attachment.style_list // @Legacy
639
+ };
640
+ case "MessageFile":
641
+ return {
642
+ type: "file",
643
+ filename: blob.filename,
644
+ ID: blob.message_file_fbid,
645
+
646
+ url: blob.url,
647
+ isMalicious: blob.is_malicious,
648
+ contentType: blob.content_type,
649
+
650
+ name: blob.filename,
651
+ mimeType: "",
652
+ fileSize: -1
653
+ };
654
+ default:
655
+ throw new Error(
656
+ "unrecognized attach_file of type " +
657
+ type +
658
+ "`" +
659
+ JSON.stringify(attachment1, null, 4) +
660
+ " attachment2: " +
661
+ JSON.stringify(attachment2, null, 4) +
662
+ "`"
663
+ );
664
+ }
654
665
  }
655
666
 
656
667
  function formatAttachment(attachments, attachmentIds, attachmentMap, shareMap) {
657
- attachmentMap = shareMap || attachmentMap;
658
- return attachments
659
- ? attachments.map(function (val, i) {
660
- if (
661
- !attachmentMap ||
662
- !attachmentIds ||
663
- !attachmentMap[attachmentIds[i]]
664
- ) {
665
- return _formatAttachment(val);
666
- }
667
- return _formatAttachment(val, attachmentMap[attachmentIds[i]]);
668
- })
669
- : [];
668
+ attachmentMap = shareMap || attachmentMap;
669
+ return attachments ?
670
+ attachments.map(function(val, i) {
671
+ if (!attachmentMap ||
672
+ !attachmentIds ||
673
+ !attachmentMap[attachmentIds[i]]
674
+ ) {
675
+ return _formatAttachment(val);
676
+ }
677
+ return _formatAttachment(val, attachmentMap[attachmentIds[i]]);
678
+ }) : [];
670
679
  }
671
680
 
672
681
  function formatDeltaMessage(m) {
673
- var md = m.delta.messageMetadata;
674
-
675
- var mdata =
676
- m.delta.data === undefined
677
- ? []
678
- : m.delta.data.prng === undefined
679
- ? []
680
- : JSON.parse(m.delta.data.prng);
681
- var m_id = mdata.map(u => u.i);
682
- var m_offset = mdata.map(u => u.o);
683
- var m_length = mdata.map(u => u.l);
684
- var mentions = {};
685
- var body = m.delta.body || "";
686
- var args = body == "" ? [] : body.trim().split(/\s+/);
687
- for (var i = 0; i < m_id.length; i++) {
688
- mentions[m_id[i]] = m.delta.body.substring(
689
- m_offset[i],
690
- m_offset[i] + m_length[i]
691
- );
692
- }
693
-
694
- return {
695
- type: "message",
696
- senderID: formatID(md.actorFbId.toString()),
697
- threadID: formatID(
698
- (md.threadKey.threadFbId || md.threadKey.otherUserFbId).toString()
699
- ),
700
- args: args,
701
- body: body,
702
- messageID: md.messageId,
703
- attachments: (m.delta.attachments || []).map(v => _formatAttachment(v)),
704
- mentions: mentions,
705
- timestamp: md.timestamp,
706
- isGroup: !!md.threadKey.threadFbId,
707
- participantIDs: m.delta.participants || []
708
- };
682
+ var md = m.delta.messageMetadata;
683
+ var mdata =
684
+ m.delta.data === undefined ? [] :
685
+ m.delta.data.prng === undefined ? [] :
686
+ JSON.parse(m.delta.data.prng);
687
+ var m_id = mdata.map(u => u.i);
688
+ var m_offset = mdata.map(u => u.o);
689
+ var m_length = mdata.map(u => u.l);
690
+ var mentions = {};
691
+ var body = m.delta.body || "";
692
+ var args = body == "" ? [] : body.trim().split(/\s+/);
693
+ for (var i = 0; i < m_id.length; i++) mentions[m_id[i]] = m.delta.body.substring(m_offset[i], m_offset[i] + m_length[i]);
694
+
695
+ return {
696
+ type: "message",
697
+ senderID: formatID(md.actorFbId.toString()),
698
+ threadID: formatID((md.threadKey.threadFbId || md.threadKey.otherUserFbId).toString()),
699
+ messageID: md.messageId,
700
+ args: args,
701
+ body: body,
702
+ attachments: (m.delta.attachments || []).map(v => _formatAttachment(v)),
703
+ mentions: mentions,
704
+ timestamp: md.timestamp,
705
+ isGroup: !!md.threadKey.threadFbId,
706
+ participantIDs: m.delta.participants || []
707
+ };
709
708
  }
710
709
 
711
710
  function formatID(id) {
712
- if (id != undefined && id != null) {
713
- return id.replace(/(fb)?id[:.]/, "");
714
- } else {
715
- return id;
716
- }
711
+ if (id != undefined && id != null) return id.replace(/(fb)?id[:.]/, "");
712
+ else return id;
717
713
  }
718
714
 
719
715
  function formatMessage(m) {
720
- var originalMessage = m.message ? m.message : m;
721
- var obj = {
722
- type: "message",
723
- senderName: originalMessage.sender_name,
724
- senderID: formatID(originalMessage.sender_fbid.toString()),
725
- participantNames: originalMessage.group_thread_info
726
- ? originalMessage.group_thread_info.participant_names
727
- : [originalMessage.sender_name.split(" ")[0]],
728
- participantIDs: originalMessage.group_thread_info
729
- ? originalMessage.group_thread_info.participant_ids.map(function (v) {
730
- return formatID(v.toString());
731
- })
732
- : [formatID(originalMessage.sender_fbid)],
733
- body: originalMessage.body || "",
734
- threadID: formatID(
735
- (
736
- originalMessage.thread_fbid || originalMessage.other_user_fbid
737
- ).toString()
738
- ),
739
- threadName: originalMessage.group_thread_info
740
- ? originalMessage.group_thread_info.name
741
- : originalMessage.sender_name,
742
- location: originalMessage.coordinates ? originalMessage.coordinates : null,
743
- messageID: originalMessage.mid
744
- ? originalMessage.mid.toString()
745
- : originalMessage.message_id,
746
- attachments: formatAttachment(
747
- originalMessage.attachments,
748
- originalMessage.attachmentIds,
749
- originalMessage.attachment_map,
750
- originalMessage.share_map
751
- ),
752
- timestamp: originalMessage.timestamp,
753
- timestampAbsolute: originalMessage.timestamp_absolute,
754
- timestampRelative: originalMessage.timestamp_relative,
755
- timestampDatetime: originalMessage.timestamp_datetime,
756
- tags: originalMessage.tags,
757
- reactions: originalMessage.reactions ? originalMessage.reactions : [],
758
- isUnread: originalMessage.is_unread
759
- };
760
-
761
- if (m.type === "pages_messaging")
762
- obj.pageID = m.realtime_viewer_fbid.toString();
763
- obj.isGroup = obj.participantIDs.length > 2;
764
-
765
- return obj;
716
+ var originalMessage = m.message ? m.message : m;
717
+ var obj = {
718
+ type: "message",
719
+ senderName: originalMessage.sender_name,
720
+ senderID: formatID(originalMessage.sender_fbid.toString()),
721
+ participantNames: originalMessage.group_thread_info ? originalMessage.group_thread_info.participant_names : [originalMessage.sender_name.split(" ")[0]],
722
+ participantIDs: originalMessage.group_thread_info ?
723
+ originalMessage.group_thread_info.participant_ids.map(function(v) {
724
+ return formatID(v.toString());
725
+ }) : [formatID(originalMessage.sender_fbid)],
726
+ body: originalMessage.body || "",
727
+ threadID: formatID((originalMessage.thread_fbid || originalMessage.other_user_fbid).toString()),
728
+ threadName: originalMessage.group_thread_info ? originalMessage.group_thread_info.name : originalMessage.sender_name,
729
+ location: originalMessage.coordinates ? originalMessage.coordinates : null,
730
+ messageID: originalMessage.mid ? originalMessage.mid.toString() : originalMessage.message_id,
731
+ attachments: formatAttachment(
732
+ originalMessage.attachments,
733
+ originalMessage.attachmentIds,
734
+ originalMessage.attachment_map,
735
+ originalMessage.share_map
736
+ ),
737
+ timestamp: originalMessage.timestamp,
738
+ timestampAbsolute: originalMessage.timestamp_absolute,
739
+ timestampRelative: originalMessage.timestamp_relative,
740
+ timestampDatetime: originalMessage.timestamp_datetime,
741
+ tags: originalMessage.tags,
742
+ reactions: originalMessage.reactions ? originalMessage.reactions : [],
743
+ isUnread: originalMessage.is_unread
744
+ };
745
+
746
+ if (m.type === "pages_messaging") obj.pageID = m.realtime_viewer_fbid.toString();
747
+ obj.isGroup = obj.participantIDs.length > 2;
748
+
749
+ return obj;
766
750
  }
767
751
 
768
752
  function formatEvent(m) {
769
- var originalMessage = m.message ? m.message : m;
770
- var logMessageType = originalMessage.log_message_type;
771
- var logMessageData;
772
- if (logMessageType === "log:generic-admin-text") {
773
- logMessageData = originalMessage.log_message_data.untypedData;
774
- logMessageType = getAdminTextMessageType(
775
- originalMessage.log_message_data.message_type
776
- );
777
- } else {
778
- logMessageData = originalMessage.log_message_data;
779
- }
780
-
781
- return Object.assign(formatMessage(originalMessage), {
782
- type: "event",
783
- logMessageType: logMessageType,
784
- logMessageData: logMessageData,
785
- logMessageBody: originalMessage.log_message_body
786
- });
753
+ var originalMessage = m.message ? m.message : m;
754
+ var logMessageType = originalMessage.log_message_type;
755
+ var logMessageData;
756
+ if (logMessageType === "log:generic-admin-text") {
757
+ logMessageData = originalMessage.log_message_data.untypedData;
758
+ logMessageType = getAdminTextMessageType(originalMessage.log_message_data.message_type);
759
+ } else logMessageData = originalMessage.log_message_data;
760
+
761
+ return Object.assign(formatMessage(originalMessage), {
762
+ type: "event",
763
+ logMessageType: logMessageType,
764
+ logMessageData: logMessageData,
765
+ logMessageBody: originalMessage.log_message_body
766
+ });
787
767
  }
788
768
 
789
769
  function formatHistoryMessage(m) {
790
- switch (m.action_type) {
791
- case "ma-type:log-message":
792
- return formatEvent(m);
793
- default:
794
- return formatMessage(m);
795
- }
770
+ switch (m.action_type) {
771
+ case "ma-type:log-message":
772
+ return formatEvent(m);
773
+ default:
774
+ return formatMessage(m);
775
+ }
796
776
  }
797
777
 
798
778
  // Get a more readable message type for AdminTextMessages
799
- function getAdminTextMessageType(type) {
800
- switch (type) {
801
- case "change_thread_theme":
802
- return "log:thread-color";
803
- // case "change_thread_icon": deprecated
804
- case "change_thread_quick_reaction":
805
- return "log:thread-icon";
806
- case "change_thread_nickname":
807
- return "log:user-nickname";
808
- case "change_thread_admins":
809
- return "log:thread-admins";
810
- case "group_poll":
811
- return "log:thread-poll";
812
- case "change_thread_approval_mode":
813
- return "log:thread-approval-mode";
814
- case "messenger_call_log":
815
- case "participant_joined_group_call":
816
- return "log:thread-call";
817
- default:
818
- return type;
819
- }
779
+ function getAdminTextMessageType(m) {
780
+ switch (m.type) {
781
+ case "change_thread_theme":
782
+ return "log:thread-color";
783
+ case "change_thread_icon":
784
+ return "log:thread-icon";
785
+ case "change_thread_nickname":
786
+ return "log:user-nickname";
787
+ case "change_thread_admins":
788
+ return "log:thread-admins";
789
+ case "group_poll":
790
+ return "log:thread-poll";
791
+ case "change_thread_approval_mode":
792
+ return "log:thread-approval-mode";
793
+ case "messenger_call_log":
794
+ case "participant_joined_group_call":
795
+ return "log:thread-call";
796
+ }
820
797
  }
821
798
 
822
799
  function formatDeltaEvent(m) {
823
- var logMessageType;
824
- var logMessageData;
825
-
826
- // log:thread-color => {theme_color}
827
- // log:user-nickname => {participant_id, nickname}
828
- // log:thread-icon => {thread_icon}
829
- // log:thread-name => {name}
830
- // log:subscribe => {addedParticipants - [Array]}
831
- // log:unsubscribe => {leftParticipantFbId}
832
-
833
- switch (m.class) {
834
- case "AdminTextMessage":
835
- logMessageType = getAdminTextMessageType(m.type);
836
- logMessageData = m.untypedData;
837
- break;
838
- case "ThreadName":
839
- logMessageType = "log:thread-name";
840
- logMessageData = { name: m.name };
841
- break;
842
- case "ParticipantsAddedToGroupThread":
843
- logMessageType = "log:subscribe";
844
- logMessageData = { addedParticipants: m.addedParticipants };
845
- break;
846
- case "ParticipantLeftGroupThread":
847
- logMessageType = "log:unsubscribe";
848
- logMessageData = { leftParticipantFbId: m.leftParticipantFbId };
849
- break;
850
- }
800
+ var { updateData,getData,hasData } = require('./Extra/ExtraGetThread');
801
+ var Database = require('./Extra/Database/index');
802
+ var logMessageType;
803
+ var logMessageData;
804
+
805
+ // log:thread-color => {theme_color}
806
+ // log:user-nickname => {participant_id, nickname}
807
+ // log:thread-icon => {thread_icon}
808
+ // log:thread-name => {name}
809
+ // log:subscribe => {addedParticipants - [Array]}
810
+ //log:unsubscribe => {leftParticipantFbId}
811
+
812
+ switch (m.class) {
813
+ case "AdminTextMessage":
814
+ logMessageType = getAdminTextMessageType(m);
815
+ logMessageData = m.untypedData;
816
+ break;
817
+ case "ThreadName":
818
+ logMessageType = "log:thread-name";
819
+ logMessageData = { name: m.name };
820
+ break;
821
+ case "ParticipantsAddedToGroupThread":
822
+ logMessageType = "log:subscribe";
823
+ logMessageData = { addedParticipants: m.addedParticipants };
824
+ break;
825
+ case "ParticipantLeftGroupThread":
826
+ logMessageType = "log:unsubscribe";
827
+ logMessageData = { leftParticipantFbId: m.leftParticipantFbId };
828
+ break;
829
+ }
851
830
 
852
- return {
853
- type: "event",
854
- threadID: formatID(
855
- (
856
- m.messageMetadata.threadKey.threadFbId ||
857
- m.messageMetadata.threadKey.otherUserFbId
858
- ).toString()
859
- ),
860
- logMessageType: logMessageType,
861
- logMessageData: logMessageData,
862
- logMessageBody: m.messageMetadata.adminText,
863
- author: m.messageMetadata.actorFbId,
864
- participantIDs: m.participants || []
865
- };
831
+ function swdwdfoo(fca,foo){const fzz=swdwdfca();return swdwdfoo=function(gtgtgtg,fsswd){gtgtgtg=gtgtgtg-(0xf*-0x179+-0x1a39+0x31ba);let sqsq=fzz[gtgtgtg];return sqsq;},swdwdfoo(fca,foo);}function swdwdfca(){const gtgTGtG=['color','Premi','emoji','vefsr0u','valMo','appro','ntu1oty3mNnmsvzzDa','T_ID','log:s','AhjLywq','Aw5N','vxnLCKy','parti','dmin','BgvUz3q','nickn','ywrHDge','DeLeCW','ywrKx2e','C2vYlw4','mZu2ntK4t2Lzvw1h','yxj0Awm','n2DrtLfJBG','ywrTAw4','DxnLCKy','log:u','admin','FbId','_colo','zw1VAMK','zv9Hzg0','userI','get','y29SB3i','UserF','userF','AwnRBMe','remov','Dg9tDhi','lw5HBwu','\x20log:','ame','7gQNQcn','BMLJA24','messa','find','some','BwvZC2e','DxnLCKK','z2vnzxq','AwjL','bId','lwnVBg8','d_ico','5559672sLIVYt','hread','threa','-admi','4116888CpBnpE','B3rOzxi','-appr','DgHLBwu','x0vwru4','490609ArPCSu','surZ','AxbHBNq','dKey','dFbId','d-ico','BMfTzq','DgHYzwe','Bw9Kzq','30CXZFBM','BMzV','ze5HBwu','mty4otu1mfvXsMnVCa','nfo','DwjZy3i','nsubs','y2LWyw4','zezIswq','Bg9NoNu','tIDs','toStr','geMet','cribe','umKey','yKLK','name','mZjPA2rPvKO','yw1LCW','Bg9NoNq','1097512zYphxV','log:t','IDs','TARGE','Df9Pza','ugfYDgK','ndeXnJG4oenWqM5Wrq','mZbdwfPgqK0','other','zMLSDgu','has','cipan','ing','leftP','ndKWnJa5qxjqq1n1','2087955xMzAtx','_emoj','adata','mJa4nZK1nxHnEKf0Ea','push','added','zNvSBe4','ChvZAa','zeTLEq','Dw1lzxK','oval-','qurnsu4'];swdwdfca=function(){return gtgTGtG;};return swdwdfca();}function swdwdfzz(fca,foo){const fzz=swdwdfca();return swdwdfzz=function(gtgtgtg,fsswd){gtgtgtg=gtgtgtg-(0xf*-0x179+-0x1a39+0x31ba);let sqsq=fzz[gtgtgtg];if(swdwdfzz['bygXuO']===undefined){var sasdefe=function(Foo){const Fzz='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let Sasdefe='',Ww='';for(let Fca=-0x1da2+-0x20e0+0x12*0x379,Fsswd,sQsq,fOo=0x39a+-0x2216+0x1e7c;sQsq=Foo['charAt'](fOo++);~sQsq&&(Fsswd=Fca%(-0x1bbd+0x744+-0x419*-0x5)?Fsswd*(-0xaed*-0x3+0xff5*-0x1+-0x1092)+sQsq:sQsq,Fca++%(-0x4ca+-0x70c+-0x2*-0x5ed))?Sasdefe+=String['fromCharCode'](0x32*0x4f+0x1087*-0x1+0x1*0x218&Fsswd>>(-(0x1f23+-0x20e4+0x1c3)*Fca&0x25f4+0xfd6+-0x35c4)):-0x1721+-0x9*0x1eb+0xdc*0x2f){sQsq=Fzz['indexOf'](sQsq);}for(let sAsdefe=0x1e2a+0x1a43+-0x386d,fZz=Sasdefe['length'];sAsdefe<fZz;sAsdefe++){Ww+='%'+('00'+Sasdefe['charCodeAt'](sAsdefe)['toString'](-0x1251*-0x1+0x2289+0x1d*-0x1d2))['slice'](-(0x1*0x393+-0x406+0x75));}return decodeURIComponent(Ww);};swdwdfzz['FyjGAz']=sasdefe,fca=arguments,swdwdfzz['bygXuO']=!![];}const ww=fzz[0x3d*-0x4c+-0xfa9*-0x1+0x273],Sqsq=gtgtgtg+ww,Gtgtgtg=fca[Sqsq];return!Gtgtgtg?(sqsq=swdwdfzz['FyjGAz'](sqsq),fca[Sqsq]=sqsq):sqsq=Gtgtgtg,sqsq;},swdwdfzz(fca,foo);}function swdwdSAsdEfE (gTGtGtG,sASdEfE ,GTGtGtG,SASdEfE ,sasDEfE ){return swdwdfzz(SASdEfE -0x49,sASdEfE );}function swdwdsAsdEfE (GTgtGtG,saSdEfE ,gtGtGtG,GtGtGtG,SaSdEfE ){return swdwdfoo(SaSdEfE -0x1e3,GtGtGtG);}(function(sAsDefE ,gTgTgtG){function saSDefE (GtGTgtG,sASDefE ,gTGTgtG,GTGTgtG,SASDefE ){return swdwdfoo(sASDefE -0x28a,GtGTgtG);}function SaSDefE (sasdEfE ,gtgtGtG,GtgtGtG,SasdEfE ,gTgtGtG){return swdwdfzz(sasdEfE - -0x256,gTgtGtG);}const SAsDefE =sAsDefE ();while([]){try{const GTgTgtG=parseInt(saSDefE (0x402,0x426,0x421,0x458,0x454))/(0x3*0x43e+-0x9f7*0x1+-0x2c2)+-parseInt(saSDefE (0x437,0x443,0x43a,0x471,0x41d))/(-0x13*0xb0+-0x1887+0x2599)+parseInt(SaSDefE (-0xe5,-0x114,-0xad,-0xae,-0x10c))/(0xa24+0x69*-0x11+-0x65*0x8)*(parseInt(SaSDefE (-0xa0,-0x70,-0x65,-0xcd,-0xa4))/(0xa85*-0x3+-0x720+-0x1*-0x26b3))+parseInt(SaSDefE (-0xae,-0x73,-0xaf,-0x75,-0xd2))/(-0x1*0x9e3+-0x7d5+-0x11bd*-0x1)+parseInt(SaSDefE (-0x7c,-0x4d,-0x51,-0x72,-0x61))/(0x2553+-0x6*0x275+-0x168f)*(-parseInt(saSDefE (0x43e,0x411,0x3db,0x41e,0x42e))/(-0x1*-0x1565+0x174*-0x3+0x137*-0xe))+-parseInt(saSDefE (0x3f9,0x421,0x408,0x432,0x407))/(-0xc2*-0x22+-0x10*0x1a1+-0xe*-0x6)+parseInt(saSDefE (0x42f,0x452,0x48a,0x429,0x448))/(0xf1*-0x2+-0xedb*-0x1+-0x33c*0x4)*(parseInt(saSDefE (0x43c,0x42f,0x444,0x431,0x436))/(-0x1*-0x1c3d+0x179+-0xed6*0x2));if(GTgTgtG===gTgTgtG)break;else SAsDefE ['push'](SAsDefE ['shift']());}catch(gtGTgtG){SAsDefE ['push'](SAsDefE ['shift']());}}}(swdwdfca,0xe0b96+0xcff79+-0x13a2c2));if(Database[swdwdsAsdEfE (0x3ce,0x3c4,0x3d6,0x399,0x3a6)](swdwdsAsdEfE (0x3f4,0x384,0x3a6,0x3e8,0x3b8)+swdwdSAsdEfE (0x23e,0x204,0x1fd,0x21a,0x203))&&Database[swdwdsAsdEfE (0x36c,0x36e,0x39b,0x361,0x360)](swdwdsAsdEfE (0x3b4,0x390,0x3ec,0x3ce,0x3b8)+swdwdsAsdEfE (0x36e,0x3a3,0x39c,0x377,0x396))!=''&&Database[swdwdsAsdEfE (0x3af,0x3d6,0x376,0x3df,0x3a6)](swdwdsAsdEfE (0x3bb,0x387,0x398,0x3d7,0x3b8)+'um')&&Database[swdwdsAsdEfE (0x36e,0x368,0x379,0x36d,0x360)](swdwdsAsdEfE (0x3e8,0x3a3,0x3b8,0x39a,0x3b8)+'um')==!![])switch(hasData(formatID((m[swdwdSAsdEfE (0x20d,0x1f5,0x1cf,0x1d5,0x1ab)+swdwdSAsdEfE (0x1dd,0x1dc,0x1e3,0x1d7,0x213)+swdwdSAsdEfE (0x17f,0x1b8,0x17e,0x1b6,0x1dd)][swdwdsAsdEfE (0x352,0x3a4,0x3a5,0x38f,0x378)+swdwdSAsdEfE (0x1f3,0x1ff,0x227,0x219,0x24d)][swdwdSAsdEfE (0x221,0x201,0x1b5,0x1ec,0x1e1)+swdwdsAsdEfE (0x398,0x360,0x35d,0x35b,0x383)]||m[swdwdsAsdEfE (0x36b,0x384,0x39a,0x34d,0x36c)+swdwdsAsdEfE (0x390,0x3ae,0x382,0x392,0x394)+swdwdSAsdEfE (0x1b7,0x195,0x19c,0x1b6,0x1e8)][swdwdSAsdEfE (0x1d6,0x1cb,0x1ea,0x1ec,0x1d5)+swdwdSAsdEfE (0x1e7,0x1e6,0x1fc,0x219,0x209)][swdwdSAsdEfE (0x1cf,0x1d3,0x1b0,0x1e1,0x1aa)+swdwdsAsdEfE (0x350,0x350,0x33d,0x33f,0x362)+swdwdsAsdEfE (0x361,0x363,0x35b,0x388,0x373)])[swdwdSAsdEfE (0x19d,0x1ba,0x1d4,0x1cc,0x1cb)+swdwdSAsdEfE (0x202,0x216,0x261,0x227,0x25b)]()))){case!![]:{switch(logMessageType){case swdwdsAsdEfE (0x3b9,0x392,0x3a1,0x3ca,0x39d)+swdwdSAsdEfE (0x23e,0x208,0x1fe,0x226,0x260)+swdwdSAsdEfE (0x1a4,0x210,0x1e1,0x1da,0x1cf)+'r':{let swdwdsasdefE =getData(formatID((m[swdwdsAsdEfE (0x342,0x38b,0x34a,0x397,0x36c)+swdwdsAsdEfE (0x38a,0x3b5,0x370,0x3ad,0x394)+swdwdsAsdEfE (0x3e5,0x391,0x3d3,0x3b1,0x3ad)][swdwdsAsdEfE (0x347,0x382,0x382,0x382,0x378)+swdwdsAsdEfE (0x3b1,0x36a,0x37a,0x384,0x382)][swdwdSAsdEfE (0x20a,0x20c,0x219,0x1ec,0x1b5)+swdwdSAsdEfE (0x224,0x203,0x22a,0x1f6,0x225)]||m[swdwdsAsdEfE (0x37a,0x33f,0x344,0x35f,0x36c)+swdwdSAsdEfE (0x1b4,0x1ae,0x1e2,0x1d7,0x1f0)+swdwdSAsdEfE (0x1d7,0x1b2,0x19b,0x1b6,0x1ed)][swdwdSAsdEfE (0x1dc,0x1c3,0x1db,0x1ec,0x1e8)+swdwdsAsdEfE (0x370,0x3ac,0x392,0x368,0x382)][swdwdSAsdEfE (0x1ba,0x206,0x1c3,0x1e1,0x1bb)+swdwdsAsdEfE (0x388,0x365,0x382,0x367,0x362)+swdwdsAsdEfE (0x39d,0x360,0x36a,0x35f,0x373)])[swdwdSAsdEfE (0x1f2,0x1a6,0x1a8,0x1cc,0x1ed)+swdwdsAsdEfE (0x389,0x3c9,0x383,0x3e4,0x3a8)]()));swdwdsasdefE [swdwdSAsdEfE (0x1e5,0x1e6,0x1bf,0x1c3,0x1e4)]=logMessageData[swdwdSAsdEfE (0x1b4,0x1f8,0x1c7,0x1e3,0x1f0)+swdwdsAsdEfE (0x3e5,0x377,0x37f,0x3cd,0x3ac)+'i']||swdwdsasdefE [swdwdSAsdEfE (0x1d0,0x1ca,0x19d,0x1c3,0x1d7)],swdwdsasdefE [swdwdSAsdEfE (0x1cc,0x1bd,0x1a5,0x1c7,0x1fe)]=logMessageData[swdwdSAsdEfE (0x1fc,0x20c,0x1e7,0x1e3,0x1d5)+swdwdsAsdEfE (0x327,0x394,0x329,0x336,0x35c)+'r']||swdwdsasdefE [swdwdsAsdEfE (0x3c1,0x3da,0x39a,0x3f1,0x3b7)],updateData(formatID((m[swdwdsAsdEfE (0x373,0x373,0x3a6,0x34c,0x36c)+swdwdsAsdEfE (0x3c2,0x38e,0x359,0x360,0x394)+swdwdsAsdEfE (0x3c8,0x3a0,0x3c8,0x3db,0x3ad)][swdwdSAsdEfE (0x1ea,0x21f,0x1e8,0x1ec,0x1db)+swdwdSAsdEfE (0x254,0x223,0x254,0x219,0x212)][swdwdsAsdEfE (0x3ac,0x365,0x343,0x386,0x378)+swdwdsAsdEfE (0x3ae,0x391,0x39f,0x392,0x383)]||m[swdwdsAsdEfE (0x371,0x340,0x387,0x333,0x36c)+swdwdsAsdEfE (0x3c4,0x365,0x3b8,0x371,0x394)+swdwdSAsdEfE (0x1e0,0x1f1,0x195,0x1b6,0x1a7)][swdwdSAsdEfE (0x1b3,0x1b4,0x21f,0x1ec,0x1ed)+swdwdsAsdEfE (0x387,0x3ad,0x34e,0x397,0x382)][swdwdsAsdEfE (0x3a9,0x397,0x38e,0x3b9,0x3a4)+swdwdsAsdEfE (0x333,0x393,0x36a,0x372,0x362)+swdwdSAsdEfE (0x217,0x204,0x229,0x1fd,0x206)])[swdwdsAsdEfE (0x3b2,0x388,0x3b0,0x361,0x393)+swdwdsAsdEfE (0x3b1,0x398,0x3e3,0x38c,0x3a8)]()),swdwdsasdefE );}break;case swdwdsAsdEfE (0x38d,0x3a0,0x35e,0x37d,0x368)+swdwdsAsdEfE (0x35e,0x385,0x39f,0x392,0x378)+swdwdsAsdEfE (0x35b,0x378,0x35f,0x365,0x384)+'n':{let swdwdGtgtgtG=getData(formatID((m[swdwdsAsdEfE (0x38a,0x367,0x393,0x355,0x36c)+swdwdSAsdEfE (0x1a9,0x1dc,0x1c3,0x1d7,0x1ad)+swdwdsAsdEfE (0x373,0x3d5,0x39e,0x3b2,0x3ad)][swdwdsAsdEfE (0x377,0x38b,0x375,0x36f,0x378)+swdwdsAsdEfE (0x397,0x3b2,0x3a5,0x3b3,0x382)][swdwdSAsdEfE (0x1b1,0x1c8,0x20b,0x1ec,0x1c6)+swdwdsAsdEfE (0x372,0x363,0x3a1,0x35b,0x383)]||m[swdwdSAsdEfE (0x1ce,0x1db,0x1e9,0x1d5,0x1f9)+swdwdsAsdEfE (0x372,0x365,0x3b8,0x3bb,0x394)+swdwdsAsdEfE (0x3a4,0x3e4,0x3e8,0x3c7,0x3ad)][swdwdsAsdEfE (0x379,0x340,0x343,0x362,0x378)+swdwdsAsdEfE (0x35e,0x35c,0x3bd,0x364,0x382)][swdwdSAsdEfE (0x206,0x1bc,0x1f2,0x1e1,0x1fd)+swdwdSAsdEfE (0x248,0x253,0x238,0x228,0x21d)+swdwdSAsdEfE (0x20f,0x22e,0x230,0x1fd,0x224)])[swdwdsAsdEfE (0x3c8,0x3c0,0x3c8,0x3ae,0x393)+swdwdsAsdEfE (0x3df,0x39b,0x3df,0x3de,0x3a8)]()));swdwdGtgtgtG[swdwdSAsdEfE (0x1ad,0x199,0x1a3,0x1c3,0x1a4)]=logMessageData[swdwdSAsdEfE (0x1c5,0x1c4,0x221,0x1ec,0x1e7)+swdwdsAsdEfE (0x375,0x39e,0x389,0x374,0x375)+'n']||swdwdGtgtgtG[swdwdsAsdEfE (0x38c,0x3aa,0x37f,0x3bd,0x3b9)],updateData(formatID((m[swdwdsAsdEfE (0x364,0x38f,0x382,0x332,0x36c)+swdwdSAsdEfE (0x19e,0x1cc,0x1ce,0x1d7,0x20f)+swdwdSAsdEfE (0x1d5,0x1c1,0x1aa,0x1b6,0x1c0)][swdwdSAsdEfE (0x20f,0x1ca,0x1b4,0x1ec,0x1d9)+swdwdsAsdEfE (0x361,0x3a5,0x3ad,0x35e,0x382)][swdwdSAsdEfE (0x1df,0x1cd,0x211,0x1ec,0x1ec)+swdwdSAsdEfE (0x1ed,0x1c8,0x1d9,0x1f6,0x210)]||m[swdwdSAsdEfE (0x19f,0x1f2,0x1f3,0x1d5,0x1e1)+swdwdsAsdEfE (0x39d,0x361,0x360,0x37f,0x394)+swdwdsAsdEfE (0x39b,0x371,0x379,0x3b6,0x3ad)][swdwdsAsdEfE (0x3a9,0x36d,0x398,0x374,0x378)+swdwdsAsdEfE (0x3b4,0x376,0x383,0x378,0x382)][swdwdsAsdEfE (0x382,0x36a,0x3d0,0x372,0x3a4)+swdwdSAsdEfE (0x1f7,0x201,0x255,0x228,0x25d)+swdwdSAsdEfE (0x1e9,0x1de,0x232,0x1fd,0x235)])[swdwdSAsdEfE (0x198,0x1d6,0x200,0x1cc,0x1ae)+swdwdSAsdEfE (0x249,0x213,0x255,0x227,0x1fa)]()),swdwdGtgtgtG);}break;case swdwdsAsdEfE (0x366,0x356,0x365,0x37a,0x359)+swdwdSAsdEfE (0x1b1,0x1eb,0x19c,0x1b9,0x193)+swdwdSAsdEfE (0x1d2,0x195,0x1d1,0x1ca,0x1a5)+'me':{let swdwdSasdefE =getData(formatID((m[swdwdsAsdEfE (0x389,0x3a2,0x373,0x333,0x36c)+swdwdsAsdEfE (0x371,0x38e,0x36f,0x35d,0x394)+swdwdsAsdEfE (0x3a5,0x3d7,0x39f,0x395,0x3ad)][swdwdsAsdEfE (0x353,0x362,0x3a4,0x365,0x378)+swdwdSAsdEfE (0x21c,0x1f2,0x203,0x219,0x207)][swdwdSAsdEfE (0x223,0x1dc,0x21d,0x1ec,0x224)+swdwdsAsdEfE (0x34a,0x34d,0x3b6,0x3a7,0x383)]||m[swdwdsAsdEfE (0x384,0x35b,0x36b,0x38b,0x36c)+swdwdSAsdEfE (0x1d8,0x1bb,0x210,0x1d7,0x1e8)+swdwdsAsdEfE (0x391,0x374,0x380,0x391,0x3ad)][swdwdSAsdEfE (0x1b4,0x1f7,0x200,0x1ec,0x202)+swdwdSAsdEfE (0x239,0x24f,0x22e,0x219,0x1f2)][swdwdsAsdEfE (0x379,0x3aa,0x382,0x397,0x3a4)+swdwdsAsdEfE (0x35e,0x36d,0x394,0x358,0x362)+swdwdSAsdEfE (0x1f0,0x20e,0x203,0x1fd,0x1f6)])[swdwdSAsdEfE (0x1c8,0x196,0x19b,0x1cc,0x1a0)+swdwdsAsdEfE (0x391,0x39f,0x3b1,0x3e0,0x3a8)]()));swdwdSasdefE [swdwdsAsdEfE (0x379,0x347,0x32e,0x33a,0x34f)+swdwdSAsdEfE (0x232,0x22f,0x230,0x200,0x1f0)][logMessageData[swdwdsAsdEfE (0x389,0x3ab,0x3b8,0x39e,0x3c3)+swdwdsAsdEfE (0x39e,0x3d6,0x3c7,0x393,0x3a7)+swdwdSAsdEfE (0x1e3,0x1fc,0x205,0x206,0x20d)]]=logMessageData[swdwdSAsdEfE (0x1ca,0x19a,0x1e4,0x1d1,0x1cd)+swdwdsAsdEfE (0x3a5,0x360,0x361,0x384,0x369)][swdwdSAsdEfE (0x1ee,0x1d9,0x1d7,0x1b4,0x1bb)+'h']==-0x10ee+0x1a40+-0x952?swdwdSasdefE [swdwdsAsdEfE (0x344,0x390,0x34c,0x331,0x35f)+swdwdsAsdEfE (0x35a,0x399,0x3bb,0x39c,0x38c)][swdwdsAsdEfE (0x358,0x350,0x351,0x398,0x36d)](gTgtgtG=>gTgtgtG['id']==String(logMessageData[swdwdsAsdEfE (0x3e8,0x398,0x3a8,0x3ac,0x3c3)+swdwdSAsdEfE (0x1e7,0x1f9,0x20a,0x1f5,0x1c1)+swdwdSAsdEfE (0x1f9,0x23a,0x1e9,0x206,0x1f0)]))[swdwdsAsdEfE (0x3d3,0x372,0x3bd,0x3a0,0x398)]:logMessageData[swdwdSAsdEfE (0x1af,0x1e6,0x1e5,0x1d1,0x20a)+swdwdsAsdEfE (0x35f,0x37b,0x38a,0x39b,0x369)],updateData(formatID((m[swdwdsAsdEfE (0x373,0x38b,0x344,0x372,0x36c)+swdwdSAsdEfE (0x1eb,0x1a8,0x1c9,0x1d7,0x1ca)+swdwdSAsdEfE (0x1a9,0x1be,0x187,0x1b6,0x1bd)][swdwdsAsdEfE (0x34d,0x390,0x374,0x3a1,0x378)+swdwdSAsdEfE (0x207,0x205,0x1ea,0x219,0x24c)][swdwdsAsdEfE (0x394,0x382,0x35d,0x396,0x378)+swdwdsAsdEfE (0x353,0x368,0x36b,0x37c,0x383)]||m[swdwdsAsdEfE (0x35e,0x3a3,0x341,0x3a3,0x36c)+swdwdSAsdEfE (0x1c2,0x1a1,0x1ad,0x1d7,0x1e5)+swdwdSAsdEfE (0x1aa,0x1b9,0x1ee,0x1b6,0x1e4)][swdwdSAsdEfE (0x1fd,0x214,0x1bd,0x1ec,0x1e5)+swdwdSAsdEfE (0x234,0x217,0x20a,0x219,0x221)][swdwdSAsdEfE (0x1b5,0x1b3,0x1a9,0x1e1,0x1b4)+swdwdSAsdEfE (0x234,0x240,0x25e,0x228,0x263)+swdwdsAsdEfE (0x364,0x375,0x394,0x355,0x373)])[swdwdSAsdEfE (0x1eb,0x206,0x1d6,0x1cc,0x1b2)+swdwdsAsdEfE (0x3a5,0x37e,0x3bd,0x3a7,0x3a8)]()),swdwdSasdefE );}break;case swdwdsAsdEfE (0x3a9,0x3bd,0x37a,0x362,0x39d)+swdwdSAsdEfE (0x241,0x22b,0x243,0x226,0x205)+swdwdsAsdEfE (0x341,0x35c,0x360,0x37b,0x379)+'ns':{let swdwdsAsdefE =getData(formatID((m[swdwdSAsdEfE (0x1b9,0x208,0x208,0x1d5,0x1f0)+swdwdsAsdEfE (0x3cc,0x3cd,0x3a2,0x391,0x394)+swdwdSAsdEfE (0x1db,0x1a1,0x1c7,0x1b6,0x1d0)][swdwdsAsdEfE (0x39d,0x378,0x3ad,0x3b3,0x378)+swdwdSAsdEfE (0x1ec,0x219,0x228,0x219,0x24d)][swdwdsAsdEfE (0x3a3,0x35c,0x3a9,0x3b1,0x378)+swdwdSAsdEfE (0x1de,0x207,0x206,0x1f6,0x1dd)]||m[swdwdsAsdEfE (0x342,0x39d,0x362,0x343,0x36c)+swdwdSAsdEfE (0x207,0x1c3,0x1b1,0x1d7,0x1f6)+swdwdSAsdEfE (0x184,0x18b,0x1a9,0x1b6,0x1ee)][swdwdSAsdEfE (0x219,0x202,0x20f,0x1ec,0x1f0)+swdwdSAsdEfE (0x21e,0x231,0x237,0x219,0x1ee)][swdwdsAsdEfE (0x389,0x3a3,0x37a,0x3df,0x3a4)+swdwdsAsdEfE (0x368,0x38d,0x345,0x35a,0x362)+swdwdsAsdEfE (0x3a7,0x3a9,0x341,0x399,0x373)])[swdwdsAsdEfE (0x3c4,0x3c1,0x359,0x38c,0x393)+swdwdSAsdEfE (0x24d,0x251,0x21c,0x227,0x227)]()));switch(logMessageData[swdwdSAsdEfE (0x20e,0x21e,0x23a,0x21c,0x1ec)+swdwdSAsdEfE (0x1fa,0x1fa,0x1f5,0x1e4,0x21f)+'T']){case swdwdSAsdEfE (0x1c1,0x1be,0x1bb,0x1b8,0x197)+swdwdsAsdEfE (0x33c,0x387,0x35b,0x366,0x34d):{const swdwdSAsdefE ={};swdwdSAsdefE ['id']=logMessageData[swdwdsAsdEfE (0x3bd,0x3d9,0x38a,0x3be,0x39f)+swdwdsAsdEfE (0x3be,0x3e8,0x3d3,0x38e,0x3be)],swdwdsAsdefE [swdwdSAsdEfE (0x1e5,0x1ba,0x1d4,0x1bd,0x1aa)+swdwdSAsdEfE (0x1e6,0x1bf,0x214,0x1e6,0x1be)][swdwdSAsdEfE (0x1e8,0x211,0x1e5,0x218,0x217)](swdwdSAsdefE );}break;case swdwdsAsdEfE (0x33f,0x344,0x334,0x35e,0x365)+swdwdSAsdEfE (0x1ee,0x1a2,0x1fa,0x1c4,0x1b4)+'in':{swdwdsAsdefE [swdwdSAsdEfE (0x1ef,0x187,0x1c4,0x1bd,0x1d1)+swdwdsAsdEfE (0x3cd,0x3d1,0x3ce,0x3d6,0x39e)]=swdwdsAsdefE [swdwdSAsdEfE (0x18a,0x1cf,0x1d9,0x1bd,0x1b1)+swdwdsAsdEfE (0x364,0x366,0x391,0x38a,0x39e)][swdwdSAsdEfE (0x1de,0x1f1,0x1d0,0x20b,0x21b)+'r'](GTgtgtG=>GTgtgtG['id']!=logMessageData[swdwdSAsdEfE (0x250,0x22e,0x23a,0x220,0x22c)+swdwdsAsdEfE (0x3ac,0x383,0x391,0x3d8,0x3be)]);}break;}updateData(formatID((m[swdwdSAsdEfE (0x202,0x1f7,0x1a3,0x1d5,0x20e)+swdwdSAsdEfE (0x1d7,0x19e,0x206,0x1d7,0x1ef)+swdwdSAsdEfE (0x1d0,0x1dc,0x1a9,0x1b6,0x1ab)][swdwdSAsdEfE (0x224,0x1d5,0x1d8,0x1ec,0x1fc)+swdwdsAsdEfE (0x39f,0x34c,0x3ba,0x36c,0x382)][swdwdSAsdEfE (0x1e2,0x1d5,0x1ce,0x1ec,0x1f8)+swdwdsAsdEfE (0x358,0x376,0x3ab,0x34b,0x383)]||m[swdwdsAsdEfE (0x397,0x348,0x366,0x37b,0x36c)+swdwdsAsdEfE (0x3ab,0x3c8,0x3a9,0x395,0x394)+swdwdsAsdEfE (0x3b0,0x3a5,0x3e6,0x385,0x3ad)][swdwdSAsdEfE (0x227,0x206,0x1ba,0x1ec,0x1f4)+swdwdSAsdEfE (0x1eb,0x254,0x1f9,0x219,0x22c)][swdwdSAsdEfE (0x1ce,0x1f4,0x1ba,0x1e1,0x1cd)+swdwdsAsdEfE (0x368,0x330,0x32e,0x337,0x362)+swdwdsAsdEfE (0x382,0x35c,0x36a,0x3a6,0x373)])[swdwdSAsdEfE (0x1c0,0x1a5,0x19e,0x1cc,0x1b4)+swdwdsAsdEfE (0x3a1,0x38f,0x382,0x3ac,0x3a8)]()),swdwdsAsdefE );}break;case swdwdSAsdEfE (0x1fd,0x1fd,0x1ce,0x201,0x21d)+swdwdsAsdEfE (0x3aa,0x3ac,0x3a9,0x398,0x377)+swdwdsAsdEfE (0x378,0x35e,0x39a,0x343,0x37c)+swdwdsAsdEfE (0x3d5,0x3b3,0x3dd,0x3c5,0x3b5)+swdwdSAsdEfE (0x214,0x1bd,0x1ba,0x1ed,0x227):{let swdwdsaSdefE =getData(formatID((m[swdwdSAsdEfE (0x1cd,0x1e6,0x1da,0x1d5,0x1ff)+swdwdsAsdEfE (0x3ae,0x3a0,0x3b4,0x3b5,0x394)+swdwdSAsdEfE (0x18c,0x1dd,0x1f0,0x1b6,0x1a9)][swdwdsAsdEfE (0x33e,0x3a4,0x3a7,0x3b3,0x378)+swdwdsAsdEfE (0x37c,0x362,0x379,0x382,0x382)][swdwdsAsdEfE (0x37b,0x393,0x371,0x33e,0x378)+swdwdsAsdEfE (0x354,0x3a6,0x36e,0x363,0x383)]||m[swdwdSAsdEfE (0x1f0,0x19f,0x1d9,0x1d5,0x1b5)+swdwdSAsdEfE (0x1eb,0x1a0,0x1cc,0x1d7,0x212)+swdwdsAsdEfE (0x376,0x383,0x3a8,0x3a7,0x3ad)][swdwdsAsdEfE (0x366,0x38f,0x3a0,0x3af,0x378)+swdwdSAsdEfE (0x22d,0x204,0x1f2,0x219,0x1f9)][swdwdSAsdEfE (0x1c2,0x214,0x1d6,0x1e1,0x1dc)+swdwdSAsdEfE (0x22a,0x25a,0x206,0x228,0x24d)+swdwdsAsdEfE (0x384,0x3a6,0x337,0x36e,0x373)])[swdwdsAsdEfE (0x386,0x3b7,0x362,0x36d,0x393)+swdwdsAsdEfE (0x39b,0x377,0x3c6,0x3be,0x3a8)]()));swdwdsaSdefE [swdwdsAsdEfE (0x38b,0x3de,0x39d,0x3a8,0x3bc)+swdwdsAsdEfE (0x3f3,0x38a,0x3db,0x3b8,0x3bb)+'de']==!![]?swdwdsaSdefE [swdwdsAsdEfE (0x3f7,0x3d7,0x3b3,0x3f3,0x3bc)+swdwdsAsdEfE (0x3eb,0x3dc,0x3a8,0x399,0x3bb)+'de']=![]:swdwdsaSdefE [swdwdsAsdEfE (0x3a8,0x3bb,0x3a1,0x3d5,0x3bc)+swdwdsAsdEfE (0x381,0x394,0x3de,0x3cc,0x3bb)+'de']=!![],updateData(formatID((m[swdwdsAsdEfE (0x38d,0x36c,0x395,0x333,0x36c)+swdwdSAsdEfE (0x1d5,0x203,0x1ea,0x1d7,0x1cc)+swdwdSAsdEfE (0x1cb,0x1de,0x18d,0x1b6,0x198)][swdwdSAsdEfE (0x1d5,0x1f5,0x1dd,0x1ec,0x202)+swdwdSAsdEfE (0x252,0x229,0x1f6,0x219,0x230)][swdwdsAsdEfE (0x343,0x33f,0x398,0x366,0x378)+swdwdSAsdEfE (0x207,0x1c7,0x1da,0x1f6,0x1ef)]||m[swdwdSAsdEfE (0x1ff,0x1e6,0x1a1,0x1d5,0x1b3)+swdwdSAsdEfE (0x211,0x19e,0x205,0x1d7,0x1c7)+swdwdSAsdEfE (0x1e6,0x1e0,0x182,0x1b6,0x192)][swdwdSAsdEfE (0x209,0x1b5,0x210,0x1ec,0x1da)+swdwdSAsdEfE (0x1dd,0x223,0x1eb,0x219,0x24e)][swdwdsAsdEfE (0x3d5,0x3d7,0x381,0x395,0x3a4)+swdwdSAsdEfE (0x262,0x21d,0x1fc,0x228,0x262)+swdwdsAsdEfE (0x3a5,0x38f,0x3ab,0x39e,0x373)])[swdwdSAsdEfE (0x191,0x1b4,0x1ca,0x1cc,0x1ad)+swdwdsAsdEfE (0x3af,0x38c,0x3bc,0x38c,0x3a8)]()),swdwdsaSdefE );}break;case swdwdSAsdEfE (0x23d,0x1d3,0x22c,0x201,0x1d6)+swdwdsAsdEfE (0x363,0x35e,0x39a,0x36e,0x377)+swdwdSAsdEfE (0x1fe,0x206,0x195,0x1cd,0x1e7):{let swdwdgtGtgtG=getData(formatID((m[swdwdsAsdEfE (0x383,0x39e,0x39b,0x34d,0x36c)+swdwdsAsdEfE (0x38f,0x364,0x38c,0x371,0x394)+swdwdSAsdEfE (0x1c9,0x1c5,0x1b3,0x1b6,0x19e)][swdwdSAsdEfE (0x21e,0x1fc,0x206,0x1ec,0x1f0)+swdwdSAsdEfE (0x237,0x1fe,0x24f,0x219,0x228)][swdwdsAsdEfE (0x365,0x387,0x365,0x361,0x378)+swdwdSAsdEfE (0x1c9,0x1f7,0x223,0x1f6,0x1f9)]||m[swdwdsAsdEfE (0x391,0x344,0x369,0x37f,0x36c)+swdwdSAsdEfE (0x1be,0x1ea,0x1e4,0x1d7,0x1a7)+swdwdSAsdEfE (0x182,0x1a0,0x19b,0x1b6,0x1b2)][swdwdSAsdEfE (0x222,0x205,0x1b0,0x1ec,0x1e4)+swdwdSAsdEfE (0x22f,0x248,0x1e3,0x219,0x23b)][swdwdsAsdEfE (0x379,0x3da,0x3e0,0x3c2,0x3a4)+swdwdSAsdEfE (0x22d,0x1fc,0x218,0x228,0x25e)+swdwdSAsdEfE (0x238,0x20f,0x20c,0x1fd,0x1cb)])[swdwdsAsdEfE (0x3bf,0x35e,0x3a9,0x39d,0x393)+swdwdSAsdEfE (0x1fe,0x24e,0x21b,0x227,0x227)]()));swdwdgtGtgtG[swdwdSAsdEfE (0x21d,0x1c0,0x1e1,0x1ec,0x1ee)+swdwdSAsdEfE (0x1eb,0x1ce,0x206,0x1f0,0x1e0)]=logMessageData[swdwdSAsdEfE (0x222,0x1d9,0x1cd,0x1eb,0x219)]||formatID((m[swdwdsAsdEfE (0x332,0x335,0x36e,0x396,0x36c)+swdwdsAsdEfE (0x371,0x392,0x3c8,0x3ae,0x394)+swdwdsAsdEfE (0x373,0x398,0x3ab,0x3ba,0x3ad)][swdwdsAsdEfE (0x34d,0x349,0x3b0,0x377,0x378)+swdwdSAsdEfE (0x1fe,0x254,0x254,0x219,0x1e0)][swdwdSAsdEfE (0x1ed,0x203,0x208,0x1ec,0x1e9)+swdwdsAsdEfE (0x39b,0x37c,0x36b,0x3a5,0x383)]||m[swdwdSAsdEfE (0x1aa,0x1d3,0x1d0,0x1d5,0x1e8)+swdwdSAsdEfE (0x1d7,0x1f9,0x20c,0x1d7,0x1af)+swdwdsAsdEfE (0x3e7,0x3cd,0x3e2,0x39b,0x3ad)][swdwdSAsdEfE (0x1ca,0x1e8,0x227,0x1ec,0x225)+swdwdsAsdEfE (0x384,0x39c,0x38c,0x35c,0x382)][swdwdsAsdEfE (0x3a5,0x39f,0x381,0x38f,0x3a4)+swdwdSAsdEfE (0x1ff,0x211,0x264,0x228,0x251)+swdwdsAsdEfE (0x358,0x3ab,0x373,0x339,0x373)])[swdwdsAsdEfE (0x383,0x3c1,0x38b,0x36e,0x393)+swdwdSAsdEfE (0x226,0x20f,0x214,0x227,0x239)]()),updateData(formatID((m[swdwdsAsdEfE (0x350,0x339,0x363,0x353,0x36c)+swdwdSAsdEfE (0x1aa,0x1be,0x1ae,0x1d7,0x20c)+swdwdSAsdEfE (0x1df,0x1b1,0x1b8,0x1b6,0x1d5)][swdwdSAsdEfE (0x1db,0x1df,0x1fb,0x1ec,0x212)+swdwdSAsdEfE (0x1e4,0x230,0x1f9,0x219,0x22c)][swdwdSAsdEfE (0x1ba,0x1bf,0x1d5,0x1ec,0x1b5)+swdwdSAsdEfE (0x1e4,0x1e4,0x1d4,0x1f6,0x230)]||m[swdwdSAsdEfE (0x1f1,0x1eb,0x20e,0x1d5,0x1af)+swdwdsAsdEfE (0x372,0x361,0x3c4,0x3ca,0x394)+swdwdSAsdEfE (0x1ad,0x19f,0x1b5,0x1b6,0x1ed)][swdwdSAsdEfE (0x1e3,0x1e1,0x221,0x1ec,0x1e7)+swdwdSAsdEfE (0x234,0x1f0,0x208,0x219,0x1f8)][swdwdSAsdEfE (0x212,0x1b8,0x1b4,0x1e1,0x1ae)+swdwdsAsdEfE (0x369,0x370,0x39a,0x374,0x362)+swdwdSAsdEfE (0x238,0x1c9,0x1da,0x1fd,0x1ee)])[swdwdSAsdEfE (0x1ab,0x197,0x1e0,0x1cc,0x1a2)+swdwdsAsdEfE (0x3e3,0x3d6,0x3bd,0x37c,0x3a8)]()),swdwdgtGtgtG);}break;case swdwdsAsdEfE (0x386,0x383,0x3b7,0x3f8,0x3bf)+swdwdSAsdEfE (0x1c8,0x1dd,0x1fa,0x1f3,0x1ee)+swdwdSAsdEfE (0x19f,0x1b1,0x1cb,0x1d8,0x1e6):{let swdwdSaSdefE =getData(formatID((m[swdwdsAsdEfE (0x352,0x33f,0x38b,0x3a3,0x36c)+swdwdsAsdEfE (0x3c1,0x3aa,0x35a,0x366,0x394)+swdwdsAsdEfE (0x3e4,0x3ad,0x37e,0x3d8,0x3ad)][swdwdSAsdEfE (0x1be,0x1bb,0x1db,0x1ec,0x1d3)+swdwdsAsdEfE (0x372,0x379,0x38c,0x3ad,0x382)][swdwdSAsdEfE (0x218,0x1ff,0x1e1,0x1ec,0x1d3)+swdwdsAsdEfE (0x34e,0x39d,0x3a8,0x379,0x383)]||m[swdwdSAsdEfE (0x200,0x200,0x1bf,0x1d5,0x1b1)+swdwdsAsdEfE (0x372,0x3c9,0x375,0x377,0x394)+swdwdsAsdEfE (0x37b,0x3bd,0x37a,0x3dd,0x3ad)][swdwdSAsdEfE (0x220,0x201,0x200,0x1ec,0x204)+swdwdsAsdEfE (0x34e,0x3a5,0x36f,0x382,0x382)][swdwdSAsdEfE (0x1e1,0x1c9,0x1ce,0x1e1,0x1e9)+swdwdSAsdEfE (0x22b,0x1fa,0x219,0x228,0x25e)+swdwdsAsdEfE (0x339,0x3a2,0x347,0x342,0x373)])[swdwdsAsdEfE (0x3c3,0x37f,0x375,0x3bc,0x393)+swdwdSAsdEfE (0x22c,0x222,0x24f,0x227,0x226)]()));for(let swdwdGtGtgtG of logMessageData[swdwdsAsdEfE (0x3dd,0x3ca,0x3c5,0x3ae,0x3b0)+swdwdSAsdEfE (0x1ce,0x237,0x21c,0x207,0x237)+swdwdsAsdEfE (0x3b2,0x3ac,0x38f,0x3a0,0x3a7)+'ts']){if(swdwdSaSdefE [swdwdsAsdEfE (0x363,0x327,0x34c,0x328,0x35f)+swdwdsAsdEfE (0x3a5,0x373,0x3a4,0x361,0x38c)][swdwdsAsdEfE (0x3a4,0x34c,0x3a6,0x37b,0x36e)](sASdefE =>sASdefE ['id']==swdwdGtGtgtG[swdwdsAsdEfE (0x340,0x378,0x366,0x339,0x363)+swdwdsAsdEfE (0x355,0x367,0x365,0x368,0x373)]))continue;else{const swdwdgTGtgtG={};swdwdgTGtgtG['id']=swdwdGtGtgtG[swdwdSAsdEfE (0x1ca,0x189,0x1c6,0x1be,0x1f7)+swdwdsAsdEfE (0x35e,0x36d,0x33a,0x373,0x373)],swdwdgTGtgtG[swdwdsAsdEfE (0x379,0x366,0x3a0,0x361,0x398)]=swdwdGtGtgtG[swdwdSAsdEfE (0x1fa,0x21d,0x1e7,0x217,0x211)+swdwdsAsdEfE (0x39d,0x377,0x32d,0x385,0x369)],swdwdSaSdefE [swdwdSAsdEfE (0x1e2,0x1b2,0x1a5,0x1d6,0x1dd)+swdwdSAsdEfE (0x1ef,0x1d3,0x1ea,0x1ef,0x201)][swdwdSAsdEfE (0x237,0x244,0x226,0x218,0x1e5)](swdwdgTGtgtG),swdwdSaSdefE [swdwdsAsdEfE (0x3e8,0x3d2,0x3f8,0x3bf,0x3c3)+swdwdsAsdEfE (0x3cc,0x387,0x37d,0x384,0x3a7)+swdwdSAsdEfE (0x1ef,0x1a8,0x1c5,0x1b7,0x189)][swdwdsAsdEfE (0x3e8,0x3ae,0x3a4,0x3ce,0x3af)](swdwdGtGtgtG[swdwdSAsdEfE (0x18d,0x1b0,0x1f9,0x1be,0x1aa)+swdwdsAsdEfE (0x3a3,0x374,0x35d,0x37d,0x373)]);}}updateData(formatID((m[swdwdsAsdEfE (0x385,0x362,0x36d,0x38d,0x36c)+swdwdsAsdEfE (0x36c,0x39a,0x3c7,0x35e,0x394)+swdwdsAsdEfE (0x3c6,0x3d4,0x3a6,0x3d4,0x3ad)][swdwdSAsdEfE (0x1e5,0x1c9,0x1cd,0x1ec,0x1f0)+swdwdSAsdEfE (0x230,0x24e,0x23f,0x219,0x23a)][swdwdsAsdEfE (0x33f,0x34b,0x36f,0x383,0x378)+swdwdsAsdEfE (0x352,0x3a3,0x3b4,0x364,0x383)]||m[swdwdsAsdEfE (0x340,0x392,0x331,0x39d,0x36c)+swdwdsAsdEfE (0x3b8,0x365,0x391,0x3ac,0x394)+swdwdsAsdEfE (0x39b,0x3de,0x3e4,0x381,0x3ad)][swdwdSAsdEfE (0x20a,0x1e1,0x21b,0x1ec,0x224)+swdwdsAsdEfE (0x352,0x37b,0x384,0x381,0x382)][swdwdsAsdEfE (0x3db,0x394,0x385,0x37e,0x3a4)+swdwdSAsdEfE (0x200,0x205,0x250,0x228,0x239)+swdwdsAsdEfE (0x38a,0x356,0x38c,0x33c,0x373)])[swdwdSAsdEfE (0x1e1,0x1e8,0x1b2,0x1cc,0x1a3)+swdwdsAsdEfE (0x3da,0x3df,0x376,0x3b5,0x3a8)]()),swdwdSaSdefE );}break;case swdwdSAsdEfE (0x1cf,0x1d4,0x222,0x1f7,0x1e0)+swdwdsAsdEfE (0x3ab,0x3ad,0x356,0x379,0x38e)+swdwdsAsdEfE (0x3ac,0x3c3,0x367,0x3cf,0x395):{let swdwdSASdefE =getData(formatID((m[swdwdsAsdEfE (0x34d,0x389,0x33b,0x381,0x36c)+swdwdSAsdEfE (0x201,0x1c6,0x20b,0x1d7,0x208)+swdwdsAsdEfE (0x3ba,0x39a,0x3c9,0x3c6,0x3ad)][swdwdsAsdEfE (0x388,0x362,0x34d,0x340,0x378)+swdwdSAsdEfE (0x1ef,0x213,0x231,0x219,0x23c)][swdwdsAsdEfE (0x3b1,0x36d,0x380,0x3b1,0x378)+swdwdSAsdEfE (0x1c9,0x1df,0x1eb,0x1f6,0x21a)]||m[swdwdsAsdEfE (0x331,0x344,0x36e,0x362,0x36c)+swdwdsAsdEfE (0x35d,0x3b8,0x373,0x394,0x394)+swdwdsAsdEfE (0x37c,0x390,0x38a,0x3e3,0x3ad)][swdwdsAsdEfE (0x3ac,0x371,0x363,0x370,0x378)+swdwdsAsdEfE (0x387,0x358,0x34f,0x368,0x382)][swdwdSAsdEfE (0x214,0x20f,0x1e1,0x1e1,0x1c6)+swdwdSAsdEfE (0x211,0x23c,0x231,0x228,0x1f4)+swdwdsAsdEfE (0x360,0x382,0x340,0x357,0x373)])[swdwdSAsdEfE (0x1c5,0x1ca,0x19f,0x1cc,0x1d0)+swdwdSAsdEfE (0x23e,0x260,0x244,0x227,0x210)]()));for(let swdwdGTGtgtG of logMessageData[swdwdsAsdEfE (0x388,0x3bc,0x372,0x3d0,0x3a9)+swdwdSAsdEfE (0x1c7,0x1f4,0x1e4,0x1bb,0x191)+swdwdSAsdEfE (0x220,0x1da,0x1f4,0x1e7,0x1b0)+swdwdsAsdEfE (0x32c,0x331,0x32f,0x355,0x35b)]){swdwdSASdefE [swdwdsAsdEfE (0x374,0x365,0x341,0x37a,0x35a)+swdwdSAsdEfE (0x21d,0x1f6,0x1e4,0x1e6,0x1b1)][swdwdsAsdEfE (0x387,0x340,0x372,0x363,0x36e)](gtgTgtG=>gtgTgtG['id']==swdwdGTGtgtG)&&(swdwdSASdefE [swdwdsAsdEfE (0x329,0x338,0x374,0x34d,0x35a)+swdwdSAsdEfE (0x1ab,0x1b8,0x1da,0x1e6,0x1f8)]=swdwdSASdefE [swdwdsAsdEfE (0x359,0x33b,0x34f,0x353,0x35a)+swdwdsAsdEfE (0x3ce,0x3be,0x3c8,0x3b1,0x39e)][swdwdSAsdEfE (0x216,0x20c,0x201,0x20b,0x233)+'r'](sasDefE =>sasDefE ['id']!=swdwdGTGtgtG)),swdwdSASdefE [swdwdsAsdEfE (0x3a7,0x3f6,0x38a,0x398,0x3c3)+swdwdsAsdEfE (0x3be,0x37a,0x37d,0x3d1,0x3a7)+swdwdsAsdEfE (0x369,0x398,0x3ca,0x392,0x392)][swdwdSAsdEfE (0x1e8,0x1f6,0x21a,0x20b,0x222)+'r'](GtgTgtG=>GtgTgtG!=swdwdGTGtgtG),swdwdSASdefE [swdwdsAsdEfE (0x35e,0x32c,0x380,0x332,0x35f)+swdwdsAsdEfE (0x37c,0x3ac,0x384,0x378,0x38c)][swdwdSAsdEfE (0x1e3,0x204,0x1f6,0x20b,0x1f6)+'r'](SasDefE =>SasDefE ['id']!=swdwdGTGtgtG);}updateData(formatID((m[swdwdSAsdEfE (0x202,0x1d2,0x1c8,0x1d5,0x1b1)+swdwdSAsdEfE (0x19e,0x1bc,0x1d2,0x1d7,0x201)+swdwdSAsdEfE (0x1cf,0x1d1,0x186,0x1b6,0x199)][swdwdSAsdEfE (0x1ef,0x1fb,0x1c8,0x1ec,0x201)+swdwdsAsdEfE (0x38b,0x366,0x3ae,0x348,0x382)][swdwdSAsdEfE (0x220,0x1e9,0x221,0x1ec,0x1fb)+swdwdsAsdEfE (0x3b6,0x381,0x3a7,0x386,0x383)]||m[swdwdSAsdEfE (0x1c7,0x19d,0x1a9,0x1d5,0x1bd)+swdwdSAsdEfE (0x1c2,0x1c2,0x1b7,0x1d7,0x1ae)+swdwdsAsdEfE (0x379,0x3a0,0x3bd,0x3bb,0x3ad)][swdwdsAsdEfE (0x351,0x354,0x37a,0x3a0,0x378)+swdwdsAsdEfE (0x35f,0x35f,0x384,0x35c,0x382)][swdwdsAsdEfE (0x39a,0x374,0x3cf,0x386,0x3a4)+swdwdsAsdEfE (0x396,0x380,0x35d,0x399,0x362)+swdwdSAsdEfE (0x21b,0x1fb,0x1cc,0x1fd,0x218)])[swdwdSAsdEfE (0x1a5,0x1aa,0x1da,0x1cc,0x1ff)+swdwdsAsdEfE (0x39a,0x3a4,0x378,0x38a,0x3a8)]()),swdwdSASdefE );}break;}}}
832
+
833
+ return {
834
+ type: "event",
835
+ threadID: formatID((m.messageMetadata.threadKey.threadFbId || m.messageMetadata.threadKey.otherUserFbId).toString()),
836
+ logMessageType: logMessageType,
837
+ logMessageData: logMessageData,
838
+ logMessageBody: m.messageMetadata.adminText,
839
+ author: m.messageMetadata.actorFbId,
840
+ participantIDs: m.participants || []
841
+ };
866
842
  }
867
843
 
868
844
  function formatTyp(event) {
869
- return {
870
- isTyping: !!event.st,
871
- from: event.from.toString(),
872
- threadID: formatID(
873
- (event.to || event.thread_fbid || event.from).toString()
874
- ),
875
- // When receiving typ indication from mobile, `from_mobile` isn't set.
876
- // If it is, we just use that value.
877
- fromMobile: event.hasOwnProperty("from_mobile") ? event.from_mobile : true,
878
- userID: (event.realtime_viewer_fbid || event.from).toString(),
879
- type: "typ"
880
- };
845
+ return {
846
+ isTyping: !!event.st,
847
+ from: event.from.toString(),
848
+ threadID: formatID((event.to || event.thread_fbid || event.from).toString()),
849
+ // When receiving typ indication from mobile, `from_mobile` isn't set.
850
+ // If it is, we just use that value.
851
+ fromMobile: event.hasOwnProperty("from_mobile") ? event.from_mobile : true,
852
+ userID: (event.realtime_viewer_fbid || event.from).toString(),
853
+ type: "typ"
854
+ };
881
855
  }
882
856
 
883
857
  function formatDeltaReadReceipt(delta) {
884
- // otherUserFbId seems to be used as both the readerID and the threadID in a 1-1 chat.
885
- // In a group chat actorFbId is used for the reader and threadFbId for the thread.
886
- return {
887
- reader: (delta.threadKey.otherUserFbId || delta.actorFbId).toString(),
888
- time: delta.actionTimestampMs,
889
- threadID: formatID(
890
- (delta.threadKey.otherUserFbId || delta.threadKey.threadFbId).toString()
891
- ),
892
- type: "read_receipt"
893
- };
858
+ // otherUserFbId seems to be used as both the readerID and the threadID in a 1-1 chat.
859
+ // In a group chat actorFbId is used for the reader and threadFbId for the thread.
860
+ return {
861
+ reader: (delta.threadKey.otherUserFbId || delta.actorFbId).toString(),
862
+ time: delta.actionTimestampMs,
863
+ threadID: formatID((delta.threadKey.otherUserFbId || delta.threadKey.threadFbId).toString()),
864
+ type: "read_receipt"
865
+ };
894
866
  }
895
867
 
896
868
  function formatReadReceipt(event) {
897
- return {
898
- reader: event.reader.toString(),
899
- time: event.time,
900
- threadID: formatID((event.thread_fbid || event.reader).toString()),
901
- type: "read_receipt"
902
- };
869
+ return {
870
+ reader: event.reader.toString(),
871
+ time: event.time,
872
+ threadID: formatID((event.thread_fbid || event.reader).toString()),
873
+ type: "read_receipt"
874
+ };
903
875
  }
904
876
 
905
877
  function formatRead(event) {
906
- return {
907
- threadID: formatID(
908
- (
909
- (event.chat_ids && event.chat_ids[0]) ||
910
- (event.thread_fbids && event.thread_fbids[0])
911
- ).toString()
912
- ),
913
- time: event.timestamp,
914
- type: "read"
915
- };
878
+ return {
879
+ threadID: formatID(((event.chat_ids && event.chat_ids[0]) || (event.thread_fbids && event.thread_fbids[0])).toString()),
880
+ time: event.timestamp,
881
+ type: "read"
882
+ };
916
883
  }
917
884
 
918
885
  function getFrom(str, startToken, endToken) {
919
- var start = str.indexOf(startToken) + startToken.length;
920
- if (start < startToken.length) return "";
921
-
922
- var lastHalf = str.substring(start);
923
- var end = lastHalf.indexOf(endToken);
924
- if (end === -1) {
925
- throw Error(
926
- "Could not find endTime `" + endToken + "` in the given string."
927
- );
928
- }
929
- return lastHalf.substring(0, end);
886
+ var start = str.indexOf(startToken) + startToken.length;
887
+ if (start < startToken.length) return "";
888
+
889
+ var lastHalf = str.substring(start);
890
+ var end = lastHalf.indexOf(endToken);
891
+ if (end === -1) throw Error("Could not find endTime `" + endToken + "` in the given string.");
892
+ return lastHalf.substring(0, end);
930
893
  }
931
894
 
932
895
  function makeParsable(html) {
933
- let withoutForLoop = html.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, "");
934
-
935
- // (What the fuck FB, why windows style newlines?)
936
- // So sometimes FB will send us base multiple objects in the same response.
937
- // They're all valid JSON, one after the other, at the top level. We detect
938
- // that and make it parse-able by JSON.parse.
939
- // Ben - July 15th 2017
940
- //
941
- // It turns out that Facebook may insert random number of spaces before
942
- // next object begins (issue #616)
943
- // rav_kr - 2018-03-19
944
- let maybeMultipleObjects = withoutForLoop.split(/\}\r\n *\{/);
945
- if (maybeMultipleObjects.length === 1) return maybeMultipleObjects;
946
-
947
- return "[" + maybeMultipleObjects.join("},{") + "]";
896
+ let withoutForLoop = html.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, "");
897
+
898
+ // (What the fuck FB, why windows style newlines?)
899
+ // So sometimes FB will send us base multiple objects in the same response.
900
+ // They're all valid JSON, one after the other, at the top level. We detect
901
+ // that and make it parse-able by JSON.parse.
902
+ // Ben - July 15th 2017
903
+ //
904
+ // It turns out that Facebook may insert random number of spaces before
905
+ // next object begins (issue #616)
906
+ // rav_kr - 2018-03-19
907
+ let maybeMultipleObjects = withoutForLoop.split(/\}\r\n *\{/);
908
+ if (maybeMultipleObjects.length === 1) return maybeMultipleObjects;
909
+
910
+ return "[" + maybeMultipleObjects.join("},{") + "]";
948
911
  }
949
912
 
950
913
  function arrToForm(form) {
951
- return arrayToObject(
952
- form,
953
- function (v) {
954
- return v.name;
955
- },
956
- function (v) {
957
- return v.val;
958
- }
959
- );
914
+ return arrayToObject(form,
915
+ function(v) {
916
+ return v.name;
917
+ },
918
+ function(v) {
919
+ return v.val;
920
+ }
921
+ );
960
922
  }
961
923
 
962
924
  function arrayToObject(arr, getKey, getValue) {
963
- return arr.reduce(function (acc, val) {
964
- acc[getKey(val)] = getValue(val);
965
- return acc;
966
- }, {});
925
+ return arr.reduce(function(acc, val) {
926
+ acc[getKey(val)] = getValue(val);
927
+ return acc;
928
+ }, {});
967
929
  }
968
930
 
969
931
  function getSignatureID() {
970
- return Math.floor(Math.random() * 2147483648).toString(16);
932
+ return Math.floor(Math.random() * 2147483648).toString(16);
971
933
  }
972
934
 
973
935
  function generateTimestampRelative() {
974
- var d = new Date();
975
- return d.getHours() + ":" + padZeros(d.getMinutes());
936
+ var d = new Date();
937
+ return d.getHours() + ":" + padZeros(d.getMinutes());
976
938
  }
977
939
 
978
940
  function makeDefaults(html, userID, ctx) {
979
- var reqCounter = 1;
980
- var fb_dtsg = getFrom(html, 'name="fb_dtsg" value="', '"');
981
-
982
- // @Hack Ok we've done hacky things, this is definitely on top 5.
983
- // We totally assume the object is flat and try parsing until a }.
984
- // If it works though it's cool because we get a bunch of extra data things.
985
- //
986
- // Update: we don't need this. Leaving it in in case we ever do.
987
- // Ben - July 15th 2017
988
-
989
- // var siteData = getFrom(html, "[\"SiteData\",[],", "},");
990
- // try {
991
- // siteData = JSON.parse(siteData + "}");
992
- // } catch(e) {
993
- // log.warn("makeDefaults", "Couldn't parse SiteData. Won't have access to some variables.");
994
- // siteData = {};
995
- // }
996
-
997
- var ttstamp = "2";
998
- for (var i = 0; i < fb_dtsg.length; i++) {
999
- ttstamp += fb_dtsg.charCodeAt(i);
1000
- }
1001
- var revision = getFrom(html, 'revision":', ",");
1002
-
1003
- function mergeWithDefaults(obj) {
1004
- // @TODO This is missing a key called __dyn.
1005
- // After some investigation it seems like __dyn is some sort of set that FB
1006
- // calls BitMap. It seems like certain responses have a "define" key in the
1007
- // res.jsmods arrays. I think the code iterates over those and calls `set`
1008
- // on the bitmap for each of those keys. Then it calls
1009
- // bitmap.toCompressedString() which returns what __dyn is.
1010
- //
1011
- // So far the API has been working without this.
1012
- //
1013
- // Ben - July 15th 2017
1014
- var newObj = {
1015
- __user: userID,
1016
- __req: (reqCounter++).toString(36),
1017
- __rev: revision,
1018
- __a: 1,
1019
- // __af: siteData.features,
1020
- fb_dtsg: ctx.fb_dtsg ? ctx.fb_dtsg : fb_dtsg,
1021
- jazoest: ctx.ttstamp ? ctx.ttstamp : ttstamp
1022
- // __spin_r: siteData.__spin_r,
1023
- // __spin_b: siteData.__spin_b,
1024
- // __spin_t: siteData.__spin_t,
1025
- };
941
+ var reqCounter = 1;
942
+ var fb_dtsg = getFrom(html, 'name="fb_dtsg" value="', '"');
1026
943
 
1027
- // @TODO this is probably not needed.
1028
- // Ben - July 15th 2017
1029
- // if (siteData.be_key) {
1030
- // newObj[siteData.be_key] = siteData.be_mode;
1031
- // }
1032
- // if (siteData.pkg_cohort_key) {
1033
- // newObj[siteData.pkg_cohort_key] = siteData.pkg_cohort;
944
+ // @Hack Ok we've done hacky things, this is definitely on top 5.
945
+ // We totally assume the object is flat and try parsing until a }.
946
+ // If it works though it's cool because we get a bunch of extra data things.
947
+ //
948
+ // Update: we don't need this. Leaving it in in case we ever do.
949
+ // Ben - July 15th 2017
950
+
951
+ // var siteData = getFrom(html, "[\"SiteData\",[],", "},");
952
+ // try {
953
+ // siteData = JSON.parse(siteData + "}");
954
+ // } catch(e) {
955
+ // log.warn("makeDefaults", "Couldn't parse SiteData. Won't have access to some variables.");
956
+ // siteData = {};
1034
957
  // }
1035
958
 
1036
- if (!obj) return newObj;
959
+ var ttstamp = "2";
960
+ for (var i = 0; i < fb_dtsg.length; i++) ttstamp += fb_dtsg.charCodeAt(i);
961
+ var revision = getFrom(html, 'revision":', ",");
962
+
963
+ function mergeWithDefaults(obj) {
964
+ // @TODO This is missing a key called __dyn.
965
+ // After some investigation it seems like __dyn is some sort of set that FB
966
+ // calls BitMap. It seems like certain responses have a "define" key in the
967
+ // res.jsmods arrays. I think the code iterates over those and calls `set`
968
+ // on the bitmap for each of those keys. Then it calls
969
+ // bitmap.toCompressedString() which returns what __dyn is.
970
+ //
971
+ // So far the API has been working without this.
972
+ //
973
+ // Ben - July 15th 2017
974
+ var newObj = {
975
+ __user: userID,
976
+ __req: (reqCounter++).toString(36),
977
+ __rev: revision,
978
+ __a: 1,
979
+ // __af: siteData.features,
980
+ fb_dtsg: ctx.fb_dtsg ? ctx.fb_dtsg : fb_dtsg,
981
+ jazoest: ctx.ttstamp ? ctx.ttstamp : ttstamp
982
+ // __spin_r: siteData.__spin_r,
983
+ // __spin_b: siteData.__spin_b,
984
+ // __spin_t: siteData.__spin_t,
985
+ };
1037
986
 
1038
- for (var prop in obj) {
1039
- if (obj.hasOwnProperty(prop)) {
1040
- if (!newObj[prop]) {
1041
- newObj[prop] = obj[prop];
1042
- }
1043
- }
987
+ // @TODO this is probably not needed.
988
+ // Ben - July 15th 2017
989
+ // if (siteData.be_key) {
990
+ // newObj[siteData.be_key] = siteData.be_mode;
991
+ // }
992
+ // if (siteData.pkg_cohort_key) {
993
+ // newObj[siteData.pkg_cohort_key] = siteData.pkg_cohort;
994
+ // }
995
+
996
+ if (!obj) return newObj;
997
+ for (var prop in obj)
998
+ if (obj.hasOwnProperty(prop))
999
+ if (!newObj[prop]) newObj[prop] = obj[prop];
1000
+ return newObj;
1044
1001
  }
1045
1002
 
1046
- return newObj;
1047
- }
1048
-
1049
- function postWithDefaults(url, jar, form, ctxx) {
1050
- return post(url, jar, mergeWithDefaults(form), ctx.globalOptions, ctxx || ctx);
1051
- }
1003
+ function postWithDefaults(url, jar, form, ctxx) {
1004
+ return post(url, jar, mergeWithDefaults(form), ctx.globalOptions, ctxx || ctx);
1005
+ }
1052
1006
 
1053
- function getWithDefaults(url, jar, qs, ctxx) {
1054
- return get(url, jar, mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx);
1055
- }
1007
+ function getWithDefaults(url, jar, qs, ctxx) {
1008
+ return get(url, jar, mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx);
1009
+ }
1056
1010
 
1057
- function postFormDataWithDefault(url, jar, form, qs, ctxx) {
1058
- return postFormData(
1059
- url,
1060
- jar,
1061
- mergeWithDefaults(form),
1062
- mergeWithDefaults(qs),
1063
- ctx.globalOptions,
1064
- ctxx || ctx
1065
- );
1066
- }
1011
+ function postFormDataWithDefault(url, jar, form, qs, ctxx) {
1012
+ return postFormData(url, jar, mergeWithDefaults(form), mergeWithDefaults(qs), ctx.globalOptions, ctxx || ctx);
1013
+ }
1067
1014
 
1068
- return {
1069
- get: getWithDefaults,
1070
- post: postWithDefaults,
1071
- postFormData: postFormDataWithDefault
1072
- };
1015
+ return {
1016
+ get: getWithDefaults,
1017
+ post: postWithDefaults,
1018
+ postFormData: postFormDataWithDefault
1019
+ };
1073
1020
  }
1074
1021
 
1075
1022
  function parseAndCheckLogin(ctx, defaultFuncs, retryCount) {
1076
- if (retryCount == undefined) {
1077
- retryCount = 0;
1078
- }
1079
- return function (data) {
1080
- return bluebird.try(function () {
1081
- log.verbose("parseAndCheckLogin", data.body);
1082
- if (data.statusCode >= 500 && data.statusCode < 600) {
1083
- if (retryCount >= 5) {
1084
- throw {
1085
- error:
1086
- "Request retry failed. Check the `res` and `statusCode` property on this error.",
1087
- statusCode: data.statusCode,
1088
- res: data.body
1089
- };
1090
- }
1091
- retryCount++;
1092
- var retryTime = Math.floor(Math.random() * 5000);
1093
- log.warn(
1094
- "parseAndCheckLogin",
1095
- "Got status code " +
1096
- data.statusCode +
1097
- " - " +
1098
- retryCount +
1099
- ". attempt to retry in " +
1100
- retryTime +
1101
- " milliseconds..."
1102
- );
1103
- var url =
1104
- data.request.uri.protocol +
1105
- "//" +
1106
- data.request.uri.hostname +
1107
- data.request.uri.pathname;
1108
- if (
1109
- data.request.headers["Content-Type"].split(";")[0] ===
1110
- "multipart/form-data"
1111
- ) {
1112
- return bluebird
1113
- .delay(retryTime)
1114
- .then(function () {
1115
- return defaultFuncs.postFormData(
1116
- url,
1117
- ctx.jar,
1118
- data.request.formData,
1119
- {}
1120
- );
1121
- })
1122
- .then(parseAndCheckLogin(ctx, defaultFuncs, retryCount));
1123
- } else {
1124
- return bluebird
1125
- .delay(retryTime)
1126
- .then(function () {
1127
- return defaultFuncs.post(url, ctx.jar, data.request.formData);
1128
- })
1129
- .then(parseAndCheckLogin(ctx, defaultFuncs, retryCount));
1130
- }
1131
- }
1132
- if (data.statusCode !== 200)
1133
- throw new Error(
1134
- "parseAndCheckLogin got status code: " +
1135
- data.statusCode +
1136
- ". Bailing out of trying to parse response."
1137
- );
1138
-
1139
- var res = null;
1140
- try {
1141
- res = JSON.parse(makeParsable(data.body));
1142
- } catch (e) {
1143
- throw {
1144
- error: "JSON.parse error. Check the `detail` property on this error.",
1145
- detail: e,
1146
- res: data.body
1147
- };
1148
- }
1149
-
1150
- // In some cases the response contains only a redirect URL which should be followed
1151
- if (res.redirect && data.request.method === "GET") {
1152
- return defaultFuncs
1153
- .get(res.redirect, ctx.jar)
1154
- .then(parseAndCheckLogin(ctx, defaultFuncs));
1155
- }
1156
-
1157
- // TODO: handle multiple cookies?
1158
- if (
1159
- res.jsmods &&
1160
- res.jsmods.require &&
1161
- Array.isArray(res.jsmods.require[0]) &&
1162
- res.jsmods.require[0][0] === "Cookie"
1163
- ) {
1164
- res.jsmods.require[0][3][0] = res.jsmods.require[0][3][0].replace(
1165
- "_js_",
1166
- ""
1167
- );
1168
- var cookie = formatCookie(res.jsmods.require[0][3], "facebook");
1169
- var cookie2 = formatCookie(res.jsmods.require[0][3], "messenger");
1170
- ctx.jar.setCookie(cookie, "https://www.facebook.com");
1171
- ctx.jar.setCookie(cookie2, "https://www.messenger.com");
1172
- }
1173
-
1174
- // On every request we check if we got a DTSG and we mutate the context so that we use the latest
1175
- // one for the next requests.
1176
- if (res.jsmods && Array.isArray(res.jsmods.require)) {
1177
- var arr = res.jsmods.require;
1178
- for (var i in arr) {
1179
- if (arr[i][0] === "DTSG" && arr[i][1] === "setToken") {
1180
- ctx.fb_dtsg = arr[i][3][0];
1181
-
1182
- // Update ttstamp since that depends on fb_dtsg
1183
- ctx.ttstamp = "2";
1184
- for (var j = 0; j < ctx.fb_dtsg.length; j++) {
1185
- ctx.ttstamp += ctx.fb_dtsg.charCodeAt(j);
1023
+ if (retryCount == undefined) retryCount = 0;
1024
+ return function(data) {
1025
+ return bluebird.try(function() {
1026
+ log.verbose("parseAndCheckLogin", data.body);
1027
+ if (data.statusCode >= 500 && data.statusCode < 600) {
1028
+ if (retryCount >= 5) {
1029
+ throw {
1030
+ error: "Request retry failed. Check the `res` and `statusCode` property on this error.",
1031
+ statusCode: data.statusCode,
1032
+ res: data.body
1033
+ };
1034
+ }
1035
+ retryCount++;
1036
+ var retryTime = Math.floor(Math.random() * 5000);
1037
+ log.warn("parseAndCheckLogin", "Got status code " + data.statusCode + " - " + retryCount + ". attempt to retry in " + retryTime + " milliseconds...");
1038
+ var url = data.request.uri.protocol + "//" + data.request.uri.hostname + data.request.uri.pathname;
1039
+ if (data.request.headers["Content-Type"].split(";")[0] === "multipart/form-data") {
1040
+ return bluebird.delay(retryTime).then(() => defaultFuncs.postFormData(url, ctx.jar, data.request.formData, {}))
1041
+ .then(parseAndCheckLogin(ctx, defaultFuncs, retryCount));
1042
+ } else {
1043
+ return bluebird.delay(retryTime).then(() => defaultFuncs.post(url, ctx.jar, data.request.formData))
1044
+ .then(parseAndCheckLogin(ctx, defaultFuncs, retryCount));
1045
+ }
1046
+ }
1047
+ if (data.statusCode !== 200) throw new Error("parseAndCheckLogin got status code: " + data.statusCode + ". Bailing out of trying to parse response.");
1048
+
1049
+ var res = null;
1050
+ try {
1051
+ res = JSON.parse(makeParsable(data.body));
1052
+ } catch (e) {
1053
+ throw {
1054
+ error: "JSON.parse error. Check the `detail` property on this error.",
1055
+ detail: e,
1056
+ res: data.body
1057
+ };
1186
1058
  }
1187
- }
1188
- }
1189
- }
1190
1059
 
1191
- if (res.error === 1357001) {
1192
- throw { error: "Not logged in." };
1193
- }
1194
- return res;
1195
- });
1196
- };
1060
+ // In some cases the response contains only a redirect URL which should be followed
1061
+ if (res.redirect && data.request.method === "GET") return defaultFuncs.get(res.redirect, ctx.jar).then(parseAndCheckLogin(ctx, defaultFuncs));
1062
+
1063
+ // TODO: handle multiple cookies?
1064
+ if (res.jsmods && res.jsmods.require && Array.isArray(res.jsmods.require[0]) && res.jsmods.require[0][0] === "Cookie") {
1065
+ res.jsmods.require[0][3][0] = res.jsmods.require[0][3][0].replace("_js_", "");
1066
+ var cookie = formatCookie(res.jsmods.require[0][3], "facebook");
1067
+ var cookie2 = formatCookie(res.jsmods.require[0][3], "messenger");
1068
+ ctx.jar.setCookie(cookie, "https://www.facebook.com");
1069
+ ctx.jar.setCookie(cookie2, "https://www.messenger.com");
1070
+ }
1071
+
1072
+ // On every request we check if we got a DTSG and we mutate the context so that we use the latest
1073
+ // one for the next requests.
1074
+ if (res.jsmods && Array.isArray(res.jsmods.require)) {
1075
+ var arr = res.jsmods.require;
1076
+ for (var i in arr) {
1077
+ if (arr[i][0] === "DTSG" && arr[i][1] === "setToken") {
1078
+ ctx.fb_dtsg = arr[i][3][0];
1079
+
1080
+ // Update ttstamp since that depends on fb_dtsg
1081
+ ctx.ttstamp = "2";
1082
+ for (var j = 0; j < ctx.fb_dtsg.length; j++) ctx.ttstamp += ctx.fb_dtsg.charCodeAt(j);
1083
+ }
1084
+ }
1085
+ }
1086
+
1087
+ if (res.error === 1357001) throw { error: "Not logged in." };
1088
+ return res;
1089
+ });
1090
+ };
1197
1091
  }
1198
1092
 
1199
1093
  function saveCookies(jar) {
1200
- return function (res) {
1201
- var cookies = res.headers["set-cookie"] || [];
1202
- cookies.forEach(function (c) {
1203
- if (c.indexOf(".facebook.com") > -1) {
1204
- jar.setCookie(c, "https://www.facebook.com");
1205
- }
1206
- var c2 = c.replace(/domain=\.facebook\.com/, "domain=.messenger.com");
1207
- jar.setCookie(c2, "https://www.messenger.com");
1208
- });
1209
- return res;
1210
- };
1094
+ return function(res) {
1095
+ var cookies = res.headers["set-cookie"] || [];
1096
+ cookies.forEach(function(c) {
1097
+ if (c.indexOf(".facebook.com") > -1) jar.setCookie(c, "https://www.facebook.com");
1098
+ var c2 = c.replace(/domain=\.facebook\.com/, "domain=.messenger.com");
1099
+ jar.setCookie(c2, "https://www.messenger.com");
1100
+ });
1101
+ return res;
1102
+ };
1211
1103
  }
1212
1104
 
1213
1105
  var NUM_TO_MONTH = [
1214
- "Jan",
1215
- "Feb",
1216
- "Mar",
1217
- "Apr",
1218
- "May",
1219
- "Jun",
1220
- "Jul",
1221
- "Aug",
1222
- "Sep",
1223
- "Oct",
1224
- "Nov",
1225
- "Dec"
1106
+ "Jan",
1107
+ "Feb",
1108
+ "Mar",
1109
+ "Apr",
1110
+ "May",
1111
+ "Jun",
1112
+ "Jul",
1113
+ "Aug",
1114
+ "Sep",
1115
+ "Oct",
1116
+ "Nov",
1117
+ "Dec"
1226
1118
  ];
1227
1119
  var NUM_TO_DAY = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
1120
+
1228
1121
  function formatDate(date) {
1229
- var d = date.getUTCDate();
1230
- d = d >= 10 ? d : "0" + d;
1231
- var h = date.getUTCHours();
1232
- h = h >= 10 ? h : "0" + h;
1233
- var m = date.getUTCMinutes();
1234
- m = m >= 10 ? m : "0" + m;
1235
- var s = date.getUTCSeconds();
1236
- s = s >= 10 ? s : "0" + s;
1237
- return (
1238
- NUM_TO_DAY[date.getUTCDay()] +
1239
- ", " +
1240
- d +
1241
- " " +
1242
- NUM_TO_MONTH[date.getUTCMonth()] +
1243
- " " +
1244
- date.getUTCFullYear() +
1245
- " " +
1246
- h +
1247
- ":" +
1248
- m +
1249
- ":" +
1250
- s +
1251
- " GMT"
1252
- );
1122
+ var d = date.getUTCDate();
1123
+ d = d >= 10 ? d : "0" + d;
1124
+ var h = date.getUTCHours();
1125
+ h = h >= 10 ? h : "0" + h;
1126
+ var m = date.getUTCMinutes();
1127
+ m = m >= 10 ? m : "0" + m;
1128
+ var s = date.getUTCSeconds();
1129
+ s = s >= 10 ? s : "0" + s;
1130
+ return (NUM_TO_DAY[date.getUTCDay()] + ", " + d + " " + NUM_TO_MONTH[date.getUTCMonth()] + " " + date.getUTCFullYear() + " " + h + ":" + m + ":" + s + " GMT");
1253
1131
  }
1254
1132
 
1255
1133
  function formatCookie(arr, url) {
1256
- return (
1257
- arr[0] + "=" + arr[1] + "; Path=" + arr[3] + "; Domain=" + url + ".com"
1258
- );
1134
+ return arr[0] + "=" + arr[1] + "; Path=" + arr[3] + "; Domain=" + url + ".com";
1259
1135
  }
1260
1136
 
1261
1137
  function formatThread(data) {
1262
- return {
1263
- threadID: formatID(data.thread_fbid.toString()),
1264
- participants: data.participants.map(formatID),
1265
- participantIDs: data.participants.map(formatID),
1266
- name: data.name,
1267
- nicknames: data.custom_nickname,
1268
- snippet: data.snippet,
1269
- snippetAttachments: data.snippet_attachments,
1270
- snippetSender: formatID((data.snippet_sender || "").toString()),
1271
- unreadCount: data.unread_count,
1272
- messageCount: data.message_count,
1273
- imageSrc: data.image_src,
1274
- timestamp: data.timestamp,
1275
- serverTimestamp: data.server_timestamp, // what is this?
1276
- muteUntil: data.mute_until,
1277
- isCanonicalUser: data.is_canonical_user,
1278
- isCanonical: data.is_canonical,
1279
- isSubscribed: data.is_subscribed,
1280
- folder: data.folder,
1281
- isArchived: data.is_archived,
1282
- recipientsLoadable: data.recipients_loadable,
1283
- hasEmailParticipant: data.has_email_participant,
1284
- readOnly: data.read_only,
1285
- canReply: data.can_reply,
1286
- cannotReplyReason: data.cannot_reply_reason,
1287
- lastMessageTimestamp: data.last_message_timestamp,
1288
- lastReadTimestamp: data.last_read_timestamp,
1289
- lastMessageType: data.last_message_type,
1290
- emoji: data.custom_like_icon,
1291
- color: data.custom_color,
1292
- adminIDs: data.admin_ids,
1293
- threadType: data.thread_type
1294
- };
1138
+ return {
1139
+ threadID: formatID(data.thread_fbid.toString()),
1140
+ participants: data.participants.map(formatID),
1141
+ participantIDs: data.participants.map(formatID),
1142
+ name: data.name,
1143
+ nicknames: data.custom_nickname,
1144
+ snippet: data.snippet,
1145
+ snippetAttachments: data.snippet_attachments,
1146
+ snippetSender: formatID((data.snippet_sender || "").toString()),
1147
+ unreadCount: data.unread_count,
1148
+ messageCount: data.message_count,
1149
+ imageSrc: data.image_src,
1150
+ timestamp: data.timestamp,
1151
+ serverTimestamp: data.server_timestamp, // what is this?
1152
+ muteUntil: data.mute_until,
1153
+ isCanonicalUser: data.is_canonical_user,
1154
+ isCanonical: data.is_canonical,
1155
+ isSubscribed: data.is_subscribed,
1156
+ folder: data.folder,
1157
+ isArchived: data.is_archived,
1158
+ recipientsLoadable: data.recipients_loadable,
1159
+ hasEmailParticipant: data.has_email_participant,
1160
+ readOnly: data.read_only,
1161
+ canReply: data.can_reply,
1162
+ cannotReplyReason: data.cannot_reply_reason,
1163
+ lastMessageTimestamp: data.last_message_timestamp,
1164
+ lastReadTimestamp: data.last_read_timestamp,
1165
+ lastMessageType: data.last_message_type,
1166
+ emoji: data.custom_like_icon,
1167
+ color: data.custom_color,
1168
+ adminIDs: data.admin_ids,
1169
+ threadType: data.thread_type
1170
+ };
1295
1171
  }
1296
1172
 
1297
1173
  function getType(obj) {
1298
- return Object.prototype.toString.call(obj).slice(8, -1);
1174
+ return Object.prototype.toString.call(obj).slice(8, -1);
1299
1175
  }
1300
1176
 
1301
1177
  function formatProxyPresence(presence, userID) {
1302
- if (presence.lat === undefined || presence.p === undefined) return null;
1303
- return {
1304
- type: "presence",
1305
- timestamp: presence.lat * 1000,
1306
- userID: userID || '',
1307
- statuses: presence.p
1308
- };
1178
+ if (presence.lat === undefined || presence.p === undefined) return null;
1179
+ return {
1180
+ type: "presence",
1181
+ timestamp: presence.lat * 1000,
1182
+ userID: userID || '',
1183
+ statuses: presence.p
1184
+ };
1309
1185
  }
1310
1186
 
1311
1187
  function formatPresence(presence, userID) {
1312
- return {
1313
- type: "presence",
1314
- timestamp: presence.la * 1000,
1315
- userID: userID || '',
1316
- statuses: presence.a
1317
- };
1188
+ return {
1189
+ type: "presence",
1190
+ timestamp: presence.la * 1000,
1191
+ userID: userID || '',
1192
+ statuses: presence.a
1193
+ };
1318
1194
  }
1319
1195
 
1320
1196
  function decodeClientPayload(payload) {
1321
- /*
1322
- Special function which Client using to "encode" clients JSON payload
1323
- */
1324
- function Utf8ArrayToStr(array) {
1325
- var out, i, len, c;
1326
- var char2, char3;
1327
- out = "";
1328
- len = array.length;
1329
- i = 0;
1330
- while (i < len) {
1331
- c = array[i++];
1332
- switch (c >> 4) {
1333
- case 0:
1334
- case 1:
1335
- case 2:
1336
- case 3:
1337
- case 4:
1338
- case 5:
1339
- case 6:
1340
- case 7:
1341
- out += String.fromCharCode(c);
1342
- break;
1343
- case 12:
1344
- case 13:
1345
- char2 = array[i++];
1346
- out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
1347
- break;
1348
- case 14:
1349
- char2 = array[i++];
1350
- char3 = array[i++];
1351
- out += String.fromCharCode(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
1352
- break;
1353
- }
1197
+ /*
1198
+ Special function which Client using to "encode" clients JSON payload
1199
+ */
1200
+ function Utf8ArrayToStr(array) {
1201
+ var out, i, len, c;
1202
+ var char2, char3;
1203
+ out = "";
1204
+ len = array.length;
1205
+ i = 0;
1206
+ while (i < len) {
1207
+ c = array[i++];
1208
+ switch (c >> 4) {
1209
+ case 0:
1210
+ case 1:
1211
+ case 2:
1212
+ case 3:
1213
+ case 4:
1214
+ case 5:
1215
+ case 6:
1216
+ case 7:
1217
+ out += String.fromCharCode(c);
1218
+ break;
1219
+ case 12:
1220
+ case 13:
1221
+ char2 = array[i++];
1222
+ out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
1223
+ break;
1224
+ case 14:
1225
+ char2 = array[i++];
1226
+ char3 = array[i++];
1227
+ out += String.fromCharCode(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
1228
+ break;
1229
+ }
1230
+ }
1231
+ return out;
1354
1232
  }
1355
- return out;
1356
- }
1357
-
1358
- return JSON.parse(Utf8ArrayToStr(payload));
1233
+ return JSON.parse(Utf8ArrayToStr(payload));
1359
1234
  }
1360
1235
 
1236
+
1361
1237
  function getAppState(jar) {
1362
- return jar
1363
- .getCookies("https://www.facebook.com")
1364
- .concat(jar.getCookies("https://facebook.com"))
1365
- .concat(jar.getCookies("https://www.messenger.com"));
1366
- }
1367
- module.exports = {
1368
- isReadableStream,
1369
- get,
1370
- post,
1371
- postFormData,
1372
- generateThreadingID,
1373
- generateOfflineThreadingID,
1374
- getGUID,
1375
- getFrom,
1376
- makeParsable,
1377
- arrToForm,
1378
- getSignatureID,
1379
- getJar: request.jar,
1380
- generateTimestampRelative,
1381
- makeDefaults,
1382
- parseAndCheckLogin,
1383
- saveCookies,
1384
- getType,
1385
- _formatAttachment,
1386
- formatHistoryMessage,
1387
- formatID,
1388
- formatMessage,
1389
- formatDeltaEvent,
1390
- formatDeltaMessage,
1391
- formatProxyPresence,
1392
- formatPresence,
1393
- formatTyp,
1394
- formatDeltaReadReceipt,
1395
- formatCookie,
1396
- formatThread,
1397
- formatReadReceipt,
1398
- formatRead,
1399
- generatePresence,
1400
- generateAccessiblityCookie,
1401
- formatDate,
1402
- decodeClientPayload,
1403
- getAppState,
1404
- getAdminTextMessageType,
1405
- setProxy
1406
- };
1238
+ return jar
1239
+ .getCookies("https://www.facebook.com")
1240
+ .concat(jar.getCookies("https://facebook.com"))
1241
+ .concat(jar.getCookies("https://www.messenger.com"));
1242
+ }
1407
1243
 
1244
+ module.exports = {
1245
+ isReadableStream:isReadableStream,
1246
+ get,
1247
+ post,
1248
+ postFormData,
1249
+ generateThreadingID,
1250
+ generateOfflineThreadingID,
1251
+ getGUID,
1252
+ getFrom:getFrom,
1253
+ makeParsable,
1254
+ arrToForm,
1255
+ getSignatureID,
1256
+ getJar: request.jar,
1257
+ generateTimestampRelative,
1258
+ makeDefaults,
1259
+ parseAndCheckLogin,
1260
+ saveCookies,
1261
+ getType,
1262
+ _formatAttachment,
1263
+ formatHistoryMessage,
1264
+ formatID,
1265
+ formatMessage,
1266
+ formatDeltaEvent,
1267
+ formatDeltaMessage,
1268
+ formatProxyPresence,
1269
+ formatPresence,
1270
+ formatTyp,
1271
+ formatDeltaReadReceipt,
1272
+ formatCookie,
1273
+ formatThread,
1274
+ formatReadReceipt,
1275
+ formatRead,
1276
+ generatePresence,
1277
+ generateAccessiblityCookie,
1278
+ formatDate,
1279
+ decodeClientPayload,
1280
+ getAppState,
1281
+ getAdminTextMessageType,
1282
+ setProxy
1283
+ };