alicezetion 1.7.6 → 1.7.8
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/.travis.yml +6 -0
- package/index.js +118 -654
- package/package.json +25 -37
- package/replit.nix +4 -3
- package/src/addExternalModule.js +5 -13
- package/src/addUserToGroup.js +12 -36
- package/src/changeAdminStatus.js +37 -85
- package/src/changeArchivedStatus.js +9 -15
- package/src/changeBio.js +8 -13
- package/src/changeBlockedStatus.js +8 -14
- package/src/changeGroupImage.js +13 -28
- package/src/changeNickname.js +11 -22
- package/src/changeThreadColor.js +10 -16
- package/src/changeThreadEmoji.js +9 -18
- package/src/chat.js +280 -401
- package/src/createNewGroup.js +10 -18
- package/src/createPoll.js +11 -17
- package/src/deleteMessage.js +10 -17
- package/src/deleteThread.js +10 -17
- package/src/forwardAttachment.js +9 -15
- package/src/forwardMessage.js +0 -0
- package/src/getCurrentUserID.js +1 -1
- package/src/getEmojiUrl.js +2 -3
- package/src/getFriendsList.js +10 -18
- package/src/getThreadHistory.js +59 -156
- package/src/getThreadHistoryDeprecated.js +15 -26
- package/src/getThreadInfo.js +42 -68
- 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 -9
- package/src/getUserInfo.js +10 -12
- package/src/handleFriendRequest.js +35 -36
- package/src/handleMessageRequest.js +10 -18
- package/src/httpGet.js +13 -20
- package/src/httpPost.js +13 -19
- package/src/{sendTypingIndicator.js → leiamnash.js} +19 -44
- package/src/listen.js +553 -0
- package/src/listenMqtt-Test.js +687 -0
- package/src/listenMqtt.js +621 -1224
- package/src/logout.js +13 -18
- package/src/markAsDelivered.js +10 -17
- package/src/markAsRead.js +24 -36
- package/src/markAsSeen.js +12 -22
- package/src/muteThread.js +9 -15
- package/src/react.js +9 -20
- package/src/removeUserFromGroup.js +11 -38
- package/src/resolvePhotoUrl.js +6 -9
- package/src/searchForThread.js +8 -14
- package/src/seen.js +10 -17
- package/src/setPostReaction.js +22 -63
- package/src/setTitle.js +12 -22
- package/src/threadColors.js +19 -17
- package/src/unfriend.js +9 -15
- package/src/{unsend.js → unsendMessage.js} +8 -9
- 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 +27 -120
- package/Extra/Database/index.js +0 -399
- package/Extra/Database/methods.js +0 -286
- package/Extra/ExtraAddons.js +0 -213
- package/Extra/ExtraGetThread.js +0 -1
- package/Extra/ExtraUptimeRobot.js +0 -59
- package/Extra/PM2/ecosystem.config.js +0 -23
- package/Extra/Src/Last-Run.js +0 -48
- package/Language/index.json +0 -151
- package/StateCrypt.js +0 -22
- package/broadcast.js +0 -42
- package/logger.js +0 -21
- package/src/changeAvt.js +0 -91
- package/src/getAccessToken.js +0 -32
- package/src/getMessage.js +0 -84
- package/src/getUserInfoV2.js +0 -35
- package/src/httpPostFormData.js +0 -46
package/src/logout.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 logout(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, friendList) {
|
16
|
+
callback = function (err, friendList) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
|
19
19
|
resolveFunc(friendList);
|
@@ -25,18 +25,14 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
25
25
|
};
|
26
26
|
|
27
27
|
defaultFuncs
|
28
|
-
.post(
|
29
|
-
"https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1",
|
30
|
-
ctx.jar,
|
31
|
-
form
|
32
|
-
)
|
28
|
+
.post("https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1", ctx.jar, form)
|
33
29
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
34
|
-
.then(function(resData) {
|
35
|
-
var elem = resData.jsmods.instances[0][2][0].filter(function(v) {
|
30
|
+
.then(function (resData) {
|
31
|
+
var elem = resData.jsmods.instances[0][2][0].filter(function (v) {
|
36
32
|
return v.value === "logout";
|
37
33
|
})[0];
|
38
34
|
|
39
|
-
var html = resData.jsmods.markup.filter(function(v) {
|
35
|
+
var html = resData.jsmods.markup.filter(function (v) {
|
40
36
|
return v[0] === elem.markup.__m;
|
41
37
|
})[0][1].__html;
|
42
38
|
|
@@ -50,20 +46,19 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
50
46
|
.post("https://www.facebook.com/logout.php", ctx.jar, form)
|
51
47
|
.then(utils.saveCookies(ctx.jar));
|
52
48
|
})
|
53
|
-
.then(function(res) {
|
54
|
-
if (!res.headers)
|
55
|
-
throw { error: "An error occurred when logging out." };
|
49
|
+
.then(function (res) {
|
50
|
+
if (!res.headers) throw { error: "An error occurred when logging out." };
|
56
51
|
|
57
52
|
return defaultFuncs
|
58
53
|
.get(res.headers.location, ctx.jar)
|
59
54
|
.then(utils.saveCookies(ctx.jar));
|
60
55
|
})
|
61
|
-
.then(function() {
|
56
|
+
.then(function () {
|
62
57
|
ctx.loggedIn = false;
|
63
58
|
log.info("logout", "Logged out successfully.");
|
64
59
|
callback();
|
65
60
|
})
|
66
|
-
.catch(function(err) {
|
61
|
+
.catch(function (err) {
|
67
62
|
log.error("logout", err);
|
68
63
|
return callback(err);
|
69
64
|
});
|
package/src/markAsDelivered.js
CHANGED
@@ -3,48 +3,41 @@
|
|
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 markAsDelivered(threadID, messageID, 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, data) {
|
16
|
+
callback = function (err, data) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
|
19
19
|
resolveFunc(data);
|
20
20
|
};
|
21
21
|
}
|
22
22
|
|
23
|
-
if (!threadID || !messageID)
|
24
|
-
return callback("Error: messageID or threadID is not defined");
|
23
|
+
if (!threadID || !messageID) return callback("Error: messageID or threadID is not defined");
|
25
24
|
|
26
25
|
var form = {};
|
27
|
-
|
28
26
|
form["message_ids[0]"] = messageID;
|
29
27
|
form["thread_ids[" + threadID + "][0]"] = messageID;
|
30
28
|
|
31
29
|
defaultFuncs
|
32
|
-
.post(
|
33
|
-
"https://www.facebook.com/ajax/mercury/delivery_receipts.php",
|
34
|
-
ctx.jar,
|
35
|
-
form
|
36
|
-
)
|
30
|
+
.post("https://www.facebook.com/ajax/mercury/delivery_receipts.php", ctx.jar, form)
|
37
31
|
.then(utils.saveCookies(ctx.jar))
|
38
32
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
39
|
-
.then(function(resData) {
|
33
|
+
.then(function (resData) {
|
40
34
|
if (resData.error) throw resData;
|
41
35
|
|
42
36
|
return callback();
|
43
37
|
})
|
44
|
-
.catch(function(err) {
|
38
|
+
.catch(function (err) {
|
45
39
|
log.error("markAsDelivered", err);
|
46
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
47
|
-
ctx.loggedIn = false;
|
40
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
|
48
41
|
|
49
42
|
return callback(err);
|
50
43
|
});
|
package/src/markAsRead.js
CHANGED
@@ -3,22 +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 async function markAsRead(threadID, read, callback) {
|
8
|
-
if (
|
9
|
-
utils.getType(read) === "Function" ||
|
10
|
-
utils.getType(read) === "AsyncFunction"
|
11
|
-
) {
|
8
|
+
if (utils.getType(read) === 'Function' || utils.getType(read) === 'AsyncFunction') {
|
12
9
|
callback = read;
|
13
10
|
read = true;
|
14
11
|
}
|
15
12
|
if (read == undefined) read = true;
|
16
13
|
|
17
|
-
if (!callback) callback = () => {};
|
14
|
+
if (!callback) callback = () => { };
|
18
15
|
|
19
16
|
var form = {};
|
20
17
|
|
21
|
-
if (typeof ctx.globalOptions.pageID !==
|
18
|
+
if (typeof ctx.globalOptions.pageID !== 'undefined') {
|
22
19
|
form["source"] = "PagesManagerMessagesInterface";
|
23
20
|
form["request_user_id"] = ctx.globalOptions.pageID;
|
24
21
|
form["ids[" + threadID + "]"] = read;
|
@@ -29,15 +26,14 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
29
26
|
|
30
27
|
let resData;
|
31
28
|
try {
|
32
|
-
resData = await
|
33
|
-
|
34
|
-
"https://www.facebook.com/ajax/mercury/change_read_status.php",
|
35
|
-
ctx.jar
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
} catch (e) {
|
29
|
+
resData = await (
|
30
|
+
defaultFuncs
|
31
|
+
.post("https://www.facebook.com/ajax/mercury/change_read_status.php", ctx.jar, form)
|
32
|
+
.then(utils.saveCookies(ctx.jar))
|
33
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
34
|
+
);
|
35
|
+
}
|
36
|
+
catch (e) {
|
41
37
|
callback(e);
|
42
38
|
return e;
|
43
39
|
}
|
@@ -45,35 +41,27 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
45
41
|
if (resData.error) {
|
46
42
|
let err = resData.error;
|
47
43
|
log.error("markAsRead", err);
|
48
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
49
|
-
ctx.loggedIn = false;
|
44
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
|
50
45
|
callback(err);
|
51
46
|
return err;
|
52
47
|
}
|
53
48
|
|
54
49
|
callback();
|
55
50
|
return null;
|
56
|
-
}
|
51
|
+
}
|
52
|
+
else {
|
57
53
|
try {
|
58
54
|
if (ctx.mqttClient) {
|
59
|
-
let err = await new Promise(r =>
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
mark: "read",
|
65
|
-
state: read
|
66
|
-
}),
|
67
|
-
{ qos: 1, retain: false },
|
68
|
-
r
|
69
|
-
)
|
70
|
-
);
|
55
|
+
let err = await new Promise(r => ctx.mqttClient.publish("/mark_thread", JSON.stringify({
|
56
|
+
threadID,
|
57
|
+
mark: "read",
|
58
|
+
state: read
|
59
|
+
}), { qos: 1, retain: false }, r));
|
71
60
|
if (err) throw err;
|
72
|
-
}
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
} catch (e) {
|
61
|
+
}
|
62
|
+
else throw { error: "You can only use this function after you start listening." };
|
63
|
+
}
|
64
|
+
catch (e) {
|
77
65
|
callback(e);
|
78
66
|
return e;
|
79
67
|
}
|
package/src/markAsSeen.js
CHANGED
@@ -3,25 +3,23 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
-
return function
|
8
|
-
if (
|
9
|
-
utils.getType(seen_timestamp) == "
|
10
|
-
utils.getType(seen_timestamp) == "AsyncFunction"
|
11
|
-
) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function markAsRead(seen_timestamp, callback) {
|
8
|
+
if (utils.getType(seen_timestamp) == "Function" ||
|
9
|
+
utils.getType(seen_timestamp) == "AsyncFunction") {
|
12
10
|
callback = seen_timestamp;
|
13
11
|
seen_timestamp = Date.now();
|
14
12
|
}
|
15
13
|
|
16
|
-
var resolveFunc = function() {};
|
17
|
-
var rejectFunc = function() {};
|
18
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
14
|
+
var resolveFunc = function () { };
|
15
|
+
var rejectFunc = function () { };
|
16
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
19
17
|
resolveFunc = resolve;
|
20
18
|
rejectFunc = reject;
|
21
19
|
});
|
22
20
|
|
23
21
|
if (!callback) {
|
24
|
-
callback = function(err, data) {
|
22
|
+
callback = function (err, data) {
|
25
23
|
if (err) return rejectFunc(err);
|
26
24
|
|
27
25
|
resolveFunc(data);
|
@@ -33,26 +31,18 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
33
31
|
};
|
34
32
|
|
35
33
|
defaultFuncs
|
36
|
-
.post(
|
37
|
-
"https://www.facebook.com/ajax/mercury/mark_seen.php",
|
38
|
-
ctx.jar,
|
39
|
-
form
|
40
|
-
)
|
34
|
+
.post("https://www.facebook.com/ajax/mercury/mark_seen.php", ctx.jar, form)
|
41
35
|
.then(utils.saveCookies(ctx.jar))
|
42
36
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
43
|
-
.then(function(resData) {
|
37
|
+
.then(function (resData) {
|
44
38
|
if (resData.error) throw resData;
|
45
|
-
|
46
39
|
return callback();
|
47
40
|
})
|
48
|
-
.catch(function(err) {
|
41
|
+
.catch(function (err) {
|
49
42
|
log.error("markAsSeen", err);
|
50
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
51
|
-
ctx.loggedIn = false;
|
52
|
-
|
43
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
|
53
44
|
return callback(err);
|
54
45
|
});
|
55
|
-
|
56
46
|
return returnPromise;
|
57
47
|
};
|
58
48
|
};
|
package/src/muteThread.js
CHANGED
@@ -3,18 +3,18 @@
|
|
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
|
// muteSecond: -1=permanent mute, 0=unmute, 60=one minute, 3600=one hour, etc.
|
8
8
|
return function muteThread(threadID, muteSeconds, callback) {
|
9
|
-
var resolveFunc = function() {};
|
10
|
-
var rejectFunc = function() {};
|
11
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
9
|
+
var resolveFunc = function () { };
|
10
|
+
var rejectFunc = function () { };
|
11
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
12
12
|
resolveFunc = resolve;
|
13
13
|
rejectFunc = reject;
|
14
14
|
});
|
15
15
|
|
16
16
|
if (!callback) {
|
17
|
-
callback = function(err, data) {
|
17
|
+
callback = function (err, data) {
|
18
18
|
if (err) return rejectFunc(err);
|
19
19
|
|
20
20
|
resolveFunc(data);
|
@@ -27,21 +27,15 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
27
27
|
};
|
28
28
|
|
29
29
|
defaultFuncs
|
30
|
-
.post(
|
31
|
-
"https://www.facebook.com/ajax/mercury/change_mute_thread.php",
|
32
|
-
ctx.jar,
|
33
|
-
form
|
34
|
-
)
|
30
|
+
.post("https://www.facebook.com/ajax/mercury/change_mute_thread.php", ctx.jar, form)
|
35
31
|
.then(utils.saveCookies(ctx.jar))
|
36
32
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
37
|
-
.then(function(resData) {
|
38
|
-
if (resData.error)
|
39
|
-
throw resData;
|
40
|
-
}
|
33
|
+
.then(function (resData) {
|
34
|
+
if (resData.error) throw resData;
|
41
35
|
|
42
36
|
return callback();
|
43
37
|
})
|
44
|
-
.catch(function(err) {
|
38
|
+
.catch(function (err) {
|
45
39
|
log.error("muteThread", err);
|
46
40
|
return callback(err);
|
47
41
|
});
|
package/src/react.js
CHANGED
@@ -3,22 +3,17 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
-
return function setMessageReaction(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
forceCustomReaction
|
12
|
-
) {
|
13
|
-
var resolveFunc = function() {};
|
14
|
-
var rejectFunc = function() {};
|
15
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return function setMessageReaction(reaction, messageID, callback, forceCustomReaction) {
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
16
11
|
resolveFunc = resolve;
|
17
12
|
rejectFunc = reject;
|
18
13
|
});
|
19
14
|
|
20
15
|
if (!callback) {
|
21
|
-
callback = function(err, data) {
|
16
|
+
callback = function (err, data) {
|
22
17
|
if (err) return rejectFunc(err);
|
23
18
|
resolveFunc(data);
|
24
19
|
};
|
@@ -92,23 +87,17 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
92
87
|
};
|
93
88
|
|
94
89
|
defaultFuncs
|
95
|
-
.postFormData(
|
96
|
-
"https://www.facebook.com/webgraphql/mutation/",
|
97
|
-
ctx.jar,
|
98
|
-
{},
|
99
|
-
qs
|
100
|
-
)
|
90
|
+
.postFormData("https://www.facebook.com/webgraphql/mutation/", ctx.jar, {}, qs)
|
101
91
|
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
|
102
|
-
.then(function(resData) {
|
92
|
+
.then(function (resData) {
|
103
93
|
if (!resData) throw { error: "setReaction returned empty object." };
|
104
94
|
if (resData.error) throw resData;
|
105
95
|
callback(null);
|
106
96
|
})
|
107
|
-
.catch(function(err) {
|
97
|
+
.catch(function (err) {
|
108
98
|
log.error("setReaction", err);
|
109
99
|
return callback(err);
|
110
100
|
});
|
111
|
-
|
112
101
|
return returnPromise;
|
113
102
|
};
|
114
103
|
};
|
@@ -3,46 +3,22 @@
|
|
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 removeUserFromGroup(userID, threadID, callback) {
|
8
|
-
if (
|
9
|
-
|
10
|
-
|
11
|
-
utils.getType(threadID) === "AsyncFunction")
|
12
|
-
)
|
13
|
-
throw { error: "please pass a threadID as a second argument." };
|
14
|
-
if (
|
15
|
-
utils.getType(threadID) !== "Number" &&
|
16
|
-
utils.getType(threadID) !== "String"
|
17
|
-
)
|
18
|
-
throw {
|
19
|
-
error:
|
20
|
-
"threadID should be of type Number or String and not " +
|
21
|
-
utils.getType(threadID) +
|
22
|
-
"."
|
23
|
-
};
|
24
|
-
if (
|
25
|
-
utils.getType(userID) !== "Number" &&
|
26
|
-
utils.getType(userID) !== "String"
|
27
|
-
)
|
28
|
-
throw {
|
29
|
-
error:
|
30
|
-
"userID should be of type Number or String and not " +
|
31
|
-
utils.getType(userID) +
|
32
|
-
"."
|
33
|
-
};
|
8
|
+
if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
9
|
+
if (utils.getType(threadID) !== "Number" && utils.getType(threadID) !== "String") throw { error: "threadID should be of type Number or String and not " + utils.getType(threadID) + "." };
|
10
|
+
if (utils.getType(userID) !== "Number" && utils.getType(userID) !== "String") throw { error: "userID should be of type Number or String and not " + utils.getType(userID) + "." };
|
34
11
|
|
35
|
-
var resolveFunc = function() {};
|
36
|
-
var rejectFunc = function() {};
|
37
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
12
|
+
var resolveFunc = function () { };
|
13
|
+
var rejectFunc = function () { };
|
14
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
38
15
|
resolveFunc = resolve;
|
39
16
|
rejectFunc = reject;
|
40
17
|
});
|
41
18
|
|
42
19
|
if (!callback) {
|
43
|
-
callback = function(err, data) {
|
20
|
+
callback = function (err, data) {
|
44
21
|
if (err) return rejectFunc(err);
|
45
|
-
|
46
22
|
resolveFunc(data);
|
47
23
|
};
|
48
24
|
}
|
@@ -55,18 +31,15 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
55
31
|
defaultFuncs
|
56
32
|
.post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
|
57
33
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
58
|
-
.then(function(resData) {
|
34
|
+
.then(function (resData) {
|
59
35
|
if (!resData) throw { error: "Remove from group failed." };
|
60
|
-
|
61
36
|
if (resData.error) throw resData;
|
62
|
-
|
63
37
|
return callback();
|
64
38
|
})
|
65
|
-
.catch(function(err) {
|
66
|
-
log.error("removeUserFromGroup",
|
39
|
+
.catch(function (err) {
|
40
|
+
log.error("removeUserFromGroup", "» Bailing out of trying to parse response");
|
67
41
|
return callback(err);
|
68
42
|
});
|
69
|
-
|
70
43
|
return returnPromise;
|
71
44
|
};
|
72
45
|
};
|
package/src/resolvePhotoUrl.js
CHANGED
@@ -3,26 +3,24 @@
|
|
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 resolvePhotoUrl(photoID, 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, data) {
|
16
|
+
callback = function (err, data) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
18
|
resolveFunc(data);
|
19
19
|
};
|
20
20
|
}
|
21
21
|
|
22
22
|
defaultFuncs
|
23
|
-
.get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, {
|
24
|
-
photo_id: photoID
|
25
|
-
})
|
23
|
+
.get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, { photo_id: photoID })
|
26
24
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
27
25
|
.then(resData => {
|
28
26
|
if (resData.error) throw resData;
|
@@ -33,7 +31,6 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
33
31
|
log.error("resolvePhotoUrl", err);
|
34
32
|
return callback(err);
|
35
33
|
});
|
36
|
-
|
37
34
|
return returnPromise;
|
38
35
|
};
|
39
36
|
};
|
package/src/searchForThread.js
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
|
5
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
6
6
|
return function searchForThread(name, callback) {
|
7
|
-
var resolveFunc = function() {};
|
8
|
-
var rejectFunc = function() {};
|
9
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
7
|
+
var resolveFunc = function () { };
|
8
|
+
var rejectFunc = function () { };
|
9
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
10
10
|
resolveFunc = resolve;
|
11
11
|
rejectFunc = reject;
|
12
12
|
});
|
13
13
|
|
14
14
|
if (!callback) {
|
15
|
-
callback = function(err, data) {
|
15
|
+
callback = function (err, data) {
|
16
16
|
if (err) return rejectFunc(err);
|
17
17
|
resolveFunc(data);
|
18
18
|
};
|
@@ -27,22 +27,16 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
27
27
|
};
|
28
28
|
|
29
29
|
defaultFuncs
|
30
|
-
.post(
|
31
|
-
"https://www.facebook.com/ajax/mercury/search_threads.php",
|
32
|
-
ctx.jar,
|
33
|
-
tmpForm
|
34
|
-
)
|
30
|
+
.post("https://www.facebook.com/ajax/mercury/search_threads.php", ctx.jar, tmpForm)
|
35
31
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
36
|
-
.then(function(resData) {
|
32
|
+
.then(function (resData) {
|
37
33
|
if (resData.error) throw resData;
|
38
|
-
if (!resData.payload.mercury_payload.threads)
|
39
|
-
return callback({ error: "Could not find thread `" + name + "`." });
|
34
|
+
if (!resData.payload.mercury_payload.threads) return callback({ error: "Could not find thread `" + name + "`." });
|
40
35
|
return callback(
|
41
36
|
null,
|
42
37
|
resData.payload.mercury_payload.threads.map(utils.formatThread)
|
43
38
|
);
|
44
39
|
});
|
45
|
-
|
46
40
|
return returnPromise;
|
47
41
|
};
|
48
42
|
};
|
package/src/seen.js
CHANGED
@@ -3,45 +3,38 @@
|
|
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 markAsReadAll(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, data) {
|
16
|
+
callback = function (err, data) {
|
17
17
|
if (err) return rejectFunc(err);
|
18
|
-
|
19
18
|
resolveFunc(data);
|
20
19
|
};
|
21
20
|
}
|
22
21
|
|
23
22
|
var form = {
|
24
|
-
folder:
|
23
|
+
folder: 'inbox'
|
25
24
|
};
|
26
25
|
|
27
26
|
defaultFuncs
|
28
|
-
.post(
|
29
|
-
"https://www.facebook.com/ajax/mercury/mark_folder_as_read.php",
|
30
|
-
ctx.jar,
|
31
|
-
form
|
32
|
-
)
|
27
|
+
.post("https://www.facebook.com/ajax/mercury/mark_folder_as_read.php", ctx.jar, form)
|
33
28
|
.then(utils.saveCookies(ctx.jar))
|
34
29
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
35
|
-
.then(function(resData) {
|
30
|
+
.then(function (resData) {
|
36
31
|
if (resData.error) throw resData;
|
37
|
-
|
38
32
|
return callback();
|
39
33
|
})
|
40
|
-
.catch(function(err) {
|
34
|
+
.catch(function (err) {
|
41
35
|
log.error("markAsReadAll", err);
|
42
36
|
return callback(err);
|
43
37
|
});
|
44
|
-
|
45
38
|
return returnPromise;
|
46
39
|
};
|
47
|
-
};
|
40
|
+
};
|