node-ainzfb-new 1.6.30-test → 1.6.2210-test
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +1 -1
- package/package.json +3 -3
- package/src/addExternalModule.js +6 -13
- package/src/addUserToGroup.js +12 -35
- package/src/changeAdminStatus.js +16 -32
- package/src/changeArchivedStatus.js +9 -15
- package/src/changeBio.js +8 -12
- package/src/changeBlockedStatus.js +8 -14
- package/src/changeGroupImage.js +13 -27
- package/src/changeNickname.js +10 -19
- package/src/changeThreadColor.js +10 -15
- package/src/changeThreadEmoji.js +9 -17
- package/src/createNewGroup.js +10 -18
- package/src/createPoll.js +11 -16
- package/src/deleteMessage.js +10 -16
- package/src/deleteThread.js +10 -16
- package/src/forwardAttachment.js +9 -14
- package/src/getCurrentUserID.js +1 -1
- package/src/getEmojiUrl.js +2 -3
- package/src/getFriendsList.js +10 -18
- package/src/getMessage.js +48 -52
- package/src/getThreadHistory.js +59 -156
- package/src/getThreadHistoryDeprecated.js +15 -26
- package/src/getThreadInfoDeprecated.js +13 -25
- package/src/getThreadList.js +53 -112
- package/src/getThreadListDeprecated.js +12 -30
- package/src/getThreadPictures.js +13 -25
- package/src/getUserID.js +7 -8
- package/src/getUserInfo.js +9 -12
- package/src/handleFriendRequest.js +9 -10
- package/src/handleMessageRequest.js +10 -16
- package/src/httpGet.js +13 -18
- package/src/httpPost.js +13 -18
- package/src/httpPostFormData.js +9 -14
- package/src/listenMqtt.js +571 -1218
- package/src/logout.js +13 -18
- package/src/markAsDelivered.js +10 -16
- package/src/markAsRead.js +24 -36
- package/src/markAsReadAll.js +10 -14
- package/src/markAsSeen.js +11 -18
- package/src/muteThread.js +8 -12
- package/src/removeUserFromGroup.js +10 -33
- package/src/resolvePhotoUrl.js +6 -8
- package/src/searchForThread.js +8 -13
- package/src/sendMessage.js +78 -172
- package/src/sendTypingIndicator.js +14 -29
- package/src/setMessageReaction.js +8 -13
- package/src/setPostReaction.js +95 -97
- package/src/setTitle.js +12 -18
- package/src/threadColors.js +17 -17
- package/src/unfriend.js +9 -14
- package/src/unsendMessage.js +7 -7
- package/utils.js +10 -9
- package/src/changeAvt.js +0 -91
package/index.js
CHANGED
@@ -997,7 +997,7 @@ async function loginHelper(appState, email, password, globalOptions, callback, p
|
|
997
997
|
Fetch('https://raw.githubusercontent.com/amogusdevlol/node-ainzfb/main/package.json').then(async(res) => {
|
998
998
|
const localbrand = JSON.parse(readFileSync('./node_modules/node-ainzfb-new/package.json')).version;
|
999
999
|
if (Number(localbrand.replace(/\./g, "")) < Number(JSON.parse(res.body.toString()).version.replace(/\./g, ""))) {
|
1000
|
-
log.warn("[ FCA-SUS ] •", getText.gettext(Language.NewVersionFound, JSON.parse(readFileSync('./node_modules/node-ainzfb/package.json')).version, JSON.parse(res.body.toString()).version));
|
1000
|
+
log.warn("[ FCA-SUS ] •", getText.gettext(Language.NewVersionFound, JSON.parse(readFileSync('./node_modules/node-ainzfb-new/package.json')).version, JSON.parse(res.body.toString()).version));
|
1001
1001
|
log.warn("[ FCA-SUS ] •", Language.AutoUpdate);
|
1002
1002
|
try {
|
1003
1003
|
execSync('npm install node-ainzfb-new@latest', { stdio: 'inherit' });
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "node-ainzfb-new",
|
3
|
-
"version": "1.6.
|
3
|
+
"version": "1.6.2210-test",
|
4
4
|
"description": "A Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated after April 30th 2015.",
|
5
5
|
"scripts": {
|
6
6
|
"test": "mocha",
|
@@ -37,10 +37,10 @@
|
|
37
37
|
"lodash": "",
|
38
38
|
"mqtt": "^4.3.7",
|
39
39
|
"node-superfetch": "^0.2.3",
|
40
|
-
"npmlog": "
|
40
|
+
"npmlog": "^1.2.0",
|
41
41
|
"path": "latest",
|
42
42
|
"pretty-ms": "latest",
|
43
|
-
"request": "
|
43
|
+
"request": "^2.53.0",
|
44
44
|
"semver": "latest",
|
45
45
|
"sus-support": "git+https://github.com/amogusdevlol/sus-support.git",
|
46
46
|
"websocket-stream": "latest"
|
package/src/addExternalModule.js
CHANGED
@@ -2,22 +2,15 @@
|
|
2
2
|
|
3
3
|
const utils = require("../utils");
|
4
4
|
|
5
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
6
6
|
return function addExternalModule(moduleObj) {
|
7
7
|
if (utils.getType(moduleObj) == "Object") {
|
8
8
|
for (let apiName in moduleObj) {
|
9
|
-
if (utils.getType(moduleObj[apiName]) == "Function")
|
10
|
-
|
11
|
-
|
12
|
-
throw new Error(
|
13
|
-
`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(
|
14
|
-
moduleObj[apiName]
|
15
|
-
)}!`
|
16
|
-
);
|
9
|
+
if (utils.getType(moduleObj[apiName]) == "Function") api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
|
10
|
+
else throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
|
11
|
+
|
17
12
|
}
|
18
|
-
}
|
19
|
-
|
20
|
-
`moduleObj must be an object, not ${utils.getType(moduleObj)}!`
|
21
|
-
);
|
13
|
+
}
|
14
|
+
else throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
|
22
15
|
};
|
23
16
|
};
|
package/src/addUserToGroup.js
CHANGED
@@ -3,39 +3,25 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function addUserToGroup(userID, threadID, callback) {
|
8
|
-
var resolveFunc = function() {};
|
9
|
-
var rejectFunc = function() {};
|
10
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
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." };
|
15
|
+
if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
21
16
|
|
22
17
|
if (!callback) {
|
23
|
-
callback = function(err) {
|
18
|
+
callback = function (err) {
|
24
19
|
if (err) return rejectFunc(err);
|
25
20
|
resolveFunc();
|
26
21
|
};
|
27
22
|
}
|
28
23
|
|
29
|
-
if (
|
30
|
-
utils.getType(threadID) !== "Number" &&
|
31
|
-
utils.getType(threadID) !== "String"
|
32
|
-
)
|
33
|
-
throw {
|
34
|
-
error:
|
35
|
-
"ThreadID should be of type Number or String and not " +
|
36
|
-
utils.getType(threadID) +
|
37
|
-
"."
|
38
|
-
};
|
24
|
+
if (utils.getType(threadID) !== "Number" && utils.getType(threadID) !== "String") throw { error: "ThreadID should be of type Number or String and not " + utils.getType(threadID) + "." };
|
39
25
|
|
40
26
|
if (utils.getType(userID) !== "Array") userID = [userID];
|
41
27
|
|
@@ -68,30 +54,21 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
68
54
|
};
|
69
55
|
|
70
56
|
for (var i = 0; i < userID.length; i++) {
|
71
|
-
if (
|
72
|
-
|
73
|
-
utils.getType(userID[i]) !== "String"
|
74
|
-
)
|
75
|
-
throw {
|
76
|
-
error:
|
77
|
-
"Elements of userID should be of type Number or String and not " +
|
78
|
-
utils.getType(userID[i]) +
|
79
|
-
"."
|
80
|
-
};
|
81
|
-
form["log_message_data[added_participants][" + i + "]"] =
|
82
|
-
"fbid:" + userID[i];
|
57
|
+
if (utils.getType(userID[i]) !== "Number" && utils.getType(userID[i]) !== "String") throw { error: "Elements of userID should be of type Number or String and not " + utils.getType(userID[i]) + "." };
|
58
|
+
form["log_message_data[added_participants][" + i + "]"] = "fbid:" + userID[i];
|
83
59
|
}
|
84
60
|
|
85
61
|
defaultFuncs
|
86
62
|
.post("https://www.facebook.com/messaging/send/", ctx.jar, form)
|
87
63
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
88
|
-
.then(function(resData) {
|
64
|
+
.then(function (resData) {
|
89
65
|
if (!resData) throw { error: "Add to group failed." };
|
90
66
|
if (resData.error) throw resData;
|
91
67
|
|
68
|
+
|
92
69
|
return callback();
|
93
70
|
})
|
94
|
-
.catch(function(err) {
|
71
|
+
.catch(function (err) {
|
95
72
|
log.error("addUserToGroup", err);
|
96
73
|
return callback(err);
|
97
74
|
});
|
package/src/changeAdminStatus.js
CHANGED
@@ -6,7 +6,7 @@ const log = require("npmlog");
|
|
6
6
|
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
|
8
8
|
if (utils.getType(threadID) !== "String") {
|
9
|
-
throw {
|
9
|
+
throw {error: "changeAdminStatus: threadID must be a string"};
|
10
10
|
}
|
11
11
|
|
12
12
|
if (utils.getType(adminIDs) === "String") {
|
@@ -14,22 +14,22 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
14
14
|
}
|
15
15
|
|
16
16
|
if (utils.getType(adminIDs) !== "Array") {
|
17
|
-
throw {
|
17
|
+
throw {error: "changeAdminStatus: adminIDs must be an array or string"};
|
18
18
|
}
|
19
19
|
|
20
20
|
if (utils.getType(adminStatus) !== "Boolean") {
|
21
|
-
throw {
|
21
|
+
throw {error: "changeAdminStatus: adminStatus must be a string"};
|
22
22
|
}
|
23
23
|
|
24
|
-
var resolveFunc = function()
|
25
|
-
var rejectFunc = function()
|
26
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
24
|
+
var resolveFunc = function(){};
|
25
|
+
var rejectFunc = function(){};
|
26
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
27
27
|
resolveFunc = resolve;
|
28
28
|
rejectFunc = reject;
|
29
29
|
});
|
30
30
|
|
31
31
|
if (!callback) {
|
32
|
-
callback = function(err) {
|
32
|
+
callback = function (err) {
|
33
33
|
if (err) {
|
34
34
|
return rejectFunc(err);
|
35
35
|
}
|
@@ -37,15 +37,12 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
37
37
|
};
|
38
38
|
}
|
39
39
|
|
40
|
-
if (
|
41
|
-
|
42
|
-
utils.getType(callback) !== "AsyncFunction"
|
43
|
-
) {
|
44
|
-
throw { error: "changeAdminStatus: callback is not a function" };
|
40
|
+
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
41
|
+
throw {error: "changeAdminStatus: callback is not a function"};
|
45
42
|
}
|
46
43
|
|
47
44
|
let form = {
|
48
|
-
thread_fbid: threadID
|
45
|
+
"thread_fbid": threadID,
|
49
46
|
};
|
50
47
|
|
51
48
|
let i = 0;
|
@@ -55,31 +52,17 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
55
52
|
form["add"] = adminStatus;
|
56
53
|
|
57
54
|
defaultFuncs
|
58
|
-
.post(
|
59
|
-
"https://www.facebook.com/messaging/save_admins/?dpr=1",
|
60
|
-
ctx.jar,
|
61
|
-
form
|
62
|
-
)
|
55
|
+
.post("https://www.facebook.com/messaging/save_admins/?dpr=1", ctx.jar, form)
|
63
56
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
64
57
|
.then(function(resData) {
|
65
58
|
if (resData.error) {
|
66
59
|
switch (resData.error) {
|
67
60
|
case 1976004:
|
68
|
-
throw {
|
69
|
-
error: "Cannot alter admin status: you are not an admin.",
|
70
|
-
rawResponse: resData
|
71
|
-
};
|
61
|
+
throw { error: "Cannot alter admin status: you are not an admin.", rawResponse: resData };
|
72
62
|
case 1357031:
|
73
|
-
throw {
|
74
|
-
error:
|
75
|
-
"Cannot alter admin status: this thread is not a group chat.",
|
76
|
-
rawResponse: resData
|
77
|
-
};
|
63
|
+
throw { error: "Cannot alter admin status: this thread is not a group chat.", rawResponse: resData };
|
78
64
|
default:
|
79
|
-
throw {
|
80
|
-
error: "Cannot alter admin status: unknown error.",
|
81
|
-
rawResponse: resData
|
82
|
-
};
|
65
|
+
throw { error: "Cannot alter admin status: unknown error.", rawResponse: resData };
|
83
66
|
}
|
84
67
|
}
|
85
68
|
|
@@ -89,7 +72,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
89
72
|
log.error("changeAdminStatus", err);
|
90
73
|
return callback(err);
|
91
74
|
});
|
92
|
-
|
75
|
+
|
93
76
|
return returnPromise;
|
94
77
|
};
|
95
78
|
};
|
79
|
+
|
@@ -3,17 +3,17 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function changeArchivedStatus(threadOrThreads, archive, callback) {
|
8
|
-
var resolveFunc = function() {};
|
9
|
-
var rejectFunc = function() {};
|
10
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
|
15
15
|
if (!callback) {
|
16
|
-
callback = function(err) {
|
16
|
+
callback = function (err) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
resolveFunc();
|
19
19
|
};
|
@@ -21,23 +21,17 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
21
21
|
|
22
22
|
var form = {};
|
23
23
|
|
24
|
-
if (utils.getType(threadOrThreads) === "Array")
|
25
|
-
for (var i = 0; i < threadOrThreads.length; i++)
|
26
|
-
form["ids[" + threadOrThreads[i] + "]"] = archive;
|
24
|
+
if (utils.getType(threadOrThreads) === "Array") for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + threadOrThreads[i] + "]"] = archive;
|
27
25
|
else form["ids[" + threadOrThreads + "]"] = archive;
|
28
26
|
|
29
27
|
defaultFuncs
|
30
|
-
.post(
|
31
|
-
"https://www.facebook.com/ajax/mercury/change_archived_status.php",
|
32
|
-
ctx.jar,
|
33
|
-
form
|
34
|
-
)
|
28
|
+
.post("https://www.facebook.com/ajax/mercury/change_archived_status.php", ctx.jar, form)
|
35
29
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
36
|
-
.then(function(resData) {
|
30
|
+
.then(function (resData) {
|
37
31
|
if (resData.error) throw resData;
|
38
32
|
return callback();
|
39
33
|
})
|
40
|
-
.catch(function(err) {
|
34
|
+
.catch(function (err) {
|
41
35
|
log.error("changeArchivedStatus", err);
|
42
36
|
return callback(err);
|
43
37
|
});
|
package/src/changeBio.js
CHANGED
@@ -3,23 +3,19 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function changeBio(bio, publish, callback) {
|
8
|
-
var resolveFunc = function() {};
|
9
|
-
var rejectFunc = function() {};
|
10
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
|
15
15
|
if (!callback) {
|
16
|
-
if (
|
17
|
-
utils.getType(publish) == "Function" ||
|
18
|
-
utils.getType(publish) == "AsyncFunction"
|
19
|
-
)
|
20
|
-
callback = publish;
|
16
|
+
if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") callback = publish;
|
21
17
|
else {
|
22
|
-
callback = function(err) {
|
18
|
+
callback = function (err) {
|
23
19
|
if (err) return rejectFunc(err);
|
24
20
|
resolveFunc();
|
25
21
|
};
|
@@ -54,12 +50,12 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
54
50
|
defaultFuncs
|
55
51
|
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
56
52
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
57
|
-
.then(function(resData) {
|
53
|
+
.then(function (resData) {
|
58
54
|
if (resData.errors) throw resData;
|
59
55
|
|
60
56
|
return callback();
|
61
57
|
})
|
62
|
-
.catch(function(err) {
|
58
|
+
.catch(function (err) {
|
63
59
|
log.error("changeBio", err);
|
64
60
|
return callback(err);
|
65
61
|
});
|
@@ -3,37 +3,31 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function changeBlockedStatus(userID, block, callback) {
|
8
|
-
var resolveFunc = function() {};
|
9
|
-
var rejectFunc = function() {};
|
10
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
|
15
15
|
if (!callback) {
|
16
|
-
callback = function(err) {
|
16
|
+
callback = function (err) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
resolveFunc();
|
19
19
|
};
|
20
20
|
}
|
21
21
|
|
22
22
|
defaultFuncs
|
23
|
-
.post(
|
24
|
-
`https://www.facebook.com/messaging/${
|
25
|
-
block ? "" : "un"
|
26
|
-
}block_messages/`,
|
27
|
-
ctx.jar,
|
28
|
-
{ fbid: userID }
|
29
|
-
)
|
23
|
+
.post(`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`, ctx.jar, { fbid: userID })
|
30
24
|
.then(utils.saveCookies(ctx.jar))
|
31
25
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
32
|
-
.then(function(resData) {
|
26
|
+
.then(function (resData) {
|
33
27
|
if (resData.error) throw resData;
|
34
28
|
return callback();
|
35
29
|
})
|
36
|
-
.catch(function(err) {
|
30
|
+
.catch(function (err) {
|
37
31
|
log.error("changeBlockedStatus", err);
|
38
32
|
return callback(err);
|
39
33
|
});
|
package/src/changeGroupImage.js
CHANGED
@@ -4,7 +4,7 @@ var utils = require("../utils");
|
|
4
4
|
var log = require("npmlog");
|
5
5
|
var bluebird = require("bluebird");
|
6
6
|
|
7
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
8
8
|
function handleUpload(image, callback) {
|
9
9
|
var uploads = [];
|
10
10
|
|
@@ -15,14 +15,9 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
15
15
|
|
16
16
|
uploads.push(
|
17
17
|
defaultFuncs
|
18
|
-
.postFormData(
|
19
|
-
"https://upload.facebook.com/ajax/mercury/upload.php",
|
20
|
-
ctx.jar,
|
21
|
-
form,
|
22
|
-
{}
|
23
|
-
)
|
18
|
+
.postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
|
24
19
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
25
|
-
.then(function(resData) {
|
20
|
+
.then(function (resData) {
|
26
21
|
if (resData.error) throw resData;
|
27
22
|
|
28
23
|
return resData.payload.metadata[0];
|
@@ -33,29 +28,24 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
33
28
|
bluebird
|
34
29
|
.all(uploads)
|
35
30
|
.then(resData => callback(null, resData))
|
36
|
-
.catch(function(err) {
|
31
|
+
.catch(function (err) {
|
37
32
|
log.error("handleUpload", err);
|
38
33
|
return callback(err);
|
39
34
|
});
|
40
35
|
}
|
41
36
|
|
42
37
|
return function changeGroupImage(image, threadID, callback) {
|
43
|
-
if (
|
44
|
-
!callback &&
|
45
|
-
(utils.getType(threadID) === "Function" ||
|
46
|
-
utils.getType(threadID) === "AsyncFunction")
|
47
|
-
)
|
48
|
-
throw { error: "please pass a threadID as a second argument." };
|
38
|
+
if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
49
39
|
|
50
|
-
var resolveFunc = function() {};
|
51
|
-
var rejectFunc = function() {};
|
52
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
40
|
+
var resolveFunc = function () { };
|
41
|
+
var rejectFunc = function () { };
|
42
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
53
43
|
resolveFunc = resolve;
|
54
44
|
rejectFunc = reject;
|
55
45
|
});
|
56
46
|
|
57
47
|
if (!callback) {
|
58
|
-
callback = function(err) {
|
48
|
+
callback = function (err) {
|
59
49
|
if (err) return rejectFunc(err);
|
60
50
|
resolveFunc();
|
61
51
|
};
|
@@ -91,25 +81,21 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
91
81
|
timestamp_time_passed: "0"
|
92
82
|
};
|
93
83
|
|
94
|
-
handleUpload(image, function(err, payload) {
|
84
|
+
handleUpload(image, function (err, payload) {
|
95
85
|
if (err) return callback(err);
|
96
86
|
|
97
87
|
form["thread_image_id"] = payload[0]["image_id"];
|
98
88
|
form["thread_id"] = threadID;
|
99
89
|
|
100
90
|
defaultFuncs
|
101
|
-
.post(
|
102
|
-
"https://www.facebook.com/messaging/set_thread_image/",
|
103
|
-
ctx.jar,
|
104
|
-
form
|
105
|
-
)
|
91
|
+
.post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
|
106
92
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
107
|
-
.then(function(resData) {
|
93
|
+
.then(function (resData) {
|
108
94
|
// check for errors here
|
109
95
|
if (resData.error) throw resData;
|
110
96
|
return callback();
|
111
97
|
})
|
112
|
-
.catch(function(err) {
|
98
|
+
.catch(function (err) {
|
113
99
|
log.error("changeGroupImage", err);
|
114
100
|
return callback(err);
|
115
101
|
});
|
package/src/changeNickname.js
CHANGED
@@ -3,16 +3,16 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function changeNickname(nickname, threadID, participantID, callback) {
|
8
|
-
var resolveFunc = function() {};
|
9
|
-
var rejectFunc = function() {};
|
10
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
if (!callback) {
|
15
|
-
callback = function(err) {
|
15
|
+
callback = function (err) {
|
16
16
|
if (err) return rejectFunc(err);
|
17
17
|
resolveFunc();
|
18
18
|
};
|
@@ -25,26 +25,17 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
25
25
|
};
|
26
26
|
|
27
27
|
defaultFuncs
|
28
|
-
.post(
|
29
|
-
"https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",
|
30
|
-
ctx.jar,
|
31
|
-
form
|
32
|
-
)
|
28
|
+
.post("https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1", ctx.jar, form)
|
33
29
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
34
|
-
.then(function(resData) {
|
35
|
-
if (resData.error === 1545014)
|
36
|
-
|
37
|
-
if (resData.error === 1357031)
|
38
|
-
throw {
|
39
|
-
error:
|
40
|
-
"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."
|
41
|
-
};
|
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." };
|
42
33
|
|
43
34
|
if (resData.error) throw resData;
|
44
35
|
|
45
36
|
return callback();
|
46
37
|
})
|
47
|
-
.catch(function(err) {
|
38
|
+
.catch(function (err) {
|
48
39
|
log.error("changeNickname", err);
|
49
40
|
return callback(err);
|
50
41
|
});
|
package/src/changeThreadColor.js
CHANGED
@@ -3,31 +3,27 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function changeThreadColor(color, threadID, callback) {
|
8
|
-
var resolveFunc = function() {};
|
9
|
-
var rejectFunc = function() {};
|
10
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
|
15
15
|
if (!callback) {
|
16
|
-
callback = function(err) {
|
16
|
+
callback = function (err) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
resolveFunc(err);
|
19
19
|
};
|
20
20
|
}
|
21
21
|
|
22
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) {
|
23
|
+
var colorList = Object.keys(api.threadColors).map(function (name) {
|
24
24
|
return api.threadColors[name];
|
25
25
|
});
|
26
|
-
if (!colorList.includes(validatedColor))
|
27
|
-
throw {
|
28
|
-
error:
|
29
|
-
"The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values."
|
30
|
-
};
|
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." };
|
31
27
|
|
32
28
|
var form = {
|
33
29
|
dpr: 1,
|
@@ -51,13 +47,12 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
51
47
|
defaultFuncs
|
52
48
|
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
53
49
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
54
|
-
.then(function(resData) {
|
55
|
-
if (resData[resData.length - 1].error_results > 0)
|
56
|
-
throw resData[0].o0.errors;
|
50
|
+
.then(function (resData) {
|
51
|
+
if (resData[resData.length - 1].error_results > 0) throw resData[0].o0.errors;
|
57
52
|
|
58
53
|
return callback();
|
59
54
|
})
|
60
|
-
.catch(function(err) {
|
55
|
+
.catch(function (err) {
|
61
56
|
log.error("changeThreadColor", err);
|
62
57
|
return callback(err);
|
63
58
|
});
|
package/src/changeThreadEmoji.js
CHANGED
@@ -3,17 +3,17 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function changeThreadEmoji(emoji, threadID, callback) {
|
8
|
-
var resolveFunc = function() {};
|
9
|
-
var rejectFunc = function() {};
|
10
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
13
13
|
});
|
14
14
|
|
15
15
|
if (!callback) {
|
16
|
-
callback = function(err) {
|
16
|
+
callback = function (err) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
resolveFunc();
|
19
19
|
};
|
@@ -24,23 +24,15 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
24
24
|
};
|
25
25
|
|
26
26
|
defaultFuncs
|
27
|
-
.post(
|
28
|
-
"https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg",
|
29
|
-
ctx.jar,
|
30
|
-
form
|
31
|
-
)
|
27
|
+
.post("https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg", ctx.jar, form)
|
32
28
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
33
|
-
.then(function(resData) {
|
34
|
-
if (resData.error === 1357031)
|
35
|
-
throw {
|
36
|
-
error:
|
37
|
-
"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."
|
38
|
-
};
|
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." };
|
39
31
|
if (resData.error) throw resData;
|
40
32
|
|
41
33
|
return callback();
|
42
34
|
})
|
43
|
-
.catch(function(err) {
|
35
|
+
.catch(function (err) {
|
44
36
|
log.error("changeThreadEmoji", err);
|
45
37
|
return callback(err);
|
46
38
|
});
|