shadowx-fca 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +479 -0
- package/package.json +55 -0
- package/src/OldMessage.js +329 -0
- package/src/Screenshot.js +83 -0
- package/src/addExternalModule.js +25 -0
- package/src/addUserToGroup.js +115 -0
- package/src/changeAdminStatus.js +103 -0
- package/src/changeArchivedStatus.js +55 -0
- package/src/changeAvatar.js +136 -0
- package/src/changeAvatarV2.js +86 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +76 -0
- package/src/changeBlockedStatus.js +49 -0
- package/src/changeBlockedStatusMqtt.js +80 -0
- package/src/changeCover.js +72 -0
- package/src/changeGroupImage.js +135 -0
- package/src/changeName.js +79 -0
- package/src/changeNickname.js +59 -0
- package/src/changeThreadColor.js +65 -0
- package/src/changeThreadEmoji.js +55 -0
- package/src/changeUsername.js +59 -0
- package/src/createCommentPost.js +230 -0
- package/src/createNewGroup.js +88 -0
- package/src/createPoll.js +71 -0
- package/src/createPost.js +276 -0
- package/src/data/cache/system/data.json +4 -0
- package/src/data/cache/system/datahandle.js +21 -0
- package/src/data/getThreadInfo.json +1 -0
- package/src/deleteMessage.js +56 -0
- package/src/deleteThread.js +56 -0
- package/src/editMessage.js +68 -0
- package/src/editMessageOld.js +67 -0
- package/src/follow.js +74 -0
- package/src/forwardAttachment.js +60 -0
- package/src/friendList.js +103 -0
- package/src/getAccess.js +112 -0
- package/src/getAvatarUser.js +78 -0
- package/src/getBotInitialData.js +42 -0
- package/src/getCtx.js +5 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +29 -0
- package/src/getFriendsList.js +83 -0
- package/src/getMessage.js +847 -0
- package/src/getOptions.js +5 -0
- package/src/getRegion.js +7 -0
- package/src/getThreadHistory.js +680 -0
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/src/getThreadInfo.js +232 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getThreadTheme.js +82 -0
- package/src/getUID.js +119 -0
- package/src/getUserID.js +61 -0
- package/src/getUserInfo.js +66 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +47 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/httpPostFormData.js +70 -0
- package/src/listenMqtt.js +870 -0
- package/src/listenNotification.js +85 -0
- package/src/logout.js +75 -0
- package/src/markAsDelivered.js +47 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +40 -0
- package/src/markAsSeen.js +48 -0
- package/src/metaTheme.js +190 -0
- package/src/muteThread.js +45 -0
- package/src/note.js +228 -0
- package/src/pinMessage.js +59 -0
- package/src/refreshFb_dtsg.js +89 -0
- package/src/removeSuspiciousAccount.js +79 -0
- package/src/removeUserFromGroup.js +79 -0
- package/src/reply.js +442 -0
- package/src/resolvePhotoUrl.js +45 -0
- package/src/searchForThread.js +53 -0
- package/src/searchFriends.js +139 -0
- package/src/searchStickers.js +53 -0
- package/src/send.js +46 -0
- package/src/sendComment.js +159 -0
- package/src/sendFriendRequest.js +113 -0
- package/src/sendMessage.js +243 -0
- package/src/sendMessageMqtt.js +322 -0
- package/src/sendTypingIndicator.js +101 -0
- package/src/sendTypingIndicatorV2.js +28 -0
- package/src/setActiveStatus.js +93 -0
- package/src/setMessageReaction.js +122 -0
- package/src/setMessageReactionMqtt.js +62 -0
- package/src/setPostReaction.js +112 -0
- package/src/setProfileGuard.js +44 -0
- package/src/setProfileLock.js +98 -0
- package/src/setStoryReaction.js +134 -0
- package/src/setStorySeen.js +109 -0
- package/src/setThreadTheme.js +103 -0
- package/src/setTitle.js +90 -0
- package/src/shareContact.js +110 -0
- package/src/shareLink.js +59 -0
- package/src/stopListenMqtt.js +23 -0
- package/src/storyManager.js +358 -0
- package/src/suggestFriend.js +133 -0
- package/src/threadColors.js +131 -0
- package/src/unfriend.js +52 -0
- package/src/unsendMessage.js +45 -0
- package/src/uploadAttachment.js +93 -0
- package/utils.js +2867 -0
package/src/setTitle.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require("../utils");
|
|
4
|
+
// @NethWs3Dev
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function setTitle(newTitle, threadID, callback) {
|
|
8
|
+
if (
|
|
9
|
+
!callback &&
|
|
10
|
+
(utils.getType(threadID) === "Function" ||
|
|
11
|
+
utils.getType(threadID) === "AsyncFunction")
|
|
12
|
+
) {
|
|
13
|
+
throw { error: "please pass a threadID as a second argument." };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let resolveFunc = function () {};
|
|
17
|
+
let rejectFunc = function () {};
|
|
18
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
19
|
+
resolveFunc = resolve;
|
|
20
|
+
rejectFunc = reject;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (!callback) {
|
|
24
|
+
callback = function (err, friendList) {
|
|
25
|
+
if (err) {
|
|
26
|
+
return rejectFunc(err);
|
|
27
|
+
}
|
|
28
|
+
resolveFunc(friendList);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const messageAndOTID = utils.generateOfflineThreadingID();
|
|
33
|
+
const form = {
|
|
34
|
+
client: "mercury",
|
|
35
|
+
action_type: "ma-type:log-message",
|
|
36
|
+
author: "fbid:" + (ctx.userID),
|
|
37
|
+
author_email: "",
|
|
38
|
+
coordinates: "",
|
|
39
|
+
timestamp: Date.now(),
|
|
40
|
+
timestamp_absolute: "Today",
|
|
41
|
+
timestamp_relative: utils.generateTimestampRelative(),
|
|
42
|
+
timestamp_time_passed: "0",
|
|
43
|
+
is_unread: false,
|
|
44
|
+
is_cleared: false,
|
|
45
|
+
is_forward: false,
|
|
46
|
+
is_filtered_content: false,
|
|
47
|
+
is_spoof_warning: false,
|
|
48
|
+
source: "source:chat:web",
|
|
49
|
+
"source_tags[0]": "source:chat",
|
|
50
|
+
status: "0",
|
|
51
|
+
offline_threading_id: messageAndOTID,
|
|
52
|
+
message_id: messageAndOTID,
|
|
53
|
+
threading_id: utils.generateThreadingID(ctx.clientID),
|
|
54
|
+
manual_retry_cnt: "0",
|
|
55
|
+
thread_fbid: threadID,
|
|
56
|
+
thread_name: newTitle,
|
|
57
|
+
thread_id: threadID,
|
|
58
|
+
log_message_type: "log:thread-name",
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
defaultFuncs
|
|
62
|
+
.post(
|
|
63
|
+
"https://www.facebook.com/messaging/set_thread_name/",
|
|
64
|
+
ctx.jar,
|
|
65
|
+
form,
|
|
66
|
+
)
|
|
67
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
68
|
+
.then(function (resData) {
|
|
69
|
+
if (resData.error && resData.error === 1545012) {
|
|
70
|
+
throw { error: "Cannot change chat title: Not member of chat." };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (resData.error && resData.error === 1545003) {
|
|
74
|
+
throw { error: "Cannot set title of single-user chat." };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (resData.error) {
|
|
78
|
+
throw resData;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return callback();
|
|
82
|
+
})
|
|
83
|
+
.catch(function (err) {
|
|
84
|
+
console.error("setTitle", err);
|
|
85
|
+
return callback(err);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return returnPromise;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/* eslint-disable linebreak-style */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// fixed by kenneth panio
|
|
5
|
+
|
|
6
|
+
var utils = require("../utils");
|
|
7
|
+
|
|
8
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
9
|
+
return function shareContact(text, senderID, threadID, callback) {
|
|
10
|
+
if (!ctx.mqttClient) {
|
|
11
|
+
throw new Error('Not connected to MQTT');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
ctx.wsReqNumber ??= 0;
|
|
15
|
+
ctx.wsTaskNumber ??= 0;
|
|
16
|
+
|
|
17
|
+
ctx.wsReqNumber += 1;
|
|
18
|
+
ctx.wsTaskNumber += 1;
|
|
19
|
+
|
|
20
|
+
const queryPayload = {
|
|
21
|
+
contact_id: senderID,
|
|
22
|
+
sync_group: 1,
|
|
23
|
+
text: text || "",
|
|
24
|
+
thread_id: threadID
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const query = {
|
|
28
|
+
failure_count: null,
|
|
29
|
+
label: '359',
|
|
30
|
+
payload: JSON.stringify(queryPayload),
|
|
31
|
+
queue_name: 'messenger_contact_sharing',//xma_open_contact_share
|
|
32
|
+
task_id: Math.random() * 1001 << 0,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const context = {
|
|
36
|
+
app_id: '2220391788200892',
|
|
37
|
+
payload: {
|
|
38
|
+
tasks: [query],
|
|
39
|
+
epoch_id: utils.generateOfflineThreadingID(),
|
|
40
|
+
version_id: '7214102258676893',
|
|
41
|
+
},
|
|
42
|
+
request_id: ctx.wsReqNumber,
|
|
43
|
+
type: 3,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
context.payload = JSON.stringify(context.payload);
|
|
47
|
+
|
|
48
|
+
if (typeof callback === 'function') {
|
|
49
|
+
ctx.callback_Task[ctx.wsReqNumber] = { callback, type: "shareContact" };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ctx.mqttClient.publish('/ls_req', JSON.stringify(context), { qos: 1, retain: false });
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/*"use strict";
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
var utils = require("../utils");
|
|
60
|
+
|
|
61
|
+
// @NethWs3Dev
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
65
|
+
return async function shareContact(text, senderID, threadID, callback) {
|
|
66
|
+
await utils.parseAndCheckLogin(ctx, defaultFuncs);
|
|
67
|
+
const mqttClient = ctx.mqttClient;
|
|
68
|
+
|
|
69
|
+
if (!mqttClient) {
|
|
70
|
+
throw new Error("Not connected to MQTT");
|
|
71
|
+
}
|
|
72
|
+
var resolveFunc = function () { };
|
|
73
|
+
var rejectFunc = function () { };
|
|
74
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
75
|
+
resolveFunc = resolve;
|
|
76
|
+
rejectFunc = reject;
|
|
77
|
+
});
|
|
78
|
+
if (!callback) {
|
|
79
|
+
callback = function (err, data) {
|
|
80
|
+
if (err) return rejectFunc(err);
|
|
81
|
+
resolveFunc(data);
|
|
82
|
+
data };
|
|
83
|
+
}
|
|
84
|
+
let count_req = 0
|
|
85
|
+
var form = JSON.stringify({
|
|
86
|
+
"app_id": "2220391788200892",
|
|
87
|
+
"payload": JSON.stringify({
|
|
88
|
+
tasks: [{
|
|
89
|
+
label: '359',
|
|
90
|
+
payload: JSON.stringify({
|
|
91
|
+
"contact_id": senderID,
|
|
92
|
+
"sync_group": 1,
|
|
93
|
+
"text": text || "",
|
|
94
|
+
"thread_id": threadID
|
|
95
|
+
}),
|
|
96
|
+
queue_name: 'messenger_contact_sharing',
|
|
97
|
+
task_id: Math.random() * 1001 << 0,
|
|
98
|
+
failure_count: null,
|
|
99
|
+
}],
|
|
100
|
+
epoch_id: utils.generateOfflineThreadingID(),
|
|
101
|
+
version_id: '7214102258676893',
|
|
102
|
+
}),
|
|
103
|
+
"request_id": ++count_req,
|
|
104
|
+
"type": 3
|
|
105
|
+
});
|
|
106
|
+
mqttClient.publish('/ls_req',form)
|
|
107
|
+
|
|
108
|
+
return returnPromise;
|
|
109
|
+
};
|
|
110
|
+
};*/
|
package/src/shareLink.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var utils = require("../utils");
|
|
5
|
+
// @NethWs3Dev
|
|
6
|
+
|
|
7
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
8
|
+
return async function shareLink(text, url, threadID, callback) {
|
|
9
|
+
var resolveFunc = function () {};
|
|
10
|
+
var rejectFunc = function () {};
|
|
11
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
12
|
+
resolveFunc = resolve;
|
|
13
|
+
rejectFunc = reject;
|
|
14
|
+
});
|
|
15
|
+
if (!callback) {
|
|
16
|
+
callback = function (err, data) {
|
|
17
|
+
if (err) return rejectFunc(err);
|
|
18
|
+
resolveFunc(data);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
ctx.mqttClient.publish('/ls_req',
|
|
22
|
+
JSON.stringify({
|
|
23
|
+
"app_id": "2220391788200892",
|
|
24
|
+
"payload": JSON.stringify({
|
|
25
|
+
tasks: [{
|
|
26
|
+
label: 46,
|
|
27
|
+
payload: JSON.stringify({
|
|
28
|
+
"otid": utils.generateOfflineThreadingID(),
|
|
29
|
+
"source": 524289,
|
|
30
|
+
"sync_group": 1,
|
|
31
|
+
"send_type": 6,
|
|
32
|
+
"mark_thread_read": 0,
|
|
33
|
+
"url": url || "https://www.facebook.com/haji.atomyc2727",
|
|
34
|
+
"text": text || "",
|
|
35
|
+
"thread_id": threadID,
|
|
36
|
+
"initiating_source": 0
|
|
37
|
+
}),
|
|
38
|
+
queue_name: threadID,
|
|
39
|
+
task_id: Math.random() * 1001 << 0,
|
|
40
|
+
failure_count: null,
|
|
41
|
+
}],
|
|
42
|
+
epoch_id: utils.generateOfflineThreadingID(),
|
|
43
|
+
version_id: '7191105584331330',
|
|
44
|
+
}),
|
|
45
|
+
"request_id": ++ctx.req_ID,
|
|
46
|
+
"type": 3
|
|
47
|
+
}),
|
|
48
|
+
{
|
|
49
|
+
qos: 1,
|
|
50
|
+
retain: false,
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
ctx.callback_Task[ctx.req_ID] = new Object({
|
|
54
|
+
callback,
|
|
55
|
+
type: "shareLink"
|
|
56
|
+
});
|
|
57
|
+
return returnPromise;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
@NethWs3Dev
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// @NethWs3Dev
|
|
8
|
+
module.exports = function (defaultFuncs, api, ctx){
|
|
9
|
+
return function stopListenMqtt() {
|
|
10
|
+
if (!ctx.mqttClient) {
|
|
11
|
+
throw new Error("Not connected to MQTT");
|
|
12
|
+
}
|
|
13
|
+
console.log("stopListenMqtt", "Stopping...");
|
|
14
|
+
ctx.mqttClient.unsubscribe("/webrtc");
|
|
15
|
+
ctx.mqttClient.unsubscribe("/rtc_multi");
|
|
16
|
+
ctx.mqttClient.unsubscribe("/onevc");
|
|
17
|
+
ctx.mqttClient.publish("/browser_close", "{}");
|
|
18
|
+
ctx.mqttClient.end(false, (...data) => {
|
|
19
|
+
console.log("stopListenMqtt", "Stopped");
|
|
20
|
+
ctx.mqttClient = null;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ===========================================================
|
|
3
|
+
* 🧑💻 Author: Sheikh Tamim (ST | Sheikh Tamim)
|
|
4
|
+
* 🔰 Owner & Developer
|
|
5
|
+
* 🌐 GitHub: https://github.com/sheikhtamimlover
|
|
6
|
+
* 📸 Instagram: https://instagram.com/sheikh.tamim_lover
|
|
7
|
+
* -----------------------------------------------------------
|
|
8
|
+
* 🕊️ Respect the creator & give proper credits if reused.
|
|
9
|
+
* ===========================================================
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var utils = require('../utils.js');
|
|
14
|
+
var log = require('npmlog');
|
|
15
|
+
|
|
16
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
17
|
+
/** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Instagram: @sheikh.tamim_lover */
|
|
18
|
+
return function storyManager(options, callback) {
|
|
19
|
+
var resolveFunc = function () { };
|
|
20
|
+
var rejectFunc = function () { };
|
|
21
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
22
|
+
resolveFunc = resolve;
|
|
23
|
+
rejectFunc = reject;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (!callback) {
|
|
27
|
+
callback = function (err, data) {
|
|
28
|
+
if (err) return rejectFunc(err);
|
|
29
|
+
resolveFunc(data);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!options || typeof options !== 'object') {
|
|
34
|
+
return callback({ error: "Options object is required" });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const { action, attachment, storyID } = options;
|
|
38
|
+
|
|
39
|
+
if (!action || !['add', 'upload', 'delete', 'check'].includes(action)) {
|
|
40
|
+
return callback({ error: "Action must be 'add', 'upload', 'delete', or 'check'" });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Helper function to upload story attachment
|
|
44
|
+
function uploadStoryAttachment(attachment) {
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
if (!utils.isReadableStream(attachment)) {
|
|
47
|
+
return reject({ error: 'Attachment should be a readable stream and not ' + utils.getType(attachment) });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const uploadForm = {
|
|
51
|
+
source: "8",
|
|
52
|
+
profile_id: ctx.userID,
|
|
53
|
+
waterfallxapp: "comet_stories",
|
|
54
|
+
farr: attachment,
|
|
55
|
+
upload_id: "jsc_c_m"
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const uploadUrl = `https://upload.facebook.com/ajax/react_composer/attachments/photo/upload?av=${ctx.userID}&__aaid=0&__user=${ctx.userID}&__a=1&__req=${utils.getSignatureID()}&__hs=${ctx.fb_dtsg_ag}&dpr=1&__ccg=EXCELLENT&__rev=${ctx.req_ID}&__s=${utils.getSignatureID()}&__hsi=${ctx.hsi}&__comet_req=15&fb_dtsg=${ctx.fb_dtsg}&jazoest=${ctx.ttstamp}&lsd=${ctx.fb_dtsg}&__spin_r=${ctx.req_ID}&__spin_b=trunk&__spin_t=${Date.now()}`;
|
|
59
|
+
|
|
60
|
+
defaultFuncs
|
|
61
|
+
.postFormData(uploadUrl, ctx.jar, uploadForm)
|
|
62
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
63
|
+
.then(function (resData) {
|
|
64
|
+
if (resData.error || !resData.payload || !resData.payload.photoID) {
|
|
65
|
+
throw resData || { error: "Upload failed - no photo ID returned" };
|
|
66
|
+
}
|
|
67
|
+
resolve(resData.payload.photoID);
|
|
68
|
+
})
|
|
69
|
+
.catch(reject);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Helper function to create story
|
|
74
|
+
function createStory(photoID) {
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
const form = {
|
|
77
|
+
av: ctx.userID,
|
|
78
|
+
__aaid: 0,
|
|
79
|
+
__user: ctx.userID,
|
|
80
|
+
__a: 1,
|
|
81
|
+
__req: utils.getSignatureID(),
|
|
82
|
+
__hs: ctx.fb_dtsg_ag,
|
|
83
|
+
dpr: 1,
|
|
84
|
+
__ccg: "EXCELLENT",
|
|
85
|
+
__rev: ctx.req_ID,
|
|
86
|
+
__s: utils.getSignatureID(),
|
|
87
|
+
__hsi: ctx.hsi,
|
|
88
|
+
__comet_req: 15,
|
|
89
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
90
|
+
jazoest: ctx.ttstamp,
|
|
91
|
+
lsd: ctx.fb_dtsg,
|
|
92
|
+
__spin_r: ctx.req_ID,
|
|
93
|
+
__spin_b: "trunk",
|
|
94
|
+
__spin_t: Date.now(),
|
|
95
|
+
fb_api_caller_class: "RelayModern",
|
|
96
|
+
fb_api_req_friendly_name: "StoriesCreateMutation",
|
|
97
|
+
variables: JSON.stringify({
|
|
98
|
+
input: {
|
|
99
|
+
audiences: [{
|
|
100
|
+
stories: {
|
|
101
|
+
self: {
|
|
102
|
+
target_id: ctx.userID
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}],
|
|
106
|
+
audiences_is_complete: true,
|
|
107
|
+
logging: {
|
|
108
|
+
composer_session_id: `${Math.random().toString(36).substring(2, 8)}-${Math.random().toString(36).substring(2, 4)}-${Math.random().toString(36).substring(2, 4)}-${Math.random().toString(36).substring(2, 4)}-${Math.random().toString(36).substring(2, 12)}`
|
|
109
|
+
},
|
|
110
|
+
navigation_data: {
|
|
111
|
+
attribution_id_v2: `StoriesCreateRoot.react,comet.stories.create,unexpected,${Date.now()},545826,,;CometHomeRoot.react,comet.home,tap_tabbar,${Date.now()},661597,4748854339,,`
|
|
112
|
+
},
|
|
113
|
+
source: "WWW",
|
|
114
|
+
attachments: [{
|
|
115
|
+
photo: {
|
|
116
|
+
id: photoID,
|
|
117
|
+
overlays: []
|
|
118
|
+
}
|
|
119
|
+
}],
|
|
120
|
+
tracking: [null],
|
|
121
|
+
actor_id: ctx.userID,
|
|
122
|
+
client_mutation_id: String(Math.floor(Math.random() * 16) + 1)
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
server_timestamps: true,
|
|
126
|
+
doc_id: "24226878183562473"
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
defaultFuncs
|
|
130
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
131
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
132
|
+
.then(function (resData) {
|
|
133
|
+
if (resData.error || !resData.data || !resData.data.story_create) {
|
|
134
|
+
throw resData || { error: "Story creation failed" };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Extract story ID from response
|
|
138
|
+
let extractedStoryId = null;
|
|
139
|
+
const storyData = resData.data.story_create;
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
if (storyData.viewer && storyData.viewer.actor && storyData.viewer.actor.story_bucket) {
|
|
143
|
+
const storyNodes = storyData.viewer.actor.story_bucket.nodes;
|
|
144
|
+
if (storyNodes && storyNodes.length > 0 && storyNodes[0].first_story_to_show) {
|
|
145
|
+
extractedStoryId = storyNodes[0].first_story_to_show.id;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
} catch (e) {
|
|
149
|
+
log.warn("createStory", "Could not extract story ID from response:", e);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
resolve({
|
|
153
|
+
story_id: extractedStoryId,
|
|
154
|
+
logging_token: storyData.logging_token,
|
|
155
|
+
full_response: resData
|
|
156
|
+
});
|
|
157
|
+
})
|
|
158
|
+
.catch(reject);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Helper function to delete story
|
|
163
|
+
function deleteStory(storyID) {
|
|
164
|
+
return new Promise((resolve, reject) => {
|
|
165
|
+
const form = {
|
|
166
|
+
av: ctx.userID,
|
|
167
|
+
__aaid: 0,
|
|
168
|
+
__user: ctx.userID,
|
|
169
|
+
__a: 1,
|
|
170
|
+
__req: utils.getSignatureID(),
|
|
171
|
+
__hs: ctx.fb_dtsg_ag,
|
|
172
|
+
dpr: 1,
|
|
173
|
+
__ccg: "EXCELLENT",
|
|
174
|
+
__rev: ctx.req_ID,
|
|
175
|
+
__s: utils.getSignatureID(),
|
|
176
|
+
__hsi: ctx.hsi,
|
|
177
|
+
__comet_req: 15,
|
|
178
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
179
|
+
jazoest: ctx.ttstamp,
|
|
180
|
+
lsd: ctx.fb_dtsg,
|
|
181
|
+
__spin_r: ctx.req_ID,
|
|
182
|
+
__spin_b: "trunk",
|
|
183
|
+
__spin_t: Date.now(),
|
|
184
|
+
fb_api_caller_class: "RelayModern",
|
|
185
|
+
fb_api_req_friendly_name: "StoriesDeleteCardOptionMenuItem_StoriesDeleteMutation",
|
|
186
|
+
variables: JSON.stringify({
|
|
187
|
+
input: {
|
|
188
|
+
story_ids: [storyID],
|
|
189
|
+
actor_id: ctx.userID,
|
|
190
|
+
client_mutation_id: String(Math.floor(Math.random() * 16) + 1)
|
|
191
|
+
},
|
|
192
|
+
enable_profile_story_consumption: false
|
|
193
|
+
}),
|
|
194
|
+
server_timestamps: true,
|
|
195
|
+
doc_id: "30236153679305121"
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
defaultFuncs
|
|
199
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
200
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
201
|
+
.then(function (resData) {
|
|
202
|
+
if (resData.error) {
|
|
203
|
+
throw resData;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (!resData.data || !resData.data.stories_delete) {
|
|
207
|
+
throw { error: "Delete response missing expected data" };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
resolve({
|
|
211
|
+
deleted_story_ids: resData.data.stories_delete.deleted_story_thread_ids || [storyID],
|
|
212
|
+
success: true
|
|
213
|
+
});
|
|
214
|
+
})
|
|
215
|
+
.catch(reject);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Helper function to check user stories
|
|
220
|
+
function checkUserStories() {
|
|
221
|
+
return new Promise((resolve, reject) => {
|
|
222
|
+
const form = {
|
|
223
|
+
av: ctx.userID,
|
|
224
|
+
__aaid: 0,
|
|
225
|
+
__user: ctx.userID,
|
|
226
|
+
__a: 1,
|
|
227
|
+
__req: utils.getSignatureID(),
|
|
228
|
+
__hs: ctx.fb_dtsg_ag,
|
|
229
|
+
dpr: 1,
|
|
230
|
+
__ccg: "EXCELLENT",
|
|
231
|
+
__rev: ctx.req_ID,
|
|
232
|
+
__s: utils.getSignatureID(),
|
|
233
|
+
__hsi: ctx.hsi,
|
|
234
|
+
__comet_req: 15,
|
|
235
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
236
|
+
jazoest: ctx.ttstamp,
|
|
237
|
+
lsd: ctx.fb_dtsg,
|
|
238
|
+
__spin_r: ctx.req_ID,
|
|
239
|
+
__spin_b: "trunk",
|
|
240
|
+
__spin_t: Date.now(),
|
|
241
|
+
fb_api_caller_class: "RelayModern",
|
|
242
|
+
fb_api_req_friendly_name: "CometStoriesSuspenseViewerPaginationQuery",
|
|
243
|
+
variables: JSON.stringify({
|
|
244
|
+
count: 50,
|
|
245
|
+
scale: 1,
|
|
246
|
+
id: ctx.userID
|
|
247
|
+
}),
|
|
248
|
+
server_timestamps: true,
|
|
249
|
+
doc_id: "7723194127725452"
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
defaultFuncs
|
|
253
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
254
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
255
|
+
.then(function (resData) {
|
|
256
|
+
if (resData.error) {
|
|
257
|
+
throw resData;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
let stories = [];
|
|
261
|
+
try {
|
|
262
|
+
if (resData.data && resData.data.node && resData.data.node.story_bucket) {
|
|
263
|
+
const storyBucket = resData.data.node.story_bucket;
|
|
264
|
+
if (storyBucket.unified_stories && storyBucket.unified_stories.edges) {
|
|
265
|
+
stories = storyBucket.unified_stories.edges.map(edge => ({
|
|
266
|
+
id: edge.node.id,
|
|
267
|
+
creation_time: edge.node.creation_time,
|
|
268
|
+
attachments: edge.node.attachments || [],
|
|
269
|
+
bucket_id: storyBucket.id
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
} catch (e) {
|
|
274
|
+
log.warn("checkUserStories", "Error parsing stories:", e);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
resolve(stories);
|
|
278
|
+
})
|
|
279
|
+
.catch(reject);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Execute based on action
|
|
284
|
+
switch (action) {
|
|
285
|
+
case 'upload':
|
|
286
|
+
if (!attachment) {
|
|
287
|
+
return callback({ error: "Attachment is required for upload action" });
|
|
288
|
+
}
|
|
289
|
+
uploadStoryAttachment(attachment)
|
|
290
|
+
.then(photoID => {
|
|
291
|
+
callback(null, { success: true, photoID: photoID });
|
|
292
|
+
})
|
|
293
|
+
.catch(callback);
|
|
294
|
+
break;
|
|
295
|
+
|
|
296
|
+
case 'add':
|
|
297
|
+
if (!attachment) {
|
|
298
|
+
return callback({ error: "Attachment is required for add action" });
|
|
299
|
+
}
|
|
300
|
+
uploadStoryAttachment(attachment)
|
|
301
|
+
.then(photoID => {
|
|
302
|
+
return createStory(photoID).then(result => ({ photoID, result }));
|
|
303
|
+
})
|
|
304
|
+
.then(({ photoID, result }) => {
|
|
305
|
+
callback(null, {
|
|
306
|
+
success: true,
|
|
307
|
+
story_id: result.story_id,
|
|
308
|
+
logging_token: result.logging_token,
|
|
309
|
+
photoID: photoID,
|
|
310
|
+
full_response: result.full_response
|
|
311
|
+
});
|
|
312
|
+
})
|
|
313
|
+
.catch(err => {
|
|
314
|
+
log.error("storyManager add", err);
|
|
315
|
+
callback(err);
|
|
316
|
+
});
|
|
317
|
+
break;
|
|
318
|
+
|
|
319
|
+
case 'delete':
|
|
320
|
+
if (!storyID) {
|
|
321
|
+
return callback({ error: "Story ID is required for delete action" });
|
|
322
|
+
}
|
|
323
|
+
deleteStory(storyID)
|
|
324
|
+
.then(result => {
|
|
325
|
+
callback(null, {
|
|
326
|
+
success: true,
|
|
327
|
+
deleted_story_ids: result.deleted_story_ids
|
|
328
|
+
});
|
|
329
|
+
})
|
|
330
|
+
.catch(err => {
|
|
331
|
+
log.error("storyManager delete", err);
|
|
332
|
+
callback(err);
|
|
333
|
+
});
|
|
334
|
+
break;
|
|
335
|
+
|
|
336
|
+
case 'check':
|
|
337
|
+
checkUserStories()
|
|
338
|
+
.then(stories => {
|
|
339
|
+
callback(null, {
|
|
340
|
+
success: true,
|
|
341
|
+
stories: stories,
|
|
342
|
+
count: stories ? stories.length : 0
|
|
343
|
+
});
|
|
344
|
+
})
|
|
345
|
+
.catch(err => {
|
|
346
|
+
log.error("storyManager check", err);
|
|
347
|
+
callback(err);
|
|
348
|
+
});
|
|
349
|
+
break;
|
|
350
|
+
|
|
351
|
+
default:
|
|
352
|
+
callback({ error: "Invalid action" });
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return returnPromise;
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
/** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Please give credits if reused. */
|