alicezetion 1.9.2 → 1.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/index.js +1 -1
  2. package/package.json +1 -1
  3. package/src/addExternalModule.js +19 -0
  4. package/src/addUserToGroup.js +113 -0
  5. package/src/changeAdminStatus.js +79 -0
  6. package/src/changeArchivedStatus.js +55 -0
  7. package/{leiamnash → src}/changeAvatar.js +2 -3
  8. package/src/changeBio.js +77 -0
  9. package/src/changeBlockedStatus.js +47 -0
  10. package/src/changeGroupImage.js +132 -0
  11. package/src/changeNickname.js +59 -0
  12. package/src/changeThreadColor.js +65 -0
  13. package/src/changeThreadEmoji.js +55 -0
  14. package/{leiamnash → src}/chat.js +29 -4
  15. package/src/createNewGroup.js +86 -0
  16. package/src/createPoll.js +71 -0
  17. package/src/deleteMessage.js +56 -0
  18. package/src/deleteThread.js +56 -0
  19. package/src/edit.js +66 -0
  20. package/src/forwardAttachment.js +60 -0
  21. package/src/getCurrentUserID.js +7 -0
  22. package/src/getEmojiUrl.js +29 -0
  23. package/src/getFriendsList.js +83 -0
  24. package/src/getThreadHistory.js +666 -0
  25. package/src/getThreadInfo.js +232 -0
  26. package/src/getThreadList.js +241 -0
  27. package/src/getThreadPictures.js +79 -0
  28. package/src/getUserID.js +66 -0
  29. package/src/getUserInfo.js +74 -0
  30. package/src/handleFriendRequest.js +61 -0
  31. package/src/handleMessageRequest.js +65 -0
  32. package/src/httpGet.js +57 -0
  33. package/src/httpPost.js +57 -0
  34. package/src/httpPostFormData.js +63 -0
  35. package/src/listenMqtt.js +853 -0
  36. package/src/logout.js +75 -0
  37. package/src/markAsDelivered.js +58 -0
  38. package/src/markAsRead.js +80 -0
  39. package/src/markAsReadAll.js +50 -0
  40. package/src/markAsSeen.js +59 -0
  41. package/src/muteThread.js +52 -0
  42. package/src/react.js +109 -0
  43. package/{leiamnash → src}/refreshFb_dtsg.js +1 -1
  44. package/src/removeUserFromGroup.js +79 -0
  45. package/src/resolvePhotoUrl.js +45 -0
  46. package/src/searchForThread.js +53 -0
  47. package/src/seen.js +50 -0
  48. package/src/sendMessage.js +477 -0
  49. package/src/sendTypingIndicator.js +103 -0
  50. package/src/setMessageReaction.js +121 -0
  51. package/src/setPostReaction.js +109 -0
  52. package/src/setTitle.js +86 -0
  53. package/src/threadColors.js +131 -0
  54. package/src/unfriend.js +52 -0
  55. package/src/unsendMessage.js +49 -0
  56. package/{leiamnash → src}/uploadAttachment.js +1 -2
  57. package/leiamnash/addExternalModule.js +0 -15
  58. package/leiamnash/addUserToGroup.js +0 -77
  59. package/leiamnash/changeAdminStatus.js +0 -47
  60. package/leiamnash/changeArchivedStatus.js +0 -41
  61. package/leiamnash/changeBio.js +0 -64
  62. package/leiamnash/changeBlockedStatus.js +0 -36
  63. package/leiamnash/changeGroupImage.js +0 -105
  64. package/leiamnash/changeNickname.js +0 -43
  65. package/leiamnash/changeThreadColor.js +0 -61
  66. package/leiamnash/changeThreadEmoji.js +0 -41
  67. package/leiamnash/createNewGroup.js +0 -70
  68. package/leiamnash/createPoll.js +0 -59
  69. package/leiamnash/deleteMessage.js +0 -44
  70. package/leiamnash/deleteThread.js +0 -42
  71. package/leiamnash/edit.js +0 -59
  72. package/leiamnash/forwardAttachment.js +0 -47
  73. package/leiamnash/forwardMessage.js +0 -0
  74. package/leiamnash/getCurrentUserID.js +0 -7
  75. package/leiamnash/getEmojiUrl.js +0 -27
  76. package/leiamnash/getFriendsList.js +0 -73
  77. package/leiamnash/getInfoVideo.js +0 -134
  78. package/leiamnash/getThreadHistory.js +0 -537
  79. package/leiamnash/getThreadHistoryDeprecated.js +0 -71
  80. package/leiamnash/getThreadInfo.js +0 -171
  81. package/leiamnash/getThreadInfoDeprecated.js +0 -56
  82. package/leiamnash/getThreadList.js +0 -213
  83. package/leiamnash/getThreadListDeprecated.js +0 -46
  84. package/leiamnash/getThreadPictures.js +0 -59
  85. package/leiamnash/getUserID.js +0 -61
  86. package/leiamnash/getUserInfo.js +0 -66
  87. package/leiamnash/handleFriendRequest.js +0 -46
  88. package/leiamnash/handleMessageRequest.js +0 -47
  89. package/leiamnash/httpGet.js +0 -47
  90. package/leiamnash/httpPost.js +0 -47
  91. package/leiamnash/httpPostFormData.js +0 -42
  92. package/leiamnash/listenMqtt.js +0 -853
  93. package/leiamnash/logout.js +0 -68
  94. package/leiamnash/markAsDelivered.js +0 -47
  95. package/leiamnash/markAsRead.js +0 -70
  96. package/leiamnash/markAsReadAll.js +0 -40
  97. package/leiamnash/markAsSeen.js +0 -48
  98. package/leiamnash/muteThread.js +0 -45
  99. package/leiamnash/react.js +0 -109
  100. package/leiamnash/removeUserFromGroup.js +0 -45
  101. package/leiamnash/resolvePhotoUrl.js +0 -36
  102. package/leiamnash/searchForThread.js +0 -42
  103. package/leiamnash/seen.js +0 -40
  104. package/leiamnash/sendMessage.js +0 -315
  105. package/leiamnash/sendTypingIndicator.js +0 -70
  106. package/leiamnash/setMessageReaction.js +0 -103
  107. package/leiamnash/setPostReaction.js +0 -63
  108. package/leiamnash/setTitle.js +0 -70
  109. package/leiamnash/threadColors.js +0 -41
  110. package/leiamnash/unfriend.js +0 -42
  111. package/leiamnash/unsendMessage.js +0 -39
  112. /package/{leiamnash → src}/getMessage.js +0 -0
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
-
5
- module.exports = function (defaultFuncs, api, ctx) {
6
- return function changeAdminStatus(threadID, adminID, adminStatus) {
7
- if (utils.getType(threadID) !== "String") throw { error: "changeAdminStatus: threadID must be a string" };
8
- if (utils.getType(adminID) !== "String" && utils.getType(adminID) !== "Array") throw { error: "changeAdminStatus: adminID must be a string or an array" };
9
- if (utils.getType(adminStatus) !== "Boolean") throw { error: "changeAdminStatus: adminStatus must be true or false" };
10
-
11
- let wsContent = {
12
- request_id: 1,
13
- type: 3,
14
- payload: {
15
- version_id: '3816854585040595',
16
- tasks: [],
17
- epoch_id: 6763184801413415579,
18
- data_trace_id: null
19
- },
20
- app_id: '772021112871879'
21
- }
22
-
23
- if (utils.getType(adminID) === "Array") {
24
- for (let i = 0; i < adminID.length; i++) {
25
- wsContent.payload.tasks.push({
26
- label: '25',
27
- payload: JSON.stringify({ thread_key: threadID, contact_id: adminID[i], is_admin: adminStatus }),
28
- queue_name: 'admin_status',
29
- task_id: i + 1,
30
- failure_count: null
31
- });
32
- }
33
- }
34
- else {
35
- wsContent.payload.tasks.push({
36
- label: '25',
37
- payload: JSON.stringify({ thread_key: threadID, contact_id: adminID, is_admin: adminStatus }),
38
- queue_name: 'admin_status',
39
- task_id: 1,
40
- failure_count: null
41
- });
42
- }
43
-
44
- wsContent.payload = JSON.stringify(wsContent.payload);
45
- return new Promise((resolve, reject) => ctx.mqttClient && ctx.mqttClient.publish('/ls_req', JSON.stringify(wsContent), {}, (err, _packet) => err ? reject(err) : resolve()));
46
- };
47
- };
@@ -1,41 +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 changeArchivedStatus(threadOrThreads, archive, 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) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc();
19
- };
20
- }
21
-
22
- var form = {};
23
-
24
- if (utils.getType(threadOrThreads) === "Array") for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + threadOrThreads[i] + "]"] = archive;
25
- else form["ids[" + threadOrThreads + "]"] = archive;
26
-
27
- defaultFuncs
28
- .post("https://www.facebook.com/ajax/mercury/change_archived_status.php", ctx.jar, form)
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("changeArchivedStatus", err);
36
- return callback(err);
37
- });
38
-
39
- return returnPromise;
40
- };
41
- };
@@ -1,64 +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 changeBio(bio, publish, 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
- if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") callback = publish;
17
- else {
18
- callback = function (err) {
19
- if (err) return rejectFunc(err);
20
- resolveFunc();
21
- };
22
- }
23
- }
24
-
25
- if (utils.getType(publish) != "Boolean") publish = false;
26
- if (utils.getType(bio) != "String") {
27
- bio = "";
28
- publish = false;
29
- }
30
-
31
- var form = {
32
- fb_api_caller_class: "RelayModern",
33
- fb_api_req_friendly_name: "ProfileCometSetBioMutation",
34
- // This doc_is is valid as of May 23, 2020
35
- doc_id: "2725043627607610",
36
- variables: JSON.stringify({
37
- input: {
38
- bio: bio,
39
- publish_bio_feed_story: publish,
40
- actor_id: ctx.userID,
41
- client_mutation_id: Math.round(Math.random() * 1024).toString()
42
- },
43
- hasProfileTileViewID: false,
44
- profileTileViewID: null,
45
- scale: 1
46
- }),
47
- av: ctx.userID
48
- };
49
-
50
- defaultFuncs
51
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
52
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
53
- .then(function (resData) {
54
- if (resData.errors) throw resData;
55
- return callback();
56
- })
57
- .catch(function (err) {
58
- log.error("changeBio", err);
59
- return callback(err);
60
- });
61
-
62
- return returnPromise;
63
- };
64
- };
@@ -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 changeBlockedStatus(userID, block, 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) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc();
19
- };
20
- }
21
-
22
- defaultFuncs
23
- .post(`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`, ctx.jar, { fbid: userID })
24
- .then(utils.saveCookies(ctx.jar))
25
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
26
- .then(function (resData) {
27
- if (resData.error) throw resData;
28
- return callback();
29
- })
30
- .catch(function (err) {
31
- log.error("changeBlockedStatus", err);
32
- return callback(err);
33
- });
34
- return returnPromise;
35
- };
36
- };
@@ -1,105 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require("../utils");
4
- var log = require("npmlog");
5
- var bluebird = require("bluebird");
6
-
7
- module.exports = function (defaultFuncs, api, ctx) {
8
- function handleUpload(image, callback) {
9
- var uploads = [];
10
-
11
- var form = {
12
- images_only: "true",
13
- "attachment[]": image
14
- };
15
-
16
- uploads.push(
17
- defaultFuncs
18
- .postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
19
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
20
- .then(function (resData) {
21
- if (resData.error) throw resData;
22
- return resData.payload.metadata[0];
23
- })
24
- );
25
-
26
- // resolve all promises
27
- bluebird
28
- .all(uploads)
29
- .then(resData => callback(null, resData))
30
- .catch(function (err) {
31
- log.error("handleUpload", err);
32
- return callback(err);
33
- });
34
- }
35
-
36
- return function changeGroupImage(image, threadID, callback) {
37
- if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
38
-
39
- var resolveFunc = function () { };
40
- var rejectFunc = function () { };
41
- var returnPromise = new Promise(function (resolve, reject) {
42
- resolveFunc = resolve;
43
- rejectFunc = reject;
44
- });
45
-
46
- if (!callback) {
47
- callback = function (err) {
48
- if (err) return rejectFunc(err);
49
- resolveFunc();
50
- };
51
- }
52
-
53
- var messageAndOTID = utils.generateOfflineThreadingID();
54
- var form = {
55
- client: "mercury",
56
- action_type: "ma-type:log-message",
57
- author: "fbid:" + ctx.userID,
58
- author_email: "",
59
- ephemeral_ttl_mode: "0",
60
- is_filtered_content: false,
61
- is_filtered_content_account: false,
62
- is_filtered_content_bh: false,
63
- is_filtered_content_invalid_app: false,
64
- is_filtered_content_quasar: false,
65
- is_forward: false,
66
- is_spoof_warning: false,
67
- is_unread: false,
68
- log_message_type: "log:thread-image",
69
- manual_retry_cnt: "0",
70
- message_id: messageAndOTID,
71
- offline_threading_id: messageAndOTID,
72
- source: "source:chat:web",
73
- "source_tags[0]": "source:chat",
74
- status: "0",
75
- thread_fbid: threadID,
76
- thread_id: "",
77
- timestamp: Date.now(),
78
- timestamp_absolute: "Today",
79
- timestamp_relative: utils.generateTimestampRelative(),
80
- timestamp_time_passed: "0"
81
- };
82
-
83
- handleUpload(image, function (err, payload) {
84
- if (err) return callback(err);
85
-
86
- form["thread_image_id"] = payload[0]["image_id"];
87
- form["thread_id"] = threadID;
88
-
89
- defaultFuncs
90
- .post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
91
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
92
- .then(function (resData) {
93
- // check for errors here
94
- if (resData.error) throw resData;
95
- return callback();
96
- })
97
- .catch(function (err) {
98
- log.error("changeGroupImage", err);
99
- return callback(err);
100
- });
101
- });
102
-
103
- return returnPromise;
104
- };
105
- };
@@ -1,43 +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 changeNickname(nickname, threadID, participantID, 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) {
16
- if (err) return rejectFunc(err);
17
- resolveFunc();
18
- };
19
- }
20
-
21
- var form = {
22
- nickname: nickname,
23
- participant_id: participantID,
24
- thread_or_other_fbid: threadID
25
- };
26
-
27
- defaultFuncs
28
- .post("https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1", ctx.jar, form)
29
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
- .then(function (resData) {
31
- if (resData.error === 1545014) throw { error: "Trying to change nickname of user isn't in thread" };
32
- if (resData.error === 1357031) throw { error: "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname." };
33
- if (resData.error) throw resData;
34
- return callback();
35
- })
36
- .catch(function (err) {
37
- log.error("changeNickname", "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname.");
38
- return callback(err);
39
- });
40
-
41
- return returnPromise;
42
- };
43
- };
@@ -1,61 +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 changeThreadColor(color, 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
-
15
- if (!callback) {
16
- callback = function (err) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc(err);
19
- };
20
- }
21
-
22
- var validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
23
- var colorList = Object.keys(api.threadColors).map(function (name) {
24
- return api.threadColors[name];
25
- });
26
- if (!colorList.includes(validatedColor)) throw { error: "The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values." };
27
-
28
- var form = {
29
- dpr: 1,
30
- queries: JSON.stringify({
31
- o0: {
32
- //This doc_id is valid as of January 31, 2020
33
- doc_id: "1727493033983591",
34
- query_params: {
35
- data: {
36
- actor_id: ctx.userID,
37
- client_mutation_id: "0",
38
- source: "SETTINGS",
39
- theme_id: validatedColor,
40
- thread_id: threadID
41
- }
42
- }
43
- }
44
- })
45
- };
46
-
47
- defaultFuncs
48
- .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
49
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
50
- .then(function (resData) {
51
- if (resData[resData.length - 1].error_results > 0) throw resData[0].o0.errors;
52
- return callback();
53
- })
54
- .catch(function (err) {
55
- log.error("changeThreadColor", err);
56
- return callback(err);
57
- });
58
-
59
- return returnPromise;
60
- };
61
- };
@@ -1,41 +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 changeThreadEmoji(emoji, 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
-
15
- if (!callback) {
16
- callback = function (err) {
17
- if (err) return rejectFunc(err);
18
- resolveFunc();
19
- };
20
- }
21
- var form = {
22
- emoji_choice: emoji,
23
- thread_or_other_fbid: threadID
24
- };
25
-
26
- defaultFuncs
27
- .post("https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg", ctx.jar, form)
28
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
29
- .then(function (resData) {
30
- if (resData.error === 1357031) throw { error: "Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji." };
31
- if (resData.error) throw resData;
32
- return callback();
33
- })
34
- .catch(function (err) {
35
- log.error("changeThreadEmoji", err);
36
- return callback(err);
37
- });
38
-
39
- return returnPromise;
40
- };
41
- };
@@ -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 function createNewGroup(participantIDs, groupTitle, callback) {
8
- if (utils.getType(groupTitle) == "Function") {
9
- callback = groupTitle;
10
- groupTitle = null;
11
- }
12
-
13
- if (utils.getType(participantIDs) !== "Array") throw { error: "createNewGroup: participantIDs should be an array." };
14
-
15
- if (participantIDs.length < 2) throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
16
-
17
- var resolveFunc = function () { };
18
- var rejectFunc = function () { };
19
- var returnPromise = new Promise(function (resolve, reject) {
20
- resolveFunc = resolve;
21
- rejectFunc = reject;
22
- });
23
-
24
- if (!callback) {
25
- callback = function (err, threadID) {
26
- if (err) return rejectFunc(err);
27
- resolveFunc(threadID);
28
- };
29
- }
30
-
31
- var pids = [];
32
- for (var n in participantIDs) pids.push({ fbid: participantIDs[n] });
33
- pids.push({ fbid: ctx.userID });
34
-
35
- var form = {
36
- fb_api_caller_class: "RelayModern",
37
- fb_api_req_friendly_name: "MessengerGroupCreateMutation",
38
- av: ctx.userID,
39
- //This doc_id is valid as of January 11th, 2020
40
- doc_id: "577041672419534",
41
- variables: JSON.stringify({
42
- input: {
43
- entry_point: "jewel_new_group",
44
- actor_id: ctx.userID,
45
- participants: pids,
46
- client_mutation_id: Math.round(Math.random() * 1024).toString(),
47
- thread_settings: {
48
- name: groupTitle,
49
- joinable_mode: "PRIVATE",
50
- thread_image_fbid: null
51
- }
52
- }
53
- })
54
- };
55
-
56
- defaultFuncs
57
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
58
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
59
- .then(function (resData) {
60
- if (resData.errors) throw resData;
61
- return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
62
- })
63
- .catch(function (err) {
64
- log.error("createNewGroup", err);
65
- return callback(err);
66
- });
67
-
68
- return returnPromise;
69
- };
70
- };
@@ -1,59 +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 createPoll(title, threadID, options, 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
- if (utils.getType(options) == "Function") {
17
- callback = options;
18
- options = null;
19
- }
20
- else {
21
- callback = function (err) {
22
- if (err) return rejectFunc(err);
23
- resolveFunc();
24
- };
25
- }
26
- }
27
- if (!options) options = {}; // Initial poll options are optional
28
-
29
- var form = {
30
- target_id: threadID,
31
- question_text: title
32
- };
33
-
34
- // Set fields for options (and whether they are selected initially by the posting user)
35
- var ind = 0;
36
- for (var opt in options) {
37
- // eslint-disable-next-line no-prototype-builtins
38
- if (options.hasOwnProperty(opt)) {
39
- form["option_text_array[" + ind + "]"] = opt;
40
- form["option_is_selected_array[" + ind + "]"] = options[opt] ? "1" : "0";
41
- ind++;
42
- }
43
- }
44
-
45
- defaultFuncs
46
- .post("https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1", ctx.jar, form)
47
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
48
- .then(function (resData) {
49
- if (resData.payload.status != "success") throw resData;
50
- return callback();
51
- })
52
- .catch(function (err) {
53
- log.error("createPoll", err);
54
- return callback(err);
55
- });
56
-
57
- return returnPromise;
58
- };
59
- };
@@ -1,44 +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 deleteMessage(messageOrMessages, 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) {
16
- if (err) return rejectFunc(err);
17
-
18
- resolveFunc();
19
- };
20
- }
21
-
22
- var form = {
23
- client: "mercury"
24
- };
25
-
26
- if (utils.getType(messageOrMessages) !== "Array") messageOrMessages = [messageOrMessages];
27
-
28
- for (var i = 0; i < messageOrMessages.length; i++) form["message_ids[" + i + "]"] = messageOrMessages[i];
29
-
30
- defaultFuncs
31
- .post("https://www.facebook.com/ajax/mercury/delete_messages.php", ctx.jar, form)
32
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
- .then(function (resData) {
34
- if (resData.error) throw resData;
35
- return callback();
36
- })
37
- .catch(function (err) {
38
- log.error("deleteMessage", err);
39
- return callback(err);
40
- });
41
-
42
- return returnPromise;
43
- };
44
- };
@@ -1,42 +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 deleteThread(threadOrThreads, 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) {
16
- if (err) return rejectFunc(err);
17
- resolveFunc();
18
- };
19
- }
20
-
21
- var form = {
22
- client: "mercury"
23
- };
24
-
25
- if (utils.getType(threadOrThreads) !== "Array") threadOrThreads = [threadOrThreads];
26
- for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + i + "]"] = threadOrThreads[i];
27
-
28
- defaultFuncs
29
- .post("https://www.facebook.com/ajax/mercury/delete_thread.php", ctx.jar, form)
30
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
31
- .then(function (resData) {
32
- if (resData.error) throw resData;
33
- return callback();
34
- })
35
- .catch(function (err) {
36
- log.error("deleteThread", err);
37
- return callback(err);
38
- });
39
-
40
- return returnPromise;
41
- };
42
- };