alicezetion 1.0.3 → 1.0.5
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/modules.stamp +1 -0
- package/.cache/replit/nix/env.json +1 -1
- package/index.js +536 -604
- package/package.json +78 -75
- package/replit.nix +6 -0
- package/src/addExternalModule.js +15 -0
- package/{alice → src}/addUserToGroup.js +77 -113
- package/src/changeAdminStatus.js +47 -0
- package/src/changeArchivedStatus.js +41 -0
- package/{alice → src}/changeBio.js +64 -77
- package/{alice → src}/changeBlockedStatus.js +36 -47
- package/{alice → src}/changeGroupImage.js +105 -129
- package/src/changeNickname.js +43 -0
- package/{alice → src}/changeThreadColor.js +61 -71
- package/src/changeThreadEmoji.js +41 -0
- package/src/chat.js +315 -0
- package/{alice → src}/createNewGroup.js +70 -86
- package/{alice → src}/createPoll.js +59 -71
- 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/{alice → src}/getCurrentUserID.js +7 -7
- package/{alice → src}/getEmojiUrl.js +27 -29
- package/{alice → src}/getFriendsList.js +73 -84
- package/{alice → src}/getThreadHistory.js +537 -645
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/{alice → src}/getThreadInfo.js +171 -206
- package/src/getThreadInfoDeprecated.js +56 -0
- package/{alice → src}/getThreadList.js +213 -238
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/{alice → src}/getUserID.js +61 -66
- package/{alice → src}/getUserInfo.js +66 -72
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +47 -0
- package/{alice → src}/httpGet.js +47 -52
- package/{alice → src}/httpPost.js +47 -52
- package/src/listen.js +553 -0
- package/src/listenMqtt-Test.js +687 -0
- package/src/listenMqtt.js +677 -0
- package/{alice → src}/logout.js +68 -75
- package/{alice → src}/markAsDelivered.js +47 -58
- package/{alice → src}/markAsRead.js +70 -80
- package/{alice/seen.js → src/markAsReadAll.js} +39 -49
- package/{alice → src}/markAsSeen.js +48 -59
- package/{alice → src}/muteThread.js +45 -52
- package/src/removeUserFromGroup.js +45 -0
- package/{alice → src}/resolvePhotoUrl.js +36 -45
- package/src/searchForThread.js +42 -0
- package/{alice → src}/sendTypingIndicator.js +70 -103
- package/{alice/react.js → src/setMessageReaction.js} +103 -117
- package/{alice → src}/setPostReaction.js +63 -76
- package/{alice → src}/setTitle.js +70 -86
- package/src/threadColors.js +41 -0
- package/{alice → src}/unfriend.js +42 -52
- package/{alice → src}/unsendMessage.js +39 -49
- package/utils.js +1193 -1357
- package/alice/addExternalModule.js +0 -19
- package/alice/changeAdminStatus.js +0 -79
- package/alice/changeArchivedStatus.js +0 -55
- package/alice/changeNickname.js +0 -59
- package/alice/changeThreadEmoji.js +0 -55
- package/alice/chat.js +0 -459
- package/alice/deleteMessage.js +0 -56
- package/alice/deleteThread.js +0 -56
- package/alice/forwardAttachment.js +0 -60
- package/alice/getThreadHistoryDeprecated.js +0 -93
- package/alice/getThreadInfoDeprecated.js +0 -80
- package/alice/getThreadListDeprecated.js +0 -75
- package/alice/getThreadPictures.js +0 -79
- package/alice/handleFriendRequest.js +0 -61
- package/alice/handleMessageRequest.js +0 -65
- package/alice/listenMqtt.js +0 -789
- package/alice/removeUserFromGroup.js +0 -79
- package/alice/searchForThread.js +0 -53
- package/alice/threadColors.js +0 -57
- package/test/data/shareAttach.js +0 -146
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +0 -7
- package/test/example-config.json +0 -18
- package/test/test-page.js +0 -140
- package/test/test.js +0 -385
package/{alice → src}/logout.js
RENAMED
@@ -1,75 +1,68 @@
|
|
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 logout(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
|
-
callback = function (err, friendList) {
|
17
|
-
if (err)
|
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
|
-
log.error("logout", err);
|
70
|
-
return callback(err);
|
71
|
-
});
|
72
|
-
|
73
|
-
return returnPromise;
|
74
|
-
};
|
75
|
-
};
|
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 logout(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
|
+
callback = function (err, friendList) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
|
19
|
+
resolveFunc(friendList);
|
20
|
+
};
|
21
|
+
}
|
22
|
+
|
23
|
+
var form = {
|
24
|
+
pmid: "0"
|
25
|
+
};
|
26
|
+
|
27
|
+
defaultFuncs
|
28
|
+
.post("https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1", ctx.jar, form)
|
29
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
30
|
+
.then(function (resData) {
|
31
|
+
var elem = resData.jsmods.instances[0][2][0].filter(function (v) {
|
32
|
+
return v.value === "logout";
|
33
|
+
})[0];
|
34
|
+
|
35
|
+
var html = resData.jsmods.markup.filter(function (v) {
|
36
|
+
return v[0] === elem.markup.__m;
|
37
|
+
})[0][1].__html;
|
38
|
+
|
39
|
+
var form = {
|
40
|
+
fb_dtsg: utils.getFrom(html, '"fb_dtsg" value="', '"'),
|
41
|
+
ref: utils.getFrom(html, '"ref" value="', '"'),
|
42
|
+
h: utils.getFrom(html, '"h" value="', '"')
|
43
|
+
};
|
44
|
+
|
45
|
+
return defaultFuncs
|
46
|
+
.post("https://www.facebook.com/logout.php", ctx.jar, form)
|
47
|
+
.then(utils.saveCookies(ctx.jar));
|
48
|
+
})
|
49
|
+
.then(function (res) {
|
50
|
+
if (!res.headers) throw { error: "An error occurred when logging out." };
|
51
|
+
|
52
|
+
return defaultFuncs
|
53
|
+
.get(res.headers.location, ctx.jar)
|
54
|
+
.then(utils.saveCookies(ctx.jar));
|
55
|
+
})
|
56
|
+
.then(function () {
|
57
|
+
ctx.loggedIn = false;
|
58
|
+
log.info("logout", "Logged out successfully.");
|
59
|
+
callback();
|
60
|
+
})
|
61
|
+
.catch(function (err) {
|
62
|
+
log.error("logout", err);
|
63
|
+
return callback(err);
|
64
|
+
});
|
65
|
+
|
66
|
+
return returnPromise;
|
67
|
+
};
|
68
|
+
};
|
@@ -1,58 +1,47 @@
|
|
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 markAsDelivered(threadID, messageID, 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
|
-
callback = function (err,
|
17
|
-
if (err)
|
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
|
-
.catch(function (err) {
|
49
|
-
log.error("markAsDelivered", err);
|
50
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.") {
|
51
|
-
ctx.loggedIn = false;
|
52
|
-
}
|
53
|
-
return callback(err);
|
54
|
-
});
|
55
|
-
|
56
|
-
return returnPromise;
|
57
|
-
};
|
58
|
-
};
|
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 markAsDelivered(threadID, messageID, 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
|
+
callback = function (err, data) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
|
19
|
+
resolveFunc(data);
|
20
|
+
};
|
21
|
+
}
|
22
|
+
|
23
|
+
if (!threadID || !messageID) return callback("Error: messageID or threadID is not defined");
|
24
|
+
|
25
|
+
var form = {};
|
26
|
+
form["message_ids[0]"] = messageID;
|
27
|
+
form["thread_ids[" + threadID + "][0]"] = messageID;
|
28
|
+
|
29
|
+
defaultFuncs
|
30
|
+
.post("https://www.facebook.com/ajax/mercury/delivery_receipts.php", ctx.jar, form)
|
31
|
+
.then(utils.saveCookies(ctx.jar))
|
32
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
33
|
+
.then(function (resData) {
|
34
|
+
if (resData.error) throw resData;
|
35
|
+
|
36
|
+
return callback();
|
37
|
+
})
|
38
|
+
.catch(function (err) {
|
39
|
+
log.error("markAsDelivered", err);
|
40
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
|
41
|
+
|
42
|
+
return callback(err);
|
43
|
+
});
|
44
|
+
|
45
|
+
return returnPromise;
|
46
|
+
};
|
47
|
+
};
|
@@ -1,80 +1,70 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var utils = require("../utils");
|
4
|
-
var log = require("npmlog");
|
5
|
-
|
6
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
-
return async function markAsRead(threadID, read, callback) {
|
8
|
-
if (utils.getType(read) === 'Function' || utils.getType(read) === 'AsyncFunction') {
|
9
|
-
callback = read;
|
10
|
-
read = true;
|
11
|
-
}
|
12
|
-
if (read == undefined)
|
13
|
-
|
14
|
-
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
form["
|
24
|
-
form["
|
25
|
-
form["
|
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
|
-
error: "You can only use this function after you start listening."
|
72
|
-
};
|
73
|
-
}
|
74
|
-
} catch (e) {
|
75
|
-
callback(e);
|
76
|
-
return e;
|
77
|
-
}
|
78
|
-
}
|
79
|
-
};
|
80
|
-
};
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
7
|
+
return async function markAsRead(threadID, read, callback) {
|
8
|
+
if (utils.getType(read) === 'Function' || utils.getType(read) === 'AsyncFunction') {
|
9
|
+
callback = read;
|
10
|
+
read = true;
|
11
|
+
}
|
12
|
+
if (read == undefined) read = true;
|
13
|
+
|
14
|
+
if (!callback) callback = () => { };
|
15
|
+
|
16
|
+
var form = {};
|
17
|
+
|
18
|
+
if (typeof ctx.globalOptions.pageID !== 'undefined') {
|
19
|
+
form["source"] = "PagesManagerMessagesInterface";
|
20
|
+
form["request_user_id"] = ctx.globalOptions.pageID;
|
21
|
+
form["ids[" + threadID + "]"] = read;
|
22
|
+
form["watermarkTimestamp"] = new Date().getTime();
|
23
|
+
form["shouldSendReadReceipt"] = true;
|
24
|
+
form["commerce_last_message_type"] = "";
|
25
|
+
//form["titanOriginatedThreadId"] = utils.generateThreadingID(ctx.clientID);
|
26
|
+
|
27
|
+
let resData;
|
28
|
+
try {
|
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) {
|
37
|
+
callback(e);
|
38
|
+
return e;
|
39
|
+
}
|
40
|
+
|
41
|
+
if (resData.error) {
|
42
|
+
let err = resData.error;
|
43
|
+
log.error("markAsRead", err);
|
44
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
|
45
|
+
callback(err);
|
46
|
+
return err;
|
47
|
+
}
|
48
|
+
|
49
|
+
callback();
|
50
|
+
return null;
|
51
|
+
}
|
52
|
+
else {
|
53
|
+
try {
|
54
|
+
if (ctx.mqttClient) {
|
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));
|
60
|
+
if (err) throw err;
|
61
|
+
}
|
62
|
+
else throw { error: "You can only use this function after you start listening." };
|
63
|
+
}
|
64
|
+
catch (e) {
|
65
|
+
callback(e);
|
66
|
+
return e;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
};
|
70
|
+
};
|
@@ -1,50 +1,40 @@
|
|
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 markAsReadAll(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
|
-
callback = function (err,
|
17
|
-
if (err)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
)
|
34
|
-
.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
return callback();
|
42
|
-
})
|
43
|
-
.catch(function(err) {
|
44
|
-
log.error("markAsReadAll", err);
|
45
|
-
return callback(err);
|
46
|
-
});
|
47
|
-
|
48
|
-
return returnPromise;
|
49
|
-
};
|
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 markAsReadAll(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
|
+
callback = function (err, data) {
|
17
|
+
if (err) return rejectFunc(err);
|
18
|
+
resolveFunc(data);
|
19
|
+
};
|
20
|
+
}
|
21
|
+
|
22
|
+
var form = {
|
23
|
+
folder: 'inbox'
|
24
|
+
};
|
25
|
+
|
26
|
+
defaultFuncs
|
27
|
+
.post("https://www.facebook.com/ajax/mercury/mark_folder_as_read.php", ctx.jar, form)
|
28
|
+
.then(utils.saveCookies(ctx.jar))
|
29
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
30
|
+
.then(function (resData) {
|
31
|
+
if (resData.error) throw resData;
|
32
|
+
return callback();
|
33
|
+
})
|
34
|
+
.catch(function (err) {
|
35
|
+
log.error("markAsReadAll", err);
|
36
|
+
return callback(err);
|
37
|
+
});
|
38
|
+
return returnPromise;
|
39
|
+
};
|
50
40
|
};
|
@@ -1,59 +1,48 @@
|
|
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 markAsRead(seen_timestamp, callback) {
|
8
|
-
if (utils.getType(seen_timestamp) == "Function" ||
|
9
|
-
utils.getType(seen_timestamp) == "AsyncFunction") {
|
10
|
-
callback = seen_timestamp;
|
11
|
-
seen_timestamp = Date.now();
|
12
|
-
}
|
13
|
-
|
14
|
-
var resolveFunc = function () { };
|
15
|
-
var rejectFunc = function () { };
|
16
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
17
|
-
resolveFunc = resolve;
|
18
|
-
rejectFunc = reject;
|
19
|
-
});
|
20
|
-
|
21
|
-
if (!callback) {
|
22
|
-
callback = function (err,
|
23
|
-
if (err)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
.
|
42
|
-
|
43
|
-
if (
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
.catch(function (err) {
|
50
|
-
log.error("markAsSeen", err);
|
51
|
-
if (utils.getType(err) == "Object" && err.error === "Not logged in.") {
|
52
|
-
ctx.loggedIn = false;
|
53
|
-
}
|
54
|
-
return callback(err);
|
55
|
-
});
|
56
|
-
|
57
|
-
return returnPromise;
|
58
|
-
};
|
59
|
-
};
|
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 markAsRead(seen_timestamp, callback) {
|
8
|
+
if (utils.getType(seen_timestamp) == "Function" ||
|
9
|
+
utils.getType(seen_timestamp) == "AsyncFunction") {
|
10
|
+
callback = seen_timestamp;
|
11
|
+
seen_timestamp = Date.now();
|
12
|
+
}
|
13
|
+
|
14
|
+
var resolveFunc = function () { };
|
15
|
+
var rejectFunc = function () { };
|
16
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
17
|
+
resolveFunc = resolve;
|
18
|
+
rejectFunc = reject;
|
19
|
+
});
|
20
|
+
|
21
|
+
if (!callback) {
|
22
|
+
callback = function (err, data) {
|
23
|
+
if (err) return rejectFunc(err);
|
24
|
+
|
25
|
+
resolveFunc(data);
|
26
|
+
};
|
27
|
+
}
|
28
|
+
|
29
|
+
var form = {
|
30
|
+
seen_timestamp: seen_timestamp
|
31
|
+
};
|
32
|
+
|
33
|
+
defaultFuncs
|
34
|
+
.post("https://www.facebook.com/ajax/mercury/mark_seen.php", ctx.jar, form)
|
35
|
+
.then(utils.saveCookies(ctx.jar))
|
36
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
37
|
+
.then(function (resData) {
|
38
|
+
if (resData.error) throw resData;
|
39
|
+
return callback();
|
40
|
+
})
|
41
|
+
.catch(function (err) {
|
42
|
+
log.error("markAsSeen", err);
|
43
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in.") ctx.loggedIn = false;
|
44
|
+
return callback(err);
|
45
|
+
});
|
46
|
+
return returnPromise;
|
47
|
+
};
|
48
|
+
};
|