node-ainzfb-new 1.6.1-test → 1.6.32-stable
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 +2 -3
- 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 +91 -0
- 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/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/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 +8 -7
- package/src/getUserInfo.js +12 -9
- 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 +18 -19
package/src/changeThreadColor.js
CHANGED
@@ -3,27 +3,31 @@
|
|
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 changeThreadColor(color, threadID, 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) {
|
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
|
23
|
+
var colorList = Object.keys(api.threadColors).map(function(name) {
|
24
24
|
return api.threadColors[name];
|
25
25
|
});
|
26
|
-
if (!colorList.includes(validatedColor))
|
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
|
+
};
|
27
31
|
|
28
32
|
var form = {
|
29
33
|
dpr: 1,
|
@@ -47,12 +51,13 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
47
51
|
defaultFuncs
|
48
52
|
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
49
53
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
50
|
-
.then(function
|
51
|
-
if (resData[resData.length - 1].error_results > 0)
|
54
|
+
.then(function(resData) {
|
55
|
+
if (resData[resData.length - 1].error_results > 0)
|
56
|
+
throw resData[0].o0.errors;
|
52
57
|
|
53
58
|
return callback();
|
54
59
|
})
|
55
|
-
.catch(function
|
60
|
+
.catch(function(err) {
|
56
61
|
log.error("changeThreadColor", err);
|
57
62
|
return callback(err);
|
58
63
|
});
|
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
|
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
|
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) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
resolveFunc();
|
19
19
|
};
|
@@ -24,15 +24,23 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
24
24
|
};
|
25
25
|
|
26
26
|
defaultFuncs
|
27
|
-
.post(
|
27
|
+
.post(
|
28
|
+
"https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg",
|
29
|
+
ctx.jar,
|
30
|
+
form
|
31
|
+
)
|
28
32
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
29
|
-
.then(function
|
30
|
-
if (resData.error === 1357031)
|
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
|
+
};
|
31
39
|
if (resData.error) throw resData;
|
32
40
|
|
33
41
|
return callback();
|
34
42
|
})
|
35
|
-
.catch(function
|
43
|
+
.catch(function(err) {
|
36
44
|
log.error("changeThreadEmoji", err);
|
37
45
|
return callback(err);
|
38
46
|
});
|
package/src/createNewGroup.js
CHANGED
@@ -3,26 +3,30 @@
|
|
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 createNewGroup(participantIDs, groupTitle, callback) {
|
8
8
|
if (utils.getType(groupTitle) == "Function") {
|
9
9
|
callback = groupTitle;
|
10
10
|
groupTitle = null;
|
11
11
|
}
|
12
12
|
|
13
|
-
if (utils.getType(participantIDs) !== "Array")
|
13
|
+
if (utils.getType(participantIDs) !== "Array")
|
14
|
+
throw { error: "createNewGroup: participantIDs should be an array." };
|
14
15
|
|
15
|
-
if (participantIDs.length < 2)
|
16
|
+
if (participantIDs.length < 2)
|
17
|
+
throw {
|
18
|
+
error: "createNewGroup: participantIDs should have at least 2 IDs."
|
19
|
+
};
|
16
20
|
|
17
|
-
var resolveFunc = function
|
18
|
-
var rejectFunc = function
|
19
|
-
var returnPromise = new Promise(function
|
21
|
+
var resolveFunc = function() {};
|
22
|
+
var rejectFunc = function() {};
|
23
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
20
24
|
resolveFunc = resolve;
|
21
25
|
rejectFunc = reject;
|
22
26
|
});
|
23
27
|
|
24
28
|
if (!callback) {
|
25
|
-
callback = function
|
29
|
+
callback = function(err, threadID) {
|
26
30
|
if (err) return rejectFunc(err);
|
27
31
|
resolveFunc(threadID);
|
28
32
|
};
|
@@ -56,11 +60,15 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
56
60
|
defaultFuncs
|
57
61
|
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
58
62
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
59
|
-
.then(function
|
63
|
+
.then(function(resData) {
|
60
64
|
if (resData.errors) throw resData;
|
61
|
-
return callback(
|
65
|
+
return callback(
|
66
|
+
null,
|
67
|
+
resData.data.messenger_group_thread_create.thread.thread_key
|
68
|
+
.thread_fbid
|
69
|
+
);
|
62
70
|
})
|
63
|
-
.catch(function
|
71
|
+
.catch(function(err) {
|
64
72
|
log.error("createNewGroup", err);
|
65
73
|
return callback(err);
|
66
74
|
});
|
package/src/createPoll.js
CHANGED
@@ -3,11 +3,11 @@
|
|
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 createPoll(title, threadID, options, 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
|
});
|
@@ -16,9 +16,8 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
16
16
|
if (utils.getType(options) == "Function") {
|
17
17
|
callback = options;
|
18
18
|
options = null;
|
19
|
-
}
|
20
|
-
|
21
|
-
callback = function (err) {
|
19
|
+
} else {
|
20
|
+
callback = function(err) {
|
22
21
|
if (err) return rejectFunc(err);
|
23
22
|
resolveFunc();
|
24
23
|
};
|
@@ -37,20 +36,26 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
37
36
|
// eslint-disable-next-line no-prototype-builtins
|
38
37
|
if (options.hasOwnProperty(opt)) {
|
39
38
|
form["option_text_array[" + ind + "]"] = opt;
|
40
|
-
form["option_is_selected_array[" + ind + "]"] = options[opt]
|
39
|
+
form["option_is_selected_array[" + ind + "]"] = options[opt]
|
40
|
+
? "1"
|
41
|
+
: "0";
|
41
42
|
ind++;
|
42
43
|
}
|
43
44
|
}
|
44
45
|
|
45
46
|
defaultFuncs
|
46
|
-
.post(
|
47
|
+
.post(
|
48
|
+
"https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
|
49
|
+
ctx.jar,
|
50
|
+
form
|
51
|
+
)
|
47
52
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
48
|
-
.then(function
|
53
|
+
.then(function(resData) {
|
49
54
|
if (resData.payload.status != "success") throw resData;
|
50
55
|
|
51
56
|
return callback();
|
52
57
|
})
|
53
|
-
.catch(function
|
58
|
+
.catch(function(err) {
|
54
59
|
log.error("createPoll", err);
|
55
60
|
return callback(err);
|
56
61
|
});
|
package/src/deleteMessage.js
CHANGED
@@ -3,16 +3,16 @@
|
|
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 deleteMessage(messageOrMessages, 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
|
if (!callback) {
|
15
|
-
callback = function
|
15
|
+
callback = function(err) {
|
16
16
|
if (err) return rejectFunc(err);
|
17
17
|
|
18
18
|
resolveFunc();
|
@@ -23,19 +23,25 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
23
23
|
client: "mercury"
|
24
24
|
};
|
25
25
|
|
26
|
-
if (utils.getType(messageOrMessages) !== "Array")
|
26
|
+
if (utils.getType(messageOrMessages) !== "Array")
|
27
|
+
messageOrMessages = [messageOrMessages];
|
27
28
|
|
28
|
-
for (var i = 0; i < messageOrMessages.length; i++)
|
29
|
+
for (var i = 0; i < messageOrMessages.length; i++)
|
30
|
+
form["message_ids[" + i + "]"] = messageOrMessages[i];
|
29
31
|
|
30
32
|
defaultFuncs
|
31
|
-
.post(
|
33
|
+
.post(
|
34
|
+
"https://www.facebook.com/ajax/mercury/delete_messages.php",
|
35
|
+
ctx.jar,
|
36
|
+
form
|
37
|
+
)
|
32
38
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
33
|
-
.then(function
|
39
|
+
.then(function(resData) {
|
34
40
|
if (resData.error) throw resData;
|
35
41
|
|
36
42
|
return callback();
|
37
43
|
})
|
38
|
-
.catch(function
|
44
|
+
.catch(function(err) {
|
39
45
|
log.error("deleteMessage", err);
|
40
46
|
return callback(err);
|
41
47
|
});
|
package/src/deleteThread.js
CHANGED
@@ -3,16 +3,16 @@
|
|
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 deleteThread(threadOrThreads, 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
|
if (!callback) {
|
15
|
-
callback = function
|
15
|
+
callback = function(err) {
|
16
16
|
if (err) return rejectFunc(err);
|
17
17
|
resolveFunc();
|
18
18
|
};
|
@@ -22,18 +22,24 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
22
22
|
client: "mercury"
|
23
23
|
};
|
24
24
|
|
25
|
-
if (utils.getType(threadOrThreads) !== "Array")
|
26
|
-
|
25
|
+
if (utils.getType(threadOrThreads) !== "Array")
|
26
|
+
threadOrThreads = [threadOrThreads];
|
27
|
+
for (var i = 0; i < threadOrThreads.length; i++)
|
28
|
+
form["ids[" + i + "]"] = threadOrThreads[i];
|
27
29
|
|
28
30
|
defaultFuncs
|
29
|
-
.post(
|
31
|
+
.post(
|
32
|
+
"https://www.facebook.com/ajax/mercury/delete_thread.php",
|
33
|
+
ctx.jar,
|
34
|
+
form
|
35
|
+
)
|
30
36
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
31
|
-
.then(function
|
37
|
+
.then(function(resData) {
|
32
38
|
if (resData.error) throw resData;
|
33
39
|
|
34
40
|
return callback();
|
35
41
|
})
|
36
|
-
.catch(function
|
42
|
+
.catch(function(err) {
|
37
43
|
log.error("deleteThread", err);
|
38
44
|
return callback(err);
|
39
45
|
});
|
package/src/forwardAttachment.js
CHANGED
@@ -3,16 +3,16 @@
|
|
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 forwardAttachment(attachmentID, userOrUsers, 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
|
if (!callback) {
|
15
|
-
callback = function
|
15
|
+
callback = function(err) {
|
16
16
|
if (err) return rejectFunc(err);
|
17
17
|
resolveFunc();
|
18
18
|
};
|
@@ -28,17 +28,22 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
28
28
|
|
29
29
|
//That's good, the key of the array is really timestmap in seconds + index
|
30
30
|
//Probably time when the attachment will be sent?
|
31
|
-
for (var i = 0; i < userOrUsers.length; i++)
|
31
|
+
for (var i = 0; i < userOrUsers.length; i++)
|
32
|
+
form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
|
32
33
|
|
33
34
|
defaultFuncs
|
34
|
-
.post(
|
35
|
+
.post(
|
36
|
+
"https://www.facebook.com/mercury/attachments/forward/",
|
37
|
+
ctx.jar,
|
38
|
+
form
|
39
|
+
)
|
35
40
|
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
36
|
-
.then(function
|
41
|
+
.then(function(resData) {
|
37
42
|
if (resData.error) throw resData;
|
38
43
|
|
39
44
|
return callback();
|
40
45
|
})
|
41
|
-
.catch(function
|
46
|
+
.catch(function(err) {
|
42
47
|
log.error("forwardAttachment", err);
|
43
48
|
return callback(err);
|
44
49
|
});
|
package/src/getCurrentUserID.js
CHANGED
package/src/getEmojiUrl.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
const util = require("util");
|
4
4
|
|
5
|
-
module.exports = function
|
5
|
+
module.exports = function() {
|
6
6
|
return function getEmojiUrl(c, size, pixelRatio) {
|
7
7
|
/*
|
8
8
|
Resolves Facebook Messenger emoji image asset URL for an emoji character.
|
@@ -19,7 +19,8 @@ module.exports = function () {
|
|
19
19
|
c.codePointAt(0).toString(16)
|
20
20
|
);
|
21
21
|
let base = 317426846;
|
22
|
-
for (let i = 0; i < ending.length; i++)
|
22
|
+
for (let i = 0; i < ending.length; i++)
|
23
|
+
base = (base << 5) - base + ending.charCodeAt(i);
|
23
24
|
|
24
25
|
let hashed = (base & 255).toString(16);
|
25
26
|
return util.format(baseUrl, hashed, ending);
|
package/src/getFriendsList.js
CHANGED
@@ -21,7 +21,7 @@ var GENDERS = {
|
|
21
21
|
};
|
22
22
|
|
23
23
|
function formatData(obj) {
|
24
|
-
return Object.keys(obj).map(function
|
24
|
+
return Object.keys(obj).map(function(key) {
|
25
25
|
var user = obj[key];
|
26
26
|
return {
|
27
27
|
alternateName: user.alternateName,
|
@@ -39,32 +39,40 @@ function formatData(obj) {
|
|
39
39
|
});
|
40
40
|
}
|
41
41
|
|
42
|
-
module.exports = function
|
42
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
43
43
|
return function getFriendsList(callback) {
|
44
|
-
var resolveFunc = function
|
45
|
-
var rejectFunc = function
|
46
|
-
var returnPromise = new Promise(function
|
44
|
+
var resolveFunc = function() {};
|
45
|
+
var rejectFunc = function() {};
|
46
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
47
47
|
resolveFunc = resolve;
|
48
48
|
rejectFunc = reject;
|
49
49
|
});
|
50
50
|
|
51
51
|
if (!callback) {
|
52
|
-
callback = function
|
52
|
+
callback = function(err, friendList) {
|
53
53
|
if (err) return rejectFunc(err);
|
54
54
|
resolveFunc(friendList);
|
55
55
|
};
|
56
56
|
}
|
57
57
|
|
58
58
|
defaultFuncs
|
59
|
-
.postFormData(
|
59
|
+
.postFormData(
|
60
|
+
"https://www.facebook.com/chat/user_info_all",
|
61
|
+
ctx.jar,
|
62
|
+
{},
|
63
|
+
{ viewer: ctx.userID }
|
64
|
+
)
|
60
65
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
61
|
-
.then(function
|
66
|
+
.then(function(resData) {
|
62
67
|
if (!resData) throw { error: "getFriendsList returned empty object." };
|
63
68
|
if (resData.error) throw resData;
|
64
69
|
callback(null, formatData(resData.payload));
|
65
70
|
})
|
66
|
-
.catch(function
|
67
|
-
log.error(
|
71
|
+
.catch(function(err) {
|
72
|
+
log.error(
|
73
|
+
"getFriendsList",
|
74
|
+
"Lỗi getFriendsList Có Thể Do Bạn Spam Quá Nhiều ! Hãy Hạn Chế !"
|
75
|
+
);
|
68
76
|
return callback(err);
|
69
77
|
});
|
70
78
|
|
package/src/getMessage.js
CHANGED
@@ -5,76 +5,80 @@ var utils = require("../utils");
|
|
5
5
|
var log = require("npmlog");
|
6
6
|
|
7
7
|
module.exports = function(defaultFuncs, api, ctx) {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
return function getMessage(threadID, messageID, callback) {
|
9
|
+
if (!callback) {
|
10
|
+
return callback({ error: "getMessage: need callback" });
|
11
|
+
}
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
if (!threadID || !messageID) {
|
14
|
+
return callback({ error: "getMessage: need threadID and messageID" });
|
15
|
+
}
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
17
|
+
const form = {
|
18
|
+
av: ctx.globalOptions.pageID,
|
19
|
+
queries: JSON.stringify({
|
20
|
+
o0: {
|
21
|
+
//This doc_id is valid as of ? (prob January 18, 2020)
|
22
|
+
doc_id: "1768656253222505",
|
23
|
+
query_params: {
|
24
|
+
thread_and_message_id: {
|
25
|
+
thread_id: threadID,
|
26
|
+
message_id: messageID
|
28
27
|
}
|
29
28
|
}
|
30
|
-
}
|
31
|
-
}
|
29
|
+
}
|
30
|
+
})
|
31
|
+
};
|
32
32
|
|
33
|
-
|
33
|
+
defaultFuncs
|
34
34
|
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
35
35
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
36
|
-
.then(
|
36
|
+
.then(resData => {
|
37
37
|
if (resData[resData.length - 1].error_results > 0) {
|
38
38
|
throw resData[0].o0.errors;
|
39
39
|
}
|
40
40
|
|
41
41
|
if (resData[resData.length - 1].successful_results === 0) {
|
42
|
-
throw {
|
42
|
+
throw {
|
43
|
+
error: "getMessage: there was no successful_results",
|
44
|
+
res: resData
|
45
|
+
};
|
43
46
|
}
|
44
47
|
|
45
48
|
var fetchData = resData[0].o0.data.message;
|
46
49
|
if (fetchData) {
|
47
50
|
(!ctx.globalOptions.selfListen &&
|
48
51
|
fetchData.message_sender.id.toString() === ctx.userID) ||
|
49
|
-
|
50
|
-
undefined
|
51
|
-
(function
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
!ctx.loggedIn
|
53
|
+
? undefined
|
54
|
+
: (function() {
|
55
|
+
callback(null, {
|
56
|
+
threadID: threadID,
|
57
|
+
messageID: fetchData.message_id,
|
58
|
+
senderID: fetchData.message_sender.id,
|
59
|
+
attachments: fetchData.blob_attachments.map(att => {
|
56
60
|
var x;
|
57
61
|
try {
|
58
|
-
|
62
|
+
x = utils._formatAttachment(att);
|
59
63
|
} catch (ex) {
|
60
|
-
|
61
|
-
|
62
|
-
|
64
|
+
x = att;
|
65
|
+
x.error = ex;
|
66
|
+
x.type = "unknown";
|
63
67
|
}
|
64
68
|
return x;
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
}),
|
70
|
+
body: fetchData.message.text,
|
71
|
+
mentions: fetchData.message.ranges,
|
72
|
+
timestamp: fetchData.timestamp_precise,
|
73
|
+
messageReply: fetchData.replied_to_message,
|
74
|
+
raw: fetchData
|
75
|
+
});
|
76
|
+
})();
|
72
77
|
}
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
})
|
79
|
+
.catch(err => {
|
80
|
+
log.error("getMessage", err);
|
81
|
+
callback(err);
|
82
|
+
});
|
79
83
|
};
|
80
|
-
};
|
84
|
+
};
|