node-ainzfb-new 1.7.9-uOw19mf → 1.7.10-13

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,32 +4,29 @@
4
4
  var utils = require("../utils");
5
5
  var log = require("npmlog");
6
6
 
7
+ module.exports = function(defaultFuncs, api, ctx) {
8
+ return function getUserInfoV2(id, callback) {
9
+ var resolveFunc = function() {};
10
+ var rejectFunc = function() {};
11
+ var returnPromise = new Promise(function(resolve, reject) {
12
+ resolveFunc = resolve;
13
+ rejectFunc = reject;
14
+ });
7
15
 
8
- module.exports = function (defaultFuncs, api, ctx) {
9
- return function getUserInfoV2(id, callback) {
10
- var resolveFunc = function () { };
11
- var rejectFunc = function () { };
12
- var returnPromise = new Promise(function (resolve, reject) {
13
- resolveFunc = resolve;
14
- rejectFunc = reject;
15
- });
16
-
17
- if (!callback) {
18
- callback = function (err, userInfo) {
19
- if (err) return rejectFunc(err);
20
- resolveFunc(userInfo);
21
- };
22
- }
16
+ if (!callback) {
17
+ callback = function(err, userInfo) {
18
+ if (err) return rejectFunc(err);
19
+ resolveFunc(userInfo);
20
+ };
21
+ }
23
22
  try {
24
- var { getInfo } = require('../Extra/ExtraAddons');
25
- getInfo(id)
26
- .then(data => {
23
+ var { getInfo } = require("../Extra/ExtraAddons");
24
+ getInfo(id).then(data => {
27
25
  return callback(null, data);
28
26
  });
29
- }
30
- catch (e) {
27
+ } catch (e) {
31
28
  return callback(null, e);
32
29
  }
33
30
  return returnPromise;
34
- };
35
- };
31
+ };
32
+ };
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ const { generateOfflineThreadingID, getCurrentTimestamp } = require("../utils");
4
+
5
+ function isCallable(func) {
6
+ try {
7
+ Reflect.apply(func, null, []);
8
+ return true;
9
+ } catch (error) {
10
+ return false;
11
+ }
12
+ }
13
+
14
+ module.exports = function(defaultFuncs, api, ctx) {
15
+ return function pinMessage(pinMode, messageID, threadID, callback) {
16
+ if (!ctx.mqttClient) {
17
+ throw new Error("Not connected to MQTT");
18
+ }
19
+
20
+ ctx.wsReqNumber += 1;
21
+ ctx.wsTaskNumber += 1;
22
+
23
+ const taskLabel = pinMode ? "430" : "431";
24
+ const queueNamePrefix = pinMode ? "pin_msg_v2_" : "unpin_msg_v2_";
25
+
26
+ const taskPayload = {
27
+ thread_key: threadID,
28
+ message_id: messageID,
29
+ timestamp_ms: getCurrentTimestamp()
30
+ };
31
+
32
+ const task = {
33
+ failure_count: null,
34
+ label: taskLabel,
35
+ payload: JSON.stringify(taskPayload),
36
+ queue_name: `${queueNamePrefix}${threadID}`,
37
+ task_id: ctx.wsTaskNumber
38
+ };
39
+
40
+ const content = {
41
+ app_id: "2220391788200892",
42
+ payload: JSON.stringify({
43
+ data_trace_id: null,
44
+ epoch_id: parseInt(generateOfflineThreadingID()),
45
+ tasks: [task],
46
+ version_id: "25095469420099952"
47
+ }),
48
+ request_id: ctx.wsReqNumber,
49
+ type: 3
50
+ };
51
+
52
+ if (isCallable(callback)) {
53
+ // to be implemented
54
+ }
55
+
56
+ ctx.mqttClient.publish("/ls_req", JSON.stringify(content), {
57
+ qos: 1,
58
+ retain: false
59
+ });
60
+ };
61
+ };
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
+ return async function shareContact(
8
+ text,
9
+ senderID,
10
+ threadID,
11
+ mentionID,
12
+ userID,
13
+ leaverID,
14
+ callback
15
+ ) {
16
+ var resolveFunc = function() {};
17
+ var rejectFunc = function() {};
18
+ var returnPromise = new Promise(function(resolve, reject) {
19
+ resolveFunc = resolve;
20
+ rejectFunc = reject;
21
+ });
22
+ if (!callback) {
23
+ callback = function(err, data) {
24
+ if (err) return rejectFunc(err);
25
+ resolveFunc(data);
26
+ };
27
+ }
28
+ let count_req = 0;
29
+ var form = JSON.stringify({
30
+ app_id: "2220391788200892",
31
+ payload: JSON.stringify({
32
+ tasks: [
33
+ {
34
+ label: "359",
35
+ payload: JSON.stringify({
36
+ contact_id: senderID,
37
+ sync_group: 1,
38
+ text: text || "",
39
+ thread_id: threadID
40
+ }),
41
+ queue_name: "messenger_contact_sharing",
42
+ task_id: (Math.random() * 1001) << 0,
43
+ failure_count: null
44
+ }
45
+ ],
46
+ epoch_id: utils.generateOfflineThreadingID(),
47
+ version_id: "7214102258676893"
48
+ }),
49
+ request_id: ++count_req,
50
+ type: 3
51
+ });
52
+ ctx.mqttClient.publish("/ls_req", form);
53
+
54
+ return returnPromise;
55
+ };
56
+ };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
+ return async function shareLink(text, url, threadID, callback) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+ if (!callback) {
15
+ callback = function(err, data) {
16
+ if (err) return rejectFunc(err);
17
+ resolveFunc(data);
18
+ };
19
+ }
20
+ ctx.mqttClient.publish(
21
+ "/ls_req",
22
+ JSON.stringify({
23
+ app_id: "2220391788200892",
24
+ payload: JSON.stringify({
25
+ tasks: [
26
+ {
27
+ label: 46,
28
+ payload: JSON.stringify({
29
+ otid: utils.generateOfflineThreadingID(),
30
+ source: 524289,
31
+ sync_group: 1,
32
+ send_type: 6,
33
+ mark_thread_read: 0,
34
+ url: url || "",
35
+ text: text || "",
36
+ thread_id: threadID,
37
+ initiating_source: 0
38
+ }),
39
+ queue_name: threadID,
40
+ task_id: (Math.random() * 1001) << 0,
41
+ failure_count: null
42
+ }
43
+ ],
44
+ epoch_id: utils.generateOfflineThreadingID(),
45
+ version_id: "7191105584331330"
46
+ }),
47
+ request_id: ++ctx.req_ID,
48
+ type: 3
49
+ }),
50
+ {
51
+ qos: 1,
52
+ retain: false
53
+ }
54
+ );
55
+ return returnPromise;
56
+ };
57
+ };
package/utils.js CHANGED
@@ -150,6 +150,12 @@ function generateThreadingID(clientID) {
150
150
  return "<" + k + ":" + l + "-" + m + "@mail.projektitan.com>";
151
151
  }
152
152
 
153
+ function getCurrentTimestamp() {
154
+ const date = new Date();
155
+ const unixTime = date.getTime();
156
+ return unixTime;
157
+ }
158
+
153
159
  function binaryToDecimal(data) {
154
160
  var ret = "";
155
161
  while (data !== "0") {
@@ -1321,7 +1327,7 @@ function decodeClientPayload(payload) {
1321
1327
 
1322
1328
 
1323
1329
 
1324
- /*function getAppState(jar) {
1330
+ function getAppState(jar) {
1325
1331
  try {
1326
1332
  var appstate = jar.getCookies("https://www.facebook.com").concat(jar.getCookies("https://facebook.com")).concat(jar.getCookies("https://www.messenger.com"));
1327
1333
 
@@ -1343,8 +1349,8 @@ function decodeClientPayload(payload) {
1343
1349
  logger('Error retrieving cookies:', error, '[ FCA-SUS ]');
1344
1350
  throw error;
1345
1351
  }
1346
- }*/
1347
- function getAppState(jar) {
1352
+ }
1353
+ /*function getAppState(jar) {
1348
1354
  const prettyMilliseconds = require('pretty-ms');
1349
1355
  var appstate = jar.getCookies("https://www.facebook.com").concat(jar.getCookies("https://facebook.com")).concat(jar.getCookies("https://www.messenger.com"));
1350
1356
  var StateCrypt = require('./StateCrypt');
@@ -1355,7 +1361,7 @@ function getAppState(jar) {
1355
1361
  return StateCrypt.encryptState(JSON.stringify(appstate),process.env['FBKEY']);
1356
1362
  }
1357
1363
  else return appstate;
1358
- }
1364
+ }*/
1359
1365
 
1360
1366
  module.exports = {
1361
1367
  isReadableStream:isReadableStream,
@@ -1395,5 +1401,6 @@ module.exports = {
1395
1401
  decodeClientPayload,
1396
1402
  getAppState,
1397
1403
  getAdminTextMessageType,
1398
- setProxy
1399
- };
1404
+ setProxy,
1405
+ getCurrentTimestamp
1406
+ };