stfca 1.0.14 → 1.0.15
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/package.json +1 -1
- package/src/note.js +228 -0
- package/src/removeSuspiciousAccount.js +79 -0
- package/src/setActiveStatus.js +93 -0
- package/src/setProfileLock.js +98 -0
- package/src/setStoryReaction.js +98 -28
- package/src/setStorySeen.js +109 -0
- package/src/storyManager.js +358 -0
package/package.json
CHANGED
package/src/note.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const utils = require('../utils');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description Enhanced module for interacting with Facebook Messenger Notes with additional features
|
|
8
|
+
* @param {Object} defaultFuncs The default functions provided by the API wrapper
|
|
9
|
+
* @param {Object} api The full API object
|
|
10
|
+
* @param {Object} ctx The context object containing the user's session state
|
|
11
|
+
* @returns {Object} An object containing enhanced methods for note management
|
|
12
|
+
*/
|
|
13
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @callback notesCallback
|
|
17
|
+
* @param {Error|null} error An error object if the request fails, otherwise null
|
|
18
|
+
* @param {Object} [data] The data returned from the API
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Enhanced check note function with additional user info
|
|
23
|
+
*/
|
|
24
|
+
function checkNoteAdvanced(callback) {
|
|
25
|
+
if (typeof callback !== 'function') {
|
|
26
|
+
callback = () => {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const form = {
|
|
30
|
+
fb_api_caller_class: "RelayModern",
|
|
31
|
+
fb_api_req_friendly_name: "MWInboxTrayNoteCreationDialogQuery",
|
|
32
|
+
variables: JSON.stringify({ scale: 2 }),
|
|
33
|
+
doc_id: "30899655739648624",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
defaultFuncs
|
|
37
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
38
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
39
|
+
.then(resData => {
|
|
40
|
+
if (resData && resData.errors) throw resData.errors[0];
|
|
41
|
+
const currentNote = resData?.data?.viewer?.actor?.msgr_user_rich_status;
|
|
42
|
+
|
|
43
|
+
// Enhanced response with additional metadata
|
|
44
|
+
const enhancedResponse = {
|
|
45
|
+
note: currentNote,
|
|
46
|
+
hasActiveNote: !!currentNote,
|
|
47
|
+
userId: ctx.userID,
|
|
48
|
+
timestamp: Date.now(),
|
|
49
|
+
expiresAt: currentNote ? (currentNote.created_time * 1000) + (24 * 60 * 60 * 1000) : null
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
callback(null, enhancedResponse);
|
|
53
|
+
})
|
|
54
|
+
.catch(err => {
|
|
55
|
+
utils.error && utils.error("notesv2.checkNoteAdvanced", err);
|
|
56
|
+
callback(err);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Create note with enhanced privacy options and validation
|
|
62
|
+
*/
|
|
63
|
+
function createNoteAdvanced(text, options = {}, callback) {
|
|
64
|
+
if (typeof options === 'function') {
|
|
65
|
+
callback = options;
|
|
66
|
+
options = {};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (typeof callback !== 'function') {
|
|
70
|
+
callback = () => {};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Validate input
|
|
74
|
+
if (!text || text.trim().length === 0) {
|
|
75
|
+
return callback(new Error("Note text cannot be empty"));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (text.length > 280) {
|
|
79
|
+
return callback(new Error("Note text cannot exceed 280 characters"));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const {
|
|
83
|
+
privacy = "FRIENDS",
|
|
84
|
+
duration = 86400,
|
|
85
|
+
noteType = "TEXT_NOTE"
|
|
86
|
+
} = options;
|
|
87
|
+
|
|
88
|
+
const variables = {
|
|
89
|
+
input: {
|
|
90
|
+
client_mutation_id: Math.round(Math.random() * 1000000).toString(),
|
|
91
|
+
actor_id: ctx.userID,
|
|
92
|
+
description: text.trim(),
|
|
93
|
+
duration: duration,
|
|
94
|
+
note_type: noteType,
|
|
95
|
+
privacy: privacy,
|
|
96
|
+
session_id: utils.getGUID(),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const form = {
|
|
101
|
+
fb_api_caller_class: "RelayModern",
|
|
102
|
+
fb_api_req_friendly_name: "MWInboxTrayNoteCreationDialogCreationStepContentMutation",
|
|
103
|
+
variables: JSON.stringify(variables),
|
|
104
|
+
doc_id: "24060573783603122",
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
defaultFuncs
|
|
108
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
109
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
110
|
+
.then(resData => {
|
|
111
|
+
if (resData && resData.errors) throw resData.errors[0];
|
|
112
|
+
const status = resData?.data?.xfb_rich_status_create?.status;
|
|
113
|
+
if (!status) throw new Error("Could not find note status in the server response.");
|
|
114
|
+
|
|
115
|
+
// Enhanced response
|
|
116
|
+
const enhancedResponse = {
|
|
117
|
+
...status,
|
|
118
|
+
createdAt: Date.now(),
|
|
119
|
+
expiresAt: Date.now() + (duration * 1000),
|
|
120
|
+
characterCount: text.trim().length,
|
|
121
|
+
privacy: privacy
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
callback(null, enhancedResponse);
|
|
125
|
+
})
|
|
126
|
+
.catch(err => {
|
|
127
|
+
utils.error && utils.error("notesv2.createNoteAdvanced", err);
|
|
128
|
+
callback(err);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Delete note with confirmation
|
|
134
|
+
*/
|
|
135
|
+
function deleteNoteAdvanced(noteID, callback) {
|
|
136
|
+
if (typeof callback !== 'function') {
|
|
137
|
+
callback = () => {};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!noteID) {
|
|
141
|
+
return callback(new Error("Note ID is required"));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const variables = {
|
|
145
|
+
input: {
|
|
146
|
+
client_mutation_id: Math.round(Math.random() * 1000000).toString(),
|
|
147
|
+
actor_id: ctx.userID,
|
|
148
|
+
rich_status_id: noteID,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const form = {
|
|
153
|
+
fb_api_caller_class: "RelayModern",
|
|
154
|
+
fb_api_req_friendly_name: "useMWInboxTrayDeleteNoteMutation",
|
|
155
|
+
variables: JSON.stringify(variables),
|
|
156
|
+
doc_id: "9532619970198958",
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
defaultFuncs
|
|
160
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
161
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
162
|
+
.then(resData => {
|
|
163
|
+
if (resData && resData.errors) throw resData.errors[0];
|
|
164
|
+
const deletedStatus = resData?.data?.xfb_rich_status_delete;
|
|
165
|
+
if (!deletedStatus) throw new Error("Could not find deletion status in the server response.");
|
|
166
|
+
|
|
167
|
+
const enhancedResponse = {
|
|
168
|
+
...deletedStatus,
|
|
169
|
+
deletedAt: Date.now(),
|
|
170
|
+
noteId: noteID
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
callback(null, enhancedResponse);
|
|
174
|
+
})
|
|
175
|
+
.catch(err => {
|
|
176
|
+
utils.error && utils.error("notesv2.deleteNoteAdvanced", err);
|
|
177
|
+
callback(err);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Update existing note (delete old and create new)
|
|
183
|
+
*/
|
|
184
|
+
function updateNote(oldNoteID, newText, options = {}, callback) {
|
|
185
|
+
if (typeof options === 'function') {
|
|
186
|
+
callback = options;
|
|
187
|
+
options = {};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (typeof callback !== 'function') {
|
|
191
|
+
callback = () => {};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
deleteNoteAdvanced(oldNoteID, (err, deleted) => {
|
|
195
|
+
if (err) {
|
|
196
|
+
return callback(err);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Wait a bit before creating new note
|
|
200
|
+
setTimeout(() => {
|
|
201
|
+
createNoteAdvanced(newText, options, (err, created) => {
|
|
202
|
+
if (err) {
|
|
203
|
+
return callback(err);
|
|
204
|
+
}
|
|
205
|
+
callback(null, {
|
|
206
|
+
deleted,
|
|
207
|
+
created,
|
|
208
|
+
updatedAt: Date.now()
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
}, 1000);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
// Enhanced functions
|
|
217
|
+
checkAdvanced: checkNoteAdvanced,
|
|
218
|
+
createAdvanced: createNoteAdvanced,
|
|
219
|
+
deleteAdvanced: deleteNoteAdvanced,
|
|
220
|
+
update: updateNote,
|
|
221
|
+
|
|
222
|
+
// Backward compatibility
|
|
223
|
+
check: checkNoteAdvanced,
|
|
224
|
+
create: createNoteAdvanced,
|
|
225
|
+
delete: deleteNoteAdvanced,
|
|
226
|
+
recreate: updateNote
|
|
227
|
+
};
|
|
228
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
const utils = require("../utils");
|
|
14
|
+
const 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 removeSuspiciousAccount(callback) {
|
|
19
|
+
let resolveFunc = function () {};
|
|
20
|
+
let rejectFunc = function () {};
|
|
21
|
+
const 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
|
+
const form = {
|
|
34
|
+
av: ctx.userID,
|
|
35
|
+
__user: ctx.userID,
|
|
36
|
+
__a: "1",
|
|
37
|
+
__req: utils.getGUID(),
|
|
38
|
+
__hs: utils.getEventTime(),
|
|
39
|
+
dpr: "1",
|
|
40
|
+
__ccg: "EXCELLENT",
|
|
41
|
+
__rev: "1029700657",
|
|
42
|
+
__s: utils.getSessionID(),
|
|
43
|
+
__hsi: utils.getEventTime(),
|
|
44
|
+
__dyn: ctx.__dyn || "",
|
|
45
|
+
__csr: ctx.__csr || "",
|
|
46
|
+
__comet_req: "15",
|
|
47
|
+
fb_dtsg: ctx.fb_dtsg || "",
|
|
48
|
+
jazoest: utils.getJazoest(ctx.fb_dtsg),
|
|
49
|
+
lsd: utils.getFormData(ctx.jar, "https://www.facebook.com")?.lsd || "J4SCzL5WXd7KIzVF0tdxFm",
|
|
50
|
+
__spin_r: "1029700657",
|
|
51
|
+
__spin_b: "trunk",
|
|
52
|
+
__spin_t: utils.getEventTime(),
|
|
53
|
+
fb_api_caller_class: "RelayModern",
|
|
54
|
+
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
|
55
|
+
server_timestamps: "true",
|
|
56
|
+
variables: "{}",
|
|
57
|
+
doc_id: "24406519995698862"
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
defaultFuncs
|
|
61
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
62
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
63
|
+
.then(function (resData) {
|
|
64
|
+
if (resData.error) {
|
|
65
|
+
throw resData;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
log.info("removeSuspiciousAccount", "Successfully removed suspicious account warning");
|
|
69
|
+
callback(null, { success: true, message: "Suspicious account warning removed" });
|
|
70
|
+
})
|
|
71
|
+
.catch(function (err) {
|
|
72
|
+
log.error("removeSuspiciousAccount", err);
|
|
73
|
+
return callback(err);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return returnPromise;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Please give credits if reused. */
|
|
@@ -0,0 +1,93 @@
|
|
|
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");
|
|
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 setActiveStatus(isActive, 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 (typeof isActive !== "boolean") {
|
|
34
|
+
return callback({ error: "isActive must be a boolean value" });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const form = {
|
|
38
|
+
av: ctx.userID,
|
|
39
|
+
__aaid: 0,
|
|
40
|
+
__user: ctx.userID,
|
|
41
|
+
__a: 1,
|
|
42
|
+
__req: utils.getSignatureID(),
|
|
43
|
+
__hs: "20351.HYP:comet_pkg.2.1...0",
|
|
44
|
+
dpr: 1,
|
|
45
|
+
__ccg: "EXCELLENT",
|
|
46
|
+
__rev: "1027388793",
|
|
47
|
+
__s: utils.getSignatureID(),
|
|
48
|
+
__hsi: "7552256848274926554",
|
|
49
|
+
__comet_req: 15,
|
|
50
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
51
|
+
jazoest: ctx.ttstamp,
|
|
52
|
+
lsd: ctx.fb_dtsg,
|
|
53
|
+
__spin_r: "1027388793",
|
|
54
|
+
__spin_b: "trunk",
|
|
55
|
+
__spin_t: Date.now(),
|
|
56
|
+
fb_api_caller_class: "RelayModern",
|
|
57
|
+
fb_api_req_friendly_name: "UpdatePresenceSettingsMutation",
|
|
58
|
+
variables: JSON.stringify({
|
|
59
|
+
input: {
|
|
60
|
+
online_policy: "ALLOWLIST",
|
|
61
|
+
web_allowlist: [],
|
|
62
|
+
web_visibility: isActive,
|
|
63
|
+
actor_id: ctx.userID.toString(),
|
|
64
|
+
client_mutation_id: "1"
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
server_timestamps: true,
|
|
68
|
+
doc_id: "9444355898946246"
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
defaultFuncs
|
|
72
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
73
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
74
|
+
.then(function (resData) {
|
|
75
|
+
if (resData.error) {
|
|
76
|
+
throw resData;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return callback(null, {
|
|
80
|
+
success: true,
|
|
81
|
+
activeStatus: isActive,
|
|
82
|
+
response: resData
|
|
83
|
+
});
|
|
84
|
+
})
|
|
85
|
+
.catch(function (err) {
|
|
86
|
+
log.error("setActiveStatus", err);
|
|
87
|
+
return callback(err);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return returnPromise;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Please give credits if reused. */
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
const utils = require("../utils");
|
|
14
|
+
const 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 setProfileLock(enable, callback) {
|
|
19
|
+
let resolveFunc = function () { };
|
|
20
|
+
let rejectFunc = function () { };
|
|
21
|
+
const 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) {
|
|
29
|
+
return rejectFunc(err);
|
|
30
|
+
}
|
|
31
|
+
resolveFunc(data);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (typeof enable !== "boolean") {
|
|
36
|
+
return callback(new Error("enable must be a boolean value"));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const form = {
|
|
40
|
+
av: ctx.userID,
|
|
41
|
+
__aaid: 0,
|
|
42
|
+
__user: ctx.userID,
|
|
43
|
+
__a: 1,
|
|
44
|
+
__req: utils.getGUID(),
|
|
45
|
+
__hs: ctx.fb_dtsg_ag,
|
|
46
|
+
dpr: 1,
|
|
47
|
+
__ccg: "EXCELLENT",
|
|
48
|
+
__rev: ctx.req_ID,
|
|
49
|
+
__s: utils.getGUID(),
|
|
50
|
+
__hsi: ctx.hsi,
|
|
51
|
+
__comet_req: 15,
|
|
52
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
53
|
+
jazoest: utils.getJazoest(ctx.fb_dtsg),
|
|
54
|
+
lsd: ctx.fb_dtsg,
|
|
55
|
+
__spin_r: ctx.req_ID,
|
|
56
|
+
__spin_b: "trunk",
|
|
57
|
+
__spin_t: Date.now(),
|
|
58
|
+
__crn: "comet.fbweb.CometProfileTimelineListViewRoute",
|
|
59
|
+
fb_api_caller_class: "RelayModern",
|
|
60
|
+
fb_api_req_friendly_name: "WemPrivateSharingMutation",
|
|
61
|
+
server_timestamps: true,
|
|
62
|
+
variables: JSON.stringify({
|
|
63
|
+
enable: !enable
|
|
64
|
+
}),
|
|
65
|
+
doc_id: "9144138075685633"
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
defaultFuncs
|
|
69
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
70
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
71
|
+
.then(function (resData) {
|
|
72
|
+
if (resData.error) {
|
|
73
|
+
throw resData;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const result = resData?.data?.toggle_wem_private_sharing_control_enabled;
|
|
77
|
+
|
|
78
|
+
if (!result) {
|
|
79
|
+
throw new Error("Cannot toggle profile lock status");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return callback(null, {
|
|
83
|
+
private_sharing_enabled: result.private_sharing_enabled,
|
|
84
|
+
is_ppg_converter: result.is_ppg_converter,
|
|
85
|
+
is_ppg_user: result.is_ppg_user,
|
|
86
|
+
last_toggle_time: result.private_sharing_last_toggle_time,
|
|
87
|
+
owner_id: result.owner_id
|
|
88
|
+
});
|
|
89
|
+
})
|
|
90
|
+
.catch(function (err) {
|
|
91
|
+
log.error("setProfileLock", err);
|
|
92
|
+
return callback(err);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return returnPromise;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
/** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Please give credits if reused. */
|
package/src/setStoryReaction.js
CHANGED
|
@@ -1,64 +1,134 @@
|
|
|
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
|
+
*/
|
|
1
11
|
'use strict';
|
|
2
12
|
|
|
3
13
|
var utils = require('../utils.js');
|
|
4
14
|
var log = require('npmlog');
|
|
5
15
|
|
|
6
16
|
module.exports = function(defaultFuncs, api, ctx) {
|
|
17
|
+
/** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Instagram: @sheikh.tamim_lover */
|
|
7
18
|
return function setStoryReaction(storyID, react, callback) {
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
19
|
+
var resolveFunc = function () { };
|
|
20
|
+
var rejectFunc = function () { };
|
|
21
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
22
|
+
resolveFunc = resolve;
|
|
23
|
+
rejectFunc = reject;
|
|
11
24
|
});
|
|
12
25
|
|
|
13
26
|
if (typeof react == 'function') {
|
|
14
27
|
callback = react;
|
|
15
|
-
react =
|
|
28
|
+
react = '❤️'; // Default heart reaction
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!callback) {
|
|
32
|
+
callback = function (err, data) {
|
|
33
|
+
if (err) return rejectFunc(err);
|
|
34
|
+
resolveFunc(data);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!storyID) {
|
|
39
|
+
return callback({ error: "storyID is required" });
|
|
16
40
|
}
|
|
17
|
-
if (typeof callback == 'function') cb = callback;
|
|
18
|
-
if (typeof Number(react) != 'number') react = 1;
|
|
19
41
|
|
|
20
|
-
var
|
|
42
|
+
var reactionMap = {
|
|
21
43
|
1: '👍',
|
|
22
|
-
2: '❤️',
|
|
44
|
+
2: '❤️',
|
|
23
45
|
3: '🤗',
|
|
24
46
|
4: '😆',
|
|
25
47
|
5: '😮',
|
|
26
48
|
6: '😢',
|
|
27
|
-
7: '😡'
|
|
28
|
-
|
|
49
|
+
7: '😡',
|
|
50
|
+
'like': '👍',
|
|
51
|
+
'love': '❤️',
|
|
52
|
+
'heart': '❤️',
|
|
53
|
+
'haha': '😆',
|
|
54
|
+
'wow': '😮',
|
|
55
|
+
'sad': '😢',
|
|
56
|
+
'angry': '😡'
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
var reaction = reactionMap[react] || react || '❤️';
|
|
60
|
+
|
|
29
61
|
var form = {
|
|
30
|
-
|
|
62
|
+
av: ctx.userID,
|
|
63
|
+
__aaid: 0,
|
|
64
|
+
__user: ctx.userID,
|
|
65
|
+
__a: 1,
|
|
66
|
+
__req: utils.getSignatureID(),
|
|
67
|
+
__hs: ctx.fb_dtsg_ag,
|
|
68
|
+
dpr: 1,
|
|
69
|
+
__ccg: "EXCELLENT",
|
|
70
|
+
__rev: ctx.req_ID,
|
|
71
|
+
__s: utils.getSignatureID(),
|
|
72
|
+
__hsi: ctx.hsi,
|
|
73
|
+
__comet_req: 15,
|
|
74
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
75
|
+
jazoest: ctx.ttstamp,
|
|
76
|
+
lsd: ctx.fb_dtsg,
|
|
77
|
+
__spin_r: ctx.req_ID,
|
|
78
|
+
__spin_b: "trunk",
|
|
79
|
+
__spin_t: Date.now(),
|
|
80
|
+
fb_api_caller_class: "RelayModern",
|
|
81
|
+
fb_api_req_friendly_name: "useStoriesSendReplyMutation",
|
|
31
82
|
variables: JSON.stringify({
|
|
32
83
|
input: {
|
|
33
|
-
attribution_id_v2: `StoriesCometSuspenseRoot.react,comet.stories.viewer,unexpected,${Date.now()},
|
|
84
|
+
attribution_id_v2: `StoriesCometSuspenseRoot.react,comet.stories.viewer,unexpected,${Date.now()},356653,,;CometHomeRoot.react,comet.home,tap_tabbar,${Date.now()},109945,4748854339,,`,
|
|
34
85
|
lightweight_reaction_actions: {
|
|
35
86
|
offsets: [0],
|
|
36
|
-
reaction:
|
|
87
|
+
reaction: reaction
|
|
37
88
|
},
|
|
38
|
-
message:
|
|
89
|
+
message: reaction,
|
|
39
90
|
story_id: storyID,
|
|
40
91
|
story_reply_type: "LIGHT_WEIGHT",
|
|
41
92
|
actor_id: ctx.userID,
|
|
42
|
-
client_mutation_id: String(
|
|
93
|
+
client_mutation_id: String(Math.floor(Math.random() * 16) + 1)
|
|
43
94
|
}
|
|
44
95
|
}),
|
|
45
|
-
|
|
46
|
-
|
|
96
|
+
server_timestamps: true,
|
|
97
|
+
doc_id: "9697491553691692"
|
|
98
|
+
};
|
|
47
99
|
|
|
48
100
|
defaultFuncs
|
|
49
|
-
.post(
|
|
101
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
50
102
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
51
|
-
.then(function(
|
|
52
|
-
if (
|
|
53
|
-
|
|
103
|
+
.then(function (resData) {
|
|
104
|
+
if (resData.error) throw resData;
|
|
105
|
+
|
|
106
|
+
// Parse successful response
|
|
107
|
+
if (resData.data && resData.data.direct_message_reply) {
|
|
108
|
+
const replyData = resData.data.direct_message_reply;
|
|
109
|
+
return callback(null, {
|
|
110
|
+
success: true,
|
|
111
|
+
client_mutation_id: replyData.client_mutation_id,
|
|
112
|
+
story_id: replyData.story?.id || storyID,
|
|
113
|
+
reaction: reaction,
|
|
114
|
+
story_reactions: replyData.story?.story_card_info?.story_card_reactions?.edges || [],
|
|
115
|
+
timestamp: Date.now()
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return callback(null, {
|
|
120
|
+
success: true,
|
|
121
|
+
reaction: reaction,
|
|
122
|
+
story_id: storyID,
|
|
123
|
+
timestamp: Date.now()
|
|
124
|
+
});
|
|
54
125
|
})
|
|
55
|
-
.catch(function(err) {
|
|
56
|
-
|
|
57
|
-
return
|
|
126
|
+
.catch(function (err) {
|
|
127
|
+
log.error("setStoryReaction", err);
|
|
128
|
+
return callback(err);
|
|
58
129
|
});
|
|
59
130
|
|
|
60
131
|
return returnPromise;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
//new update version 1.0.9
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
/** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Please give credits if reused. */
|
|
@@ -0,0 +1,109 @@
|
|
|
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 setStorySeen(storyID, 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 (!storyID) {
|
|
34
|
+
return callback({ error: "storyID is required" });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Extract bucket_id from story_id if needed
|
|
38
|
+
var bucketID = storyID;
|
|
39
|
+
if (typeof storyID === 'string' && storyID.includes(':')) {
|
|
40
|
+
// Extract bucket ID from the story ID pattern
|
|
41
|
+
try {
|
|
42
|
+
var decoded = Buffer.from(storyID, 'base64').toString('utf-8');
|
|
43
|
+
var match = decoded.match(/(\d+)/);
|
|
44
|
+
if (match) {
|
|
45
|
+
bucketID = match[1];
|
|
46
|
+
}
|
|
47
|
+
} catch (e) {
|
|
48
|
+
// Fallback to using story ID as bucket ID
|
|
49
|
+
bucketID = storyID;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var form = {
|
|
54
|
+
av: ctx.userID,
|
|
55
|
+
__aaid: 0,
|
|
56
|
+
__user: ctx.userID,
|
|
57
|
+
__a: 1,
|
|
58
|
+
__req: utils.getSignatureID(),
|
|
59
|
+
__hs: ctx.fb_dtsg_ag,
|
|
60
|
+
dpr: 1,
|
|
61
|
+
__ccg: "EXCELLENT",
|
|
62
|
+
__rev: ctx.req_ID,
|
|
63
|
+
__s: utils.getSignatureID(),
|
|
64
|
+
__hsi: ctx.hsi,
|
|
65
|
+
__comet_req: 15,
|
|
66
|
+
fb_dtsg: ctx.fb_dtsg,
|
|
67
|
+
jazoest: ctx.ttstamp,
|
|
68
|
+
lsd: ctx.fb_dtsg,
|
|
69
|
+
__spin_r: ctx.req_ID,
|
|
70
|
+
__spin_b: "trunk",
|
|
71
|
+
__spin_t: Date.now(),
|
|
72
|
+
fb_api_caller_class: "RelayModern",
|
|
73
|
+
fb_api_req_friendly_name: "storiesUpdateSeenStateMutation",
|
|
74
|
+
variables: JSON.stringify({
|
|
75
|
+
input: {
|
|
76
|
+
bucket_id: bucketID,
|
|
77
|
+
story_id: storyID,
|
|
78
|
+
actor_id: ctx.userID,
|
|
79
|
+
client_mutation_id: String(Math.floor(Math.random() * 16) + 1)
|
|
80
|
+
},
|
|
81
|
+
scale: 1
|
|
82
|
+
}),
|
|
83
|
+
server_timestamps: true,
|
|
84
|
+
doc_id: "9567413276713742"
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
defaultFuncs
|
|
88
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
89
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
90
|
+
.then(function (resData) {
|
|
91
|
+
if (resData.error) throw resData;
|
|
92
|
+
|
|
93
|
+
return callback(null, {
|
|
94
|
+
success: true,
|
|
95
|
+
story_id: storyID,
|
|
96
|
+
bucket_id: bucketID,
|
|
97
|
+
seen_time: Date.now(),
|
|
98
|
+
response: resData
|
|
99
|
+
});
|
|
100
|
+
})
|
|
101
|
+
.catch(function (err) {
|
|
102
|
+
log.error("setStorySeen", err);
|
|
103
|
+
return callback(err);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return returnPromise;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/** Developed by Sheikh Tamim | GitHub: sheikhtamimlover | Please give credits if reused. */
|
|
@@ -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. */
|