hridoy-ultimate 8.0.2 → 9.0.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/CHANGELOG.md +68 -40
- package/LICENSE +23 -0
- package/MERGE_REPORT.md +54 -0
- package/README.md +158 -113
- package/THIRD_PARTY_NOTICES.md +36 -0
- package/docs/TEST_RESULTS.md +68 -0
- package/docs/UPSTREAM_API_DOCS.md +2712 -0
- package/func/checkUpdate.js +6 -0
- package/func/logAdapter.js +33 -0
- package/func/logger.js +48 -0
- package/index.d.ts +812 -0
- package/index.js +30 -824
- package/module/config.js +46 -0
- package/module/login.js +136 -0
- package/module/loginHelper.js +1413 -0
- package/module/options.js +55 -0
- package/package.json +75 -22
- package/scripts/run-tests.js +19 -0
- package/scripts/syntax-check.js +22 -0
- package/src/{addExternalModule.js → api/action/addExternalModule.js} +8 -8
- package/src/{changeAvatar.js → api/action/changeAvatar.js} +32 -33
- package/src/{changeBio.js → api/action/changeBio.js} +19 -22
- package/src/api/action/dismissScrapingWarning.js +50 -0
- package/src/api/action/enableAutoSaveAppState.js +73 -0
- package/src/{getCurrentUserID.js → api/action/getCurrentUserID.js} +1 -1
- package/src/api/action/handleFriendRequest.js +57 -0
- package/src/api/action/logout.js +95 -0
- package/src/api/action/refreshFb_dtsg.js +47 -0
- package/src/{setPostReaction.js → api/action/setPostReaction.js} +23 -31
- package/src/{unfriend.js → api/action/unfriend.js} +14 -14
- package/src/api/http/httpGet.js +46 -0
- package/src/api/http/httpPost.js +52 -0
- package/src/api/http/postFormData.js +47 -0
- package/src/api/messaging/addUserToGroup.js +68 -0
- package/src/api/messaging/changeAdminStatus.js +126 -0
- package/src/{changeArchivedStatus.js → api/messaging/changeArchivedStatus.js} +15 -17
- package/src/{changeBlockedStatus.js → api/messaging/changeBlockedStatus.js} +13 -16
- package/src/api/messaging/changeGroupImage.js +91 -0
- package/src/api/messaging/changeNickname.js +70 -0
- package/src/api/messaging/changeThreadColor.js +79 -0
- package/src/api/messaging/changeThreadEmoji.js +111 -0
- package/src/{createNewGroup.js → api/messaging/createNewGroup.js} +24 -26
- package/src/api/messaging/createPoll.js +46 -0
- package/src/api/messaging/createThemeAI.js +98 -0
- package/src/api/messaging/deleteMessage.js +136 -0
- package/src/{deleteThread.js → api/messaging/deleteThread.js} +14 -16
- package/src/api/messaging/editMessage.js +105 -0
- package/src/api/messaging/forwardAttachment.js +57 -0
- package/src/api/messaging/forwardMessage.js +134 -0
- package/src/{getEmojiUrl.js → api/messaging/getEmojiUrl.js} +2 -2
- package/src/{getFriendsList.js → api/messaging/getFriendsList.js} +16 -19
- package/src/{getMessage.js → api/messaging/getMessage.js} +160 -180
- package/src/api/messaging/getThemePictures.js +62 -0
- package/src/api/messaging/handleMessageRequest.js +65 -0
- package/src/api/messaging/markAsDelivered.js +69 -0
- package/src/api/messaging/markAsRead.js +110 -0
- package/src/api/messaging/markAsReadAll.js +56 -0
- package/src/api/messaging/markAsSeen.js +68 -0
- package/src/api/messaging/muteThread.js +50 -0
- package/src/api/messaging/pinMessage.js +115 -0
- package/src/api/messaging/removeUserFromGroup.js +62 -0
- package/src/{resolvePhotoUrl.js → api/messaging/resolvePhotoUrl.js} +11 -15
- package/src/api/messaging/scheduler.js +264 -0
- package/src/{searchForThread.js → api/messaging/searchForThread.js} +12 -12
- package/src/api/messaging/sendBroadcast.js +93 -0
- package/src/api/messaging/sendMessage.js +269 -0
- package/src/api/messaging/sendTypingIndicator.js +90 -0
- package/src/api/messaging/sessionGuard.js +130 -0
- package/src/api/messaging/setMessageReaction.js +114 -0
- package/src/api/messaging/setTitle.js +124 -0
- package/src/api/messaging/shareContact.js +98 -0
- package/src/{threadColors.js → api/messaging/threadColors.js} +2 -5
- package/src/api/messaging/unsendMessage.js +105 -0
- package/src/api/messaging/uploadAttachment.js +493 -0
- package/src/api/socket/OldMessage.js +199 -0
- package/src/api/socket/core/connectMqtt.js +304 -0
- package/src/api/socket/core/emitAuth.js +95 -0
- package/src/api/socket/core/getSeqID.js +331 -0
- package/src/api/socket/core/getTaskResponseData.js +25 -0
- package/src/api/socket/core/lifecycle.js +117 -0
- package/src/api/socket/core/parseDelta.js +387 -0
- package/src/api/socket/detail/buildStream.js +215 -0
- package/src/api/socket/detail/constants.js +28 -0
- package/src/api/socket/e2ee/crypto.js +173 -0
- package/src/api/socket/e2ee/index.js +977 -0
- package/src/api/socket/e2ee/localMediaServer.js +59 -0
- package/src/api/socket/e2ee/mediaDecode.js +155 -0
- package/src/api/socket/e2ee/native/NOTICE.md +29 -0
- package/{lib → src/api/socket/e2ee/native/lib}/index.mjs +109 -66
- package/src/api/socket/e2ee/native/nativeMediaBridge.js +273 -0
- package/src/api/socket/e2ee/proto/ArmadilloApplication.proto +281 -0
- package/src/api/socket/e2ee/proto/ArmadilloICDC.proto +14 -0
- package/src/api/socket/e2ee/proto/ConsumerApplication.proto +232 -0
- package/src/api/socket/e2ee/proto/MessageApplication.proto +82 -0
- package/src/api/socket/e2ee/proto/MessageTransport.proto +77 -0
- package/src/api/socket/e2ee/proto/WACommon.proto +66 -0
- package/src/api/socket/e2ee/proto/WAMediaTransport.proto +176 -0
- package/src/api/socket/e2ee/proto/proto-writer.ts +76 -0
- package/src/api/socket/e2ee/protocol.js +196 -0
- package/src/api/socket/e2ee/ratchet.js +219 -0
- package/src/api/socket/e2ee/store.js +182 -0
- package/src/api/socket/e2ee/vendor/fme/dist/index.cjs +6477 -0
- package/src/api/socket/e2ee/vendor/fme/proto/ArmadilloApplication.proto +281 -0
- package/src/api/socket/e2ee/vendor/fme/proto/ArmadilloICDC.proto +14 -0
- package/src/api/socket/e2ee/vendor/fme/proto/ConsumerApplication.proto +232 -0
- package/src/api/socket/e2ee/vendor/fme/proto/MessageApplication.proto +82 -0
- package/src/api/socket/e2ee/vendor/fme/proto/MessageTransport.proto +77 -0
- package/src/api/socket/e2ee/vendor/fme/proto/WACommon.proto +66 -0
- package/src/api/socket/e2ee/vendor/fme/proto/WAMediaTransport.proto +176 -0
- package/src/api/socket/listenE2EE.js +87 -0
- package/src/api/socket/listenMqtt.js +499 -0
- package/src/api/socket/middleware/index.js +216 -0
- package/src/api/socket/sendMessage.js +331 -0
- package/src/api/socket/sendMessageMqtt.js +69 -0
- package/src/{getThreadHistory.js → api/threads/getThreadHistory.js} +114 -132
- package/src/api/threads/getThreadInfo.js +329 -0
- package/src/api/threads/getThreadList.js +293 -0
- package/src/api/threads/getThreadPictures.js +78 -0
- package/src/{getUserID.js → api/users/getUserID.js} +22 -18
- package/src/api/users/getUserInfo.js +402 -0
- package/src/api/users/getUserInfoV2.js +134 -0
- package/src/app/MessengerBot.js +209 -0
- package/src/app/MessengerContext.js +32 -0
- package/src/app/createFcaClient.js +136 -0
- package/src/app/threadInfoRealtimeSync.js +284 -0
- package/src/core/sendReqMqtt.js +96 -0
- package/src/database/helpers.js +53 -0
- package/src/database/models/index.js +88 -0
- package/src/database/models/thread.js +50 -0
- package/src/database/models/user.js +46 -0
- package/src/database/threadData.js +94 -0
- package/src/database/userData.js +98 -0
- package/src/remote/remoteClient.js +123 -0
- package/src/utils/antiSuspension.js +219 -0
- package/src/utils/broadcast.js +51 -0
- package/src/utils/client.js +10 -0
- package/src/utils/constants.js +23 -0
- package/src/utils/cookies.js +85 -0
- package/src/utils/fingerprint.js +110 -0
- package/src/utils/format/attachment.js +357 -0
- package/src/utils/format/cookie.js +9 -0
- package/src/utils/format/date.js +50 -0
- package/src/utils/format/decode.js +44 -0
- package/src/utils/format/delta.js +195 -0
- package/src/utils/format/ids.js +64 -0
- package/src/utils/format/index.js +64 -0
- package/src/utils/format/message.js +88 -0
- package/src/utils/format/presence.js +132 -0
- package/src/utils/format/readTyp.js +44 -0
- package/src/utils/format/thread.js +42 -0
- package/src/utils/format/utils.js +141 -0
- package/src/utils/headers.js +125 -0
- package/src/utils/humanizer.js +256 -0
- package/src/utils/loginParser/autoLogin.js +125 -0
- package/src/utils/loginParser/extractDtsg.js +44 -0
- package/src/utils/loginParser/helpers.js +43 -0
- package/src/utils/loginParser/index.js +10 -0
- package/src/utils/loginParser/parseAndCheckLogin.js +241 -0
- package/src/utils/loginParser/textUtils.js +28 -0
- package/src/utils/nexca-logger.js +144 -0
- package/src/utils/nexca-utils.js +687 -0
- package/src/utils/request/client.js +26 -0
- package/src/utils/request/config.js +23 -0
- package/src/utils/request/defaults.js +46 -0
- package/src/utils/request/helpers.js +46 -0
- package/src/utils/request/index.js +17 -0
- package/src/utils/request/methods.js +163 -0
- package/src/utils/request/proxy.js +21 -0
- package/src/utils/request/retry.js +77 -0
- package/src/utils/request/sanitize.js +49 -0
- package/src/utils/typingIndicator.js +202 -0
- package/test/helpers/stub-modules.js +122 -0
- package/test/integration/logout.test.js +69 -0
- package/test/integration/mqtt-lifecycle.test.js +195 -0
- package/test/integration/package.test.js +116 -0
- package/test/integration/typing-wiring.test.js +71 -0
- package/test/unit/fingerprint.test.js +19 -0
- package/test/unit/humanizer.test.js +32 -0
- package/test/unit/lifecycle.test.js +92 -0
- package/test/unit/parsers.test.js +43 -0
- package/test/unit/typing.test.js +136 -0
- package/ANALYSIS.md +0 -31
- package/AUDIT_REPORT.md +0 -57
- package/advancedSystem.js +0 -95
- package/checkUpdate.js +0 -47
- package/config.json +0 -51
- package/e2ee.js +0 -738
- package/examples/basic-bot.js +0 -122
- package/examples/e2ee-bot.js +0 -141
- package/fca-config.example.json +0 -73
- package/scripts/check.js +0 -38
- package/src/OldMessage.js +0 -357
- package/src/addUserToGroup.js +0 -117
- package/src/changeAdminStatus.js +0 -105
- package/src/changeAvatarV2.js +0 -86
- package/src/changeAvt.js +0 -85
- package/src/changeBlockedStatusMqtt.js +0 -75
- package/src/changeCover.js +0 -73
- package/src/changeGroupImage.js +0 -137
- package/src/changeName.js +0 -79
- package/src/changeNickname.js +0 -61
- package/src/changeThreadColor.js +0 -67
- package/src/changeThreadEmoji.js +0 -57
- package/src/changeUsername.js +0 -59
- package/src/createCommentPost.js +0 -232
- package/src/createPoll.js +0 -73
- package/src/createPost.js +0 -276
- package/src/deleteMessage.js +0 -58
- package/src/editMessage.js +0 -76
- package/src/editMessageOld.js +0 -62
- package/src/follow.js +0 -74
- package/src/forwardAttachment.js +0 -62
- package/src/friendList.js +0 -104
- package/src/getAccess.js +0 -112
- package/src/getAvatarUser.js +0 -78
- package/src/getBotInitialData.js +0 -42
- package/src/getCtx.js +0 -5
- package/src/getOptions.js +0 -5
- package/src/getRegion.js +0 -7
- package/src/getThreadHistoryDeprecated.js +0 -71
- package/src/getThreadInfo.js +0 -232
- package/src/getThreadInfoDeprecated.js +0 -56
- package/src/getThreadList.js +0 -213
- package/src/getThreadListDeprecated.js +0 -46
- package/src/getThreadPictures.js +0 -59
- package/src/getThreadTheme.js +0 -81
- package/src/getUID.js +0 -119
- package/src/getUserInfo.js +0 -66
- package/src/handleFriendRequest.js +0 -46
- package/src/handleMessageRequest.js +0 -47
- package/src/httpGet.js +0 -49
- package/src/httpPost.js +0 -48
- package/src/httpPostFormData.js +0 -70
- package/src/listenMqtt.js +0 -1081
- package/src/listenNotification.js +0 -85
- package/src/logout.js +0 -18
- package/src/markAsDelivered.js +0 -47
- package/src/markAsRead.js +0 -72
- package/src/markAsReadAll.js +0 -40
- package/src/markAsSeen.js +0 -48
- package/src/metaTheme.js +0 -189
- package/src/muteThread.js +0 -45
- package/src/note.js +0 -228
- package/src/pinMessage.js +0 -54
- package/src/refreshFb_dtsg.js +0 -49
- package/src/removeSuspiciousAccount.js +0 -78
- package/src/removeUserFromGroup.js +0 -81
- package/src/reply.js +0 -442
- package/src/searchFriends.js +0 -140
- package/src/searchStickers.js +0 -53
- package/src/send.js +0 -46
- package/src/sendButtons.js +0 -163
- package/src/sendComment.js +0 -159
- package/src/sendFriendRequest.js +0 -112
- package/src/sendMessage.js +0 -441
- package/src/sendMessageMqtt.js +0 -323
- package/src/sendTypingIndicator.js +0 -68
- package/src/sendTypingIndicatorV2.js +0 -22
- package/src/setActiveStatus.js +0 -92
- package/src/setMessageReaction.js +0 -150
- package/src/setMessageReactionMqtt.js +0 -104
- package/src/setMessageReactionSafe.js +0 -44
- package/src/setProfileGuard.js +0 -44
- package/src/setProfileLock.js +0 -97
- package/src/setStoryReaction.js +0 -133
- package/src/setStorySeen.js +0 -108
- package/src/setThreadTheme.js +0 -102
- package/src/setTitle.js +0 -92
- package/src/shareContact.js +0 -110
- package/src/shareLink.js +0 -59
- package/src/stopListenMqtt.js +0 -60
- package/src/storyManager.js +0 -357
- package/src/suggestFriend.js +0 -132
- package/src/unsendMessage.js +0 -68
- package/src/uploadAttachment.js +0 -115
- package/test/fixes-1_2_4.test.js +0 -118
- package/test/mqtt-stop.test.js +0 -32
- package/test/reaction-mqtt.test.js +0 -57
- package/utils.js +0 -3056
- /package/{build → src/api/socket/e2ee/native/build}/messagix.dll +0 -0
- /package/{build → src/api/socket/e2ee/native/build}/messagix.so +0 -0
package/src/setTitle.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var log = require("npmlog");
|
|
4
|
-
|
|
5
|
-
const utils = require("../utils");
|
|
6
|
-
// @NethWs3Dev
|
|
7
|
-
|
|
8
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
9
|
-
return function setTitle(newTitle, threadID, callback) {
|
|
10
|
-
if (
|
|
11
|
-
!callback &&
|
|
12
|
-
(utils.getType(threadID) === "Function" ||
|
|
13
|
-
utils.getType(threadID) === "AsyncFunction")
|
|
14
|
-
) {
|
|
15
|
-
throw { error: "please pass a threadID as a second argument." };
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let resolveFunc = function () {};
|
|
19
|
-
let rejectFunc = function () {};
|
|
20
|
-
const returnPromise = new Promise(function (resolve, reject) {
|
|
21
|
-
resolveFunc = resolve;
|
|
22
|
-
rejectFunc = reject;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (!callback) {
|
|
26
|
-
callback = function (err, friendList) {
|
|
27
|
-
if (err) {
|
|
28
|
-
return rejectFunc(err);
|
|
29
|
-
}
|
|
30
|
-
resolveFunc(friendList);
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const messageAndOTID = utils.generateOfflineThreadingID();
|
|
35
|
-
const form = {
|
|
36
|
-
client: "mercury",
|
|
37
|
-
action_type: "ma-type:log-message",
|
|
38
|
-
author: "fbid:" + (ctx.userID),
|
|
39
|
-
author_email: "",
|
|
40
|
-
coordinates: "",
|
|
41
|
-
timestamp: Date.now(),
|
|
42
|
-
timestamp_absolute: "Today",
|
|
43
|
-
timestamp_relative: utils.generateTimestampRelative(),
|
|
44
|
-
timestamp_time_passed: "0",
|
|
45
|
-
is_unread: false,
|
|
46
|
-
is_cleared: false,
|
|
47
|
-
is_forward: false,
|
|
48
|
-
is_filtered_content: false,
|
|
49
|
-
is_spoof_warning: false,
|
|
50
|
-
source: "source:chat:web",
|
|
51
|
-
"source_tags[0]": "source:chat",
|
|
52
|
-
status: "0",
|
|
53
|
-
offline_threading_id: messageAndOTID,
|
|
54
|
-
message_id: messageAndOTID,
|
|
55
|
-
threading_id: utils.generateThreadingID(ctx.clientID),
|
|
56
|
-
manual_retry_cnt: "0",
|
|
57
|
-
thread_fbid: threadID,
|
|
58
|
-
thread_name: newTitle,
|
|
59
|
-
thread_id: threadID,
|
|
60
|
-
log_message_type: "log:thread-name",
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
defaultFuncs
|
|
64
|
-
.post(
|
|
65
|
-
"https://www.facebook.com/messaging/set_thread_name/",
|
|
66
|
-
ctx.jar,
|
|
67
|
-
form,
|
|
68
|
-
)
|
|
69
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
70
|
-
.then(function (resData) {
|
|
71
|
-
if (resData.error && resData.error === 1545012) {
|
|
72
|
-
throw { error: "Cannot change chat title: Not member of chat." };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (resData.error && resData.error === 1545003) {
|
|
76
|
-
throw { error: "Cannot set title of single-user chat." };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (resData.error) {
|
|
80
|
-
throw resData;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return callback();
|
|
84
|
-
})
|
|
85
|
-
.catch(function (err) {
|
|
86
|
-
log.error("setTitle", err);
|
|
87
|
-
return callback(err);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
return returnPromise;
|
|
91
|
-
};
|
|
92
|
-
};
|
package/src/shareContact.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
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
|
-
};
|
package/src/stopListenMqtt.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var log = require("npmlog");
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* hridoy-ultimate v8.0.1 — stopListenMqtt.js
|
|
7
|
-
*
|
|
8
|
-
* FIX v1.1.0: Now also clears ctx._deadTimer (the 8-minute dead-connection
|
|
9
|
-
* watchdog). Previously the watchdog timer kept running after stopListenMqtt()
|
|
10
|
-
* was called, which could trigger spurious reconnect attempts on a stopped bot.
|
|
11
|
-
*/
|
|
12
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
13
|
-
return function stopListenMqtt() {
|
|
14
|
-
// Stop the dead-connection watchdog first so it cannot fire during teardown
|
|
15
|
-
if (ctx._deadTimer) {
|
|
16
|
-
clearTimeout(ctx._deadTimer);
|
|
17
|
-
ctx._deadTimer = null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Halt any pending auto-reconnect
|
|
21
|
-
if (ctx._reconnectState) {
|
|
22
|
-
ctx._reconnectState.stopped = true;
|
|
23
|
-
if (ctx._reconnectState.timer) {
|
|
24
|
-
clearTimeout(ctx._reconnectState.timer);
|
|
25
|
-
ctx._reconnectState.timer = null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!ctx.mqttClient) {
|
|
30
|
-
log.warn("stopListenMqtt", "MQTT client is not active; nothing to stop.");
|
|
31
|
-
failPendingRequests(ctx, new Error("MQTT listener stopped"));
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
log.info("stopListenMqtt", "Stopping MQTT listener...");
|
|
36
|
-
failPendingRequests(ctx, new Error("MQTT listener stopped"));
|
|
37
|
-
|
|
38
|
-
// Graceful teardown: unsubscribe real-time topics, signal browser close, end.
|
|
39
|
-
try { ctx.mqttClient.unsubscribe("/webrtc"); } catch (_) {}
|
|
40
|
-
try { ctx.mqttClient.unsubscribe("/rtc_multi"); } catch (_) {}
|
|
41
|
-
try { ctx.mqttClient.unsubscribe("/onevc"); } catch (_) {}
|
|
42
|
-
try { ctx.mqttClient.publish("/browser_close", "{}"); } catch (_) {}
|
|
43
|
-
|
|
44
|
-
ctx.mqttClient.end(false, function () {
|
|
45
|
-
log.info("stopListenMqtt", "MQTT listener stopped.");
|
|
46
|
-
ctx.mqttClient = null;
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
function failPendingRequests(ctx, err) {
|
|
52
|
-
if (!ctx || !ctx.reqCallbacks || typeof ctx.reqCallbacks !== "object") return;
|
|
53
|
-
var callbacks = ctx.reqCallbacks;
|
|
54
|
-
ctx.reqCallbacks = {};
|
|
55
|
-
Object.keys(callbacks).forEach(function (id) {
|
|
56
|
-
if (typeof callbacks[id] === "function") {
|
|
57
|
-
try { callbacks[id](err); } catch (_) {}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
package/src/storyManager.js
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ===========================================================
|
|
3
|
-
* 🧑💻 Author: HRIDOY (HRIDOY)
|
|
4
|
-
* 🔰 Owner & Developer
|
|
5
|
-
* 🌐 GitHub: https://github.com/hridoy-dev
|
|
6
|
-
* -----------------------------------------------------------
|
|
7
|
-
* 🕊️ Respect the creator & give proper credits if reused.
|
|
8
|
-
* ===========================================================
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
var utils = require('../utils.js');
|
|
13
|
-
var log = require('npmlog');
|
|
14
|
-
|
|
15
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
|
16
|
-
/** Developed by HRIDOY | GitHub: hridoy-dev | Instagram: */
|
|
17
|
-
return function storyManager(options, callback) {
|
|
18
|
-
var resolveFunc = function () { };
|
|
19
|
-
var rejectFunc = function () { };
|
|
20
|
-
var returnPromise = new Promise(function (resolve, reject) {
|
|
21
|
-
resolveFunc = resolve;
|
|
22
|
-
rejectFunc = reject;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (!callback) {
|
|
26
|
-
callback = function (err, data) {
|
|
27
|
-
if (err) return rejectFunc(err);
|
|
28
|
-
resolveFunc(data);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!options || typeof options !== 'object') {
|
|
33
|
-
return callback({ error: "Options object is required" });
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const { action, attachment, storyID } = options;
|
|
37
|
-
|
|
38
|
-
if (!action || !['add', 'upload', 'delete', 'check'].includes(action)) {
|
|
39
|
-
return callback({ error: "Action must be 'add', 'upload', 'delete', or 'check'" });
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Helper function to upload story attachment
|
|
43
|
-
function uploadStoryAttachment(attachment) {
|
|
44
|
-
return new Promise((resolve, reject) => {
|
|
45
|
-
if (!utils.isReadableStream(attachment)) {
|
|
46
|
-
return reject({ error: 'Attachment should be a readable stream and not ' + utils.getType(attachment) });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const uploadForm = {
|
|
50
|
-
source: "8",
|
|
51
|
-
profile_id: ctx.userID,
|
|
52
|
-
waterfallxapp: "comet_stories",
|
|
53
|
-
farr: attachment,
|
|
54
|
-
upload_id: "jsc_c_m"
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
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()}`;
|
|
58
|
-
|
|
59
|
-
defaultFuncs
|
|
60
|
-
.postFormData(uploadUrl, ctx.jar, uploadForm)
|
|
61
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
62
|
-
.then(function (resData) {
|
|
63
|
-
if (resData.error || !resData.payload || !resData.payload.photoID) {
|
|
64
|
-
throw resData || { error: "Upload failed - no photo ID returned" };
|
|
65
|
-
}
|
|
66
|
-
resolve(resData.payload.photoID);
|
|
67
|
-
})
|
|
68
|
-
.catch(reject);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Helper function to create story
|
|
73
|
-
function createStory(photoID) {
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
const form = {
|
|
76
|
-
av: ctx.userID,
|
|
77
|
-
__aaid: 0,
|
|
78
|
-
__user: ctx.userID,
|
|
79
|
-
__a: 1,
|
|
80
|
-
__req: utils.getSignatureID(),
|
|
81
|
-
__hs: ctx.fb_dtsg_ag,
|
|
82
|
-
dpr: 1,
|
|
83
|
-
__ccg: "EXCELLENT",
|
|
84
|
-
__rev: ctx.req_ID,
|
|
85
|
-
__s: utils.getSignatureID(),
|
|
86
|
-
__hsi: ctx.hsi,
|
|
87
|
-
__comet_req: 15,
|
|
88
|
-
fb_dtsg: ctx.fb_dtsg,
|
|
89
|
-
jazoest: ctx.ttstamp,
|
|
90
|
-
lsd: ctx.fb_dtsg,
|
|
91
|
-
__spin_r: ctx.req_ID,
|
|
92
|
-
__spin_b: "trunk",
|
|
93
|
-
__spin_t: Date.now(),
|
|
94
|
-
fb_api_caller_class: "RelayModern",
|
|
95
|
-
fb_api_req_friendly_name: "StoriesCreateMutation",
|
|
96
|
-
variables: JSON.stringify({
|
|
97
|
-
input: {
|
|
98
|
-
audiences: [{
|
|
99
|
-
stories: {
|
|
100
|
-
self: {
|
|
101
|
-
target_id: ctx.userID
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}],
|
|
105
|
-
audiences_is_complete: true,
|
|
106
|
-
logging: {
|
|
107
|
-
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)}`
|
|
108
|
-
},
|
|
109
|
-
navigation_data: {
|
|
110
|
-
attribution_id_v2: `StoriesCreateRoot.react,comet.stories.create,unexpected,${Date.now()},545826,,;CometHomeRoot.react,comet.home,tap_tabbar,${Date.now()},661597,4748854339,,`
|
|
111
|
-
},
|
|
112
|
-
source: "WWW",
|
|
113
|
-
attachments: [{
|
|
114
|
-
photo: {
|
|
115
|
-
id: photoID,
|
|
116
|
-
overlays: []
|
|
117
|
-
}
|
|
118
|
-
}],
|
|
119
|
-
tracking: [null],
|
|
120
|
-
actor_id: ctx.userID,
|
|
121
|
-
client_mutation_id: String(Math.floor(Math.random() * 16) + 1)
|
|
122
|
-
}
|
|
123
|
-
}),
|
|
124
|
-
server_timestamps: true,
|
|
125
|
-
doc_id: "24226878183562473"
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
defaultFuncs
|
|
129
|
-
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
130
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
131
|
-
.then(function (resData) {
|
|
132
|
-
if (resData.error || !resData.data || !resData.data.story_create) {
|
|
133
|
-
throw resData || { error: "Story creation failed" };
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Extract story ID from response
|
|
137
|
-
let extractedStoryId = null;
|
|
138
|
-
const storyData = resData.data.story_create;
|
|
139
|
-
|
|
140
|
-
try {
|
|
141
|
-
if (storyData.viewer && storyData.viewer.actor && storyData.viewer.actor.story_bucket) {
|
|
142
|
-
const storyNodes = storyData.viewer.actor.story_bucket.nodes;
|
|
143
|
-
if (storyNodes && storyNodes.length > 0 && storyNodes[0].first_story_to_show) {
|
|
144
|
-
extractedStoryId = storyNodes[0].first_story_to_show.id;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
} catch (e) {
|
|
148
|
-
log.warn("createStory", "Could not extract story ID from response:", e);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
resolve({
|
|
152
|
-
story_id: extractedStoryId,
|
|
153
|
-
logging_token: storyData.logging_token,
|
|
154
|
-
full_response: resData
|
|
155
|
-
});
|
|
156
|
-
})
|
|
157
|
-
.catch(reject);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Helper function to delete story
|
|
162
|
-
function deleteStory(storyID) {
|
|
163
|
-
return new Promise((resolve, reject) => {
|
|
164
|
-
const form = {
|
|
165
|
-
av: ctx.userID,
|
|
166
|
-
__aaid: 0,
|
|
167
|
-
__user: ctx.userID,
|
|
168
|
-
__a: 1,
|
|
169
|
-
__req: utils.getSignatureID(),
|
|
170
|
-
__hs: ctx.fb_dtsg_ag,
|
|
171
|
-
dpr: 1,
|
|
172
|
-
__ccg: "EXCELLENT",
|
|
173
|
-
__rev: ctx.req_ID,
|
|
174
|
-
__s: utils.getSignatureID(),
|
|
175
|
-
__hsi: ctx.hsi,
|
|
176
|
-
__comet_req: 15,
|
|
177
|
-
fb_dtsg: ctx.fb_dtsg,
|
|
178
|
-
jazoest: ctx.ttstamp,
|
|
179
|
-
lsd: ctx.fb_dtsg,
|
|
180
|
-
__spin_r: ctx.req_ID,
|
|
181
|
-
__spin_b: "trunk",
|
|
182
|
-
__spin_t: Date.now(),
|
|
183
|
-
fb_api_caller_class: "RelayModern",
|
|
184
|
-
fb_api_req_friendly_name: "StoriesDeleteCardOptionMenuItem_StoriesDeleteMutation",
|
|
185
|
-
variables: JSON.stringify({
|
|
186
|
-
input: {
|
|
187
|
-
story_ids: [storyID],
|
|
188
|
-
actor_id: ctx.userID,
|
|
189
|
-
client_mutation_id: String(Math.floor(Math.random() * 16) + 1)
|
|
190
|
-
},
|
|
191
|
-
enable_profile_story_consumption: false
|
|
192
|
-
}),
|
|
193
|
-
server_timestamps: true,
|
|
194
|
-
doc_id: "30236153679305121"
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
defaultFuncs
|
|
198
|
-
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
199
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
200
|
-
.then(function (resData) {
|
|
201
|
-
if (resData.error) {
|
|
202
|
-
throw resData;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (!resData.data || !resData.data.stories_delete) {
|
|
206
|
-
throw { error: "Delete response missing expected data" };
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
resolve({
|
|
210
|
-
deleted_story_ids: resData.data.stories_delete.deleted_story_thread_ids || [storyID],
|
|
211
|
-
success: true
|
|
212
|
-
});
|
|
213
|
-
})
|
|
214
|
-
.catch(reject);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Helper function to check user stories
|
|
219
|
-
function checkUserStories() {
|
|
220
|
-
return new Promise((resolve, reject) => {
|
|
221
|
-
const form = {
|
|
222
|
-
av: ctx.userID,
|
|
223
|
-
__aaid: 0,
|
|
224
|
-
__user: ctx.userID,
|
|
225
|
-
__a: 1,
|
|
226
|
-
__req: utils.getSignatureID(),
|
|
227
|
-
__hs: ctx.fb_dtsg_ag,
|
|
228
|
-
dpr: 1,
|
|
229
|
-
__ccg: "EXCELLENT",
|
|
230
|
-
__rev: ctx.req_ID,
|
|
231
|
-
__s: utils.getSignatureID(),
|
|
232
|
-
__hsi: ctx.hsi,
|
|
233
|
-
__comet_req: 15,
|
|
234
|
-
fb_dtsg: ctx.fb_dtsg,
|
|
235
|
-
jazoest: ctx.ttstamp,
|
|
236
|
-
lsd: ctx.fb_dtsg,
|
|
237
|
-
__spin_r: ctx.req_ID,
|
|
238
|
-
__spin_b: "trunk",
|
|
239
|
-
__spin_t: Date.now(),
|
|
240
|
-
fb_api_caller_class: "RelayModern",
|
|
241
|
-
fb_api_req_friendly_name: "CometStoriesSuspenseViewerPaginationQuery",
|
|
242
|
-
variables: JSON.stringify({
|
|
243
|
-
count: 50,
|
|
244
|
-
scale: 1,
|
|
245
|
-
id: ctx.userID
|
|
246
|
-
}),
|
|
247
|
-
server_timestamps: true,
|
|
248
|
-
doc_id: "7723194127725452"
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
defaultFuncs
|
|
252
|
-
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
253
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
254
|
-
.then(function (resData) {
|
|
255
|
-
if (resData.error) {
|
|
256
|
-
throw resData;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
let stories = [];
|
|
260
|
-
try {
|
|
261
|
-
if (resData.data && resData.data.node && resData.data.node.story_bucket) {
|
|
262
|
-
const storyBucket = resData.data.node.story_bucket;
|
|
263
|
-
if (storyBucket.unified_stories && storyBucket.unified_stories.edges) {
|
|
264
|
-
stories = storyBucket.unified_stories.edges.map(edge => ({
|
|
265
|
-
id: edge.node.id,
|
|
266
|
-
creation_time: edge.node.creation_time,
|
|
267
|
-
attachments: edge.node.attachments || [],
|
|
268
|
-
bucket_id: storyBucket.id
|
|
269
|
-
}));
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
} catch (e) {
|
|
273
|
-
log.warn("checkUserStories", "Error parsing stories:", e);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
resolve(stories);
|
|
277
|
-
})
|
|
278
|
-
.catch(reject);
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// Execute based on action
|
|
283
|
-
switch (action) {
|
|
284
|
-
case 'upload':
|
|
285
|
-
if (!attachment) {
|
|
286
|
-
return callback({ error: "Attachment is required for upload action" });
|
|
287
|
-
}
|
|
288
|
-
uploadStoryAttachment(attachment)
|
|
289
|
-
.then(photoID => {
|
|
290
|
-
callback(null, { success: true, photoID: photoID });
|
|
291
|
-
})
|
|
292
|
-
.catch(callback);
|
|
293
|
-
break;
|
|
294
|
-
|
|
295
|
-
case 'add':
|
|
296
|
-
if (!attachment) {
|
|
297
|
-
return callback({ error: "Attachment is required for add action" });
|
|
298
|
-
}
|
|
299
|
-
uploadStoryAttachment(attachment)
|
|
300
|
-
.then(photoID => {
|
|
301
|
-
return createStory(photoID).then(result => ({ photoID, result }));
|
|
302
|
-
})
|
|
303
|
-
.then(({ photoID, result }) => {
|
|
304
|
-
callback(null, {
|
|
305
|
-
success: true,
|
|
306
|
-
story_id: result.story_id,
|
|
307
|
-
logging_token: result.logging_token,
|
|
308
|
-
photoID: photoID,
|
|
309
|
-
full_response: result.full_response
|
|
310
|
-
});
|
|
311
|
-
})
|
|
312
|
-
.catch(err => {
|
|
313
|
-
log.error("storyManager add", err);
|
|
314
|
-
callback(err);
|
|
315
|
-
});
|
|
316
|
-
break;
|
|
317
|
-
|
|
318
|
-
case 'delete':
|
|
319
|
-
if (!storyID) {
|
|
320
|
-
return callback({ error: "Story ID is required for delete action" });
|
|
321
|
-
}
|
|
322
|
-
deleteStory(storyID)
|
|
323
|
-
.then(result => {
|
|
324
|
-
callback(null, {
|
|
325
|
-
success: true,
|
|
326
|
-
deleted_story_ids: result.deleted_story_ids
|
|
327
|
-
});
|
|
328
|
-
})
|
|
329
|
-
.catch(err => {
|
|
330
|
-
log.error("storyManager delete", err);
|
|
331
|
-
callback(err);
|
|
332
|
-
});
|
|
333
|
-
break;
|
|
334
|
-
|
|
335
|
-
case 'check':
|
|
336
|
-
checkUserStories()
|
|
337
|
-
.then(stories => {
|
|
338
|
-
callback(null, {
|
|
339
|
-
success: true,
|
|
340
|
-
stories: stories,
|
|
341
|
-
count: stories ? stories.length : 0
|
|
342
|
-
});
|
|
343
|
-
})
|
|
344
|
-
.catch(err => {
|
|
345
|
-
log.error("storyManager check", err);
|
|
346
|
-
callback(err);
|
|
347
|
-
});
|
|
348
|
-
break;
|
|
349
|
-
|
|
350
|
-
default:
|
|
351
|
-
callback({ error: "Invalid action" });
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return returnPromise;
|
|
355
|
-
};
|
|
356
|
-
};
|
|
357
|
-
/** Developed by HRIDOY | GitHub: hridoy-dev | Please give credits if reused. */
|