alicezetion 1.6.9 → 1.7.1
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 +182 -495
- package/package.json +10 -8
- package/replit.nix +4 -6
- package/src/addExternalModule.js +15 -0
- package/{leiamnash → src}/addUserToGroup.js +16 -52
- package/src/changeAdminStatus.js +47 -0
- package/src/changeArchivedStatus.js +41 -0
- package/{leiamnash → src}/changeBio.js +6 -19
- package/{leiamnash → src}/changeBlockedStatus.js +3 -14
- package/{leiamnash → src}/changeGroupImage.js +16 -40
- package/src/changeNickname.js +43 -0
- package/{leiamnash → src}/changeThreadColor.js +10 -20
- package/src/changeThreadEmoji.js +41 -0
- package/src/chat.js +315 -0
- package/{leiamnash → src}/createNewGroup.js +12 -28
- package/{leiamnash → src}/createPoll.js +13 -25
- package/src/deleteMessage.js +44 -0
- package/src/deleteThread.js +42 -0
- package/src/forwardAttachment.js +47 -0
- package/src/forwardMessage.js +0 -0
- package/{leiamnash → src}/getCurrentUserID.js +1 -1
- package/{leiamnash → src}/getEmojiUrl.js +2 -4
- package/{leiamnash → src}/getFriendsList.js +10 -21
- package/{leiamnash → src}/getThreadHistory.js +58 -166
- package/{leiamnash → src}/getThreadHistoryDeprecated.js +20 -42
- package/src/getThreadInfo.js +171 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/{leiamnash → src}/getThreadList.js +41 -66
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/{leiamnash → src}/getUserID.js +9 -14
- package/{leiamnash → src}/getUserInfo.js +12 -18
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +47 -0
- package/{leiamnash → src}/httpGet.js +12 -17
- package/{leiamnash → src}/httpPost.js +12 -17
- package/src/listen.js +553 -0
- package/src/listenMqtt-Test.js +687 -0
- package/src/listenMqtt.js +677 -0
- package/{leiamnash → src}/logout.js +13 -20
- package/{leiamnash → src}/markAsDelivered.js +11 -22
- package/{leiamnash → src}/markAsRead.js +11 -21
- package/{leiamnash → src}/markAsReadAll.js +10 -20
- package/{leiamnash → src}/markAsSeen.js +7 -18
- package/{leiamnash → src}/muteThread.js +11 -18
- package/src/removeUserFromGroup.js +45 -0
- package/{leiamnash → src}/resolvePhotoUrl.js +8 -17
- package/{leiamnash → src}/searchForThread.js +10 -21
- package/src/sendMessage.js +315 -0
- package/{leiamnash → src}/sendTypingIndicator.js +14 -47
- package/{leiamnash → src}/setMessageReaction.js +12 -26
- package/{leiamnash → src}/setPostReaction.js +13 -26
- package/{leiamnash → src}/setTitle.js +13 -29
- package/src/threadColors.js +41 -0
- package/{leiamnash → src}/unfriend.js +9 -19
- package/{leiamnash → src}/unsendMessage.js +9 -19
- 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 +1021 -1238
- package/leiamnash/addExternalModule.js +0 -19
- package/leiamnash/changeAdminStatus.js +0 -79
- package/leiamnash/changeApprovalMode.js +0 -80
- package/leiamnash/changeArchivedStatus.js +0 -55
- package/leiamnash/changeNickname.js +0 -59
- package/leiamnash/changeThreadEmoji.js +0 -55
- package/leiamnash/chat.js +0 -447
- package/leiamnash/deleteMessage.js +0 -56
- package/leiamnash/deleteThread.js +0 -56
- package/leiamnash/forwardAttachment.js +0 -60
- package/leiamnash/getThreadInfo.js +0 -212
- package/leiamnash/getThreadInfoDeprecated.js +0 -80
- package/leiamnash/getThreadListDeprecated.js +0 -75
- package/leiamnash/getThreadPictures.js +0 -79
- package/leiamnash/handleFriendRequest.js +0 -61
- package/leiamnash/handleMessageRequest.js +0 -65
- package/leiamnash/listenMqtt.js +0 -1129
- package/leiamnash/removeUserFromGroup.js +0 -79
- package/leiamnash/threadColors.js +0 -57
@@ -3,10 +3,10 @@
|
|
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(){};
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
10
|
var returnPromise = new Promise(function (resolve, reject) {
|
11
11
|
resolveFunc = resolve;
|
12
12
|
rejectFunc = reject;
|
@@ -14,9 +14,8 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
14
14
|
|
15
15
|
if (!callback) {
|
16
16
|
callback = function (err, friendList) {
|
17
|
-
if (err)
|
18
|
-
|
19
|
-
}
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
|
20
19
|
resolveFunc(friendList);
|
21
20
|
};
|
22
21
|
}
|
@@ -26,18 +25,14 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
26
25
|
};
|
27
26
|
|
28
27
|
defaultFuncs
|
29
|
-
.post(
|
30
|
-
"https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1",
|
31
|
-
ctx.jar,
|
32
|
-
form
|
33
|
-
)
|
28
|
+
.post("https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1", ctx.jar, form)
|
34
29
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
35
|
-
.then(function(resData) {
|
36
|
-
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) {
|
37
32
|
return v.value === "logout";
|
38
33
|
})[0];
|
39
34
|
|
40
|
-
var html = resData.jsmods.markup.filter(function(v) {
|
35
|
+
var html = resData.jsmods.markup.filter(function (v) {
|
41
36
|
return v[0] === elem.markup.__m;
|
42
37
|
})[0][1].__html;
|
43
38
|
|
@@ -51,21 +46,19 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
51
46
|
.post("https://www.facebook.com/logout.php", ctx.jar, form)
|
52
47
|
.then(utils.saveCookies(ctx.jar));
|
53
48
|
})
|
54
|
-
.then(function(res) {
|
55
|
-
if (!res.headers) {
|
56
|
-
throw { error: "An error occurred when logging out." };
|
57
|
-
}
|
49
|
+
.then(function (res) {
|
50
|
+
if (!res.headers) throw { error: "An error occurred when logging out." };
|
58
51
|
|
59
52
|
return defaultFuncs
|
60
53
|
.get(res.headers.location, ctx.jar)
|
61
54
|
.then(utils.saveCookies(ctx.jar));
|
62
55
|
})
|
63
|
-
.then(function() {
|
56
|
+
.then(function () {
|
64
57
|
ctx.loggedIn = false;
|
65
58
|
log.info("logout", "Logged out successfully.");
|
66
59
|
callback();
|
67
60
|
})
|
68
|
-
.catch(function(err) {
|
61
|
+
.catch(function (err) {
|
69
62
|
log.error("logout", err);
|
70
63
|
return callback(err);
|
71
64
|
});
|
@@ -5,51 +5,40 @@ var log = require("npmlog");
|
|
5
5
|
|
6
6
|
module.exports = function (defaultFuncs, api, ctx) {
|
7
7
|
return function markAsDelivered(threadID, messageID, callback) {
|
8
|
-
var resolveFunc = function(){};
|
9
|
-
var rejectFunc = function(){};
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
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,
|
17
|
-
if (err)
|
18
|
-
|
19
|
-
|
20
|
-
resolveFunc(friendList);
|
16
|
+
callback = function (err, data) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
|
19
|
+
resolveFunc(data);
|
21
20
|
};
|
22
21
|
}
|
23
22
|
|
24
|
-
if (!threadID || !messageID)
|
25
|
-
return callback("Error: messageID or threadID is not defined");
|
26
|
-
}
|
23
|
+
if (!threadID || !messageID) return callback("Error: messageID or threadID is not defined");
|
27
24
|
|
28
25
|
var form = {};
|
29
|
-
|
30
26
|
form["message_ids[0]"] = messageID;
|
31
27
|
form["thread_ids[" + threadID + "][0]"] = messageID;
|
32
28
|
|
33
29
|
defaultFuncs
|
34
|
-
.post(
|
35
|
-
"https://www.facebook.com/ajax/mercury/delivery_receipts.php",
|
36
|
-
ctx.jar,
|
37
|
-
form
|
38
|
-
)
|
30
|
+
.post("https://www.facebook.com/ajax/mercury/delivery_receipts.php", ctx.jar, form)
|
39
31
|
.then(utils.saveCookies(ctx.jar))
|
40
32
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
41
33
|
.then(function (resData) {
|
42
|
-
if (resData.error)
|
43
|
-
throw resData;
|
44
|
-
}
|
34
|
+
if (resData.error) throw resData;
|
45
35
|
|
46
36
|
return callback();
|
47
37
|
})
|
48
38
|
.catch(function (err) {
|
49
39
|
log.error("markAsDelivered", err);
|
50
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
51
|
-
|
52
|
-
}
|
40
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
|
41
|
+
|
53
42
|
return callback(err);
|
54
43
|
});
|
55
44
|
|
@@ -9,13 +9,9 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
9
9
|
callback = read;
|
10
10
|
read = true;
|
11
11
|
}
|
12
|
-
if (read == undefined)
|
13
|
-
read = true;
|
14
|
-
}
|
12
|
+
if (read == undefined) read = true;
|
15
13
|
|
16
|
-
if (!callback) {
|
17
|
-
callback = () => { };
|
18
|
-
}
|
14
|
+
if (!callback) callback = () => { };
|
19
15
|
|
20
16
|
var form = {};
|
21
17
|
|
@@ -32,15 +28,12 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
32
28
|
try {
|
33
29
|
resData = await (
|
34
30
|
defaultFuncs
|
35
|
-
.post(
|
36
|
-
"https://www.facebook.com/ajax/mercury/change_read_status.php",
|
37
|
-
ctx.jar,
|
38
|
-
form
|
39
|
-
)
|
31
|
+
.post("https://www.facebook.com/ajax/mercury/change_read_status.php", ctx.jar, form)
|
40
32
|
.then(utils.saveCookies(ctx.jar))
|
41
33
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
42
34
|
);
|
43
|
-
}
|
35
|
+
}
|
36
|
+
catch (e) {
|
44
37
|
callback(e);
|
45
38
|
return e;
|
46
39
|
}
|
@@ -48,16 +41,15 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
48
41
|
if (resData.error) {
|
49
42
|
let err = resData.error;
|
50
43
|
log.error("markAsRead", err);
|
51
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
52
|
-
ctx.loggedIn = false;
|
53
|
-
}
|
44
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
|
54
45
|
callback(err);
|
55
46
|
return err;
|
56
47
|
}
|
57
48
|
|
58
49
|
callback();
|
59
50
|
return null;
|
60
|
-
}
|
51
|
+
}
|
52
|
+
else {
|
61
53
|
try {
|
62
54
|
if (ctx.mqttClient) {
|
63
55
|
let err = await new Promise(r => ctx.mqttClient.publish("/mark_thread", JSON.stringify({
|
@@ -66,12 +58,10 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
66
58
|
state: read
|
67
59
|
}), { qos: 1, retain: false }, r));
|
68
60
|
if (err) throw err;
|
69
|
-
} else {
|
70
|
-
throw {
|
71
|
-
error: "You can only use this function after you start listening."
|
72
|
-
};
|
73
61
|
}
|
74
|
-
|
62
|
+
else throw { error: "You can only use this function after you start listening." };
|
63
|
+
}
|
64
|
+
catch (e) {
|
75
65
|
callback(e);
|
76
66
|
return e;
|
77
67
|
}
|
@@ -3,21 +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 markAsReadAll(callback) {
|
8
|
-
var resolveFunc = function(){};
|
9
|
-
var rejectFunc = function(){};
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
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,
|
17
|
-
if (err)
|
18
|
-
|
19
|
-
}
|
20
|
-
resolveFunc(friendList);
|
16
|
+
callback = function (err, data) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
resolveFunc(data);
|
21
19
|
};
|
22
20
|
}
|
23
21
|
|
@@ -26,25 +24,17 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
26
24
|
};
|
27
25
|
|
28
26
|
defaultFuncs
|
29
|
-
.post(
|
30
|
-
"https://www.facebook.com/ajax/mercury/mark_folder_as_read.php",
|
31
|
-
ctx.jar,
|
32
|
-
form
|
33
|
-
)
|
27
|
+
.post("https://www.facebook.com/ajax/mercury/mark_folder_as_read.php", ctx.jar, form)
|
34
28
|
.then(utils.saveCookies(ctx.jar))
|
35
29
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
36
|
-
.then(function(resData) {
|
37
|
-
if (resData.error)
|
38
|
-
throw resData;
|
39
|
-
}
|
40
|
-
|
30
|
+
.then(function (resData) {
|
31
|
+
if (resData.error) throw resData;
|
41
32
|
return callback();
|
42
33
|
})
|
43
|
-
.catch(function(err) {
|
34
|
+
.catch(function (err) {
|
44
35
|
log.error("markAsReadAll", err);
|
45
36
|
return callback(err);
|
46
37
|
});
|
47
|
-
|
48
38
|
return returnPromise;
|
49
39
|
};
|
50
40
|
};
|
@@ -19,11 +19,10 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
19
19
|
});
|
20
20
|
|
21
21
|
if (!callback) {
|
22
|
-
callback = function (err,
|
23
|
-
if (err)
|
24
|
-
|
25
|
-
|
26
|
-
resolveFunc(friendList);
|
22
|
+
callback = function (err, data) {
|
23
|
+
if (err) return rejectFunc(err);
|
24
|
+
|
25
|
+
resolveFunc(data);
|
27
26
|
};
|
28
27
|
}
|
29
28
|
|
@@ -32,28 +31,18 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
32
31
|
};
|
33
32
|
|
34
33
|
defaultFuncs
|
35
|
-
.post(
|
36
|
-
"https://www.facebook.com/ajax/mercury/mark_seen.php",
|
37
|
-
ctx.jar,
|
38
|
-
form
|
39
|
-
)
|
34
|
+
.post("https://www.facebook.com/ajax/mercury/mark_seen.php", ctx.jar, form)
|
40
35
|
.then(utils.saveCookies(ctx.jar))
|
41
36
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
42
37
|
.then(function (resData) {
|
43
|
-
if (resData.error)
|
44
|
-
throw resData;
|
45
|
-
}
|
46
|
-
|
38
|
+
if (resData.error) throw resData;
|
47
39
|
return callback();
|
48
40
|
})
|
49
41
|
.catch(function (err) {
|
50
42
|
log.error("markAsSeen", err);
|
51
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.")
|
52
|
-
ctx.loggedIn = false;
|
53
|
-
}
|
43
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
|
54
44
|
return callback(err);
|
55
45
|
});
|
56
|
-
|
57
46
|
return returnPromise;
|
58
47
|
};
|
59
48
|
};
|
@@ -3,22 +3,21 @@
|
|
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(){};
|
9
|
+
var resolveFunc = function () { };
|
10
|
+
var rejectFunc = function () { };
|
11
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,
|
18
|
-
if (err)
|
19
|
-
|
20
|
-
|
21
|
-
resolveFunc(friendList);
|
17
|
+
callback = function (err, data) {
|
18
|
+
if (err) return rejectFunc(err);
|
19
|
+
|
20
|
+
resolveFunc(data);
|
22
21
|
};
|
23
22
|
}
|
24
23
|
|
@@ -28,21 +27,15 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
28
27
|
};
|
29
28
|
|
30
29
|
defaultFuncs
|
31
|
-
.post(
|
32
|
-
"https://www.facebook.com/ajax/mercury/change_mute_thread.php",
|
33
|
-
ctx.jar,
|
34
|
-
form
|
35
|
-
)
|
30
|
+
.post("https://www.facebook.com/ajax/mercury/change_mute_thread.php", ctx.jar, form)
|
36
31
|
.then(utils.saveCookies(ctx.jar))
|
37
32
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
38
|
-
.then(function(resData) {
|
39
|
-
if (resData.error)
|
40
|
-
throw resData;
|
41
|
-
}
|
33
|
+
.then(function (resData) {
|
34
|
+
if (resData.error) throw resData;
|
42
35
|
|
43
36
|
return callback();
|
44
37
|
})
|
45
|
-
.catch(function(err) {
|
38
|
+
.catch(function (err) {
|
46
39
|
log.error("muteThread", err);
|
47
40
|
return callback(err);
|
48
41
|
});
|
@@ -0,0 +1,45 @@
|
|
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 removeUserFromGroup(userID, threadID, callback) {
|
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) + "." };
|
11
|
+
|
12
|
+
var resolveFunc = function () { };
|
13
|
+
var rejectFunc = function () { };
|
14
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
15
|
+
resolveFunc = resolve;
|
16
|
+
rejectFunc = reject;
|
17
|
+
});
|
18
|
+
|
19
|
+
if (!callback) {
|
20
|
+
callback = function (err, data) {
|
21
|
+
if (err) return rejectFunc(err);
|
22
|
+
resolveFunc(data);
|
23
|
+
};
|
24
|
+
}
|
25
|
+
|
26
|
+
var form = {
|
27
|
+
uid: userID,
|
28
|
+
tid: threadID
|
29
|
+
};
|
30
|
+
|
31
|
+
defaultFuncs
|
32
|
+
.post("https://www.facebook.com/chat/remove_participants", ctx.jar, form)
|
33
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
34
|
+
.then(function (resData) {
|
35
|
+
if (!resData) throw { error: "Remove from group failed." };
|
36
|
+
if (resData.error) throw resData;
|
37
|
+
return callback();
|
38
|
+
})
|
39
|
+
.catch(function (err) {
|
40
|
+
log.error("removeUserFromGroup", "» Bailing out of trying to parse response");
|
41
|
+
return callback(err);
|
42
|
+
});
|
43
|
+
return returnPromise;
|
44
|
+
};
|
45
|
+
};
|
@@ -3,43 +3,34 @@
|
|
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(){};
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
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,
|
17
|
-
if (err)
|
18
|
-
|
19
|
-
}
|
20
|
-
resolveFunc(friendList);
|
16
|
+
callback = function (err, data) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
resolveFunc(data);
|
21
19
|
};
|
22
20
|
}
|
23
21
|
|
24
22
|
defaultFuncs
|
25
|
-
.get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, {
|
26
|
-
photo_id: photoID
|
27
|
-
})
|
23
|
+
.get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, { photo_id: photoID })
|
28
24
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
29
25
|
.then(resData => {
|
30
|
-
if (resData.error)
|
31
|
-
throw resData;
|
32
|
-
}
|
33
|
-
|
26
|
+
if (resData.error) throw resData;
|
34
27
|
var photoUrl = resData.jsmods.require[0][3][0];
|
35
|
-
|
36
28
|
return callback(null, photoUrl);
|
37
29
|
})
|
38
30
|
.catch(err => {
|
39
31
|
log.error("resolvePhotoUrl", err);
|
40
32
|
return callback(err);
|
41
33
|
});
|
42
|
-
|
43
34
|
return returnPromise;
|
44
35
|
};
|
45
36
|
};
|
@@ -2,21 +2,19 @@
|
|
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(){};
|
7
|
+
var resolveFunc = function () { };
|
8
|
+
var rejectFunc = function () { };
|
9
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,
|
16
|
-
if (err)
|
17
|
-
|
18
|
-
}
|
19
|
-
resolveFunc(friendList);
|
15
|
+
callback = function (err, data) {
|
16
|
+
if (err) return rejectFunc(err);
|
17
|
+
resolveFunc(data);
|
20
18
|
};
|
21
19
|
}
|
22
20
|
|
@@ -29,25 +27,16 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
29
27
|
};
|
30
28
|
|
31
29
|
defaultFuncs
|
32
|
-
.post(
|
33
|
-
"https://www.facebook.com/ajax/mercury/search_threads.php",
|
34
|
-
ctx.jar,
|
35
|
-
tmpForm
|
36
|
-
)
|
30
|
+
.post("https://www.facebook.com/ajax/mercury/search_threads.php", ctx.jar, tmpForm)
|
37
31
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
38
|
-
.then(function(resData) {
|
39
|
-
if (resData.error)
|
40
|
-
|
41
|
-
}
|
42
|
-
if (!resData.payload.mercury_payload.threads) {
|
43
|
-
return callback({ error: "Could not find thread `" + name + "`." });
|
44
|
-
}
|
32
|
+
.then(function (resData) {
|
33
|
+
if (resData.error) throw resData;
|
34
|
+
if (!resData.payload.mercury_payload.threads) return callback({ error: "Could not find thread `" + name + "`." });
|
45
35
|
return callback(
|
46
36
|
null,
|
47
37
|
resData.payload.mercury_payload.threads.map(utils.formatThread)
|
48
38
|
);
|
49
39
|
});
|
50
|
-
|
51
40
|
return returnPromise;
|
52
41
|
};
|
53
42
|
};
|