node-ainzfb-new 1.6.2902-test → 1.6.2911-test
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +7 -7
- package/src/addExternalModule.js +13 -6
- package/src/addUserToGroup.js +35 -12
- package/src/changeAdminStatus.js +32 -16
- package/src/changeArchivedStatus.js +15 -9
- package/src/changeAvt.js +75 -69
- package/src/changeBio.js +12 -8
- package/src/changeBlockedStatus.js +14 -8
- package/src/changeGroupImage.js +27 -13
- package/src/changeNickname.js +19 -10
- package/src/changeThreadColor.js +15 -10
- package/src/changeThreadEmoji.js +17 -9
- package/src/createNewGroup.js +18 -10
- package/src/createPoll.js +16 -11
- package/src/deleteMessage.js +16 -10
- package/src/deleteThread.js +16 -10
- package/src/forwardAttachment.js +14 -9
- package/src/getAccessToken.js +21 -21
- package/src/getCurrentUserID.js +1 -1
- package/src/getEmojiUrl.js +3 -2
- package/src/getFriendsList.js +18 -10
- package/src/getMessage.js +52 -48
- package/src/getThreadHistory.js +156 -59
- package/src/getThreadHistoryDeprecated.js +26 -15
- package/src/getThreadInfo.js +3423 -18
- package/src/getThreadInfoDeprecated.js +25 -13
- package/src/getThreadList.js +112 -53
- package/src/getThreadListDeprecated.js +30 -12
- package/src/getThreadPictures.js +25 -13
- package/src/getUserID.js +7 -7
- package/src/getUserInfo.js +12 -9
- package/src/getUserInfoV2.js +19 -22
- package/src/handleFriendRequest.js +10 -9
- package/src/handleMessageRequest.js +16 -10
- package/src/httpGet.js +18 -13
- package/src/httpPost.js +18 -13
- package/src/httpPostFormData.js +14 -9
- package/src/listenMqtt.js +1218 -571
- package/src/logout.js +18 -13
- package/src/markAsDelivered.js +16 -10
- package/src/markAsRead.js +36 -24
- package/src/markAsReadAll.js +14 -10
- package/src/markAsSeen.js +18 -11
- package/src/muteThread.js +12 -8
- package/src/removeUserFromGroup.js +33 -10
- package/src/resolvePhotoUrl.js +8 -6
- package/src/searchForThread.js +13 -8
- package/src/sendMessage.js +172 -78
- package/src/sendTypingIndicator.js +29 -14
- package/src/setMessageReaction.js +13 -8
- package/src/setPostReaction.js +97 -95
- package/src/setTitle.js +18 -12
- package/src/threadColors.js +17 -17
- package/src/unfriend.js +14 -9
- package/src/unsendMessage.js +7 -7
- package/utils.js +2 -2
package/src/setPostReaction.js
CHANGED
@@ -4,99 +4,101 @@
|
|
4
4
|
* do not remove the author name to get more updates
|
5
5
|
*/
|
6
6
|
|
7
|
-
|
7
|
+
"use strict";
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
9
|
+
var utils = require("../utils");
|
10
|
+
var log = require("npmlog");
|
11
|
+
|
12
|
+
function formatData(resData) {
|
13
|
+
return {
|
14
|
+
viewer_feedback_reaction_info:
|
15
|
+
resData.feedback_react.feedback.viewer_feedback_reaction_info,
|
16
|
+
supported_reactions: resData.feedback_react.feedback.supported_reactions,
|
17
|
+
top_reactions: resData.feedback_react.feedback.top_reactions.edges,
|
18
|
+
reaction_count: resData.feedback_react.feedback.reaction_count
|
19
|
+
};
|
20
|
+
}
|
21
|
+
|
22
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
23
|
+
return function setPostReaction(postID, type, callback) {
|
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
|
+
if (
|
33
|
+
utils.getType(type) === "Function" ||
|
34
|
+
utils.getType(type) === "AsyncFunction"
|
35
|
+
) {
|
36
|
+
callback = type;
|
37
|
+
type = 0;
|
38
|
+
} else {
|
39
|
+
callback = function(err, data) {
|
40
|
+
if (err) {
|
41
|
+
return rejectFunc(err);
|
42
|
+
}
|
43
|
+
resolveFunc(data);
|
44
|
+
};
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
var map = {
|
49
|
+
unlike: 0,
|
50
|
+
like: 1,
|
51
|
+
heart: 2,
|
52
|
+
love: 16,
|
53
|
+
haha: 4,
|
54
|
+
wow: 3,
|
55
|
+
sad: 7,
|
56
|
+
angry: 8
|
57
|
+
};
|
58
|
+
|
59
|
+
if (utils.getType(type) !== "Number" && utils.getType(type) === "String") {
|
60
|
+
type = map[type.toLowerCase()];
|
61
|
+
} else {
|
62
|
+
throw {
|
63
|
+
error: "setPostReaction: Invalid reaction type"
|
64
|
+
};
|
65
|
+
}
|
66
|
+
|
67
|
+
var form = {
|
68
|
+
av: ctx.userID,
|
69
|
+
fb_api_caller_class: "RelayModern",
|
70
|
+
fb_api_req_friendly_name: "CometUFIFeedbackReactMutation",
|
71
|
+
doc_id: "4769042373179384",
|
72
|
+
variables: JSON.stringify({
|
73
|
+
input: {
|
74
|
+
actor_id: ctx.userID,
|
75
|
+
feedback_id: new Buffer.from("feedback:" + postID).toString("base64"),
|
76
|
+
feedback_reaction: type,
|
77
|
+
feedback_source: "OBJECT",
|
78
|
+
is_tracking_encrypted: true,
|
79
|
+
tracking: [],
|
80
|
+
session_id: "f7dd50dd-db6e-4598-8cd9-561d5002b423",
|
81
|
+
client_mutation_id: Math.round(Math.random() * 19).toString()
|
82
|
+
},
|
83
|
+
useDefaultActor: false,
|
84
|
+
scale: 3
|
85
|
+
})
|
86
|
+
};
|
87
|
+
|
88
|
+
defaultFuncs
|
89
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
90
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
91
|
+
.then(function(resData) {
|
92
|
+
if (resData.errors) {
|
93
|
+
throw resData;
|
94
|
+
}
|
95
|
+
return callback(null, formatData(resData.data));
|
96
|
+
})
|
97
|
+
.catch(function(err) {
|
98
|
+
log.error("setPostReaction", err);
|
99
|
+
return callback(err);
|
100
|
+
});
|
101
|
+
|
102
|
+
return returnPromise;
|
103
|
+
};
|
104
|
+
};
|
package/src/setTitle.js
CHANGED
@@ -3,24 +3,24 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function setTitle(newTitle, threadID, callback) {
|
8
8
|
if (
|
9
9
|
!callback &&
|
10
10
|
(utils.getType(threadID) === "Function" ||
|
11
11
|
utils.getType(threadID) === "AsyncFunction")
|
12
|
-
)
|
12
|
+
)
|
13
|
+
throw { error: "please pass a threadID as a second argument." };
|
13
14
|
|
14
|
-
|
15
|
-
var
|
16
|
-
var
|
17
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
15
|
+
var resolveFunc = function() {};
|
16
|
+
var rejectFunc = function() {};
|
17
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
18
18
|
resolveFunc = resolve;
|
19
19
|
rejectFunc = reject;
|
20
20
|
});
|
21
21
|
|
22
22
|
if (!callback) {
|
23
|
-
callback = function
|
23
|
+
callback = function(err, data) {
|
24
24
|
if (err) return rejectFunc(err);
|
25
25
|
resolveFunc(data);
|
26
26
|
};
|
@@ -56,15 +56,21 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
56
56
|
};
|
57
57
|
|
58
58
|
defaultFuncs
|
59
|
-
.post(
|
59
|
+
.post(
|
60
|
+
"https://www.facebook.com/messaging/set_thread_name/",
|
61
|
+
ctx.jar,
|
62
|
+
form
|
63
|
+
)
|
60
64
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
61
|
-
.then(function
|
62
|
-
if (resData.error && resData.error === 1545012)
|
63
|
-
|
65
|
+
.then(function(resData) {
|
66
|
+
if (resData.error && resData.error === 1545012)
|
67
|
+
throw { error: "Cannot change chat title: Not member of chat." };
|
68
|
+
if (resData.error && resData.error === 1545003)
|
69
|
+
throw { error: "Cannot set title of single-user chat." };
|
64
70
|
if (resData.error) throw resData;
|
65
71
|
return callback();
|
66
72
|
})
|
67
|
-
.catch(function
|
73
|
+
.catch(function(err) {
|
68
74
|
log.error("setTitle", err);
|
69
75
|
return callback(err);
|
70
76
|
});
|
package/src/threadColors.js
CHANGED
@@ -18,22 +18,22 @@ module.exports = function(_defaultFuncs, _api, _ctx) {
|
|
18
18
|
////Cameo: "#d4a88c",
|
19
19
|
////BrilliantRose: "#ff5ca1",
|
20
20
|
////BilobaFlower: "#a695c7"
|
21
|
-
DefaultBlue:
|
22
|
-
HotPink:
|
23
|
-
AquaBlue:
|
24
|
-
BrightPurple:
|
25
|
-
CoralPink:
|
26
|
-
Orange:
|
27
|
-
Green:
|
21
|
+
DefaultBlue: "196241301102133",
|
22
|
+
HotPink: "169463077092846",
|
23
|
+
AquaBlue: "2442142322678320",
|
24
|
+
BrightPurple: "234137870477637",
|
25
|
+
CoralPink: "980963458735625",
|
26
|
+
Orange: "175615189761153",
|
27
|
+
Green: "2136751179887052",
|
28
28
|
LavenderPurple: "2058653964378557",
|
29
|
-
Red:
|
30
|
-
Yellow:
|
31
|
-
TealBlue:
|
32
|
-
Aqua:
|
33
|
-
Mango:
|
34
|
-
Berry:
|
35
|
-
Citrus:
|
36
|
-
Candy:
|
37
|
-
StarWars:
|
29
|
+
Red: "2129984390566328",
|
30
|
+
Yellow: "174636906462322",
|
31
|
+
TealBlue: "1928399724138152",
|
32
|
+
Aqua: "417639218648241",
|
33
|
+
Mango: "930060997172551",
|
34
|
+
Berry: "164535220883264",
|
35
|
+
Citrus: "370940413392601",
|
36
|
+
Candy: "205488546921017",
|
37
|
+
StarWars: "809305022860427"
|
38
38
|
};
|
39
|
-
};
|
39
|
+
};
|
package/src/unfriend.js
CHANGED
@@ -3,17 +3,17 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function unfriend(userID, callback) {
|
8
|
-
var resolveFunc = function
|
9
|
-
var rejectFunc = function
|
10
|
-
var returnPromise = new Promise(function
|
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
|
16
|
+
callback = function(err, friendList) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
resolveFunc(friendList);
|
19
19
|
};
|
@@ -23,17 +23,22 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
23
23
|
uid: userID,
|
24
24
|
unref: "bd_friends_tab",
|
25
25
|
floc: "friends_tab",
|
26
|
-
"nctr[_mod]":
|
26
|
+
"nctr[_mod]":
|
27
|
+
"pagelet_timeline_app_collection_" + ctx.userID + ":2356318349:2"
|
27
28
|
};
|
28
29
|
|
29
30
|
defaultFuncs
|
30
|
-
.post(
|
31
|
+
.post(
|
32
|
+
"https://www.facebook.com/ajax/profile/removefriendconfirm.php",
|
33
|
+
ctx.jar,
|
34
|
+
form
|
35
|
+
)
|
31
36
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
32
|
-
.then(function
|
37
|
+
.then(function(resData) {
|
33
38
|
if (resData.error) throw resData;
|
34
39
|
return callback();
|
35
40
|
})
|
36
|
-
.catch(function
|
41
|
+
.catch(function(err) {
|
37
42
|
log.error("unfriend", err);
|
38
43
|
return callback(err);
|
39
44
|
});
|
package/src/unsendMessage.js
CHANGED
@@ -3,17 +3,17 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function unsendMessage(messageID, callback) {
|
8
|
-
var resolveFunc = function
|
9
|
-
var rejectFunc = function
|
10
|
-
var returnPromise = new Promise(function
|
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
|
16
|
+
callback = function(err, friendList) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
resolveFunc(friendList);
|
19
19
|
};
|
@@ -26,11 +26,11 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
26
26
|
defaultFuncs
|
27
27
|
.post("https://www.facebook.com/messaging/unsend_message/", ctx.jar, form)
|
28
28
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
29
|
-
.then(function
|
29
|
+
.then(function(resData) {
|
30
30
|
if (resData.error) throw resData;
|
31
31
|
return callback();
|
32
32
|
})
|
33
|
-
.catch(function
|
33
|
+
.catch(function(err) {
|
34
34
|
log.error("unsendMessage", err);
|
35
35
|
return callback(err);
|
36
36
|
});
|
package/utils.js
CHANGED
@@ -22,8 +22,8 @@ function getHeaders(url, options, ctx, customHeader) {
|
|
22
22
|
Origin: "https://www.facebook.com",
|
23
23
|
"User-Agent": options.userAgent,
|
24
24
|
Connection: "keep-alive",
|
25
|
-
"sec-fetch-site": 'same-origin',
|
26
|
-
"sec-fetch-mode": 'cors'
|
25
|
+
//"sec-fetch-site": 'same-origin',
|
26
|
+
//"sec-fetch-mode": 'cors'
|
27
27
|
};
|
28
28
|
if (customHeader) Object.assign(headers, customHeader);
|
29
29
|
|