alicezetion 1.0.2 → 1.0.3
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/alice/addExternalModule.js +19 -19
- package/alice/addUserToGroup.js +113 -113
- package/alice/changeAdminStatus.js +79 -79
- package/alice/changeArchivedStatus.js +55 -55
- package/alice/changeBio.js +77 -77
- package/alice/changeBlockedStatus.js +47 -47
- package/alice/changeGroupImage.js +129 -129
- package/alice/changeNickname.js +59 -59
- package/alice/changeThreadColor.js +71 -71
- package/alice/changeThreadEmoji.js +55 -55
- package/alice/{sendMessage.js → chat.js} +459 -459
- package/alice/createNewGroup.js +86 -86
- package/alice/createPoll.js +71 -71
- package/alice/deleteMessage.js +56 -56
- package/alice/deleteThread.js +56 -56
- package/alice/forwardAttachment.js +60 -60
- package/alice/getCurrentUserID.js +7 -7
- package/alice/getEmojiUrl.js +29 -29
- package/alice/getFriendsList.js +84 -84
- package/alice/getThreadHistory.js +645 -645
- package/alice/getThreadHistoryDeprecated.js +93 -93
- package/alice/getThreadInfo.js +206 -206
- package/alice/getThreadInfoDeprecated.js +80 -80
- package/alice/getThreadList.js +238 -238
- package/alice/getThreadListDeprecated.js +75 -75
- package/alice/getThreadPictures.js +79 -79
- package/alice/getUserID.js +66 -66
- package/alice/getUserInfo.js +72 -72
- package/alice/handleFriendRequest.js +61 -61
- package/alice/handleMessageRequest.js +65 -65
- package/alice/httpGet.js +52 -52
- package/alice/httpPost.js +52 -52
- package/alice/listenMqtt.js +789 -789
- package/alice/logout.js +75 -75
- package/alice/markAsDelivered.js +58 -58
- package/alice/markAsRead.js +80 -80
- package/alice/markAsSeen.js +59 -59
- package/alice/muteThread.js +52 -52
- package/alice/{setMessageReaction.js → react.js} +117 -117
- package/alice/removeUserFromGroup.js +79 -79
- package/alice/resolvePhotoUrl.js +45 -45
- package/alice/searchForThread.js +53 -53
- package/alice/{markAsReadAll.js → seen.js} +49 -49
- package/alice/sendTypingIndicator.js +103 -103
- package/alice/setPostReaction.js +76 -76
- package/alice/setTitle.js +86 -86
- package/alice/threadColors.js +57 -57
- package/alice/unfriend.js +52 -52
- package/alice/unsendMessage.js +49 -49
- package/index.js +604 -604
- package/package.json +74 -77
- package/test/data/shareAttach.js +146 -0
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +7 -0
- package/test/example-config.json +18 -0
- package/test/test-page.js +140 -0
- package/test/test.js +385 -0
- package/utils.js +1357 -1359
- package/.travis.yml +0 -6
package/alice/createNewGroup.js
CHANGED
@@ -1,86 +1,86 @@
|
|
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 createNewGroup(participantIDs, groupTitle, callback) {
|
8
|
-
if (utils.getType(groupTitle) == "Function") {
|
9
|
-
callback = groupTitle;
|
10
|
-
groupTitle = null;
|
11
|
-
}
|
12
|
-
|
13
|
-
if (utils.getType(participantIDs) !== "Array") {
|
14
|
-
throw { error: "createNewGroup: participantIDs should be an array." };
|
15
|
-
}
|
16
|
-
|
17
|
-
if (participantIDs.length < 2) {
|
18
|
-
throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
|
19
|
-
}
|
20
|
-
|
21
|
-
var resolveFunc = function(){};
|
22
|
-
var rejectFunc = function(){};
|
23
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
24
|
-
resolveFunc = resolve;
|
25
|
-
rejectFunc = reject;
|
26
|
-
});
|
27
|
-
|
28
|
-
if (!callback) {
|
29
|
-
callback = function (err, threadID) {
|
30
|
-
if (err) {
|
31
|
-
return rejectFunc(err);
|
32
|
-
}
|
33
|
-
resolveFunc(threadID);
|
34
|
-
};
|
35
|
-
}
|
36
|
-
|
37
|
-
var pids = [];
|
38
|
-
for (var n in participantIDs) {
|
39
|
-
pids.push({
|
40
|
-
fbid: participantIDs[n]
|
41
|
-
});
|
42
|
-
}
|
43
|
-
pids.push({fbid: ctx.userID});
|
44
|
-
|
45
|
-
var form = {
|
46
|
-
fb_api_caller_class: "RelayModern",
|
47
|
-
fb_api_req_friendly_name: "MessengerGroupCreateMutation",
|
48
|
-
av: ctx.userID,
|
49
|
-
//This doc_id is valid as of January 11th, 2020
|
50
|
-
doc_id: "577041672419534",
|
51
|
-
variables: JSON.stringify({
|
52
|
-
input: {
|
53
|
-
entry_point: "jewel_new_group",
|
54
|
-
actor_id: ctx.userID,
|
55
|
-
participants: pids,
|
56
|
-
client_mutation_id: Math.round(Math.random() * 1024).toString(),
|
57
|
-
thread_settings: {
|
58
|
-
name: groupTitle,
|
59
|
-
joinable_mode: "PRIVATE",
|
60
|
-
thread_image_fbid: null
|
61
|
-
}
|
62
|
-
}
|
63
|
-
})
|
64
|
-
};
|
65
|
-
|
66
|
-
defaultFuncs
|
67
|
-
.post(
|
68
|
-
"https://www.facebook.com/api/graphql/",
|
69
|
-
ctx.jar,
|
70
|
-
form
|
71
|
-
)
|
72
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
73
|
-
.then(function(resData) {
|
74
|
-
if (resData.errors) {
|
75
|
-
throw resData;
|
76
|
-
}
|
77
|
-
return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
|
78
|
-
})
|
79
|
-
.catch(function(err) {
|
80
|
-
log.error("createNewGroup", err);
|
81
|
-
return callback(err);
|
82
|
-
});
|
83
|
-
|
84
|
-
return returnPromise;
|
85
|
-
};
|
86
|
-
};
|
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 createNewGroup(participantIDs, groupTitle, callback) {
|
8
|
+
if (utils.getType(groupTitle) == "Function") {
|
9
|
+
callback = groupTitle;
|
10
|
+
groupTitle = null;
|
11
|
+
}
|
12
|
+
|
13
|
+
if (utils.getType(participantIDs) !== "Array") {
|
14
|
+
throw { error: "createNewGroup: participantIDs should be an array." };
|
15
|
+
}
|
16
|
+
|
17
|
+
if (participantIDs.length < 2) {
|
18
|
+
throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
|
19
|
+
}
|
20
|
+
|
21
|
+
var resolveFunc = function(){};
|
22
|
+
var rejectFunc = function(){};
|
23
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
24
|
+
resolveFunc = resolve;
|
25
|
+
rejectFunc = reject;
|
26
|
+
});
|
27
|
+
|
28
|
+
if (!callback) {
|
29
|
+
callback = function (err, threadID) {
|
30
|
+
if (err) {
|
31
|
+
return rejectFunc(err);
|
32
|
+
}
|
33
|
+
resolveFunc(threadID);
|
34
|
+
};
|
35
|
+
}
|
36
|
+
|
37
|
+
var pids = [];
|
38
|
+
for (var n in participantIDs) {
|
39
|
+
pids.push({
|
40
|
+
fbid: participantIDs[n]
|
41
|
+
});
|
42
|
+
}
|
43
|
+
pids.push({fbid: ctx.userID});
|
44
|
+
|
45
|
+
var form = {
|
46
|
+
fb_api_caller_class: "RelayModern",
|
47
|
+
fb_api_req_friendly_name: "MessengerGroupCreateMutation",
|
48
|
+
av: ctx.userID,
|
49
|
+
//This doc_id is valid as of January 11th, 2020
|
50
|
+
doc_id: "577041672419534",
|
51
|
+
variables: JSON.stringify({
|
52
|
+
input: {
|
53
|
+
entry_point: "jewel_new_group",
|
54
|
+
actor_id: ctx.userID,
|
55
|
+
participants: pids,
|
56
|
+
client_mutation_id: Math.round(Math.random() * 1024).toString(),
|
57
|
+
thread_settings: {
|
58
|
+
name: groupTitle,
|
59
|
+
joinable_mode: "PRIVATE",
|
60
|
+
thread_image_fbid: null
|
61
|
+
}
|
62
|
+
}
|
63
|
+
})
|
64
|
+
};
|
65
|
+
|
66
|
+
defaultFuncs
|
67
|
+
.post(
|
68
|
+
"https://www.facebook.com/api/graphql/",
|
69
|
+
ctx.jar,
|
70
|
+
form
|
71
|
+
)
|
72
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
73
|
+
.then(function(resData) {
|
74
|
+
if (resData.errors) {
|
75
|
+
throw resData;
|
76
|
+
}
|
77
|
+
return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
|
78
|
+
})
|
79
|
+
.catch(function(err) {
|
80
|
+
log.error("createNewGroup", err);
|
81
|
+
return callback(err);
|
82
|
+
});
|
83
|
+
|
84
|
+
return returnPromise;
|
85
|
+
};
|
86
|
+
};
|
package/alice/createPoll.js
CHANGED
@@ -1,71 +1,71 @@
|
|
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 createPoll(title, threadID, options, 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
|
-
if (utils.getType(options) == "Function") {
|
17
|
-
callback = options;
|
18
|
-
options = null;
|
19
|
-
} else {
|
20
|
-
callback = function(err) {
|
21
|
-
if (err) {
|
22
|
-
return rejectFunc(err);
|
23
|
-
}
|
24
|
-
resolveFunc();
|
25
|
-
};
|
26
|
-
}
|
27
|
-
}
|
28
|
-
if (!options) {
|
29
|
-
options = {}; // Initial poll options are optional
|
30
|
-
}
|
31
|
-
|
32
|
-
var form = {
|
33
|
-
target_id: threadID,
|
34
|
-
question_text: title
|
35
|
-
};
|
36
|
-
|
37
|
-
// Set fields for options (and whether they are selected initially by the posting user)
|
38
|
-
var ind = 0;
|
39
|
-
for (var opt in options) {
|
40
|
-
// eslint-disable-next-line no-prototype-builtins
|
41
|
-
if (options.hasOwnProperty(opt)) {
|
42
|
-
form["option_text_array[" + ind + "]"] = opt;
|
43
|
-
form["option_is_selected_array[" + ind + "]"] = options[opt]
|
44
|
-
? "1"
|
45
|
-
: "0";
|
46
|
-
ind++;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
|
50
|
-
defaultFuncs
|
51
|
-
.post(
|
52
|
-
"https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
|
53
|
-
ctx.jar,
|
54
|
-
form
|
55
|
-
)
|
56
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
57
|
-
.then(function(resData) {
|
58
|
-
if (resData.payload.status != "success") {
|
59
|
-
throw resData;
|
60
|
-
}
|
61
|
-
|
62
|
-
return callback();
|
63
|
-
})
|
64
|
-
.catch(function(err) {
|
65
|
-
log.error("createPoll", err);
|
66
|
-
return callback(err);
|
67
|
-
});
|
68
|
-
|
69
|
-
return returnPromise;
|
70
|
-
};
|
71
|
-
};
|
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 createPoll(title, threadID, options, 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
|
+
if (utils.getType(options) == "Function") {
|
17
|
+
callback = options;
|
18
|
+
options = null;
|
19
|
+
} else {
|
20
|
+
callback = function(err) {
|
21
|
+
if (err) {
|
22
|
+
return rejectFunc(err);
|
23
|
+
}
|
24
|
+
resolveFunc();
|
25
|
+
};
|
26
|
+
}
|
27
|
+
}
|
28
|
+
if (!options) {
|
29
|
+
options = {}; // Initial poll options are optional
|
30
|
+
}
|
31
|
+
|
32
|
+
var form = {
|
33
|
+
target_id: threadID,
|
34
|
+
question_text: title
|
35
|
+
};
|
36
|
+
|
37
|
+
// Set fields for options (and whether they are selected initially by the posting user)
|
38
|
+
var ind = 0;
|
39
|
+
for (var opt in options) {
|
40
|
+
// eslint-disable-next-line no-prototype-builtins
|
41
|
+
if (options.hasOwnProperty(opt)) {
|
42
|
+
form["option_text_array[" + ind + "]"] = opt;
|
43
|
+
form["option_is_selected_array[" + ind + "]"] = options[opt]
|
44
|
+
? "1"
|
45
|
+
: "0";
|
46
|
+
ind++;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
defaultFuncs
|
51
|
+
.post(
|
52
|
+
"https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
|
53
|
+
ctx.jar,
|
54
|
+
form
|
55
|
+
)
|
56
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
57
|
+
.then(function(resData) {
|
58
|
+
if (resData.payload.status != "success") {
|
59
|
+
throw resData;
|
60
|
+
}
|
61
|
+
|
62
|
+
return callback();
|
63
|
+
})
|
64
|
+
.catch(function(err) {
|
65
|
+
log.error("createPoll", err);
|
66
|
+
return callback(err);
|
67
|
+
});
|
68
|
+
|
69
|
+
return returnPromise;
|
70
|
+
};
|
71
|
+
};
|
package/alice/deleteMessage.js
CHANGED
@@ -1,56 +1,56 @@
|
|
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 deleteMessage(messageOrMessages, 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
|
-
client: "mercury"
|
25
|
-
};
|
26
|
-
|
27
|
-
if (utils.getType(messageOrMessages) !== "Array") {
|
28
|
-
messageOrMessages = [messageOrMessages];
|
29
|
-
}
|
30
|
-
|
31
|
-
for (var i = 0; i < messageOrMessages.length; i++) {
|
32
|
-
form["message_ids[" + i + "]"] = messageOrMessages[i];
|
33
|
-
}
|
34
|
-
|
35
|
-
defaultFuncs
|
36
|
-
.post(
|
37
|
-
"https://www.facebook.com/ajax/mercury/delete_messages.php",
|
38
|
-
ctx.jar,
|
39
|
-
form
|
40
|
-
)
|
41
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
42
|
-
.then(function(resData) {
|
43
|
-
if (resData.error) {
|
44
|
-
throw resData;
|
45
|
-
}
|
46
|
-
|
47
|
-
return callback();
|
48
|
-
})
|
49
|
-
.catch(function(err) {
|
50
|
-
log.error("deleteMessage", err);
|
51
|
-
return callback(err);
|
52
|
-
});
|
53
|
-
|
54
|
-
return returnPromise;
|
55
|
-
};
|
56
|
-
};
|
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 deleteMessage(messageOrMessages, 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
|
+
client: "mercury"
|
25
|
+
};
|
26
|
+
|
27
|
+
if (utils.getType(messageOrMessages) !== "Array") {
|
28
|
+
messageOrMessages = [messageOrMessages];
|
29
|
+
}
|
30
|
+
|
31
|
+
for (var i = 0; i < messageOrMessages.length; i++) {
|
32
|
+
form["message_ids[" + i + "]"] = messageOrMessages[i];
|
33
|
+
}
|
34
|
+
|
35
|
+
defaultFuncs
|
36
|
+
.post(
|
37
|
+
"https://www.facebook.com/ajax/mercury/delete_messages.php",
|
38
|
+
ctx.jar,
|
39
|
+
form
|
40
|
+
)
|
41
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
42
|
+
.then(function(resData) {
|
43
|
+
if (resData.error) {
|
44
|
+
throw resData;
|
45
|
+
}
|
46
|
+
|
47
|
+
return callback();
|
48
|
+
})
|
49
|
+
.catch(function(err) {
|
50
|
+
log.error("deleteMessage", err);
|
51
|
+
return callback(err);
|
52
|
+
});
|
53
|
+
|
54
|
+
return returnPromise;
|
55
|
+
};
|
56
|
+
};
|
package/alice/deleteThread.js
CHANGED
@@ -1,56 +1,56 @@
|
|
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 deleteThread(threadOrThreads, 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
|
-
client: "mercury"
|
25
|
-
};
|
26
|
-
|
27
|
-
if (utils.getType(threadOrThreads) !== "Array") {
|
28
|
-
threadOrThreads = [threadOrThreads];
|
29
|
-
}
|
30
|
-
|
31
|
-
for (var i = 0; i < threadOrThreads.length; i++) {
|
32
|
-
form["ids[" + i + "]"] = threadOrThreads[i];
|
33
|
-
}
|
34
|
-
|
35
|
-
defaultFuncs
|
36
|
-
.post(
|
37
|
-
"https://www.facebook.com/ajax/mercury/delete_thread.php",
|
38
|
-
ctx.jar,
|
39
|
-
form
|
40
|
-
)
|
41
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
42
|
-
.then(function(resData) {
|
43
|
-
if (resData.error) {
|
44
|
-
throw resData;
|
45
|
-
}
|
46
|
-
|
47
|
-
return callback();
|
48
|
-
})
|
49
|
-
.catch(function(err) {
|
50
|
-
log.error("deleteThread", err);
|
51
|
-
return callback(err);
|
52
|
-
});
|
53
|
-
|
54
|
-
return returnPromise;
|
55
|
-
};
|
56
|
-
};
|
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 deleteThread(threadOrThreads, 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
|
+
client: "mercury"
|
25
|
+
};
|
26
|
+
|
27
|
+
if (utils.getType(threadOrThreads) !== "Array") {
|
28
|
+
threadOrThreads = [threadOrThreads];
|
29
|
+
}
|
30
|
+
|
31
|
+
for (var i = 0; i < threadOrThreads.length; i++) {
|
32
|
+
form["ids[" + i + "]"] = threadOrThreads[i];
|
33
|
+
}
|
34
|
+
|
35
|
+
defaultFuncs
|
36
|
+
.post(
|
37
|
+
"https://www.facebook.com/ajax/mercury/delete_thread.php",
|
38
|
+
ctx.jar,
|
39
|
+
form
|
40
|
+
)
|
41
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
42
|
+
.then(function(resData) {
|
43
|
+
if (resData.error) {
|
44
|
+
throw resData;
|
45
|
+
}
|
46
|
+
|
47
|
+
return callback();
|
48
|
+
})
|
49
|
+
.catch(function(err) {
|
50
|
+
log.error("deleteThread", err);
|
51
|
+
return callback(err);
|
52
|
+
});
|
53
|
+
|
54
|
+
return returnPromise;
|
55
|
+
};
|
56
|
+
};
|
@@ -1,60 +1,60 @@
|
|
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 forwardAttachment(attachmentID, userOrUsers, 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
|
-
attachment_id: attachmentID
|
25
|
-
};
|
26
|
-
|
27
|
-
if (utils.getType(userOrUsers) !== "Array") {
|
28
|
-
userOrUsers = [userOrUsers];
|
29
|
-
}
|
30
|
-
|
31
|
-
var timestamp = Math.floor(Date.now() / 1000);
|
32
|
-
|
33
|
-
for (var i = 0; i < userOrUsers.length; i++) {
|
34
|
-
//That's good, the key of the array is really timestmap in seconds + index
|
35
|
-
//Probably time when the attachment will be sent?
|
36
|
-
form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
|
37
|
-
}
|
38
|
-
|
39
|
-
defaultFuncs
|
40
|
-
.post(
|
41
|
-
"https://www.facebook.com/mercury/attachments/forward/",
|
42
|
-
ctx.jar,
|
43
|
-
form
|
44
|
-
)
|
45
|
-
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
46
|
-
.then(function(resData) {
|
47
|
-
if (resData.error) {
|
48
|
-
throw resData;
|
49
|
-
}
|
50
|
-
|
51
|
-
return callback();
|
52
|
-
})
|
53
|
-
.catch(function(err) {
|
54
|
-
log.error("forwardAttachment", err);
|
55
|
-
return callback(err);
|
56
|
-
});
|
57
|
-
|
58
|
-
return returnPromise;
|
59
|
-
};
|
60
|
-
};
|
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 forwardAttachment(attachmentID, userOrUsers, 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
|
+
attachment_id: attachmentID
|
25
|
+
};
|
26
|
+
|
27
|
+
if (utils.getType(userOrUsers) !== "Array") {
|
28
|
+
userOrUsers = [userOrUsers];
|
29
|
+
}
|
30
|
+
|
31
|
+
var timestamp = Math.floor(Date.now() / 1000);
|
32
|
+
|
33
|
+
for (var i = 0; i < userOrUsers.length; i++) {
|
34
|
+
//That's good, the key of the array is really timestmap in seconds + index
|
35
|
+
//Probably time when the attachment will be sent?
|
36
|
+
form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
|
37
|
+
}
|
38
|
+
|
39
|
+
defaultFuncs
|
40
|
+
.post(
|
41
|
+
"https://www.facebook.com/mercury/attachments/forward/",
|
42
|
+
ctx.jar,
|
43
|
+
form
|
44
|
+
)
|
45
|
+
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
46
|
+
.then(function(resData) {
|
47
|
+
if (resData.error) {
|
48
|
+
throw resData;
|
49
|
+
}
|
50
|
+
|
51
|
+
return callback();
|
52
|
+
})
|
53
|
+
.catch(function(err) {
|
54
|
+
log.error("forwardAttachment", err);
|
55
|
+
return callback(err);
|
56
|
+
});
|
57
|
+
|
58
|
+
return returnPromise;
|
59
|
+
};
|
60
|
+
};
|
@@ -1,7 +1,7 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
4
|
-
return function getCurrentUserID() {
|
5
|
-
return ctx.userID;
|
6
|
-
};
|
7
|
-
};
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
4
|
+
return function getCurrentUserID() {
|
5
|
+
return ctx.userID;
|
6
|
+
};
|
7
|
+
};
|