alicezetion 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) 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 +654 -119
  14. package/logger.js +21 -0
  15. package/package.json +37 -25
  16. package/replit.nix +3 -4
  17. package/src/addExternalModule.js +13 -5
  18. package/src/addUserToGroup.js +36 -12
  19. package/src/changeAdminStatus.js +85 -37
  20. package/src/changeArchivedStatus.js +15 -9
  21. package/src/changeAvt.js +91 -0
  22. package/src/changeBio.js +13 -8
  23. package/src/changeBlockedStatus.js +14 -8
  24. package/src/changeGroupImage.js +28 -13
  25. package/src/changeNickname.js +22 -11
  26. package/src/changeThreadColor.js +16 -10
  27. package/src/changeThreadEmoji.js +18 -9
  28. package/src/chat.js +401 -280
  29. package/src/createNewGroup.js +18 -10
  30. package/src/createPoll.js +17 -11
  31. package/src/deleteMessage.js +17 -10
  32. package/src/deleteThread.js +17 -10
  33. package/src/forwardAttachment.js +15 -9
  34. package/src/getAccessToken.js +32 -0
  35. package/src/getCurrentUserID.js +1 -1
  36. package/src/getEmojiUrl.js +3 -2
  37. package/src/getFriendsList.js +18 -10
  38. package/src/getMessage.js +84 -0
  39. package/src/getThreadHistory.js +156 -59
  40. package/src/getThreadHistoryDeprecated.js +26 -15
  41. package/src/getThreadInfo.js +68 -42
  42. package/src/getThreadInfoDeprecated.js +25 -13
  43. package/src/getThreadList.js +112 -53
  44. package/src/getThreadListDeprecated.js +30 -12
  45. package/src/getThreadPictures.js +25 -13
  46. package/src/getUserID.js +9 -7
  47. package/src/getUserInfo.js +12 -10
  48. package/src/getUserInfoV2.js +35 -0
  49. package/src/handleFriendRequest.js +36 -35
  50. package/src/handleMessageRequest.js +18 -10
  51. package/src/httpGet.js +20 -13
  52. package/src/httpPost.js +19 -13
  53. package/src/httpPostFormData.js +46 -0
  54. package/src/listenMqtt.js +1224 -621
  55. package/src/logout.js +18 -13
  56. package/src/markAsDelivered.js +17 -10
  57. package/src/markAsRead.js +36 -24
  58. package/src/markAsSeen.js +22 -12
  59. package/src/muteThread.js +15 -9
  60. package/src/{setMessageReaction.js → react.js} +20 -9
  61. package/src/removeUserFromGroup.js +38 -11
  62. package/src/resolvePhotoUrl.js +9 -6
  63. package/src/searchForThread.js +14 -8
  64. package/src/{markAsReadAll.js → seen.js} +17 -10
  65. package/src/sendTypingIndicator.js +44 -19
  66. package/src/setPostReaction.js +63 -22
  67. package/src/setTitle.js +22 -12
  68. package/src/threadColors.js +17 -19
  69. package/src/unfriend.js +15 -9
  70. package/src/{unsendMessage.js → unsend.js} +9 -8
  71. package/utils.js +120 -27
  72. package/.travis.yml +0 -6
  73. package/src/forwardMessage.js +0 -0
  74. package/src/listen.js +0 -553
  75. package/src/listenMqtt-Test.js +0 -687
  76. package/src/sendMessage.js +0 -315
  77. package/test/data/shareAttach.js +0 -146
  78. package/test/data/something.mov +0 -0
  79. package/test/data/test.png +0 -0
  80. package/test/data/test.txt +0 -7
  81. package/test/example-config.json +0 -18
  82. package/test/test-page.js +0 -140
  83. package/test/test.js +0 -385
package/src/logout.js CHANGED
@@ -3,17 +3,17 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function logout(callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
 
15
15
  if (!callback) {
16
- callback = function (err, friendList) {
16
+ callback = function(err, friendList) {
17
17
  if (err) return rejectFunc(err);
18
18
 
19
19
  resolveFunc(friendList);
@@ -25,14 +25,18 @@ module.exports = function (defaultFuncs, api, ctx) {
25
25
  };
26
26
 
27
27
  defaultFuncs
28
- .post("https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1", ctx.jar, form)
28
+ .post(
29
+ "https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1",
30
+ ctx.jar,
31
+ form
32
+ )
29
33
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
- .then(function (resData) {
31
- var elem = resData.jsmods.instances[0][2][0].filter(function (v) {
34
+ .then(function(resData) {
35
+ var elem = resData.jsmods.instances[0][2][0].filter(function(v) {
32
36
  return v.value === "logout";
33
37
  })[0];
34
38
 
35
- var html = resData.jsmods.markup.filter(function (v) {
39
+ var html = resData.jsmods.markup.filter(function(v) {
36
40
  return v[0] === elem.markup.__m;
37
41
  })[0][1].__html;
38
42
 
@@ -46,19 +50,20 @@ module.exports = function (defaultFuncs, api, ctx) {
46
50
  .post("https://www.facebook.com/logout.php", ctx.jar, form)
47
51
  .then(utils.saveCookies(ctx.jar));
48
52
  })
49
- .then(function (res) {
50
- if (!res.headers) throw { error: "An error occurred when logging out." };
53
+ .then(function(res) {
54
+ if (!res.headers)
55
+ throw { error: "An error occurred when logging out." };
51
56
 
52
57
  return defaultFuncs
53
58
  .get(res.headers.location, ctx.jar)
54
59
  .then(utils.saveCookies(ctx.jar));
55
60
  })
56
- .then(function () {
61
+ .then(function() {
57
62
  ctx.loggedIn = false;
58
63
  log.info("logout", "Logged out successfully.");
59
64
  callback();
60
65
  })
61
- .catch(function (err) {
66
+ .catch(function(err) {
62
67
  log.error("logout", err);
63
68
  return callback(err);
64
69
  });
@@ -3,41 +3,48 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function markAsDelivered(threadID, messageID, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
 
15
15
  if (!callback) {
16
- callback = function (err, data) {
16
+ callback = function(err, data) {
17
17
  if (err) return rejectFunc(err);
18
18
 
19
19
  resolveFunc(data);
20
20
  };
21
21
  }
22
22
 
23
- if (!threadID || !messageID) return callback("Error: messageID or threadID is not defined");
23
+ if (!threadID || !messageID)
24
+ return callback("Error: messageID or threadID is not defined");
24
25
 
25
26
  var form = {};
27
+
26
28
  form["message_ids[0]"] = messageID;
27
29
  form["thread_ids[" + threadID + "][0]"] = messageID;
28
30
 
29
31
  defaultFuncs
30
- .post("https://www.facebook.com/ajax/mercury/delivery_receipts.php", ctx.jar, form)
32
+ .post(
33
+ "https://www.facebook.com/ajax/mercury/delivery_receipts.php",
34
+ ctx.jar,
35
+ form
36
+ )
31
37
  .then(utils.saveCookies(ctx.jar))
32
38
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
- .then(function (resData) {
39
+ .then(function(resData) {
34
40
  if (resData.error) throw resData;
35
41
 
36
42
  return callback();
37
43
  })
38
- .catch(function (err) {
44
+ .catch(function(err) {
39
45
  log.error("markAsDelivered", err);
40
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
46
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.")
47
+ ctx.loggedIn = false;
41
48
 
42
49
  return callback(err);
43
50
  });
package/src/markAsRead.js CHANGED
@@ -3,19 +3,22 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return async function markAsRead(threadID, read, callback) {
8
- if (utils.getType(read) === 'Function' || utils.getType(read) === 'AsyncFunction') {
8
+ if (
9
+ utils.getType(read) === "Function" ||
10
+ utils.getType(read) === "AsyncFunction"
11
+ ) {
9
12
  callback = read;
10
13
  read = true;
11
14
  }
12
15
  if (read == undefined) read = true;
13
16
 
14
- if (!callback) callback = () => { };
17
+ if (!callback) callback = () => {};
15
18
 
16
19
  var form = {};
17
20
 
18
- if (typeof ctx.globalOptions.pageID !== 'undefined') {
21
+ if (typeof ctx.globalOptions.pageID !== "undefined") {
19
22
  form["source"] = "PagesManagerMessagesInterface";
20
23
  form["request_user_id"] = ctx.globalOptions.pageID;
21
24
  form["ids[" + threadID + "]"] = read;
@@ -26,14 +29,15 @@ module.exports = function (defaultFuncs, api, ctx) {
26
29
 
27
30
  let resData;
28
31
  try {
29
- resData = await (
30
- defaultFuncs
31
- .post("https://www.facebook.com/ajax/mercury/change_read_status.php", ctx.jar, form)
32
- .then(utils.saveCookies(ctx.jar))
33
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
- );
35
- }
36
- catch (e) {
32
+ resData = await defaultFuncs
33
+ .post(
34
+ "https://www.facebook.com/ajax/mercury/change_read_status.php",
35
+ ctx.jar,
36
+ form
37
+ )
38
+ .then(utils.saveCookies(ctx.jar))
39
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
40
+ } catch (e) {
37
41
  callback(e);
38
42
  return e;
39
43
  }
@@ -41,27 +45,35 @@ module.exports = function (defaultFuncs, api, ctx) {
41
45
  if (resData.error) {
42
46
  let err = resData.error;
43
47
  log.error("markAsRead", err);
44
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
48
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.")
49
+ ctx.loggedIn = false;
45
50
  callback(err);
46
51
  return err;
47
52
  }
48
53
 
49
54
  callback();
50
55
  return null;
51
- }
52
- else {
56
+ } else {
53
57
  try {
54
58
  if (ctx.mqttClient) {
55
- let err = await new Promise(r => ctx.mqttClient.publish("/mark_thread", JSON.stringify({
56
- threadID,
57
- mark: "read",
58
- state: read
59
- }), { qos: 1, retain: false }, r));
59
+ let err = await new Promise(r =>
60
+ ctx.mqttClient.publish(
61
+ "/mark_thread",
62
+ JSON.stringify({
63
+ threadID,
64
+ mark: "read",
65
+ state: read
66
+ }),
67
+ { qos: 1, retain: false },
68
+ r
69
+ )
70
+ );
60
71
  if (err) throw err;
61
- }
62
- else throw { error: "You can only use this function after you start listening." };
63
- }
64
- catch (e) {
72
+ } else
73
+ throw {
74
+ error: "You can only use this function after you start listening."
75
+ };
76
+ } catch (e) {
65
77
  callback(e);
66
78
  return e;
67
79
  }
package/src/markAsSeen.js CHANGED
@@ -3,23 +3,25 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function markAsRead(seen_timestamp, callback) {
8
- if (utils.getType(seen_timestamp) == "Function" ||
9
- utils.getType(seen_timestamp) == "AsyncFunction") {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
+ return function markAsSeen(seen_timestamp, callback) {
8
+ if (
9
+ utils.getType(seen_timestamp) == "Function" ||
10
+ utils.getType(seen_timestamp) == "AsyncFunction"
11
+ ) {
10
12
  callback = seen_timestamp;
11
13
  seen_timestamp = Date.now();
12
14
  }
13
15
 
14
- var resolveFunc = function () { };
15
- var rejectFunc = function () { };
16
- var returnPromise = new Promise(function (resolve, reject) {
16
+ var resolveFunc = function() {};
17
+ var rejectFunc = function() {};
18
+ var returnPromise = new Promise(function(resolve, reject) {
17
19
  resolveFunc = resolve;
18
20
  rejectFunc = reject;
19
21
  });
20
22
 
21
23
  if (!callback) {
22
- callback = function (err, data) {
24
+ callback = function(err, data) {
23
25
  if (err) return rejectFunc(err);
24
26
 
25
27
  resolveFunc(data);
@@ -31,18 +33,26 @@ module.exports = function (defaultFuncs, api, ctx) {
31
33
  };
32
34
 
33
35
  defaultFuncs
34
- .post("https://www.facebook.com/ajax/mercury/mark_seen.php", ctx.jar, form)
36
+ .post(
37
+ "https://www.facebook.com/ajax/mercury/mark_seen.php",
38
+ ctx.jar,
39
+ form
40
+ )
35
41
  .then(utils.saveCookies(ctx.jar))
36
42
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
37
- .then(function (resData) {
43
+ .then(function(resData) {
38
44
  if (resData.error) throw resData;
45
+
39
46
  return callback();
40
47
  })
41
- .catch(function (err) {
48
+ .catch(function(err) {
42
49
  log.error("markAsSeen", err);
43
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
50
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.")
51
+ ctx.loggedIn = false;
52
+
44
53
  return callback(err);
45
54
  });
55
+
46
56
  return returnPromise;
47
57
  };
48
58
  };
package/src/muteThread.js CHANGED
@@ -3,18 +3,18 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  // muteSecond: -1=permanent mute, 0=unmute, 60=one minute, 3600=one hour, etc.
8
8
  return function muteThread(threadID, muteSeconds, callback) {
9
- var resolveFunc = function () { };
10
- var rejectFunc = function () { };
11
- var returnPromise = new Promise(function (resolve, reject) {
9
+ var resolveFunc = function() {};
10
+ var rejectFunc = function() {};
11
+ var returnPromise = new Promise(function(resolve, reject) {
12
12
  resolveFunc = resolve;
13
13
  rejectFunc = reject;
14
14
  });
15
15
 
16
16
  if (!callback) {
17
- callback = function (err, data) {
17
+ callback = function(err, data) {
18
18
  if (err) return rejectFunc(err);
19
19
 
20
20
  resolveFunc(data);
@@ -27,15 +27,21 @@ module.exports = function (defaultFuncs, api, ctx) {
27
27
  };
28
28
 
29
29
  defaultFuncs
30
- .post("https://www.facebook.com/ajax/mercury/change_mute_thread.php", ctx.jar, form)
30
+ .post(
31
+ "https://www.facebook.com/ajax/mercury/change_mute_thread.php",
32
+ ctx.jar,
33
+ form
34
+ )
31
35
  .then(utils.saveCookies(ctx.jar))
32
36
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
- .then(function (resData) {
34
- if (resData.error) throw resData;
37
+ .then(function(resData) {
38
+ if (resData.error) {
39
+ throw resData;
40
+ }
35
41
 
36
42
  return callback();
37
43
  })
38
- .catch(function (err) {
44
+ .catch(function(err) {
39
45
  log.error("muteThread", err);
40
46
  return callback(err);
41
47
  });
@@ -3,17 +3,22 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function setMessageReaction(reaction, messageID, callback, forceCustomReaction) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
+ return function setMessageReaction(
8
+ reaction,
9
+ messageID,
10
+ callback,
11
+ forceCustomReaction
12
+ ) {
13
+ var resolveFunc = function() {};
14
+ var rejectFunc = function() {};
15
+ var returnPromise = new Promise(function(resolve, reject) {
11
16
  resolveFunc = resolve;
12
17
  rejectFunc = reject;
13
18
  });
14
19
 
15
20
  if (!callback) {
16
- callback = function (err, data) {
21
+ callback = function(err, data) {
17
22
  if (err) return rejectFunc(err);
18
23
  resolveFunc(data);
19
24
  };
@@ -87,17 +92,23 @@ module.exports = function (defaultFuncs, api, ctx) {
87
92
  };
88
93
 
89
94
  defaultFuncs
90
- .postFormData("https://www.facebook.com/webgraphql/mutation/", ctx.jar, {}, qs)
95
+ .postFormData(
96
+ "https://www.facebook.com/webgraphql/mutation/",
97
+ ctx.jar,
98
+ {},
99
+ qs
100
+ )
91
101
  .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
92
- .then(function (resData) {
102
+ .then(function(resData) {
93
103
  if (!resData) throw { error: "setReaction returned empty object." };
94
104
  if (resData.error) throw resData;
95
105
  callback(null);
96
106
  })
97
- .catch(function (err) {
107
+ .catch(function(err) {
98
108
  log.error("setReaction", err);
99
109
  return callback(err);
100
110
  });
111
+
101
112
  return returnPromise;
102
113
  };
103
114
  };
@@ -3,22 +3,46 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function removeUserFromGroup(userID, threadID, callback) {
8
- if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
9
- if (utils.getType(threadID) !== "Number" && utils.getType(threadID) !== "String") throw { error: "threadID should be of type Number or String and not " + utils.getType(threadID) + "." };
10
- if (utils.getType(userID) !== "Number" && utils.getType(userID) !== "String") throw { error: "userID should be of type Number or String and not " + utils.getType(userID) + "." };
8
+ if (
9
+ !callback &&
10
+ (utils.getType(threadID) === "Function" ||
11
+ utils.getType(threadID) === "AsyncFunction")
12
+ )
13
+ throw { error: "please pass a threadID as a second argument." };
14
+ if (
15
+ utils.getType(threadID) !== "Number" &&
16
+ utils.getType(threadID) !== "String"
17
+ )
18
+ throw {
19
+ error:
20
+ "threadID should be of type Number or String and not " +
21
+ utils.getType(threadID) +
22
+ "."
23
+ };
24
+ if (
25
+ utils.getType(userID) !== "Number" &&
26
+ utils.getType(userID) !== "String"
27
+ )
28
+ throw {
29
+ error:
30
+ "userID should be of type Number or String and not " +
31
+ utils.getType(userID) +
32
+ "."
33
+ };
11
34
 
12
- var resolveFunc = function () { };
13
- var rejectFunc = function () { };
14
- var returnPromise = new Promise(function (resolve, reject) {
35
+ var resolveFunc = function() {};
36
+ var rejectFunc = function() {};
37
+ var returnPromise = new Promise(function(resolve, reject) {
15
38
  resolveFunc = resolve;
16
39
  rejectFunc = reject;
17
40
  });
18
41
 
19
42
  if (!callback) {
20
- callback = function (err, data) {
43
+ callback = function(err, data) {
21
44
  if (err) return rejectFunc(err);
45
+
22
46
  resolveFunc(data);
23
47
  };
24
48
  }
@@ -31,15 +55,18 @@ module.exports = function (defaultFuncs, api, ctx) {
31
55
  defaultFuncs
32
56
  .post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
33
57
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
- .then(function (resData) {
58
+ .then(function(resData) {
35
59
  if (!resData) throw { error: "Remove from group failed." };
60
+
36
61
  if (resData.error) throw resData;
62
+
37
63
  return callback();
38
64
  })
39
- .catch(function (err) {
40
- log.error("removeUserFromGroup", "» Bailing out of trying to parse response");
65
+ .catch(function(err) {
66
+ log.error("removeUserFromGroup", err);
41
67
  return callback(err);
42
68
  });
69
+
43
70
  return returnPromise;
44
71
  };
45
72
  };
@@ -3,24 +3,26 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function resolvePhotoUrl(photoID, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
 
15
15
  if (!callback) {
16
- callback = function (err, data) {
16
+ callback = function(err, data) {
17
17
  if (err) return rejectFunc(err);
18
18
  resolveFunc(data);
19
19
  };
20
20
  }
21
21
 
22
22
  defaultFuncs
23
- .get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, { photo_id: photoID })
23
+ .get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, {
24
+ photo_id: photoID
25
+ })
24
26
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
25
27
  .then(resData => {
26
28
  if (resData.error) throw resData;
@@ -31,6 +33,7 @@ module.exports = function (defaultFuncs, api, ctx) {
31
33
  log.error("resolvePhotoUrl", err);
32
34
  return callback(err);
33
35
  });
36
+
34
37
  return returnPromise;
35
38
  };
36
39
  };
@@ -2,17 +2,17 @@
2
2
 
3
3
  var utils = require("../utils");
4
4
 
5
- module.exports = function (defaultFuncs, api, ctx) {
5
+ module.exports = function(defaultFuncs, api, ctx) {
6
6
  return function searchForThread(name, callback) {
7
- var resolveFunc = function () { };
8
- var rejectFunc = function () { };
9
- var returnPromise = new Promise(function (resolve, reject) {
7
+ var resolveFunc = function() {};
8
+ var rejectFunc = function() {};
9
+ var returnPromise = new Promise(function(resolve, reject) {
10
10
  resolveFunc = resolve;
11
11
  rejectFunc = reject;
12
12
  });
13
13
 
14
14
  if (!callback) {
15
- callback = function (err, data) {
15
+ callback = function(err, data) {
16
16
  if (err) return rejectFunc(err);
17
17
  resolveFunc(data);
18
18
  };
@@ -27,16 +27,22 @@ module.exports = function (defaultFuncs, api, ctx) {
27
27
  };
28
28
 
29
29
  defaultFuncs
30
- .post("https://www.facebook.com/ajax/mercury/search_threads.php", ctx.jar, tmpForm)
30
+ .post(
31
+ "https://www.facebook.com/ajax/mercury/search_threads.php",
32
+ ctx.jar,
33
+ tmpForm
34
+ )
31
35
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
32
- .then(function (resData) {
36
+ .then(function(resData) {
33
37
  if (resData.error) throw resData;
34
- if (!resData.payload.mercury_payload.threads) return callback({ error: "Could not find thread `" + name + "`." });
38
+ if (!resData.payload.mercury_payload.threads)
39
+ return callback({ error: "Could not find thread `" + name + "`." });
35
40
  return callback(
36
41
  null,
37
42
  resData.payload.mercury_payload.threads.map(utils.formatThread)
38
43
  );
39
44
  });
45
+
40
46
  return returnPromise;
41
47
  };
42
48
  };
@@ -3,38 +3,45 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function markAsReadAll(callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
 
15
15
  if (!callback) {
16
- callback = function (err, data) {
16
+ callback = function(err, data) {
17
17
  if (err) return rejectFunc(err);
18
+
18
19
  resolveFunc(data);
19
20
  };
20
21
  }
21
22
 
22
23
  var form = {
23
- folder: 'inbox'
24
+ folder: "inbox"
24
25
  };
25
26
 
26
27
  defaultFuncs
27
- .post("https://www.facebook.com/ajax/mercury/mark_folder_as_read.php", ctx.jar, form)
28
+ .post(
29
+ "https://www.facebook.com/ajax/mercury/mark_folder_as_read.php",
30
+ ctx.jar,
31
+ form
32
+ )
28
33
  .then(utils.saveCookies(ctx.jar))
29
34
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
- .then(function (resData) {
35
+ .then(function(resData) {
31
36
  if (resData.error) throw resData;
37
+
32
38
  return callback();
33
39
  })
34
- .catch(function (err) {
40
+ .catch(function(err) {
35
41
  log.error("markAsReadAll", err);
36
42
  return callback(err);
37
43
  });
44
+
38
45
  return returnPromise;
39
46
  };
40
- };
47
+ };