naughty-fb-chatify 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/.github/workflows/publish.yml +20 -0
  2. package/README.md +225 -0
  3. package/index.js +602 -0
  4. package/package.json +80 -0
  5. package/src/addExternalModule.js +19 -0
  6. package/src/addUserToGroup.js +113 -0
  7. package/src/changeAdminStatus.js +79 -0
  8. package/src/changeArchivedStatus.js +55 -0
  9. package/src/changeBio.js +77 -0
  10. package/src/changeBlockedStatus.js +47 -0
  11. package/src/changeGroupImage.js +129 -0
  12. package/src/changeNickname.js +59 -0
  13. package/src/changeThreadColor.js +71 -0
  14. package/src/changeThreadEmoji.js +55 -0
  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/forwardAttachment.js +60 -0
  20. package/src/getCurrentUserID.js +7 -0
  21. package/src/getEmojiUrl.js +29 -0
  22. package/src/getFriendsList.js +84 -0
  23. package/src/getThreadHistory.js +645 -0
  24. package/src/getThreadHistoryDeprecated.js +93 -0
  25. package/src/getThreadInfo.js +201 -0
  26. package/src/getThreadInfoDeprecated.js +80 -0
  27. package/src/getThreadList.js +238 -0
  28. package/src/getThreadListDeprecated.js +75 -0
  29. package/src/getThreadPictures.js +79 -0
  30. package/src/getUserID.js +66 -0
  31. package/src/getUserInfo.js +72 -0
  32. package/src/handleFriendRequest.js +61 -0
  33. package/src/handleMessageRequest.js +65 -0
  34. package/src/httpGet.js +52 -0
  35. package/src/httpPost.js +52 -0
  36. package/src/listenMqtt.js +788 -0
  37. package/src/logout.js +75 -0
  38. package/src/markAsDelivered.js +58 -0
  39. package/src/markAsRead.js +80 -0
  40. package/src/markAsReadAll.js +50 -0
  41. package/src/markAsSeen.js +59 -0
  42. package/src/muteThread.js +52 -0
  43. package/src/removeUserFromGroup.js +79 -0
  44. package/src/resolvePhotoUrl.js +45 -0
  45. package/src/searchForThread.js +53 -0
  46. package/src/sendMessage.js +459 -0
  47. package/src/sendTypingIndicator.js +103 -0
  48. package/src/setMessageReaction.js +117 -0
  49. package/src/setPostReaction.js +76 -0
  50. package/src/setTitle.js +86 -0
  51. package/src/threadColors.js +57 -0
  52. package/src/unfriend.js +52 -0
  53. package/src/unsendMessage.js +49 -0
  54. package/test/data/shareAttach.js +146 -0
  55. package/test/data/something.mov +0 -0
  56. package/test/data/test.png +0 -0
  57. package/test/data/test.txt +1 -0
  58. package/test/test-page.js +140 -0
  59. package/test/test.js +385 -0
  60. package/utils.js +1357 -0
@@ -0,0 +1,113 @@
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 addUserToGroup(userID, 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 (
16
+ !callback &&
17
+ (utils.getType(threadID) === "Function" ||
18
+ utils.getType(threadID) === "AsyncFunction")
19
+ ) {
20
+ throw { error: "please pass a threadID as a second argument." };
21
+ }
22
+
23
+ if (!callback) {
24
+ callback = function(err) {
25
+ if (err) {
26
+ return rejectFunc(err);
27
+ }
28
+ resolveFunc();
29
+ };
30
+ }
31
+
32
+ if (
33
+ utils.getType(threadID) !== "Number" &&
34
+ utils.getType(threadID) !== "String"
35
+ ) {
36
+ throw {
37
+ error:
38
+ "ThreadID should be of type Number or String and not " +
39
+ utils.getType(threadID) +
40
+ "."
41
+ };
42
+ }
43
+
44
+ if (utils.getType(userID) !== "Array") {
45
+ userID = [userID];
46
+ }
47
+
48
+ var messageAndOTID = utils.generateOfflineThreadingID();
49
+ var form = {
50
+ client: "mercury",
51
+ action_type: "ma-type:log-message",
52
+ author: "fbid:" + ctx.userID,
53
+ thread_id: "",
54
+ timestamp: Date.now(),
55
+ timestamp_absolute: "Today",
56
+ timestamp_relative: utils.generateTimestampRelative(),
57
+ timestamp_time_passed: "0",
58
+ is_unread: false,
59
+ is_cleared: false,
60
+ is_forward: false,
61
+ is_filtered_content: false,
62
+ is_filtered_content_bh: false,
63
+ is_filtered_content_account: false,
64
+ is_spoof_warning: false,
65
+ source: "source:chat:web",
66
+ "source_tags[0]": "source:chat",
67
+ log_message_type: "log:subscribe",
68
+ status: "0",
69
+ offline_threading_id: messageAndOTID,
70
+ message_id: messageAndOTID,
71
+ threading_id: utils.generateThreadingID(ctx.clientID),
72
+ manual_retry_cnt: "0",
73
+ thread_fbid: threadID
74
+ };
75
+
76
+ for (var i = 0; i < userID.length; i++) {
77
+ if (
78
+ utils.getType(userID[i]) !== "Number" &&
79
+ utils.getType(userID[i]) !== "String"
80
+ ) {
81
+ throw {
82
+ error:
83
+ "Elements of userID should be of type Number or String and not " +
84
+ utils.getType(userID[i]) +
85
+ "."
86
+ };
87
+ }
88
+
89
+ form["log_message_data[added_participants][" + i + "]"] =
90
+ "fbid:" + userID[i];
91
+ }
92
+
93
+ defaultFuncs
94
+ .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
95
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
96
+ .then(function(resData) {
97
+ if (!resData) {
98
+ throw { error: "Add to group failed." };
99
+ }
100
+ if (resData.error) {
101
+ throw resData;
102
+ }
103
+
104
+ return callback();
105
+ })
106
+ .catch(function(err) {
107
+ log.error("addUserToGroup", err);
108
+ return callback(err);
109
+ });
110
+
111
+ return returnPromise;
112
+ };
113
+ };
@@ -0,0 +1,79 @@
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 changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
8
+ if (utils.getType(threadID) !== "String") {
9
+ throw {error: "changeAdminStatus: threadID must be a string"};
10
+ }
11
+
12
+ if (utils.getType(adminIDs) === "String") {
13
+ adminIDs = [adminIDs];
14
+ }
15
+
16
+ if (utils.getType(adminIDs) !== "Array") {
17
+ throw {error: "changeAdminStatus: adminIDs must be an array or string"};
18
+ }
19
+
20
+ if (utils.getType(adminStatus) !== "Boolean") {
21
+ throw {error: "changeAdminStatus: adminStatus must be a string"};
22
+ }
23
+
24
+ var resolveFunc = function(){};
25
+ var rejectFunc = function(){};
26
+ var returnPromise = new Promise(function (resolve, reject) {
27
+ resolveFunc = resolve;
28
+ rejectFunc = reject;
29
+ });
30
+
31
+ if (!callback) {
32
+ callback = function (err) {
33
+ if (err) {
34
+ return rejectFunc(err);
35
+ }
36
+ resolveFunc();
37
+ };
38
+ }
39
+
40
+ if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
41
+ throw {error: "changeAdminStatus: callback is not a function"};
42
+ }
43
+
44
+ let form = {
45
+ "thread_fbid": threadID,
46
+ };
47
+
48
+ let i = 0;
49
+ for (let u of adminIDs) {
50
+ form[`admin_ids[${i++}]`] = u;
51
+ }
52
+ form["add"] = adminStatus;
53
+
54
+ defaultFuncs
55
+ .post("https://www.facebook.com/messaging/save_admins/?dpr=1", ctx.jar, form)
56
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
+ .then(function(resData) {
58
+ if (resData.error) {
59
+ switch (resData.error) {
60
+ case 1976004:
61
+ throw { error: "Cannot alter admin status: you are not an admin.", rawResponse: resData };
62
+ case 1357031:
63
+ throw { error: "Cannot alter admin status: this thread is not a group chat.", rawResponse: resData };
64
+ default:
65
+ throw { error: "Cannot alter admin status: unknown error.", rawResponse: resData };
66
+ }
67
+ }
68
+
69
+ callback();
70
+ })
71
+ .catch(function(err) {
72
+ log.error("changeAdminStatus", err);
73
+ return callback(err);
74
+ });
75
+
76
+ return returnPromise;
77
+ };
78
+ };
79
+
@@ -0,0 +1,55 @@
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) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc();
21
+ };
22
+ }
23
+
24
+ var form = {};
25
+
26
+ if (utils.getType(threadOrThreads) === "Array") {
27
+ for (var 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
+ };
@@ -0,0 +1,77 @@
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") {
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
+ var 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.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.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
+ };
@@ -0,0 +1,47 @@
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) {
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
+ };
@@ -0,0 +1,129 @@
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(
19
+ "https://upload.facebook.com/ajax/mercury/upload.php",
20
+ ctx.jar,
21
+ form,
22
+ {}
23
+ )
24
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
25
+ .then(function(resData) {
26
+ if (resData.error) {
27
+ throw resData;
28
+ }
29
+
30
+ return resData.payload.metadata[0];
31
+ })
32
+ );
33
+
34
+ // resolve all promises
35
+ bluebird
36
+ .all(uploads)
37
+ .then(function(resData) {
38
+ callback(null, resData);
39
+ })
40
+ .catch(function(err) {
41
+ log.error("handleUpload", err);
42
+ return callback(err);
43
+ });
44
+ }
45
+
46
+ return function changeGroupImage(image, threadID, callback) {
47
+ if (
48
+ !callback &&
49
+ (utils.getType(threadID) === "Function" ||
50
+ utils.getType(threadID) === "AsyncFunction")
51
+ ) {
52
+ throw { error: "please pass a threadID as a second argument." };
53
+ }
54
+
55
+ var resolveFunc = function(){};
56
+ var rejectFunc = function(){};
57
+ var returnPromise = new Promise(function (resolve, reject) {
58
+ resolveFunc = resolve;
59
+ rejectFunc = reject;
60
+ });
61
+
62
+ if (!callback) {
63
+ callback = function(err) {
64
+ if (err) {
65
+ return rejectFunc(err);
66
+ }
67
+ resolveFunc();
68
+ };
69
+ }
70
+
71
+ var messageAndOTID = utils.generateOfflineThreadingID();
72
+ var form = {
73
+ client: "mercury",
74
+ action_type: "ma-type:log-message",
75
+ author: "fbid:" + ctx.userID,
76
+ author_email: "",
77
+ ephemeral_ttl_mode: "0",
78
+ is_filtered_content: false,
79
+ is_filtered_content_account: false,
80
+ is_filtered_content_bh: false,
81
+ is_filtered_content_invalid_app: false,
82
+ is_filtered_content_quasar: false,
83
+ is_forward: false,
84
+ is_spoof_warning: false,
85
+ is_unread: false,
86
+ log_message_type: "log:thread-image",
87
+ manual_retry_cnt: "0",
88
+ message_id: messageAndOTID,
89
+ offline_threading_id: messageAndOTID,
90
+ source: "source:chat:web",
91
+ "source_tags[0]": "source:chat",
92
+ status: "0",
93
+ thread_fbid: threadID,
94
+ thread_id: "",
95
+ timestamp: Date.now(),
96
+ timestamp_absolute: "Today",
97
+ timestamp_relative: utils.generateTimestampRelative(),
98
+ timestamp_time_passed: "0"
99
+ };
100
+
101
+ handleUpload(image, function(err, payload) {
102
+ if (err) {
103
+ return callback(err);
104
+ }
105
+
106
+ form["thread_image_id"] = payload[0]["image_id"];
107
+ form["thread_id"] = threadID;
108
+
109
+ defaultFuncs
110
+ .post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
111
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
112
+ .then(function(resData) {
113
+ // check for errors here
114
+
115
+ if (resData.error) {
116
+ throw resData;
117
+ }
118
+
119
+ return callback();
120
+ })
121
+ .catch(function(err) {
122
+ log.error("changeGroupImage", err);
123
+ return callback(err);
124
+ });
125
+ });
126
+
127
+ return returnPromise;
128
+ };
129
+ };
@@ -0,0 +1,59 @@
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) {
17
+ return rejectFunc(err);
18
+ }
19
+ resolveFunc();
20
+ };
21
+ }
22
+
23
+ var 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
+ };
@@ -0,0 +1,71 @@
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) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc(err);
21
+ };
22
+ }
23
+
24
+ var validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
25
+ var colorList = Object.keys(api.threadColors).map(function(name) {
26
+ return api.threadColors[name];
27
+ });
28
+ if (!colorList.includes(validatedColor)) {
29
+ throw {
30
+ error:
31
+ "The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values."
32
+ };
33
+ }
34
+
35
+ var form = {
36
+ dpr: 1,
37
+ queries: JSON.stringify({
38
+ o0: {
39
+ //This doc_id is valid as of January 31, 2020
40
+ doc_id: "1727493033983591",
41
+ query_params: {
42
+ data: {
43
+ actor_id: ctx.userID,
44
+ client_mutation_id: "0",
45
+ source: "SETTINGS",
46
+ theme_id: validatedColor,
47
+ thread_id: threadID
48
+ }
49
+ }
50
+ }
51
+ })
52
+ };
53
+
54
+ defaultFuncs
55
+ .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
56
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
+ .then(function(resData) {
58
+ if (resData[resData.length - 1].error_results > 0) {
59
+ throw resData[0].o0.errors;
60
+ }
61
+
62
+ return callback();
63
+ })
64
+ .catch(function(err) {
65
+ log.error("changeThreadColor", err);
66
+ return callback(err);
67
+ });
68
+
69
+ return returnPromise;
70
+ };
71
+ };
@@ -0,0 +1,55 @@
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) {
18
+ return rejectFunc(err);
19
+ }
20
+ resolveFunc();
21
+ };
22
+ }
23
+ var 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
+ };