alicezetion 1.8.2 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) 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 +210 -375
  4. package/package.json +6 -3
  5. package/replit.nix +4 -4
  6. package/src/addExternalModule.js +17 -0
  7. package/src/addUserToGroup.js +113 -0
  8. package/src/changeAdminStatus.js +79 -0
  9. package/src/changeArchivedStatus.js +55 -0
  10. package/src/changeAvatar.js +93 -0
  11. package/src/changeBio.js +77 -0
  12. package/src/changeBlockedStatus.js +47 -0
  13. package/src/changeCover.js +73 -0
  14. package/src/changeGroupImage.js +132 -0
  15. package/src/changeName.js +79 -0
  16. package/src/changeNickname.js +59 -0
  17. package/src/changeThreadColor.js +65 -0
  18. package/src/changeThreadEmoji.js +55 -0
  19. package/{leiamnash → src}/chat.js +28 -3
  20. package/src/createNewGroup.js +86 -0
  21. package/src/createPoll.js +71 -0
  22. package/src/data/getThreadInfo.json +1 -0
  23. package/src/deleteMessage.js +56 -0
  24. package/src/deleteThread.js +56 -0
  25. package/src/forwardAttachment.js +60 -0
  26. package/src/getAccess.js +112 -0
  27. package/src/getAvatarUser.js +78 -0
  28. package/src/getCurrentUserID.js +7 -0
  29. package/src/getEmojiUrl.js +29 -0
  30. package/src/getFriendsList.js +83 -0
  31. package/src/getThreadHistory.js +666 -0
  32. package/{leiamnash → src}/getThreadInfo.js +70 -54
  33. package/src/getThreadList.js +237 -0
  34. package/src/getThreadPictures.js +79 -0
  35. package/src/getUserID.js +66 -0
  36. package/src/getUserInfo.js +163 -0
  37. package/src/handleFriendRequest.js +61 -0
  38. package/src/handleMessageRequest.js +65 -0
  39. package/src/httpGet.js +57 -0
  40. package/src/httpPost.js +57 -0
  41. package/src/httpPostFormData.js +63 -0
  42. package/{leiamnash → src}/listenMqtt.js +16 -6
  43. package/src/listenNotification.js +88 -0
  44. package/src/logout.js +275 -0
  45. package/src/markAsDelivered.js +58 -0
  46. package/src/markAsRead.js +80 -0
  47. package/src/markAsReadAll.js +50 -0
  48. package/src/markAsSeen.js +59 -0
  49. package/src/muteThread.js +52 -0
  50. package/src/react.js +117 -0
  51. package/{leiamnash → src}/refreshFb_dtsg.js +1 -1
  52. package/src/removeUserFromGroup.js +79 -0
  53. package/src/resolvePhotoUrl.js +45 -0
  54. package/src/searchForThread.js +53 -0
  55. package/src/searchStickers.js +52 -0
  56. package/src/seen.js +50 -0
  57. package/src/sendMessage.js +477 -0
  58. package/src/sendMessageMqtt.js +316 -0
  59. package/src/sendTypingIndicator.js +103 -0
  60. package/src/setMessageReaction.js +117 -0
  61. package/src/setPostReaction.js +109 -0
  62. package/src/setTitle.js +86 -0
  63. package/src/threadColors.js +131 -0
  64. package/src/unfriend.js +52 -0
  65. package/src/unsendMessage.js +49 -0
  66. package/utils.js +135 -176
  67. package/.cache/replit/modules.stamp +0 -1
  68. package/leiamnash/addExternalModule.js +0 -15
  69. package/leiamnash/addUserToGroup.js +0 -77
  70. package/leiamnash/changeAdminStatus.js +0 -47
  71. package/leiamnash/changeArchivedStatus.js +0 -41
  72. package/leiamnash/changeAvatar.js +0 -127
  73. package/leiamnash/changeBio.js +0 -64
  74. package/leiamnash/changeBlockedStatus.js +0 -36
  75. package/leiamnash/changeGroupImage.js +0 -105
  76. package/leiamnash/changeNickname.js +0 -43
  77. package/leiamnash/changeThreadColor.js +0 -61
  78. package/leiamnash/changeThreadEmoji.js +0 -41
  79. package/leiamnash/createNewGroup.js +0 -70
  80. package/leiamnash/createPoll.js +0 -59
  81. package/leiamnash/deleteMessage.js +0 -44
  82. package/leiamnash/deleteThread.js +0 -42
  83. package/leiamnash/forwardAttachment.js +0 -47
  84. package/leiamnash/forwardMessage.js +0 -0
  85. package/leiamnash/getCurrentUserID.js +0 -7
  86. package/leiamnash/getEmojiUrl.js +0 -27
  87. package/leiamnash/getFriendsList.js +0 -73
  88. package/leiamnash/getInfoVideo.js +0 -134
  89. package/leiamnash/getThreadHistory.js +0 -537
  90. package/leiamnash/getThreadHistoryDeprecated.js +0 -71
  91. package/leiamnash/getThreadInfoDeprecated.js +0 -56
  92. package/leiamnash/getThreadList.js +0 -213
  93. package/leiamnash/getThreadListDeprecated.js +0 -46
  94. package/leiamnash/getThreadPictures.js +0 -59
  95. package/leiamnash/getUserID.js +0 -61
  96. package/leiamnash/getUserInfo.js +0 -66
  97. package/leiamnash/handleFriendRequest.js +0 -46
  98. package/leiamnash/handleMessageRequest.js +0 -47
  99. package/leiamnash/httpGet.js +0 -47
  100. package/leiamnash/httpPost.js +0 -47
  101. package/leiamnash/logout.js +0 -68
  102. package/leiamnash/markAsDelivered.js +0 -47
  103. package/leiamnash/markAsRead.js +0 -70
  104. package/leiamnash/markAsReadAll.js +0 -40
  105. package/leiamnash/markAsSeen.js +0 -48
  106. package/leiamnash/muteThread.js +0 -45
  107. package/leiamnash/react.js +0 -109
  108. package/leiamnash/removeUserFromGroup.js +0 -45
  109. package/leiamnash/resolvePhotoUrl.js +0 -36
  110. package/leiamnash/searchForThread.js +0 -42
  111. package/leiamnash/seen.js +0 -40
  112. package/leiamnash/sendMessage.js +0 -315
  113. package/leiamnash/sendTypingIndicator.js +0 -70
  114. package/leiamnash/setMessageReaction.js +0 -103
  115. package/leiamnash/setPostReaction.js +0 -63
  116. package/leiamnash/setTitle.js +0 -70
  117. package/leiamnash/threadColors.js +0 -41
  118. package/leiamnash/unfriend.js +0 -42
  119. package/leiamnash/unsendMessage.js +0 -39
  120. /package/{leiamnash → src}/getMessage.js +0 -0
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function logout(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
-
15
- if (!callback) {
16
- callback = function (err, friendList) {
17
- if (err) return rejectFunc(err);
18
-
19
- resolveFunc(friendList);
20
- };
21
- }
22
-
23
- var form = {
24
- pmid: "0"
25
- };
26
-
27
- defaultFuncs
28
- .post("https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1", ctx.jar, form)
29
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
- .then(function (resData) {
31
- var elem = resData.jsmods.instances[0][2][0].filter(function (v) {
32
- return v.value === "logout";
33
- })[0];
34
-
35
- var html = resData.jsmods.markup.filter(function (v) {
36
- return v[0] === elem.markup.__m;
37
- })[0][1].__html;
38
-
39
- var form = {
40
- fb_dtsg: utils.getFrom(html, '"fb_dtsg" value="', '"'),
41
- ref: utils.getFrom(html, '"ref" value="', '"'),
42
- h: utils.getFrom(html, '"h" value="', '"')
43
- };
44
-
45
- return defaultFuncs
46
- .post("https://www.facebook.com/logout.php", ctx.jar, form)
47
- .then(utils.saveCookies(ctx.jar));
48
- })
49
- .then(function (res) {
50
- if (!res.headers) throw { error: "An error occurred when logging out." };
51
-
52
- return defaultFuncs
53
- .get(res.headers.location, ctx.jar)
54
- .then(utils.saveCookies(ctx.jar));
55
- })
56
- .then(function () {
57
- ctx.loggedIn = false;
58
- log.info("logout", "Logged out successfully.");
59
- callback();
60
- })
61
- .catch(function (err) {
62
- log.error("logout", err);
63
- return callback(err);
64
- });
65
-
66
- return returnPromise;
67
- };
68
- };
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function markAsDelivered(threadID, messageID, 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
-
15
- if (!callback) {
16
- callback = function (err, data) {
17
- if (err) return rejectFunc(err);
18
-
19
- resolveFunc(data);
20
- };
21
- }
22
-
23
- if (!threadID || !messageID) return callback("Error: messageID or threadID is not defined");
24
-
25
- var form = {};
26
- form["message_ids[0]"] = messageID;
27
- form["thread_ids[" + threadID + "][0]"] = messageID;
28
-
29
- defaultFuncs
30
- .post("https://www.facebook.com/ajax/mercury/delivery_receipts.php", ctx.jar, form)
31
- .then(utils.saveCookies(ctx.jar))
32
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
- .then(function (resData) {
34
- if (resData.error) throw resData;
35
-
36
- return callback();
37
- })
38
- .catch(function (err) {
39
- log.error("markAsDelivered", err);
40
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
41
-
42
- return callback(err);
43
- });
44
-
45
- return returnPromise;
46
- };
47
- };
@@ -1,70 +0,0 @@
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 markAsRead(threadID, read, callback) {
8
- if (utils.getType(read) === 'Function' || utils.getType(read) === 'AsyncFunction') {
9
- callback = read;
10
- read = true;
11
- }
12
- if (read == undefined) read = true;
13
-
14
- if (!callback) callback = () => { };
15
-
16
- var form = {};
17
-
18
- if (typeof ctx.globalOptions.pageID !== 'undefined') {
19
- form["source"] = "PagesManagerMessagesInterface";
20
- form["request_user_id"] = ctx.globalOptions.pageID;
21
- form["ids[" + threadID + "]"] = read;
22
- form["watermarkTimestamp"] = new Date().getTime();
23
- form["shouldSendReadReceipt"] = true;
24
- form["commerce_last_message_type"] = "";
25
- //form["titanOriginatedThreadId"] = utils.generateThreadingID(ctx.clientID);
26
-
27
- let resData;
28
- 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) {
37
- callback(e);
38
- return e;
39
- }
40
-
41
- if (resData.error) {
42
- let err = resData.error;
43
- log.error("markAsRead", err);
44
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
45
- callback(err);
46
- return err;
47
- }
48
-
49
- callback();
50
- return null;
51
- }
52
- else {
53
- try {
54
- 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));
60
- if (err) throw err;
61
- }
62
- else throw { error: "You can only use this function after you start listening." };
63
- }
64
- catch (e) {
65
- callback(e);
66
- return e;
67
- }
68
- }
69
- };
70
- };
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function markAsReadAll(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
-
15
- if (!callback) {
16
- callback = function (err, data) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc(data);
19
- };
20
- }
21
-
22
- var form = {
23
- folder: 'inbox'
24
- };
25
-
26
- defaultFuncs
27
- .post("https://www.facebook.com/ajax/mercury/mark_folder_as_read.php", ctx.jar, form)
28
- .then(utils.saveCookies(ctx.jar))
29
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
- .then(function (resData) {
31
- if (resData.error) throw resData;
32
- return callback();
33
- })
34
- .catch(function (err) {
35
- log.error("markAsReadAll", err);
36
- return callback(err);
37
- });
38
- return returnPromise;
39
- };
40
- };
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
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") {
10
- callback = seen_timestamp;
11
- seen_timestamp = Date.now();
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, data) {
23
- if (err) return rejectFunc(err);
24
-
25
- resolveFunc(data);
26
- };
27
- }
28
-
29
- var form = {
30
- seen_timestamp: seen_timestamp
31
- };
32
-
33
- defaultFuncs
34
- .post("https://www.facebook.com/ajax/mercury/mark_seen.php", ctx.jar, form)
35
- .then(utils.saveCookies(ctx.jar))
36
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
37
- .then(function (resData) {
38
- if (resData.error) throw resData;
39
- return callback();
40
- })
41
- .catch(function (err) {
42
- log.error("markAsSeen", err);
43
- if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
44
- return callback(err);
45
- });
46
- return returnPromise;
47
- };
48
- };
@@ -1,45 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- // muteSecond: -1=permanent mute, 0=unmute, 60=one minute, 3600=one hour, etc.
8
- return function muteThread(threadID, muteSeconds, callback) {
9
- var resolveFunc = function () { };
10
- var rejectFunc = function () { };
11
- var returnPromise = new Promise(function (resolve, reject) {
12
- resolveFunc = resolve;
13
- rejectFunc = reject;
14
- });
15
-
16
- if (!callback) {
17
- callback = function (err, data) {
18
- if (err) return rejectFunc(err);
19
-
20
- resolveFunc(data);
21
- };
22
- }
23
-
24
- var form = {
25
- thread_fbid: threadID,
26
- mute_settings: muteSeconds
27
- };
28
-
29
- defaultFuncs
30
- .post("https://www.facebook.com/ajax/mercury/change_mute_thread.php", ctx.jar, form)
31
- .then(utils.saveCookies(ctx.jar))
32
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
- .then(function (resData) {
34
- if (resData.error) throw resData;
35
-
36
- return callback();
37
- })
38
- .catch(function (err) {
39
- log.error("muteThread", err);
40
- return callback(err);
41
- });
42
-
43
- return returnPromise;
44
- };
45
- };
@@ -1,109 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
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) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
14
-
15
- if (!callback) {
16
- callback = function (err, data) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc(data);
19
- };
20
- }
21
-
22
- switch (reaction) {
23
- case "\uD83D\uDE0D": //:heart_eyes:
24
- case "\uD83D\uDE06": //:laughing:
25
- case "\uD83D\uDE2E": //:open_mouth:
26
- case "\uD83D\uDE22": //:cry:
27
- case "\uD83D\uDE20": //:angry:
28
- case "\uD83D\uDC4D": //:thumbsup:
29
- case "\uD83D\uDC4E": //:thumbsdown:
30
- case "\u2764": //:heart:
31
- case "\uD83D\uDC97": //:glowingheart:
32
- case "":
33
- //valid
34
- break;
35
- case ":heart_eyes:":
36
- case ":love:":
37
- reaction = "\uD83D\uDE0D";
38
- break;
39
- case ":laughing:":
40
- case ":haha:":
41
- reaction = "\uD83D\uDE06";
42
- break;
43
- case ":open_mouth:":
44
- case ":wow:":
45
- reaction = "\uD83D\uDE2E";
46
- break;
47
- case ":cry:":
48
- case ":sad:":
49
- reaction = "\uD83D\uDE22";
50
- break;
51
- case ":angry:":
52
- reaction = "\uD83D\uDE20";
53
- break;
54
- case ":thumbsup:":
55
- case ":like:":
56
- reaction = "\uD83D\uDC4D";
57
- break;
58
- case ":thumbsdown:":
59
- case ":dislike:":
60
- reaction = "\uD83D\uDC4E";
61
- break;
62
- case ":heart:":
63
- reaction = "\u2764";
64
- break;
65
- case ":glowingheart:":
66
- reaction = "\uD83D\uDC97";
67
- break;
68
- default:
69
- if (forceCustomReaction) break;
70
- return callback({ error: "Reaction is not a valid emoji." });
71
- }
72
-
73
- var variables = {
74
- data: {
75
- client_mutation_id: ctx.clientMutationId++,
76
- actor_id: ctx.userID,
77
- action: reaction == "" ? "REMOVE_REACTION" : "ADD_REACTION",
78
- message_id: messageID,
79
- reaction: reaction
80
- }
81
- };
82
-
83
- var qs = {
84
- doc_id: "1491398900900362",
85
- variables: JSON.stringify(variables),
86
- dpr: 1
87
- };
88
-
89
- defaultFuncs
90
- .postFormData(
91
- "https://www.facebook.com/webgraphql/mutation/",
92
- ctx.jar,
93
- {},
94
- qs
95
- )
96
- .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
97
- .then(function (resData) {
98
- if (!resData) throw { error: "setReaction returned empty object." };
99
- if (resData.error) throw resData;
100
- callback(null);
101
- })
102
- .catch(function (err) {
103
- log.error("setReaction", err);
104
- return callback(err);
105
- });
106
-
107
- return returnPromise;
108
- };
109
- };
@@ -1,45 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
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) + "." };
11
-
12
- var resolveFunc = function () { };
13
- var rejectFunc = function () { };
14
- var returnPromise = new Promise(function (resolve, reject) {
15
- resolveFunc = resolve;
16
- rejectFunc = reject;
17
- });
18
-
19
- if (!callback) {
20
- callback = function (err, data) {
21
- if (err) return rejectFunc(err);
22
- resolveFunc(data);
23
- };
24
- }
25
-
26
- var form = {
27
- uid: userID,
28
- tid: threadID
29
- };
30
-
31
- defaultFuncs
32
- .post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
33
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
- .then(function (resData) {
35
- if (!resData) throw { error: "Remove from group failed." };
36
- if (resData.error) throw resData;
37
- return callback();
38
- })
39
- .catch(function (err) {
40
- log.error("removeUserFromGroup", "» Bailing out of trying to parse response");
41
- return callback(err);
42
- });
43
- return returnPromise;
44
- };
45
- };
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function resolvePhotoUrl(photoID, 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
-
15
- if (!callback) {
16
- callback = function (err, data) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc(data);
19
- };
20
- }
21
-
22
- defaultFuncs
23
- .get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, { photo_id: photoID })
24
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
25
- .then(resData => {
26
- if (resData.error) throw resData;
27
- var photoUrl = resData.jsmods.require[0][3][0];
28
- return callback(null, photoUrl);
29
- })
30
- .catch(err => {
31
- log.error("resolvePhotoUrl", err);
32
- return callback(err);
33
- });
34
- return returnPromise;
35
- };
36
- };
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
-
5
- module.exports = function (defaultFuncs, api, ctx) {
6
- return function searchForThread(name, callback) {
7
- var resolveFunc = function () { };
8
- var rejectFunc = function () { };
9
- var returnPromise = new Promise(function (resolve, reject) {
10
- resolveFunc = resolve;
11
- rejectFunc = reject;
12
- });
13
-
14
- if (!callback) {
15
- callback = function (err, data) {
16
- if (err) return rejectFunc(err);
17
- resolveFunc(data);
18
- };
19
- }
20
-
21
- var tmpForm = {
22
- client: "web_messenger",
23
- query: name,
24
- offset: 0,
25
- limit: 21,
26
- index: "fbid"
27
- };
28
-
29
- defaultFuncs
30
- .post("https://www.facebook.com/ajax/mercury/search_threads.php", ctx.jar, tmpForm)
31
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
32
- .then(function (resData) {
33
- if (resData.error) throw resData;
34
- if (!resData.payload.mercury_payload.threads) return callback({ error: "Could not find thread `" + name + "`." });
35
- return callback(
36
- null,
37
- resData.payload.mercury_payload.threads.map(utils.formatThread)
38
- );
39
- });
40
- return returnPromise;
41
- };
42
- };
package/leiamnash/seen.js DELETED
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function markAsReadAll(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
-
15
- if (!callback) {
16
- callback = function (err, data) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc(data);
19
- };
20
- }
21
-
22
- var form = {
23
- folder: 'inbox'
24
- };
25
-
26
- defaultFuncs
27
- .post("https://www.facebook.com/ajax/mercury/mark_folder_as_read.php", ctx.jar, form)
28
- .then(utils.saveCookies(ctx.jar))
29
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
- .then(function (resData) {
31
- if (resData.error) throw resData;
32
- return callback();
33
- })
34
- .catch(function (err) {
35
- log.error("markAsReadAll", err);
36
- return callback(err);
37
- });
38
- return returnPromise;
39
- };
40
- };