node-ainzfb-new 1.6.32-stable → 1.6.2431-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 -4
- 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/changeAvt.js +34 -40
- 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 +19 -18
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.2431-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",
|
@@ -36,11 +36,10 @@
|
|
36
36
|
"is-hexcolor": "^1.0.0",
|
37
37
|
"lodash": "",
|
38
38
|
"mqtt": "^4.3.7",
|
39
|
-
"
|
40
|
-
"npmlog": "latest",
|
39
|
+
"npmlog": "^1.2.0",
|
41
40
|
"path": "latest",
|
42
41
|
"pretty-ms": "latest",
|
43
|
-
"request": "
|
42
|
+
"request": "^2.53.0",
|
44
43
|
"semver": "latest",
|
45
44
|
"sus-support": "git+https://github.com/amogusdevlol/sus-support.git",
|
46
45
|
"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/changeAvt.js
CHANGED
@@ -10,52 +10,45 @@ var log = require("npmlog");
|
|
10
10
|
* @returns The JSON.parse(Data.split("for (;;);")[1]); is returning the following:
|
11
11
|
* {"__ar":1,"payload":null,"jsmods":{"require":[["ImageUploader","uploadPhoto",[{"__m":"__elem_0"},{"__m":"__elem_1"},{"__m":"__elem_2"},{"__m":"__
|
12
12
|
*/
|
13
|
-
async function postImage(Api,
|
14
|
-
var Data = await Api.httpPostFormData(
|
15
|
-
`https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`,
|
16
|
-
form
|
17
|
-
);
|
13
|
+
async function postImage(Api,BotID,form) {
|
14
|
+
var Data = await Api.httpPostFormData(`https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`, form);
|
18
15
|
return JSON.parse(Data.split("for (;;);")[1]);
|
19
16
|
}
|
20
17
|
|
21
|
-
module.exports = function
|
22
|
-
|
18
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
19
|
+
/* Changing the profile picture of the bot. */
|
23
20
|
return function changeAvt(link, caption, callback) {
|
24
|
-
var resolveFunc = function
|
25
|
-
var rejectFunc = function
|
26
|
-
var returnPromise = new Promise(function
|
21
|
+
var resolveFunc = function() {};
|
22
|
+
var rejectFunc = function() {};
|
23
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
27
24
|
resolveFunc = resolve;
|
28
25
|
rejectFunc = reject;
|
29
26
|
});
|
30
27
|
|
31
28
|
if (!callback) {
|
32
|
-
callback = function
|
29
|
+
callback = function(err, data) {
|
33
30
|
if (err) return rejectFunc(err);
|
34
31
|
resolveFunc(data);
|
35
32
|
};
|
36
33
|
}
|
37
34
|
try {
|
38
|
-
var Fetch = require(
|
39
|
-
Fetch.get(link, { responseType: "stream" }).then(data => {
|
35
|
+
var Fetch = require('axios')
|
36
|
+
Fetch.get(link, { responseType: "stream" }).then(data => {
|
40
37
|
postImage(api, ctx.userID, { file: data.data }).then(data => {
|
41
|
-
if (data.error)
|
42
|
-
throw new Error({
|
43
|
-
error: data.error,
|
44
|
-
des: data.error.errorDescription
|
45
|
-
});
|
38
|
+
if (data.error) throw new Error({ error: data.error, des: data.error.errorDescription });
|
46
39
|
var form = {
|
47
40
|
av: ctx.userID,
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
41
|
+
fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
|
42
|
+
fb_api_caller_class: "RelayModern",
|
43
|
+
doc_id: "5066134240065849",
|
44
|
+
variables: JSON.stringify({
|
45
|
+
input: {
|
46
|
+
caption: (caption || ""),
|
47
|
+
existing_photo_id: data.payload.fbid,
|
48
|
+
expiration_time: null,
|
49
|
+
profile_id: ctx.userID,
|
50
|
+
profile_pic_method: "EXISTING",
|
51
|
+
profile_pic_source: "TIMELINE",
|
59
52
|
scaled_crop_rect: {
|
60
53
|
height: 1,
|
61
54
|
width: 1,
|
@@ -65,27 +58,28 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
65
58
|
skip_cropping: true,
|
66
59
|
actor_id: ctx.userID,
|
67
60
|
client_mutation_id: Math.round(Math.random() * 19).toString()
|
68
|
-
|
61
|
+
},
|
69
62
|
isPage: false,
|
70
63
|
isProfile: true,
|
71
|
-
scale: 3
|
64
|
+
scale: 3,
|
72
65
|
})
|
73
66
|
};
|
74
67
|
defaultFuncs
|
75
68
|
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
76
69
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
77
|
-
.then(function
|
70
|
+
.then(function(resData) {
|
78
71
|
if (resData.error) throw resData;
|
79
|
-
else return callback(null,
|
72
|
+
else return callback(null,true)
|
80
73
|
})
|
81
|
-
.catch(function
|
82
|
-
|
83
|
-
|
84
|
-
})
|
85
|
-
})
|
86
|
-
}
|
74
|
+
.catch(function(err) {
|
75
|
+
return callback(err);
|
76
|
+
});
|
77
|
+
})
|
78
|
+
})
|
79
|
+
}
|
80
|
+
catch (e) {
|
87
81
|
throw e;
|
88
82
|
}
|
89
83
|
return returnPromise;
|
90
84
|
};
|
91
|
-
};
|
85
|
+
};
|
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
|
});
|