alicezetion 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/replit/__replit_disk_meta.json +1 -1
- package/.cache/replit/nix/env.json +1 -1
- package/index.js +601 -386
- package/leiamnash/addExternalModule.js +19 -16
- package/leiamnash/addUserToGroup.js +113 -79
- package/leiamnash/changeAdminStatus.js +79 -79
- package/leiamnash/changeArchivedStatus.js +55 -41
- package/leiamnash/changeBio.js +77 -65
- package/leiamnash/changeBlockedStatus.js +47 -36
- package/leiamnash/changeGroupImage.js +129 -106
- package/leiamnash/changeNickname.js +59 -45
- package/leiamnash/changeThreadColor.js +71 -62
- package/leiamnash/changeThreadEmoji.js +55 -42
- package/leiamnash/chat.js +459 -374
- package/leiamnash/createNewGroup.js +86 -70
- package/leiamnash/createPoll.js +71 -60
- package/leiamnash/deleteMessage.js +56 -45
- package/leiamnash/deleteThread.js +56 -43
- package/leiamnash/forwardAttachment.js +60 -48
- package/leiamnash/getCurrentUserID.js +7 -7
- package/leiamnash/getEmojiUrl.js +29 -27
- package/leiamnash/getFriendsList.js +84 -73
- package/leiamnash/getThreadHistory.js +645 -537
- package/leiamnash/getThreadHistoryDeprecated.js +93 -0
- package/leiamnash/getThreadInfo.js +206 -425
- package/leiamnash/getThreadInfoDeprecated.js +80 -0
- package/leiamnash/getThreadList.js +238 -213
- package/leiamnash/getThreadListDeprecated.js +75 -0
- package/leiamnash/getThreadPictures.js +79 -59
- package/leiamnash/getUserID.js +66 -62
- package/leiamnash/getUserInfo.js +72 -113
- package/leiamnash/handleFriendRequest.js +61 -46
- package/leiamnash/handleMessageRequest.js +65 -49
- package/leiamnash/httpGet.js +52 -49
- package/leiamnash/httpPost.js +52 -48
- package/leiamnash/listenMqtt.js +789 -787
- package/leiamnash/logout.js +75 -68
- package/leiamnash/markAsDelivered.js +58 -48
- package/leiamnash/markAsRead.js +80 -70
- package/leiamnash/markAsReadAll.js +49 -42
- package/leiamnash/markAsSeen.js +59 -51
- package/leiamnash/muteThread.js +52 -47
- package/leiamnash/removeUserFromGroup.js +79 -49
- package/leiamnash/resolvePhotoUrl.js +45 -37
- package/leiamnash/searchForThread.js +53 -43
- package/leiamnash/sendTypingIndicator.js +103 -80
- package/leiamnash/setMessageReaction.js +117 -109
- package/leiamnash/setPostReaction.js +76 -102
- package/leiamnash/setTitle.js +86 -74
- package/leiamnash/threadColors.js +57 -39
- package/leiamnash/unfriend.js +52 -43
- package/leiamnash/unsendMessage.js +49 -40
- package/package.json +72 -90
- package/utils.js +1356 -1684
- package/Extra/Database/index.js +0 -469
- package/Extra/ExtraAddons.js +0 -82
- package/Extra/ExtraFindUID.js +0 -62
- package/Extra/ExtraGetThread.js +0 -340
- package/Extra/ExtraScreenShot.js +0 -430
- package/Extra/ExtraUptimeRobot.js +0 -38
- package/Extra/Html/Classic/script.js +0 -119
- package/Extra/Html/Classic/style.css +0 -8
- package/Extra/Security/AES_256_GCM/index.js +0 -0
- package/Extra/Security/Base/Step_1.js +0 -6
- package/Extra/Security/Base/Step_2.js +0 -22
- package/Extra/Security/Base/Step_3.js +0 -22
- package/Extra/Security/Base/index.js +0 -174
- package/Extra/Security/Index.js +0 -5
- package/Extra/Security/Step_1.js +0 -6
- package/Extra/Security/Step_2.js +0 -22
- package/Extra/Security/Step_3.js +0 -22
- package/Extra/Src/Change_Environment.js +0 -24
- package/Extra/Src/Check_Update.js +0 -67
- package/Extra/Src/History.js +0 -115
- package/Extra/Src/Instant_Update.js +0 -65
- package/Extra/Src/Last-Run.js +0 -65
- package/Extra/Src/Premium.js +0 -81
- package/Extra/Src/Release_Memory.js +0 -41
- package/Extra/Src/Websocket.js +0 -213
- package/Extra/Src/image/checkmate.jpg +0 -0
- package/Extra/Src/uuid.js +0 -137
- package/Func/AcceptAgreement.js +0 -31
- package/Func/ClearCache.js +0 -64
- package/Func/ReportV1.js +0 -54
- package/Language/index.json +0 -217
- package/Main.js +0 -1270
- package/broadcast.js +0 -40
- package/leiamnash/Dev_Horizon_Data.js +0 -125
- package/leiamnash/Premium.js +0 -25
- package/leiamnash/Screenshot.js +0 -83
- package/leiamnash/changeAvt.js +0 -85
- package/leiamnash/getAccessToken.js +0 -28
- package/leiamnash/getMessage.js +0 -80
- package/leiamnash/getThreadMain.js +0 -220
- package/leiamnash/getUID.js +0 -59
- package/leiamnash/getUserInfoMain.js +0 -65
- package/leiamnash/getUserInfoV2.js +0 -32
- package/leiamnash/getUserInfoV3.js +0 -63
- package/leiamnash/getUserInfoV4.js +0 -55
- package/leiamnash/getUserInfoV5.js +0 -61
- package/leiamnash/httpPostFormData.js +0 -41
- package/leiamnash/sendMessage.js +0 -379
- package/logger.js +0 -66
@@ -1,36 +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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
+
};
|
@@ -1,106 +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
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
if (
|
48
|
-
callback
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
var
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
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
|
+
};
|
@@ -1,45 +1,59 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var utils = require("../utils");
|
4
|
-
var log = require("npmlog");
|
5
|
-
|
6
|
-
module.exports = function
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
}
|
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
|
+
};
|
@@ -1,62 +1,71 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var utils = require("../utils");
|
4
|
-
var log = require("npmlog");
|
5
|
-
|
6
|
-
module.exports = function
|
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
|
17
|
-
if (err)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
.
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
+
};
|
@@ -1,42 +1,55 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var utils = require("../utils");
|
4
|
-
var log = require("npmlog");
|
5
|
-
|
6
|
-
module.exports = function
|
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
|
17
|
-
if (err)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
+
};
|