alicezetion 1.8.4 → 1.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -1
  2. package/.cache/replit/modules.stamp +1 -0
  3. package/.cache/replit/nix/env.json +1 -1
  4. package/index.js +375 -210
  5. package/leiamnash/addExternalModule.js +15 -0
  6. package/leiamnash/addUserToGroup.js +77 -0
  7. package/leiamnash/changeAdminStatus.js +47 -0
  8. package/leiamnash/changeArchivedStatus.js +41 -0
  9. package/leiamnash/changeAvatar.js +127 -0
  10. package/leiamnash/changeBio.js +64 -0
  11. package/leiamnash/changeBlockedStatus.js +36 -0
  12. package/leiamnash/changeGroupImage.js +105 -0
  13. package/leiamnash/changeNickname.js +43 -0
  14. package/leiamnash/changeThreadColor.js +61 -0
  15. package/leiamnash/changeThreadEmoji.js +41 -0
  16. package/{src → leiamnash}/chat.js +3 -28
  17. package/leiamnash/createNewGroup.js +70 -0
  18. package/leiamnash/createPoll.js +59 -0
  19. package/leiamnash/deleteMessage.js +44 -0
  20. package/leiamnash/deleteThread.js +42 -0
  21. package/leiamnash/forwardAttachment.js +47 -0
  22. package/leiamnash/forwardMessage.js +0 -0
  23. package/leiamnash/getCurrentUserID.js +7 -0
  24. package/leiamnash/getEmojiUrl.js +27 -0
  25. package/leiamnash/getFriendsList.js +73 -0
  26. package/leiamnash/getInfoVideo.js +134 -0
  27. package/leiamnash/getThreadHistory.js +537 -0
  28. package/leiamnash/getThreadHistoryDeprecated.js +71 -0
  29. package/{src → leiamnash}/getThreadInfo.js +54 -70
  30. package/leiamnash/getThreadInfoDeprecated.js +56 -0
  31. package/leiamnash/getThreadList.js +213 -0
  32. package/leiamnash/getThreadListDeprecated.js +46 -0
  33. package/leiamnash/getThreadPictures.js +59 -0
  34. package/leiamnash/getUserID.js +61 -0
  35. package/leiamnash/getUserInfo.js +66 -0
  36. package/leiamnash/handleFriendRequest.js +46 -0
  37. package/leiamnash/handleMessageRequest.js +47 -0
  38. package/leiamnash/httpGet.js +47 -0
  39. package/leiamnash/httpPost.js +47 -0
  40. package/leiamnash/httpPostFormData.js +42 -0
  41. package/{src → leiamnash}/listenMqtt.js +6 -16
  42. package/leiamnash/logout.js +68 -0
  43. package/leiamnash/markAsDelivered.js +47 -0
  44. package/leiamnash/markAsRead.js +70 -0
  45. package/leiamnash/markAsReadAll.js +40 -0
  46. package/leiamnash/markAsSeen.js +48 -0
  47. package/leiamnash/muteThread.js +45 -0
  48. package/leiamnash/react.js +109 -0
  49. package/{src → leiamnash}/refreshFb_dtsg.js +1 -1
  50. package/leiamnash/removeUserFromGroup.js +45 -0
  51. package/leiamnash/resolvePhotoUrl.js +36 -0
  52. package/leiamnash/searchForThread.js +42 -0
  53. package/leiamnash/seen.js +40 -0
  54. package/leiamnash/sendMessage.js +315 -0
  55. package/leiamnash/sendTypingIndicator.js +70 -0
  56. package/leiamnash/setMessageReaction.js +103 -0
  57. package/leiamnash/setPostReaction.js +63 -0
  58. package/leiamnash/setTitle.js +70 -0
  59. package/leiamnash/threadColors.js +41 -0
  60. package/leiamnash/unfriend.js +42 -0
  61. package/leiamnash/unsendMessage.js +39 -0
  62. package/leiamnash/uploadAttachment.js +96 -0
  63. package/package.json +3 -6
  64. package/replit.nix +4 -4
  65. package/utils.js +176 -135
  66. package/src/addExternalModule.js +0 -17
  67. package/src/addUserToGroup.js +0 -113
  68. package/src/changeAdminStatus.js +0 -79
  69. package/src/changeArchivedStatus.js +0 -55
  70. package/src/changeAvatar.js +0 -93
  71. package/src/changeBio.js +0 -77
  72. package/src/changeBlockedStatus.js +0 -47
  73. package/src/changeCover.js +0 -73
  74. package/src/changeGroupImage.js +0 -132
  75. package/src/changeName.js +0 -79
  76. package/src/changeNickname.js +0 -59
  77. package/src/changeThreadColor.js +0 -65
  78. package/src/changeThreadEmoji.js +0 -55
  79. package/src/createNewGroup.js +0 -86
  80. package/src/createPoll.js +0 -71
  81. package/src/data/getThreadInfo.json +0 -1
  82. package/src/deleteMessage.js +0 -56
  83. package/src/deleteThread.js +0 -56
  84. package/src/forwardAttachment.js +0 -60
  85. package/src/getAccess.js +0 -112
  86. package/src/getAvatarUser.js +0 -78
  87. package/src/getCurrentUserID.js +0 -7
  88. package/src/getEmojiUrl.js +0 -29
  89. package/src/getFriendsList.js +0 -83
  90. package/src/getThreadHistory.js +0 -666
  91. package/src/getThreadList.js +0 -237
  92. package/src/getThreadPictures.js +0 -79
  93. package/src/getUserID.js +0 -66
  94. package/src/getUserInfo.js +0 -163
  95. package/src/handleFriendRequest.js +0 -61
  96. package/src/handleMessageRequest.js +0 -65
  97. package/src/httpGet.js +0 -57
  98. package/src/httpPost.js +0 -57
  99. package/src/httpPostFormData.js +0 -63
  100. package/src/listenNotification.js +0 -88
  101. package/src/logout.js +0 -275
  102. package/src/markAsDelivered.js +0 -58
  103. package/src/markAsRead.js +0 -80
  104. package/src/markAsReadAll.js +0 -50
  105. package/src/markAsSeen.js +0 -59
  106. package/src/muteThread.js +0 -52
  107. package/src/react.js +0 -117
  108. package/src/removeUserFromGroup.js +0 -79
  109. package/src/resolvePhotoUrl.js +0 -45
  110. package/src/searchForThread.js +0 -53
  111. package/src/searchStickers.js +0 -52
  112. package/src/seen.js +0 -50
  113. package/src/sendMessage.js +0 -477
  114. package/src/sendMessageMqtt.js +0 -316
  115. package/src/sendTypingIndicator.js +0 -103
  116. package/src/setMessageReaction.js +0 -117
  117. package/src/setPostReaction.js +0 -109
  118. package/src/setTitle.js +0 -86
  119. package/src/threadColors.js +0 -131
  120. package/src/unfriend.js +0 -52
  121. package/src/unsendMessage.js +0 -49
  122. /package/{src → leiamnash}/getMessage.js +0 -0
@@ -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 changeArchivedStatus(threadOrThreads, archive, 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
- const form = {};
25
-
26
- if (utils.getType(threadOrThreads) === "Array") {
27
- for (let i = 0; i < threadOrThreads.length; i++) {
28
- form["ids[" + threadOrThreads[i] + "]"] = archive;
29
- }
30
- } else {
31
- form["ids[" + threadOrThreads + "]"] = archive;
32
- }
33
-
34
- defaultFuncs
35
- .post(
36
- "https://www.facebook.com/ajax/mercury/change_archived_status.php",
37
- ctx.jar,
38
- form
39
- )
40
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
41
- .then(function (resData) {
42
- if (resData.error) {
43
- throw resData;
44
- }
45
-
46
- return callback();
47
- })
48
- .catch(function (err) {
49
- log.error("changeArchivedStatus", err);
50
- return callback(err);
51
- });
52
-
53
- return returnPromise;
54
- };
55
- };
@@ -1,93 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('../utils');
4
- var log = require('npmlog');
5
-
6
- module.exports = function (http, api, ctx) {
7
- return function changeAvatar(image, caption = '', timestamp = null, callback) {
8
- var cb;
9
- var rt = new Promise(function (resolve, reject) {
10
- cb = (error, url) => error ? reject(error) : resolve(url);
11
- });
12
-
13
- if (typeof image == 'function') {
14
- callback = image;
15
- image = null;
16
- }
17
- if (typeof caption == 'function') {
18
- callback = caption;
19
- caption = '';
20
- }
21
- if (typeof caption == 'number') {
22
- timestamp = caption;
23
- caption = '';
24
- }
25
- if (typeof timestamp == 'function') {
26
- callback = timestamp;
27
- timestamp = null;
28
- }
29
- if (typeof callback == 'function') cb = callback;
30
-
31
- if (!utils.isReadableStream(image)) {
32
- var error = 'image should be a readable stream, not ' + utils.getType(image);
33
- log.error('changeAvatar', error);
34
- cb(error);
35
- } else {
36
- http
37
- .postFormData('https://www.facebook.com/profile/picture/upload/', ctx.jar, {
38
- profile_id: ctx.userID,
39
- photo_source: 57,
40
- av: ctx.userID,
41
- file: image
42
- })
43
- .then(utils.parseAndCheckLogin(ctx, http))
44
- .then(function (res) {
45
- if (res.error || res.errors || !res.payload)
46
- throw res;
47
-
48
- var vari = {
49
- input: {
50
- caption,
51
- existing_photo_id: res.payload.fbid,
52
- expiration_time: timestamp,
53
- profile_id: ctx.userID,
54
- profile_pic_method: "EXISTING",
55
- profile_pic_source: "TIMELINE",
56
- scaled_crop_rect: {
57
- height: 1,
58
- width: 1,
59
- x: 0,
60
- y: 0
61
- },
62
- skip_cropping: true,
63
- actor_id: ctx.userID,
64
- client_mutation_id: Math.round(Math.random() * 19).toString()
65
- },
66
- isPage: false,
67
- isProfile: true,
68
- scale: 3
69
- }
70
- return http
71
- .post('https://www.facebook.com/api/graphql', ctx.jar, {
72
- doc_id: 5066134240065849,
73
- server_timestamps: true,
74
- fb_api_req_friendly_name: 'ProfileCometProfilePictureSetMutation',
75
- variables: JSON.stringify(vari)
76
- })
77
- .then(utils.parseAndCheckLogin(ctx, http));
78
- })
79
- .then(function (res) {
80
- if (res.errors)
81
- throw res;
82
-
83
- return cb(null, (res[0] || res).data.profile_picture_set.profile);
84
- })
85
- .catch(function (err) {
86
- log.error('changeAvatar', err);
87
- return cb(err);
88
- });
89
- }
90
-
91
- return rt;
92
- }
93
- }
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,73 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('../utils.js');
4
- var log = require('npmlog');
5
-
6
- module.exports = function (http, api, ctx) {
7
- return function changeCover(image, callback) {
8
- var cb;
9
- var rt = new Promise(function (resolve, reject) {
10
- cb = (error, url) => error ? reject(error) : resolve(url);
11
- });
12
-
13
- if (typeof image == 'function') {
14
- callback = image;
15
- image = null;
16
- }
17
- if (typeof callback == 'function') cb = callback;
18
- if (!utils.isReadableStream(image)) {
19
- var error = 'image should be a readable stream, not ' + utils.getType(image);
20
- log.error('changeCover', error);
21
- cb(error);
22
- }
23
- else {
24
- http
25
- .postFormData('https://www.facebook.com/profile/picture/upload/', ctx.jar, {
26
- profile_id: ctx.userID,
27
- photo_source: 57,
28
- av: ctx.userID,
29
- file: image
30
- })
31
- .then(utils.parseAndCheckLogin(ctx, http))
32
- .then(function (res) {
33
- if (res.error || res.errors || !res.payload)
34
- throw res;
35
-
36
- var vari = {
37
- input: {
38
- attribution_id_v2: `ProfileCometCollectionRoot.react,comet.profile.collection.photos_by,unexpected,${Date.now()},770083,,;ProfileCometCollectionRoot.react,comet.profile.collection.photos_albums,unexpected,${Date.now()},470774,,;ProfileCometCollectionRoot.react,comet.profile.collection.photos,unexpected,${Date.now()},94740,,;ProfileCometCollectionRoot.react,comet.profile.collection.saved_reels_on_profile,unexpected,${Date.now()},89669,,;ProfileCometCollectionRoot.react,comet.profile.collection.reels_tab,unexpected,${Date.now()},152201,,`,
39
- cover_photo_id: res.payload.fbid,
40
- focus: {
41
- x: 0.5,
42
- y: 1
43
- },
44
- target_user_id: ctx.userID,
45
- actor_id: ctx.userID,
46
- client_mutation_id: Math.round(Math.random() * 19).toString()
47
- },
48
- scale: 1,
49
- contextualProfileContext: null
50
- }
51
- return http
52
- .post('https://www.facebook.com/api/graphql', ctx.jar, {
53
- doc_id: 8247793861913071,
54
- server_timestamps: true,
55
- fb_api_req_friendly_name: 'ProfileCometCoverPhotoUpdateMutation',
56
- variables: JSON.stringify(vari)
57
- })
58
- .then(utils.parseAndCheckLogin(ctx, http));
59
- })
60
- .then(function (res) {
61
- if (res.errors)
62
- throw res;
63
- return cb(null, res.data.user_update_cover_photo.user.cover_photo.photo.url);
64
- })
65
- .catch(function (err) {
66
- log.error('changeCover', err);
67
- return cb(err);
68
- });
69
- }
70
-
71
- return rt;
72
- }
73
- }
@@ -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
- };
package/src/changeName.js DELETED
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- var utils = require('./../utils.js');
4
- var log = require('npmlog');
5
-
6
- module.exports = function (http, api, ctx) {
7
- return function changeName(input, format, callback) {
8
- var cb;
9
- var rt = new Promise(function (resolve, reject) {
10
- cb = error => error ? reject(error) : resolve();
11
- });
12
-
13
- if (typeof input == 'function') {
14
- callback = input;
15
- input = null;
16
- }
17
- if (typeof format == 'function') {
18
- callback = format;
19
- format = 'complete';
20
- }
21
- if (typeof callback == 'function') cb = callback;
22
- if (utils.getType(input) != 'Object') {
23
- var error = 'name must be an object, not ' + utils.getType(input);
24
- log('changeName', error);
25
- return cb(error);
26
- }
27
-
28
- var { first_name, middle_name, last_name } = input;
29
- if (!first_name || !last_name) {
30
- log.error('changeName', 'name is not be accepted');
31
- return cb('name is not be accepted');
32
- }
33
-
34
- middle_name = middle_name || '';
35
-
36
- var full_name =
37
- format == 'complete' ? last_name + ' ' + (middle_name != '' ? middle_name + ' ' : '') + first_name :
38
- format == 'standard' ? last_name + ' ' + first_name :
39
- format == 'reversed' ? first_name + ' ' + (middle_name != '' ? middle_name + ' ' : '') + last_name :
40
- last_name + ' ' + (middle_name != '' ? middle_name + ' ' : '') + first_name;
41
-
42
- var form = {
43
- fb_api_caller_class: 'RelayModern',
44
- fb_api_req_friendly_name: 'useFXIMUpdateNameMutation',
45
- variables: JSON.stringify({
46
- client_mutation_id: utils.getGUID(),
47
- family_device_id: "device_id_fetch_datr",
48
- identity_ids: [ctx.userID],
49
- full_name,
50
- first_name,
51
- middle_name,
52
- last_name,
53
- interface: 'FB_WEB'
54
- }),
55
- server_timestamps: true,
56
- doc_id: '5763510853763960'
57
- }
58
-
59
- http
60
- .post('https://accountscenter.facebook.com/api/graphql/', ctx.jar, form, null, null, {
61
- Origin: 'https://accountscenter.facebook.com',
62
- Referer: `https://accountscenter.facebook.com/profiles/${ctx.userID}/name`
63
- })
64
- .then(utils.parseAndCheckLogin(ctx, http))
65
- .then(function (res) {
66
- if (res.errors)
67
- throw res;
68
- else if (res.data.fxim_update_identity_name.error)
69
- throw res.data.fxim_update_identity_name.error;
70
- return cb();
71
- })
72
- .catch(function (err) {
73
- log.error('changeName', err);
74
- return cb(err);
75
- });
76
-
77
- return rt;
78
- }
79
- }
@@ -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
- };