alicezetion 1.2.6 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/nix/env.json +1 -1
  3. package/index.js +3 -6
  4. package/leiamnash/addExternalModule.js +10 -6
  5. package/leiamnash/addUserToGroup.js +52 -16
  6. package/leiamnash/changeAdminStatus.js +69 -37
  7. package/leiamnash/changeArchivedStatus.js +26 -12
  8. package/leiamnash/changeBio.js +19 -6
  9. package/leiamnash/changeBlockedStatus.js +14 -3
  10. package/leiamnash/changeGroupImage.js +40 -16
  11. package/leiamnash/changeNickname.js +27 -11
  12. package/leiamnash/changeThreadColor.js +20 -10
  13. package/leiamnash/changeThreadEmoji.js +24 -10
  14. package/leiamnash/chat.js +414 -279
  15. package/leiamnash/createNewGroup.js +28 -12
  16. package/leiamnash/createPoll.js +25 -13
  17. package/leiamnash/deleteMessage.js +24 -12
  18. package/leiamnash/deleteThread.js +25 -11
  19. package/leiamnash/forwardAttachment.js +26 -13
  20. package/leiamnash/getCurrentUserID.js +1 -1
  21. package/leiamnash/getEmojiUrl.js +4 -2
  22. package/leiamnash/getFriendsList.js +21 -10
  23. package/leiamnash/getThreadHistory.js +166 -58
  24. package/leiamnash/getThreadHistoryDeprecated.js +42 -20
  25. package/leiamnash/getThreadInfo.js +60 -25
  26. package/leiamnash/getThreadInfoDeprecated.js +42 -18
  27. package/leiamnash/getThreadList.js +66 -41
  28. package/leiamnash/getThreadListDeprecated.js +43 -14
  29. package/leiamnash/getThreadPictures.js +37 -17
  30. package/leiamnash/getUserID.js +14 -9
  31. package/leiamnash/getUserInfo.js +18 -12
  32. package/leiamnash/handleFriendRequest.js +52 -37
  33. package/leiamnash/handleMessageRequest.js +32 -14
  34. package/leiamnash/httpGet.js +17 -12
  35. package/leiamnash/httpPost.js +17 -12
  36. package/leiamnash/listenMqtt.js +2 -1
  37. package/leiamnash/logout.js +20 -13
  38. package/leiamnash/markAsDelivered.js +22 -11
  39. package/leiamnash/markAsRead.js +21 -11
  40. package/leiamnash/markAsReadAll.js +20 -10
  41. package/leiamnash/markAsSeen.js +18 -7
  42. package/leiamnash/muteThread.js +18 -11
  43. package/leiamnash/removeUserFromGroup.js +48 -14
  44. package/leiamnash/resolvePhotoUrl.js +17 -8
  45. package/leiamnash/searchForThread.js +21 -10
  46. package/leiamnash/sendTypingIndicator.js +47 -14
  47. package/leiamnash/setMessageReaction.js +26 -12
  48. package/leiamnash/setPostReaction.js +26 -13
  49. package/leiamnash/setTitle.js +29 -13
  50. package/leiamnash/threadColors.js +44 -28
  51. package/leiamnash/unfriend.js +19 -9
  52. package/leiamnash/unsendMessage.js +19 -9
  53. package/package.json +1 -1
  54. package/replit.nix +3 -1
  55. package/utils.js +0 -0
  56. package/leiamnash/forwardMessage.js +0 -0
  57. package/leiamnash/listen.js +0 -553
  58. package/leiamnash/listenMqtt-Test.js +0 -687
@@ -4,43 +4,58 @@ var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
6
  module.exports = function(defaultFuncs, api, ctx) {
7
- return function handleFriendRequest(userID, accept, callback) {
8
- if (utils.getType(accept) !== "Boolean") throw { error: "Please pass a boolean as a second argument." };
9
-
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, data) {
19
- if (err) return rejectFunc(err);
20
- resolveFunc(data);
21
- };
7
+ return function handleFriendRequest(userID, accept, callback) {
8
+ if (utils.getType(accept) !== "Boolean") {
9
+ throw {
10
+ error: "Please pass a boolean as a second argument."
11
+ };
12
+ }
13
+
14
+ var resolveFunc = function(){};
15
+ var rejectFunc = function(){};
16
+ var returnPromise = new Promise(function (resolve, reject) {
17
+ resolveFunc = resolve;
18
+ rejectFunc = reject;
19
+ });
20
+
21
+ if (!callback) {
22
+ callback = function (err, friendList) {
23
+ if (err) {
24
+ return rejectFunc(err);
22
25
  }
26
+ resolveFunc(friendList);
27
+ };
28
+ }
23
29
 
24
- var form = {
25
- viewer_id: userID,
26
- "frefs[0]": "jwl",
27
- floc: "friend_center_requests",
28
- ref: "/reqs.php",
29
- action: (accept ? "confirm" : "reject")
30
- };
31
-
32
- defaultFuncs
33
- .post("https://www.facebook.com/requests/friends/ajax/", ctx.jar, form)
34
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
35
- .then(function(resData) {
36
- if (resData.payload.err) throw { err: resData.payload.err };
37
- return callback();
38
- })
39
- .catch(function(err) {
40
- log.error("handleFriendRequest", err);
41
- return callback(err);
42
- });
43
-
44
- return returnPromise;
30
+ var form = {
31
+ viewer_id: ctx.userID,
32
+ "frefs[0]": "jwl",
33
+ floc: "friend_center_requests",
34
+ ref: "/reqs.php",
35
+ action: (accept ? "confirm" : "reject")
45
36
  };
46
- };
37
+
38
+ defaultFuncs
39
+ .post(
40
+ "https://www.facebook.com/requests/friends/ajax/",
41
+ ctx.jar,
42
+ form
43
+ )
44
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
45
+ .then(function(resData) {
46
+ if (resData.payload.err) {
47
+ throw {
48
+ err: resData.payload.err
49
+ };
50
+ }
51
+
52
+ return callback();
53
+ })
54
+ .catch(function(err) {
55
+ log.error("handleFriendRequest", err);
56
+ return callback(err);
57
+ });
58
+
59
+ return returnPromise;
60
+ };
61
+ };
@@ -3,21 +3,27 @@
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 handleMessageRequest(threadID, accept, callback) {
8
- if (utils.getType(accept) !== "Boolean") throw { error: "Please pass a boolean as a second argument." };
8
+ if (utils.getType(accept) !== "Boolean") {
9
+ throw {
10
+ error: "Please pass a boolean as a second argument."
11
+ };
12
+ }
9
13
 
10
- var resolveFunc = function () { };
11
- var rejectFunc = function () { };
14
+ var resolveFunc = function(){};
15
+ var rejectFunc = function(){};
12
16
  var returnPromise = new Promise(function (resolve, reject) {
13
17
  resolveFunc = resolve;
14
18
  rejectFunc = reject;
15
19
  });
16
20
 
17
21
  if (!callback) {
18
- callback = function (err, data) {
19
- if (err) return rejectFunc(err);
20
- resolveFunc(data);
22
+ callback = function (err, friendList) {
23
+ if (err) {
24
+ return rejectFunc(err);
25
+ }
26
+ resolveFunc(friendList);
21
27
  };
22
28
  }
23
29
 
@@ -25,23 +31,35 @@ module.exports = function (defaultFuncs, api, ctx) {
25
31
  client: "mercury"
26
32
  };
27
33
 
28
- if (utils.getType(threadID) !== "Array") threadID = [threadID];
34
+ if (utils.getType(threadID) !== "Array") {
35
+ threadID = [threadID];
36
+ }
29
37
 
30
38
  var messageBox = accept ? "inbox" : "other";
31
- for (var i = 0; i < threadID.length; i++) form[messageBox + "[" + i + "]"] = threadID[i];
39
+
40
+ for (var i = 0; i < threadID.length; i++) {
41
+ form[messageBox + "[" + i + "]"] = threadID[i];
42
+ }
32
43
 
33
44
  defaultFuncs
34
- .post("https://www.facebook.com/ajax/mercury/move_thread.php", ctx.jar, form)
45
+ .post(
46
+ "https://www.facebook.com/ajax/mercury/move_thread.php",
47
+ ctx.jar,
48
+ form
49
+ )
35
50
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
36
- .then(function (resData) {
37
- if (resData.error) throw resData;
51
+ .then(function(resData) {
52
+ if (resData.error) {
53
+ throw resData;
54
+ }
55
+
38
56
  return callback();
39
57
  })
40
- .catch(function (err) {
58
+ .catch(function(err) {
41
59
  log.error("handleMessageRequest", err);
42
60
  return callback(err);
43
61
  });
44
-
62
+
45
63
  return returnPromise;
46
64
  };
47
65
  };
@@ -3,10 +3,10 @@
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 httpGet(url, form, callback, notAPI) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
10
 
11
11
  var returnPromise = new Promise(function (resolve, reject) {
12
12
  resolveFunc = resolve;
@@ -17,31 +17,36 @@ module.exports = function (defaultFuncs, api, ctx) {
17
17
  callback = form;
18
18
  form = {};
19
19
  }
20
+
20
21
  form = form || {};
21
22
 
22
- callback = callback || function (err, data) {
23
- if (err) return rejectFunc(err);
24
- resolveFunc(data);
23
+ callback = callback || function(err, data) {
24
+ if (err) return rejectFunc(err);
25
+ resolveFunc(data);
25
26
  };
26
27
 
27
28
  if (notAPI) {
28
29
  utils
29
30
  .get(url, ctx.jar, form, ctx.globalOptions)
30
- .then(resData => callback(null, resData.body.toString()))
31
- .catch(function (err) {
31
+ .then(function(resData) {
32
+ callback(null, resData.body.toString());
33
+ })
34
+ .catch(function(err) {
32
35
  log.error("httpGet", err);
33
36
  return callback(err);
34
37
  });
35
- }
36
- else {
38
+ } else {
37
39
  defaultFuncs
38
40
  .get(url, ctx.jar, form)
39
- .then(resData => callback(null, resData.body.toString()))
40
- .catch(function (err) {
41
+ .then(function(resData) {
42
+ callback(null, resData.body.toString());
43
+ })
44
+ .catch(function(err) {
41
45
  log.error("httpGet", err);
42
46
  return callback(err);
43
47
  });
44
48
  }
49
+
45
50
  return returnPromise;
46
51
  };
47
52
  };
@@ -3,10 +3,10 @@
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 httpGet(url, form, callback, notAPI) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
10
 
11
11
  var returnPromise = new Promise(function (resolve, reject) {
12
12
  resolveFunc = resolve;
@@ -17,31 +17,36 @@ module.exports = function (defaultFuncs, api, ctx) {
17
17
  callback = form;
18
18
  form = {};
19
19
  }
20
+
20
21
  form = form || {};
21
22
 
22
- callback = callback || function (err, data) {
23
- if (err) return rejectFunc(err);
24
- resolveFunc(data);
23
+ callback = callback || function(err, data) {
24
+ if (err) return rejectFunc(err);
25
+ resolveFunc(data);
25
26
  };
26
27
 
27
28
  if (notAPI) {
28
29
  utils
29
30
  .post(url, ctx.jar, form, ctx.globalOptions)
30
- .then(resData => callback(null, resData.body.toString()))
31
- .catch(function (err) {
31
+ .then(function(resData) {
32
+ callback(null, resData.body.toString());
33
+ })
34
+ .catch(function(err) {
32
35
  log.error("httpPost", err);
33
36
  return callback(err);
34
37
  });
35
- }
36
- else {
38
+ } else {
37
39
  defaultFuncs
38
40
  .post(url, ctx.jar, form, {})
39
- .then(resData => callback(null, resData.body.toString()))
40
- .catch(function (err) {
41
+ .then(function(resData) {
42
+ callback(null, resData.body.toString());
43
+ })
44
+ .catch(function(err) {
41
45
  log.error("httpPost", err);
42
46
  return callback(err);
43
47
  });
44
48
  }
49
+
45
50
  return returnPromise;
46
51
  };
47
52
  };
@@ -8,6 +8,7 @@ A L I C E » this project recode by one
8
8
  */
9
9
 
10
10
  "use strict";
11
+
11
12
  var utils = require("../utils");
12
13
  var log = require("npmlog");
13
14
  var mqtt = require('mqtt');
@@ -682,4 +683,4 @@ module.exports = function(defaultFuncs, api, ctx) {
682
683
  ctx.firstListen = false;
683
684
  return msgEmitter;
684
685
  };
685
- };
686
+ };
@@ -3,10 +3,10 @@
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 () { };
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
10
  var returnPromise = new Promise(function (resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
@@ -14,8 +14,9 @@ module.exports = function (defaultFuncs, api, ctx) {
14
14
 
15
15
  if (!callback) {
16
16
  callback = function (err, friendList) {
17
- if (err) return rejectFunc(err);
18
-
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
19
20
  resolveFunc(friendList);
20
21
  };
21
22
  }
@@ -25,14 +26,18 @@ module.exports = function (defaultFuncs, api, ctx) {
25
26
  };
26
27
 
27
28
  defaultFuncs
28
- .post("https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1", ctx.jar, form)
29
+ .post(
30
+ "https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1",
31
+ ctx.jar,
32
+ form
33
+ )
29
34
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
- .then(function (resData) {
31
- var elem = resData.jsmods.instances[0][2][0].filter(function (v) {
35
+ .then(function(resData) {
36
+ var elem = resData.jsmods.instances[0][2][0].filter(function(v) {
32
37
  return v.value === "logout";
33
38
  })[0];
34
39
 
35
- var html = resData.jsmods.markup.filter(function (v) {
40
+ var html = resData.jsmods.markup.filter(function(v) {
36
41
  return v[0] === elem.markup.__m;
37
42
  })[0][1].__html;
38
43
 
@@ -46,19 +51,21 @@ module.exports = function (defaultFuncs, api, ctx) {
46
51
  .post("https://www.facebook.com/logout.php", ctx.jar, form)
47
52
  .then(utils.saveCookies(ctx.jar));
48
53
  })
49
- .then(function (res) {
50
- if (!res.headers) throw { error: "An error occurred when logging out." };
54
+ .then(function(res) {
55
+ if (!res.headers) {
56
+ throw { error: "An error occurred when logging out." };
57
+ }
51
58
 
52
59
  return defaultFuncs
53
60
  .get(res.headers.location, ctx.jar)
54
61
  .then(utils.saveCookies(ctx.jar));
55
62
  })
56
- .then(function () {
63
+ .then(function() {
57
64
  ctx.loggedIn = false;
58
65
  log.info("logout", "Logged out successfully.");
59
66
  callback();
60
67
  })
61
- .catch(function (err) {
68
+ .catch(function(err) {
62
69
  log.error("logout", err);
63
70
  return callback(err);
64
71
  });
@@ -5,40 +5,51 @@ var log = require("npmlog");
5
5
 
6
6
  module.exports = function (defaultFuncs, api, ctx) {
7
7
  return function markAsDelivered(threadID, messageID, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
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) {
17
- if (err) return rejectFunc(err);
18
-
19
- resolveFunc(data);
16
+ callback = function (err, friendList) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(friendList);
20
21
  };
21
22
  }
22
23
 
23
- if (!threadID || !messageID) return callback("Error: messageID or threadID is not defined");
24
+ if (!threadID || !messageID) {
25
+ return callback("Error: messageID or threadID is not defined");
26
+ }
24
27
 
25
28
  var form = {};
29
+
26
30
  form["message_ids[0]"] = messageID;
27
31
  form["thread_ids[" + threadID + "][0]"] = messageID;
28
32
 
29
33
  defaultFuncs
30
- .post("https://www.facebook.com/ajax/mercury/delivery_receipts.php", ctx.jar, form)
34
+ .post(
35
+ "https://www.facebook.com/ajax/mercury/delivery_receipts.php",
36
+ ctx.jar,
37
+ form
38
+ )
31
39
  .then(utils.saveCookies(ctx.jar))
32
40
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
41
  .then(function (resData) {
34
- if (resData.error) throw resData;
42
+ if (resData.error) {
43
+ throw resData;
44
+ }
35
45
 
36
46
  return callback();
37
47
  })
38
48
  .catch(function (err) {
39
49
  log.error("markAsDelivered", err);
40
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
41
-
50
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") {
51
+ ctx.loggedIn = false;
52
+ }
42
53
  return callback(err);
43
54
  });
44
55
 
@@ -9,9 +9,13 @@ module.exports = function (defaultFuncs, api, ctx) {
9
9
  callback = read;
10
10
  read = true;
11
11
  }
12
- if (read == undefined) read = true;
12
+ if (read == undefined) {
13
+ read = true;
14
+ }
13
15
 
14
- if (!callback) callback = () => { };
16
+ if (!callback) {
17
+ callback = () => { };
18
+ }
15
19
 
16
20
  var form = {};
17
21
 
@@ -28,12 +32,15 @@ module.exports = function (defaultFuncs, api, ctx) {
28
32
  try {
29
33
  resData = await (
30
34
  defaultFuncs
31
- .post("https://www.facebook.com/ajax/mercury/change_read_status.php", ctx.jar, form)
35
+ .post(
36
+ "https://www.facebook.com/ajax/mercury/change_read_status.php",
37
+ ctx.jar,
38
+ form
39
+ )
32
40
  .then(utils.saveCookies(ctx.jar))
33
41
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
42
  );
35
- }
36
- catch (e) {
43
+ } catch (e) {
37
44
  callback(e);
38
45
  return e;
39
46
  }
@@ -41,15 +48,16 @@ module.exports = function (defaultFuncs, api, ctx) {
41
48
  if (resData.error) {
42
49
  let err = resData.error;
43
50
  log.error("markAsRead", err);
44
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
51
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") {
52
+ ctx.loggedIn = false;
53
+ }
45
54
  callback(err);
46
55
  return err;
47
56
  }
48
57
 
49
58
  callback();
50
59
  return null;
51
- }
52
- else {
60
+ } else {
53
61
  try {
54
62
  if (ctx.mqttClient) {
55
63
  let err = await new Promise(r => ctx.mqttClient.publish("/mark_thread", JSON.stringify({
@@ -58,10 +66,12 @@ module.exports = function (defaultFuncs, api, ctx) {
58
66
  state: read
59
67
  }), { qos: 1, retain: false }, r));
60
68
  if (err) throw err;
69
+ } else {
70
+ throw {
71
+ error: "You can only use this function after you start listening."
72
+ };
61
73
  }
62
- else throw { error: "You can only use this function after you start listening." };
63
- }
64
- catch (e) {
74
+ } catch (e) {
65
75
  callback(e);
66
76
  return e;
67
77
  }
@@ -3,19 +3,21 @@
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 () { };
8
+ var resolveFunc = function(){};
9
+ var rejectFunc = function(){};
10
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) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc(data);
16
+ callback = function (err, friendList) {
17
+ if (err) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(friendList);
19
21
  };
20
22
  }
21
23
 
@@ -24,17 +26,25 @@ module.exports = function (defaultFuncs, api, ctx) {
24
26
  };
25
27
 
26
28
  defaultFuncs
27
- .post("https://www.facebook.com/ajax/mercury/mark_folder_as_read.php", ctx.jar, form)
29
+ .post(
30
+ "https://www.facebook.com/ajax/mercury/mark_folder_as_read.php",
31
+ ctx.jar,
32
+ form
33
+ )
28
34
  .then(utils.saveCookies(ctx.jar))
29
35
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
- .then(function (resData) {
31
- if (resData.error) throw resData;
36
+ .then(function(resData) {
37
+ if (resData.error) {
38
+ throw resData;
39
+ }
40
+
32
41
  return callback();
33
42
  })
34
- .catch(function (err) {
43
+ .catch(function(err) {
35
44
  log.error("markAsReadAll", err);
36
45
  return callback(err);
37
46
  });
47
+
38
48
  return returnPromise;
39
49
  };
40
50
  };
@@ -19,10 +19,11 @@ module.exports = function (defaultFuncs, api, ctx) {
19
19
  });
20
20
 
21
21
  if (!callback) {
22
- callback = function (err, data) {
23
- if (err) return rejectFunc(err);
24
-
25
- resolveFunc(data);
22
+ callback = function (err, friendList) {
23
+ if (err) {
24
+ return rejectFunc(err);
25
+ }
26
+ resolveFunc(friendList);
26
27
  };
27
28
  }
28
29
 
@@ -31,18 +32,28 @@ module.exports = function (defaultFuncs, api, ctx) {
31
32
  };
32
33
 
33
34
  defaultFuncs
34
- .post("https://www.facebook.com/ajax/mercury/mark_seen.php", ctx.jar, form)
35
+ .post(
36
+ "https://www.facebook.com/ajax/mercury/mark_seen.php",
37
+ ctx.jar,
38
+ form
39
+ )
35
40
  .then(utils.saveCookies(ctx.jar))
36
41
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
37
42
  .then(function (resData) {
38
- if (resData.error) throw resData;
43
+ if (resData.error) {
44
+ throw resData;
45
+ }
46
+
39
47
  return callback();
40
48
  })
41
49
  .catch(function (err) {
42
50
  log.error("markAsSeen", err);
43
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
51
+ if (utils.getType(err) == "Object" && err.error === "Not logged in.") {
52
+ ctx.loggedIn = false;
53
+ }
44
54
  return callback(err);
45
55
  });
56
+
46
57
  return returnPromise;
47
58
  };
48
59
  };
@@ -3,21 +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
  // 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 () { };
9
+ var resolveFunc = function(){};
10
+ var rejectFunc = function(){};
11
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) {
18
- if (err) return rejectFunc(err);
19
-
20
- resolveFunc(data);
17
+ callback = function (err, friendList) {
18
+ if (err) {
19
+ return rejectFunc(err);
20
+ }
21
+ resolveFunc(friendList);
21
22
  };
22
23
  }
23
24
 
@@ -27,15 +28,21 @@ module.exports = function (defaultFuncs, api, ctx) {
27
28
  };
28
29
 
29
30
  defaultFuncs
30
- .post("https://www.facebook.com/ajax/mercury/change_mute_thread.php", ctx.jar, form)
31
+ .post(
32
+ "https://www.facebook.com/ajax/mercury/change_mute_thread.php",
33
+ ctx.jar,
34
+ form
35
+ )
31
36
  .then(utils.saveCookies(ctx.jar))
32
37
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
- .then(function (resData) {
34
- if (resData.error) throw resData;
38
+ .then(function(resData) {
39
+ if (resData.error) {
40
+ throw resData;
41
+ }
35
42
 
36
43
  return callback();
37
44
  })
38
- .catch(function (err) {
45
+ .catch(function(err) {
39
46
  log.error("muteThread", err);
40
47
  return callback(err);
41
48
  });