@dongdev/fca-unofficial 1.0.19 → 2.0.0

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 (128) hide show
  1. package/.gitattributes +1 -0
  2. package/CHANGELOG.md +30 -27
  3. package/DOCS.md +727 -592
  4. package/README.md +94 -97
  5. package/func/logger.js +112 -0
  6. package/html.html +474 -0
  7. package/index.js +1 -379
  8. package/module/config.js +26 -0
  9. package/module/login.js +45 -0
  10. package/module/loginHelper.js +634 -0
  11. package/module/options.js +49 -0
  12. package/package.json +6 -39
  13. package/src/api/action/addExternalModule.js +25 -0
  14. package/src/api/action/changeAvatar.js +136 -0
  15. package/src/api/action/changeBio.js +76 -0
  16. package/src/api/action/getCurrentUserID.js +7 -0
  17. package/src/api/action/handleFriendRequest.js +57 -0
  18. package/src/api/action/logout.js +75 -0
  19. package/src/{refreshFb_dtsg.js → api/action/refreshFb_dtsg.js} +8 -8
  20. package/src/api/action/setPostReaction.js +107 -0
  21. package/src/api/action/unfriend.js +55 -0
  22. package/src/api/http/httpGet.js +65 -0
  23. package/src/api/http/httpPost.js +65 -0
  24. package/src/{postFormData.js → api/http/postFormData.js} +10 -10
  25. package/src/api/messaging/addUserToGroup.js +69 -0
  26. package/src/api/messaging/changeAdminStatus.js +103 -0
  27. package/src/api/messaging/changeArchivedStatus.js +55 -0
  28. package/src/api/messaging/changeBlockedStatus.js +49 -0
  29. package/src/api/messaging/changeGroupImage.js +135 -0
  30. package/src/api/messaging/changeNickname.js +59 -0
  31. package/src/api/messaging/changeThreadColor.js +65 -0
  32. package/src/api/messaging/createNewGroup.js +88 -0
  33. package/src/api/messaging/createPoll.js +70 -0
  34. package/src/api/messaging/deleteMessage.js +56 -0
  35. package/src/api/messaging/deleteThread.js +56 -0
  36. package/src/api/messaging/forwardAttachment.js +60 -0
  37. package/src/api/messaging/getEmojiUrl.js +29 -0
  38. package/src/api/messaging/getFriendsList.js +83 -0
  39. package/src/api/messaging/getMessage.js +834 -0
  40. package/src/api/messaging/getThreadHistory.js +681 -0
  41. package/src/api/messaging/handleMessageRequest.js +65 -0
  42. package/src/api/messaging/markAsDelivered.js +57 -0
  43. package/src/api/messaging/markAsRead.js +88 -0
  44. package/src/api/messaging/markAsReadAll.js +50 -0
  45. package/src/api/messaging/markAsSeen.js +61 -0
  46. package/src/api/messaging/muteThread.js +51 -0
  47. package/src/api/messaging/removeUserFromGroup.js +79 -0
  48. package/src/api/messaging/resolvePhotoUrl.js +44 -0
  49. package/src/api/messaging/searchForThread.js +53 -0
  50. package/src/api/messaging/sendMessage.js +306 -0
  51. package/src/api/messaging/sendMessageMqtt.js +321 -0
  52. package/src/api/messaging/sendTypingIndicator.js +110 -0
  53. package/src/{setMessageReaction.js → api/messaging/setMessageReaction.js} +20 -20
  54. package/src/api/messaging/setTitle.js +90 -0
  55. package/src/api/messaging/shareContact.js +51 -0
  56. package/src/api/messaging/threadColors.js +131 -0
  57. package/src/api/messaging/unsendMessage.js +44 -0
  58. package/src/api/messaging/uploadAttachment.js +93 -0
  59. package/src/api/socket/detail/buildStream.js +100 -0
  60. package/src/{listenMqtt.js → api/socket/listenMqtt.js} +172 -256
  61. package/src/api/threads/changeThreadEmoji.js +55 -0
  62. package/src/api/threads/getThreadInfo.js +572 -0
  63. package/src/{getThreadList.js → api/threads/getThreadList.js} +110 -54
  64. package/src/api/threads/getThreadPictures.js +79 -0
  65. package/src/api/users/getUserID.js +66 -0
  66. package/src/api/users/getUserInfo.js +88 -0
  67. package/src/core/sendReqMqtt.js +63 -0
  68. package/{lib → src}/database/models/index.js +12 -10
  69. package/{lib → src}/database/models/thread.js +5 -5
  70. package/{lib → src}/database/threadData.js +19 -14
  71. package/src/utils/client.js +159 -0
  72. package/src/utils/constants.js +13 -0
  73. package/src/utils/format.js +60 -0
  74. package/src/utils/headers.js +41 -0
  75. package/src/utils/index.js +1497 -0
  76. package/src/utils/request.js +147 -0
  77. package/lib/logger.js +0 -96
  78. package/src/addExternalModule.js +0 -19
  79. package/src/addUserToGroup.js +0 -113
  80. package/src/changeAdminStatus.js +0 -79
  81. package/src/changeArchivedStatus.js +0 -55
  82. package/src/changeAvatar.js +0 -126
  83. package/src/changeBio.js +0 -77
  84. package/src/changeBlockedStatus.js +0 -47
  85. package/src/changeGroupImage.js +0 -132
  86. package/src/changeNickname.js +0 -59
  87. package/src/changeThreadColor.js +0 -65
  88. package/src/changeThreadEmoji.js +0 -55
  89. package/src/createNewGroup.js +0 -86
  90. package/src/createPoll.js +0 -71
  91. package/src/deleteMessage.js +0 -56
  92. package/src/deleteThread.js +0 -56
  93. package/src/forwardAttachment.js +0 -60
  94. package/src/getCurrentUserID.js +0 -7
  95. package/src/getEmojiUrl.js +0 -29
  96. package/src/getFriendsList.js +0 -83
  97. package/src/getMessage.js +0 -796
  98. package/src/getThreadHistory.js +0 -666
  99. package/src/getThreadInfo.js +0 -535
  100. package/src/getThreadPictures.js +0 -79
  101. package/src/getUserID.js +0 -66
  102. package/src/getUserInfo.js +0 -80
  103. package/src/handleFriendRequest.js +0 -61
  104. package/src/handleMessageRequest.js +0 -65
  105. package/src/httpGet.js +0 -57
  106. package/src/httpPost.js +0 -57
  107. package/src/httpPostFormData.js +0 -63
  108. package/src/logout.js +0 -75
  109. package/src/markAsDelivered.js +0 -58
  110. package/src/markAsRead.js +0 -80
  111. package/src/markAsReadAll.js +0 -50
  112. package/src/markAsSeen.js +0 -59
  113. package/src/muteThread.js +0 -52
  114. package/src/removeUserFromGroup.js +0 -79
  115. package/src/resolvePhotoUrl.js +0 -45
  116. package/src/searchForThread.js +0 -53
  117. package/src/sendMessage.js +0 -328
  118. package/src/sendMessageMqtt.js +0 -316
  119. package/src/sendTypingIndicator.js +0 -103
  120. package/src/setPostReaction.js +0 -109
  121. package/src/setTitle.js +0 -86
  122. package/src/shareContact.js +0 -49
  123. package/src/threadColors.js +0 -131
  124. package/src/unfriend.js +0 -52
  125. package/src/unsendMessage.js +0 -49
  126. package/src/uploadAttachment.js +0 -95
  127. package/utils.js +0 -1387
  128. /package/{lib → func}/login.js +0 -0
package/src/changeBio.js DELETED
@@ -1,77 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function changeBio(bio, publish, callback) {
8
- let resolveFunc = function () { };
9
- let rejectFunc = function () { };
10
- const 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") {
17
- callback = publish;
18
- } else {
19
- callback = function (err) {
20
- if (err) {
21
- return rejectFunc(err);
22
- }
23
- resolveFunc();
24
- };
25
- }
26
- }
27
-
28
- if (utils.getType(publish) != "Boolean") {
29
- publish = false;
30
- }
31
-
32
- if (utils.getType(bio) != "String") {
33
- bio = "";
34
- publish = false;
35
- }
36
-
37
- const form = {
38
- fb_api_caller_class: "RelayModern",
39
- fb_api_req_friendly_name: "ProfileCometSetBioMutation",
40
- // This doc_is is valid as of May 23, 2020
41
- doc_id: "2725043627607610",
42
- variables: JSON.stringify({
43
- input: {
44
- bio: bio,
45
- publish_bio_feed_story: publish,
46
- actor_id: ctx.i_userID || ctx.userID,
47
- client_mutation_id: Math.round(Math.random() * 1024).toString()
48
- },
49
- hasProfileTileViewID: false,
50
- profileTileViewID: null,
51
- scale: 1
52
- }),
53
- av: ctx.i_userID || ctx.userID
54
- };
55
-
56
- defaultFuncs
57
- .post(
58
- "https://www.facebook.com/api/graphql/",
59
- ctx.jar,
60
- form
61
- )
62
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
63
- .then(function (resData) {
64
- if (resData.errors) {
65
- throw resData;
66
- }
67
-
68
- return callback();
69
- })
70
- .catch(function (err) {
71
- log.error("changeBio", err);
72
- return callback(err);
73
- });
74
-
75
- return returnPromise;
76
- };
77
- };
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function changeBlockedStatus(userID, block, callback) {
8
- let resolveFunc = function () { };
9
- let rejectFunc = function () { };
10
- const returnPromise = new Promise(function (resolve, reject) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
14
-
15
- if (!callback) {
16
- callback = function (err) {
17
- if (err) {
18
- return rejectFunc(err);
19
- }
20
- resolveFunc();
21
- };
22
- }
23
-
24
- defaultFuncs
25
- .post(
26
- `https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`,
27
- ctx.jar,
28
- {
29
- fbid: userID
30
- }
31
- )
32
- .then(utils.saveCookies(ctx.jar))
33
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
- .then(function (resData) {
35
- if (resData.error) {
36
- throw resData;
37
- }
38
-
39
- return callback();
40
- })
41
- .catch(function (err) {
42
- log.error("changeBlockedStatus", err);
43
- return callback(err);
44
- });
45
- return returnPromise;
46
- };
47
- };
@@ -1,132 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- function handleUpload(image, callback) {
8
- const uploads = [];
9
-
10
- const form = {
11
- images_only: "true",
12
- "attachment[]": image
13
- };
14
-
15
- uploads.push(
16
- defaultFuncs
17
- .postFormData(
18
- "https://upload.facebook.com/ajax/mercury/upload.php",
19
- ctx.jar,
20
- form,
21
- {}
22
- )
23
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
24
- .then(function (resData) {
25
- if (resData.error) {
26
- throw resData;
27
- }
28
-
29
- return resData.payload.metadata[0];
30
- })
31
- );
32
-
33
- // resolve all promises
34
- Promise
35
- .all(uploads)
36
- .then(function (resData) {
37
- callback(null, resData);
38
- })
39
- .catch(function (err) {
40
- log.error("handleUpload", err);
41
- return callback(err);
42
- });
43
- }
44
-
45
- return function changeGroupImage(image, threadID, callback) {
46
- if (
47
- !callback &&
48
- (utils.getType(threadID) === "Function" ||
49
- utils.getType(threadID) === "AsyncFunction")
50
- ) {
51
- throw { error: "please pass a threadID as a second argument." };
52
- }
53
-
54
- if (!utils.isReadableStream(image)) {
55
- throw { error: "please pass a readable stream as a first argument." };
56
- }
57
-
58
- let resolveFunc = function () { };
59
- let rejectFunc = function () { };
60
- const returnPromise = new Promise(function (resolve, reject) {
61
- resolveFunc = resolve;
62
- rejectFunc = reject;
63
- });
64
-
65
- if (!callback) {
66
- callback = function (err) {
67
- if (err) {
68
- return rejectFunc(err);
69
- }
70
- resolveFunc();
71
- };
72
- }
73
-
74
- const messageAndOTID = utils.generateOfflineThreadingID();
75
- const form = {
76
- client: "mercury",
77
- action_type: "ma-type:log-message",
78
- author: "fbid:" + (ctx.i_userID || ctx.userID),
79
- author_email: "",
80
- ephemeral_ttl_mode: "0",
81
- is_filtered_content: false,
82
- is_filtered_content_account: false,
83
- is_filtered_content_bh: false,
84
- is_filtered_content_invalid_app: false,
85
- is_filtered_content_quasar: false,
86
- is_forward: false,
87
- is_spoof_warning: false,
88
- is_unread: false,
89
- log_message_type: "log:thread-image",
90
- manual_retry_cnt: "0",
91
- message_id: messageAndOTID,
92
- offline_threading_id: messageAndOTID,
93
- source: "source:chat:web",
94
- "source_tags[0]": "source:chat",
95
- status: "0",
96
- thread_fbid: threadID,
97
- thread_id: "",
98
- timestamp: Date.now(),
99
- timestamp_absolute: "Today",
100
- timestamp_relative: utils.generateTimestampRelative(),
101
- timestamp_time_passed: "0"
102
- };
103
-
104
- handleUpload(image, function (err, payload) {
105
- if (err) {
106
- return callback(err);
107
- }
108
-
109
- form["thread_image_id"] = payload[0]["image_id"];
110
- form["thread_id"] = threadID;
111
-
112
- defaultFuncs
113
- .post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
114
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
115
- .then(function (resData) {
116
- // check for errors here
117
-
118
- if (resData.error) {
119
- throw resData;
120
- }
121
-
122
- return callback();
123
- })
124
- .catch(function (err) {
125
- log.error("changeGroupImage", err);
126
- return callback(err);
127
- });
128
- });
129
-
130
- return returnPromise;
131
- };
132
- };
@@ -1,59 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function changeNickname(nickname, threadID, participantID, callback) {
8
- let resolveFunc = function () { };
9
- let rejectFunc = function () { };
10
- const returnPromise = new Promise(function (resolve, reject) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
14
- if (!callback) {
15
- callback = function (err) {
16
- if (err) {
17
- return rejectFunc(err);
18
- }
19
- resolveFunc();
20
- };
21
- }
22
-
23
- const form = {
24
- nickname: nickname,
25
- participant_id: participantID,
26
- thread_or_other_fbid: threadID
27
- };
28
-
29
- defaultFuncs
30
- .post(
31
- "https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",
32
- ctx.jar,
33
- form
34
- )
35
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
36
- .then(function (resData) {
37
- if (resData.error === 1545014) {
38
- throw { error: "Trying to change nickname of user isn't in thread" };
39
- }
40
- if (resData.error === 1357031) {
41
- throw {
42
- error:
43
- "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."
44
- };
45
- }
46
- if (resData.error) {
47
- throw resData;
48
- }
49
-
50
- return callback();
51
- })
52
- .catch(function (err) {
53
- log.error("changeNickname", err);
54
- return callback(err);
55
- });
56
-
57
- return returnPromise;
58
- };
59
- };
@@ -1,65 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function changeThreadColor(color, threadID, callback) {
8
- let resolveFunc = function () { };
9
- let rejectFunc = function () { };
10
- const returnPromise = new Promise(function (resolve, reject) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
14
-
15
- if (!callback) {
16
- callback = function (err) {
17
- if (err) {
18
- return rejectFunc(err);
19
- }
20
- resolveFunc(err);
21
- };
22
- }
23
-
24
- if (!isNaN(color)) {
25
- color = color.toString();
26
- }
27
- const validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
28
-
29
- const form = {
30
- dpr: 1,
31
- queries: JSON.stringify({
32
- o0: {
33
- //This doc_id is valid as of January 31, 2020
34
- doc_id: "1727493033983591",
35
- query_params: {
36
- data: {
37
- actor_id: ctx.i_userID || ctx.userID,
38
- client_mutation_id: "0",
39
- source: "SETTINGS",
40
- theme_id: validatedColor,
41
- thread_id: threadID
42
- }
43
- }
44
- }
45
- })
46
- };
47
-
48
- defaultFuncs
49
- .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
50
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
51
- .then(function (resData) {
52
- if (resData[resData.length - 1].error_results > 0) {
53
- throw new utils.CustomError(resData[0].o0.errors);
54
- }
55
-
56
- return callback();
57
- })
58
- .catch(function (err) {
59
- log.error("changeThreadColor", err);
60
- return callback(err);
61
- });
62
-
63
- return returnPromise;
64
- };
65
- };
@@ -1,55 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function changeThreadEmoji(emoji, threadID, callback) {
8
- let resolveFunc = function () { };
9
- let rejectFunc = function () { };
10
- const returnPromise = new Promise(function (resolve, reject) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
14
-
15
- if (!callback) {
16
- callback = function (err) {
17
- if (err) {
18
- return rejectFunc(err);
19
- }
20
- resolveFunc();
21
- };
22
- }
23
- const form = {
24
- emoji_choice: emoji,
25
- thread_or_other_fbid: threadID
26
- };
27
-
28
- defaultFuncs
29
- .post(
30
- "https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg",
31
- ctx.jar,
32
- form
33
- )
34
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
35
- .then(function (resData) {
36
- if (resData.error === 1357031) {
37
- throw {
38
- error:
39
- "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."
40
- };
41
- }
42
- if (resData.error) {
43
- throw resData;
44
- }
45
-
46
- return callback();
47
- })
48
- .catch(function (err) {
49
- log.error("changeThreadEmoji", err);
50
- return callback(err);
51
- });
52
-
53
- return returnPromise;
54
- };
55
- };
@@ -1,86 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const 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") {
14
- throw { error: "createNewGroup: participantIDs should be an array." };
15
- }
16
-
17
- if (participantIDs.length < 2) {
18
- throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
19
- }
20
-
21
- let resolveFunc = function () { };
22
- let rejectFunc = function () { };
23
- const returnPromise = new Promise(function (resolve, reject) {
24
- resolveFunc = resolve;
25
- rejectFunc = reject;
26
- });
27
-
28
- if (!callback) {
29
- callback = function (err, threadID) {
30
- if (err) {
31
- return rejectFunc(err);
32
- }
33
- resolveFunc(threadID);
34
- };
35
- }
36
-
37
- const pids = [];
38
- for (const n in participantIDs) {
39
- pids.push({
40
- fbid: participantIDs[n]
41
- });
42
- }
43
- pids.push({ fbid: ctx.i_userID || ctx.userID });
44
-
45
- const form = {
46
- fb_api_caller_class: "RelayModern",
47
- fb_api_req_friendly_name: "MessengerGroupCreateMutation",
48
- av: ctx.i_userID || ctx.userID,
49
- //This doc_id is valid as of January 11th, 2020
50
- doc_id: "577041672419534",
51
- variables: JSON.stringify({
52
- input: {
53
- entry_point: "jewel_new_group",
54
- actor_id: ctx.i_userID || ctx.userID,
55
- participants: pids,
56
- client_mutation_id: Math.round(Math.random() * 1024).toString(),
57
- thread_settings: {
58
- name: groupTitle,
59
- joinable_mode: "PRIVATE",
60
- thread_image_fbid: null
61
- }
62
- }
63
- })
64
- };
65
-
66
- defaultFuncs
67
- .post(
68
- "https://www.facebook.com/api/graphql/",
69
- ctx.jar,
70
- form
71
- )
72
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
73
- .then(function (resData) {
74
- if (resData.errors) {
75
- throw resData;
76
- }
77
- return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
78
- })
79
- .catch(function (err) {
80
- log.error("createNewGroup", err);
81
- return callback(err);
82
- });
83
-
84
- return returnPromise;
85
- };
86
- };
package/src/createPoll.js DELETED
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function createPoll(title, threadID, options, callback) {
8
- let resolveFunc = function () { };
9
- let rejectFunc = function () { };
10
- const 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
- } else {
20
- callback = function (err) {
21
- if (err) {
22
- return rejectFunc(err);
23
- }
24
- resolveFunc();
25
- };
26
- }
27
- }
28
- if (!options) {
29
- options = {}; // Initial poll options are optional
30
- }
31
-
32
- const form = {
33
- target_id: threadID,
34
- question_text: title
35
- };
36
-
37
- // Set fields for options (and whether they are selected initially by the posting user)
38
- let ind = 0;
39
- for (const opt in options) {
40
- // eslint-disable-next-line no-prototype-builtins
41
- if (options.hasOwnProperty(opt)) {
42
- form["option_text_array[" + ind + "]"] = opt;
43
- form["option_is_selected_array[" + ind + "]"] = options[opt]
44
- ? "1"
45
- : "0";
46
- ind++;
47
- }
48
- }
49
-
50
- defaultFuncs
51
- .post(
52
- "https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
53
- ctx.jar,
54
- form
55
- )
56
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
- .then(function (resData) {
58
- if (resData.payload.status != "success") {
59
- throw resData;
60
- }
61
-
62
- return callback();
63
- })
64
- .catch(function (err) {
65
- log.error("createPoll", err);
66
- return callback(err);
67
- });
68
-
69
- return returnPromise;
70
- };
71
- };
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function deleteMessage(messageOrMessages, callback) {
8
- let resolveFunc = function () { };
9
- let rejectFunc = function () { };
10
- const returnPromise = new Promise(function (resolve, reject) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
14
- if (!callback) {
15
- callback = function (err) {
16
- if (err) {
17
- return rejectFunc(err);
18
- }
19
- resolveFunc();
20
- };
21
- }
22
-
23
- const form = {
24
- client: "mercury"
25
- };
26
-
27
- if (utils.getType(messageOrMessages) !== "Array") {
28
- messageOrMessages = [messageOrMessages];
29
- }
30
-
31
- for (let i = 0; i < messageOrMessages.length; i++) {
32
- form["message_ids[" + i + "]"] = messageOrMessages[i];
33
- }
34
-
35
- defaultFuncs
36
- .post(
37
- "https://www.facebook.com/ajax/mercury/delete_messages.php",
38
- ctx.jar,
39
- form
40
- )
41
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
42
- .then(function (resData) {
43
- if (resData.error) {
44
- throw resData;
45
- }
46
-
47
- return callback();
48
- })
49
- .catch(function (err) {
50
- log.error("deleteMessage", err);
51
- return callback(err);
52
- });
53
-
54
- return returnPromise;
55
- };
56
- };
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- const utils = require("../utils");
4
- const log = require("npmlog");
5
-
6
- module.exports = function (defaultFuncs, api, ctx) {
7
- return function deleteThread(threadOrThreads, callback) {
8
- let resolveFunc = function () { };
9
- let rejectFunc = function () { };
10
- const returnPromise = new Promise(function (resolve, reject) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
14
- if (!callback) {
15
- callback = function (err) {
16
- if (err) {
17
- return rejectFunc(err);
18
- }
19
- resolveFunc();
20
- };
21
- }
22
-
23
- const form = {
24
- client: "mercury"
25
- };
26
-
27
- if (utils.getType(threadOrThreads) !== "Array") {
28
- threadOrThreads = [threadOrThreads];
29
- }
30
-
31
- for (let i = 0; i < threadOrThreads.length; i++) {
32
- form["ids[" + i + "]"] = threadOrThreads[i];
33
- }
34
-
35
- defaultFuncs
36
- .post(
37
- "https://www.facebook.com/ajax/mercury/delete_thread.php",
38
- ctx.jar,
39
- form
40
- )
41
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
42
- .then(function (resData) {
43
- if (resData.error) {
44
- throw resData;
45
- }
46
-
47
- return callback();
48
- })
49
- .catch(function (err) {
50
- log.error("deleteThread", err);
51
- return callback(err);
52
- });
53
-
54
- return returnPromise;
55
- };
56
- };