@lazyneoaz/metachat 6.0.7 → 6.0.9
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/dist/index.cjs +223 -94
- package/dist/index.mjs +223 -94
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -87484,9 +87484,14 @@ function httpGet_default(defaultFuncs, api, ctx) {
|
|
|
87484
87484
|
return body;
|
|
87485
87485
|
}).catch((err) => {
|
|
87486
87486
|
error("httpGet", err);
|
|
87487
|
-
if (typeof callback === "function")
|
|
87487
|
+
if (typeof callback === "function") {
|
|
87488
|
+
callback(err);
|
|
87489
|
+
return null;
|
|
87490
|
+
}
|
|
87488
87491
|
throw err;
|
|
87489
87492
|
});
|
|
87493
|
+
returnPromise.catch(() => {
|
|
87494
|
+
});
|
|
87490
87495
|
return returnPromise;
|
|
87491
87496
|
};
|
|
87492
87497
|
}
|
|
@@ -87510,9 +87515,14 @@ function httpPost_default(defaultFuncs, api, ctx) {
|
|
|
87510
87515
|
return body;
|
|
87511
87516
|
}).catch((err) => {
|
|
87512
87517
|
error("httpPost", err);
|
|
87513
|
-
if (typeof callback === "function")
|
|
87518
|
+
if (typeof callback === "function") {
|
|
87519
|
+
callback(err);
|
|
87520
|
+
return null;
|
|
87521
|
+
}
|
|
87514
87522
|
throw err;
|
|
87515
87523
|
});
|
|
87524
|
+
returnPromise.catch(() => {
|
|
87525
|
+
});
|
|
87516
87526
|
return returnPromise;
|
|
87517
87527
|
};
|
|
87518
87528
|
}
|
|
@@ -87536,9 +87546,14 @@ function httpPostFormData_default(defaultFuncs, api, ctx) {
|
|
|
87536
87546
|
return body;
|
|
87537
87547
|
}).catch((err) => {
|
|
87538
87548
|
error("httpPostFormData", err);
|
|
87539
|
-
if (typeof callback === "function")
|
|
87549
|
+
if (typeof callback === "function") {
|
|
87550
|
+
callback(err);
|
|
87551
|
+
return null;
|
|
87552
|
+
}
|
|
87540
87553
|
throw err;
|
|
87541
87554
|
});
|
|
87555
|
+
returnPromise.catch(() => {
|
|
87556
|
+
});
|
|
87542
87557
|
return returnPromise;
|
|
87543
87558
|
};
|
|
87544
87559
|
}
|
|
@@ -87901,37 +87916,72 @@ function enableAutoSaveAppState_default(_defaultFuncs, api, ctx) {
|
|
|
87901
87916
|
}
|
|
87902
87917
|
|
|
87903
87918
|
// src/deltas/apis/messaging/editMessage.ts
|
|
87919
|
+
function extractEditedMessage(message) {
|
|
87920
|
+
try {
|
|
87921
|
+
const candidate = message?.payload?.step?.[1]?.[2]?.[2]?.[1];
|
|
87922
|
+
const messageID = String(candidate?.[2] || "");
|
|
87923
|
+
const body = String(candidate?.[4] || "");
|
|
87924
|
+
return { messageID: messageID || void 0, body: body || void 0 };
|
|
87925
|
+
} catch {
|
|
87926
|
+
return {};
|
|
87927
|
+
}
|
|
87928
|
+
}
|
|
87904
87929
|
function editMessage_default(_defaultFuncs, _api, ctx) {
|
|
87905
|
-
return
|
|
87930
|
+
return function editMessage(text3, messageID, callback) {
|
|
87906
87931
|
const cb = typeof callback === "function" ? callback : void 0;
|
|
87907
|
-
|
|
87908
|
-
|
|
87909
|
-
|
|
87932
|
+
const fail = (err) => {
|
|
87933
|
+
error("editMessage", err?.error || err?.message || err);
|
|
87934
|
+
if (cb) {
|
|
87935
|
+
cb(err);
|
|
87936
|
+
return { error: err?.error || err?.message || String(err), success: false };
|
|
87910
87937
|
}
|
|
87911
|
-
|
|
87912
|
-
|
|
87913
|
-
|
|
87914
|
-
|
|
87915
|
-
|
|
87916
|
-
|
|
87917
|
-
|
|
87918
|
-
|
|
87919
|
-
|
|
87920
|
-
|
|
87921
|
-
|
|
87922
|
-
|
|
87923
|
-
|
|
87924
|
-
|
|
87925
|
-
|
|
87926
|
-
|
|
87927
|
-
|
|
87938
|
+
throw err;
|
|
87939
|
+
};
|
|
87940
|
+
if (!ctx.mqttClient || !ctx.mqttClient.connected) {
|
|
87941
|
+
return fail(new Error("Not connected to MQTT"));
|
|
87942
|
+
}
|
|
87943
|
+
if (!text3 || !messageID) {
|
|
87944
|
+
return fail(new Error("text and messageID are required"));
|
|
87945
|
+
}
|
|
87946
|
+
const query = {
|
|
87947
|
+
failure_count: null,
|
|
87948
|
+
label: "742",
|
|
87949
|
+
payload: JSON.stringify({
|
|
87950
|
+
message_id: messageID,
|
|
87951
|
+
text: text3
|
|
87952
|
+
}),
|
|
87953
|
+
queue_name: "edit_message"
|
|
87954
|
+
};
|
|
87955
|
+
const content = buildWsTaskContent(ctx, [query], "6903494529735864");
|
|
87956
|
+
const promise = publishLsRequestWithAck({
|
|
87957
|
+
client: ctx.mqttClient,
|
|
87958
|
+
content,
|
|
87959
|
+
requestId: content.request_id,
|
|
87960
|
+
extract: (parsed) => parsed
|
|
87961
|
+
}).then((parsed) => {
|
|
87962
|
+
const { body } = extractEditedMessage(parsed);
|
|
87963
|
+
if (body && body !== text3) {
|
|
87964
|
+
const error2 = { error: "The message is too old or not from you!", success: false };
|
|
87965
|
+
if (cb) {
|
|
87966
|
+
cb(error2);
|
|
87967
|
+
return error2;
|
|
87968
|
+
}
|
|
87969
|
+
throw error2;
|
|
87970
|
+
}
|
|
87971
|
+
const out = { messageID, text: text3, success: true };
|
|
87928
87972
|
if (cb) cb(null, out);
|
|
87929
87973
|
return out;
|
|
87930
|
-
}
|
|
87974
|
+
}).catch((err) => {
|
|
87931
87975
|
error("editMessage", err?.error || err?.message || err);
|
|
87932
|
-
if (cb)
|
|
87976
|
+
if (cb) {
|
|
87977
|
+
cb(err);
|
|
87978
|
+
return { error: err?.error || err?.message || String(err), success: false };
|
|
87979
|
+
}
|
|
87933
87980
|
throw err;
|
|
87934
|
-
}
|
|
87981
|
+
});
|
|
87982
|
+
promise.catch(() => {
|
|
87983
|
+
});
|
|
87984
|
+
return promise;
|
|
87935
87985
|
};
|
|
87936
87986
|
}
|
|
87937
87987
|
|
|
@@ -88146,6 +88196,8 @@ function emoji_default(defaultFuncs, api, ctx) {
|
|
|
88146
88196
|
_callback = void 0;
|
|
88147
88197
|
_initiatorID = void 0;
|
|
88148
88198
|
}
|
|
88199
|
+
returnPromise.catch(() => {
|
|
88200
|
+
});
|
|
88149
88201
|
if (!_callback) {
|
|
88150
88202
|
_callback = function(__err, __data) {
|
|
88151
88203
|
if (__err) _rejectPromise(__err);
|
|
@@ -88156,7 +88208,7 @@ function emoji_default(defaultFuncs, api, ctx) {
|
|
|
88156
88208
|
_callback = function(__err, __data) {
|
|
88157
88209
|
if (__err) {
|
|
88158
88210
|
originalCallback(__err);
|
|
88159
|
-
|
|
88211
|
+
_resolvePromise(void 0);
|
|
88160
88212
|
} else {
|
|
88161
88213
|
originalCallback(null, __data);
|
|
88162
88214
|
_resolvePromise(__data);
|
|
@@ -88174,6 +88226,8 @@ function emoji_default(defaultFuncs, api, ctx) {
|
|
|
88174
88226
|
if (!ctx.mqttClient) {
|
|
88175
88227
|
return _callback(new Error("Not connected to MQTT"));
|
|
88176
88228
|
}
|
|
88229
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
88230
|
+
if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
|
|
88177
88231
|
ctx.wsReqNumber += 1;
|
|
88178
88232
|
ctx.wsTaskNumber += 1;
|
|
88179
88233
|
const queryPayload = {
|
|
@@ -88355,6 +88409,8 @@ function gcname_default(defaultFuncs, api, ctx) {
|
|
|
88355
88409
|
_callback = void 0;
|
|
88356
88410
|
_initiatorID = void 0;
|
|
88357
88411
|
}
|
|
88412
|
+
returnPromise.catch(() => {
|
|
88413
|
+
});
|
|
88358
88414
|
if (!_callback) {
|
|
88359
88415
|
_callback = function(__err, __data) {
|
|
88360
88416
|
if (__err) _rejectPromise(__err);
|
|
@@ -88365,7 +88421,7 @@ function gcname_default(defaultFuncs, api, ctx) {
|
|
|
88365
88421
|
_callback = function(__err, __data) {
|
|
88366
88422
|
if (__err) {
|
|
88367
88423
|
originalCallback(__err);
|
|
88368
|
-
|
|
88424
|
+
_resolvePromise(void 0);
|
|
88369
88425
|
} else {
|
|
88370
88426
|
originalCallback(null, __data);
|
|
88371
88427
|
_resolvePromise(__data);
|
|
@@ -88383,6 +88439,8 @@ function gcname_default(defaultFuncs, api, ctx) {
|
|
|
88383
88439
|
if (!ctx.mqttClient) {
|
|
88384
88440
|
return _callback(new Error("Not connected to MQTT"));
|
|
88385
88441
|
}
|
|
88442
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
88443
|
+
if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
|
|
88386
88444
|
ctx.wsReqNumber += 1;
|
|
88387
88445
|
ctx.wsTaskNumber += 1;
|
|
88388
88446
|
const queryPayload = {
|
|
@@ -88441,6 +88499,8 @@ function gcrule_default(defaultFuncs, api, ctx) {
|
|
|
88441
88499
|
resolvePromise = resolve;
|
|
88442
88500
|
rejectPromise = reject;
|
|
88443
88501
|
});
|
|
88502
|
+
returnPromise.catch(() => {
|
|
88503
|
+
});
|
|
88444
88504
|
if (typeof _callback != "function") {
|
|
88445
88505
|
_callback = (err, data2) => {
|
|
88446
88506
|
if (err) return rejectPromise(err);
|
|
@@ -88523,28 +88583,41 @@ function gcrule_default(defaultFuncs, api, ctx) {
|
|
|
88523
88583
|
|
|
88524
88584
|
// src/deltas/apis/messaging/markAsDelivered.ts
|
|
88525
88585
|
function markAsDelivered_default(defaultFuncs, api, ctx) {
|
|
88526
|
-
return
|
|
88527
|
-
|
|
88528
|
-
|
|
88586
|
+
return function markAsDelivered(threadID, messageID, callback) {
|
|
88587
|
+
const cb = typeof callback === "function" ? callback : void 0;
|
|
88588
|
+
const fail = (err) => {
|
|
88529
88589
|
error("markAsDelivered", err);
|
|
88530
|
-
|
|
88590
|
+
if (cb) {
|
|
88591
|
+
cb(err);
|
|
88592
|
+
return;
|
|
88593
|
+
}
|
|
88594
|
+
throw err;
|
|
88595
|
+
};
|
|
88596
|
+
if (!threadID || !messageID) {
|
|
88597
|
+
return fail("Error: messageID or threadID is not defined");
|
|
88531
88598
|
}
|
|
88532
88599
|
const form = {};
|
|
88533
88600
|
form["message_ids[0]"] = messageID;
|
|
88534
88601
|
form["thread_ids[" + threadID + "][0]"] = messageID;
|
|
88535
|
-
|
|
88536
|
-
|
|
88537
|
-
|
|
88538
|
-
|
|
88539
|
-
|
|
88540
|
-
|
|
88541
|
-
if (resData
|
|
88542
|
-
|
|
88543
|
-
|
|
88544
|
-
} catch (err) {
|
|
88602
|
+
const promise = defaultFuncs.post(
|
|
88603
|
+
"https://www.facebook.com/ajax/mercury/delivery_receipts.php",
|
|
88604
|
+
ctx.jar,
|
|
88605
|
+
form
|
|
88606
|
+
).then(saveCookies(ctx.jar)).then(parseAndCheckLogin(ctx, defaultFuncs)).then((resData) => {
|
|
88607
|
+
if (resData && resData.error) throw resData;
|
|
88608
|
+
if (cb) cb(null, resData);
|
|
88609
|
+
return resData;
|
|
88610
|
+
}).catch((err) => {
|
|
88545
88611
|
error("markAsDelivered", err);
|
|
88612
|
+
if (cb) {
|
|
88613
|
+
cb(err);
|
|
88614
|
+
return null;
|
|
88615
|
+
}
|
|
88546
88616
|
throw err;
|
|
88547
|
-
}
|
|
88617
|
+
});
|
|
88618
|
+
promise.catch(() => {
|
|
88619
|
+
});
|
|
88620
|
+
return promise;
|
|
88548
88621
|
};
|
|
88549
88622
|
}
|
|
88550
88623
|
|
|
@@ -88632,20 +88705,27 @@ function markAsRead_default(defaultFuncs, api, ctx) {
|
|
|
88632
88705
|
|
|
88633
88706
|
// src/deltas/apis/messaging/markAsReadAll.ts
|
|
88634
88707
|
function markAsReadAll_default(defaultFuncs, api, ctx) {
|
|
88635
|
-
return
|
|
88636
|
-
|
|
88637
|
-
|
|
88638
|
-
|
|
88639
|
-
|
|
88640
|
-
|
|
88641
|
-
|
|
88642
|
-
|
|
88643
|
-
if (
|
|
88644
|
-
return;
|
|
88645
|
-
}
|
|
88708
|
+
return function markAsReadAll(callback) {
|
|
88709
|
+
const cb = typeof callback === "function" ? callback : void 0;
|
|
88710
|
+
const promise = defaultFuncs.post(
|
|
88711
|
+
"https://www.facebook.com/ajax/mercury/mark_folder_as_read.php",
|
|
88712
|
+
ctx.jar,
|
|
88713
|
+
{ folder: "inbox" }
|
|
88714
|
+
).then((resData) => parseAndCheckLogin(ctx, defaultFuncs)(resData)).then((parsedData) => {
|
|
88715
|
+
if (parsedData && parsedData.error) throw parsedData;
|
|
88716
|
+
if (cb) cb(null, parsedData);
|
|
88717
|
+
return parsedData;
|
|
88718
|
+
}).catch((err) => {
|
|
88646
88719
|
error("markAsReadAll", err);
|
|
88720
|
+
if (cb) {
|
|
88721
|
+
cb(err);
|
|
88722
|
+
return null;
|
|
88723
|
+
}
|
|
88647
88724
|
throw err;
|
|
88648
|
-
}
|
|
88725
|
+
});
|
|
88726
|
+
promise.catch(() => {
|
|
88727
|
+
});
|
|
88728
|
+
return promise;
|
|
88649
88729
|
};
|
|
88650
88730
|
}
|
|
88651
88731
|
|
|
@@ -88673,6 +88753,16 @@ function markAsSeen_default(defaultFuncs, api, ctx) {
|
|
|
88673
88753
|
}
|
|
88674
88754
|
resolveFunc(friendList);
|
|
88675
88755
|
};
|
|
88756
|
+
} else {
|
|
88757
|
+
const originalCallback = callback;
|
|
88758
|
+
callback = function(err, data2) {
|
|
88759
|
+
try {
|
|
88760
|
+
originalCallback(err, data2);
|
|
88761
|
+
} finally {
|
|
88762
|
+
if (err) resolveFunc(void 0);
|
|
88763
|
+
else resolveFunc(data2);
|
|
88764
|
+
}
|
|
88765
|
+
};
|
|
88676
88766
|
}
|
|
88677
88767
|
const form = {
|
|
88678
88768
|
seen_timestamp
|
|
@@ -88724,6 +88814,8 @@ function nickname_default(defaultFuncs, api, ctx) {
|
|
|
88724
88814
|
_callback = void 0;
|
|
88725
88815
|
_initiatorID = void 0;
|
|
88726
88816
|
}
|
|
88817
|
+
returnPromise.catch(() => {
|
|
88818
|
+
});
|
|
88727
88819
|
if (!_callback) {
|
|
88728
88820
|
_callback = function(__err, __data) {
|
|
88729
88821
|
if (__err) _rejectPromise(__err);
|
|
@@ -88734,7 +88826,7 @@ function nickname_default(defaultFuncs, api, ctx) {
|
|
|
88734
88826
|
_callback = function(__err, __data) {
|
|
88735
88827
|
if (__err) {
|
|
88736
88828
|
originalCallback(__err);
|
|
88737
|
-
|
|
88829
|
+
_resolvePromise(void 0);
|
|
88738
88830
|
} else {
|
|
88739
88831
|
originalCallback(null, __data);
|
|
88740
88832
|
_resolvePromise(__data);
|
|
@@ -88753,6 +88845,8 @@ function nickname_default(defaultFuncs, api, ctx) {
|
|
|
88753
88845
|
if (!ctx.mqttClient) {
|
|
88754
88846
|
return _callback(new Error("Not connected to MQTT"));
|
|
88755
88847
|
}
|
|
88848
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
88849
|
+
if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
|
|
88756
88850
|
ctx.wsReqNumber += 1;
|
|
88757
88851
|
ctx.wsTaskNumber += 1;
|
|
88758
88852
|
const queryPayload = {
|
|
@@ -89329,8 +89423,9 @@ var sendMessage_default = (defaultFuncs, api, ctx) => {
|
|
|
89329
89423
|
|
|
89330
89424
|
// src/deltas/apis/messaging/sendTypingIndicator.ts
|
|
89331
89425
|
function sendTypingIndicator_default(defaultFuncs, api, ctx) {
|
|
89332
|
-
return
|
|
89426
|
+
return function sendTypingIndicatorV2(sendTyping, threadID, options, callback) {
|
|
89333
89427
|
if (typeof options === "function") {
|
|
89428
|
+
callback = options;
|
|
89334
89429
|
options = {};
|
|
89335
89430
|
}
|
|
89336
89431
|
options = options || {};
|
|
@@ -89343,14 +89438,23 @@ function sendTypingIndicator_default(defaultFuncs, api, ctx) {
|
|
|
89343
89438
|
actualSendTyping = sendTyping;
|
|
89344
89439
|
actualThreadID = threadID;
|
|
89345
89440
|
}
|
|
89441
|
+
const fail = (message) => {
|
|
89442
|
+
const err = new Error(message);
|
|
89443
|
+
if (typeof callback === "function") {
|
|
89444
|
+
callback(err);
|
|
89445
|
+
return Promise.resolve(null);
|
|
89446
|
+
}
|
|
89447
|
+
return Promise.reject(err);
|
|
89448
|
+
};
|
|
89346
89449
|
if (!actualThreadID) {
|
|
89347
|
-
|
|
89450
|
+
return fail("sendTypingIndicator: threadID is required");
|
|
89348
89451
|
}
|
|
89349
89452
|
if (!ctx.mqttClient || !ctx.mqttClient.connected) {
|
|
89350
|
-
|
|
89453
|
+
return fail("sendTypingIndicator: not connected to MQTT");
|
|
89351
89454
|
}
|
|
89352
89455
|
const threadIDs = Array.isArray(actualThreadID) ? actualThreadID : [actualThreadID];
|
|
89353
89456
|
const attribution = options.type || 0;
|
|
89457
|
+
const publishPromises = [];
|
|
89354
89458
|
const publishTyping = (tid, isTyping) => {
|
|
89355
89459
|
ctx.wsReqNumber = (ctx.wsReqNumber || 0) + 1;
|
|
89356
89460
|
const isGroupThread = String(tid).length >= 16 ? 1 : 0;
|
|
@@ -89380,18 +89484,26 @@ function sendTypingIndicator_default(defaultFuncs, api, ctx) {
|
|
|
89380
89484
|
);
|
|
89381
89485
|
});
|
|
89382
89486
|
};
|
|
89383
|
-
await Promise.all(threadIDs.map((tid) => publishTyping(tid, actualSendTyping)));
|
|
89384
89487
|
const duration = options.duration || 1e4;
|
|
89385
89488
|
const autoStop = options.autoStop !== false;
|
|
89386
|
-
|
|
89387
|
-
|
|
89388
|
-
|
|
89389
|
-
|
|
89390
|
-
|
|
89391
|
-
|
|
89489
|
+
threadIDs.forEach((tid) => {
|
|
89490
|
+
const p = publishTyping(tid, actualSendTyping).then(() => {
|
|
89491
|
+
if (actualSendTyping && autoStop) {
|
|
89492
|
+
setTimeout(() => {
|
|
89493
|
+
publishTyping(tid, false).catch(() => {
|
|
89494
|
+
});
|
|
89495
|
+
}, duration);
|
|
89496
|
+
}
|
|
89497
|
+
return true;
|
|
89392
89498
|
});
|
|
89499
|
+
publishPromises.push(p);
|
|
89500
|
+
});
|
|
89501
|
+
const result = Promise.all(publishPromises).then(() => true);
|
|
89502
|
+
if (typeof callback === "function") {
|
|
89503
|
+
result.then(() => callback(null, true)).catch((err) => callback(err));
|
|
89504
|
+
return result.catch(() => null);
|
|
89393
89505
|
}
|
|
89394
|
-
return
|
|
89506
|
+
return result;
|
|
89395
89507
|
};
|
|
89396
89508
|
}
|
|
89397
89509
|
|
|
@@ -89705,11 +89817,22 @@ function theme_default(defaultFuncs, api, ctx) {
|
|
|
89705
89817
|
_callback = void 0;
|
|
89706
89818
|
_initiatorID = void 0;
|
|
89707
89819
|
}
|
|
89820
|
+
finalReturnPromise.catch(() => {
|
|
89821
|
+
});
|
|
89708
89822
|
if (!_callback) {
|
|
89709
89823
|
_callback = function(_err, _data) {
|
|
89710
89824
|
if (_err) _rejectFunc(_err);
|
|
89711
89825
|
else _resolveFunc(_data);
|
|
89712
89826
|
};
|
|
89827
|
+
} else {
|
|
89828
|
+
const originalCallback = _callback;
|
|
89829
|
+
_callback = function(_err, _data) {
|
|
89830
|
+
try {
|
|
89831
|
+
originalCallback(_err, _data);
|
|
89832
|
+
} finally {
|
|
89833
|
+
_resolveFunc(_data);
|
|
89834
|
+
}
|
|
89835
|
+
};
|
|
89713
89836
|
}
|
|
89714
89837
|
_initiatorID = _initiatorID || ctx.userID;
|
|
89715
89838
|
threadID = threadID || ctx.threadID;
|
|
@@ -89780,6 +89903,8 @@ function theme_default(defaultFuncs, api, ctx) {
|
|
|
89780
89903
|
let currentEpochId = parseInt(generateOfflineThreadingID());
|
|
89781
89904
|
const createAndPublish = (label, queueName, payload) => {
|
|
89782
89905
|
currentEpochId = parseInt(generateOfflineThreadingID());
|
|
89906
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
89907
|
+
if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
|
|
89783
89908
|
ctx.wsReqNumber += 1;
|
|
89784
89909
|
ctx.wsTaskNumber += 1;
|
|
89785
89910
|
const request_id = ctx.wsReqNumber;
|
|
@@ -89886,6 +90011,8 @@ function setThreadTheme_default(defaultFuncs, _api, ctx) {
|
|
|
89886
90011
|
}
|
|
89887
90012
|
throw error2;
|
|
89888
90013
|
}
|
|
90014
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
90015
|
+
if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
|
|
89889
90016
|
ctx.wsReqNumber += 1;
|
|
89890
90017
|
let baseTaskNumber = ++ctx.wsTaskNumber;
|
|
89891
90018
|
const makeTask = (label, queueName, extraPayload = {}) => ({
|
|
@@ -89907,6 +90034,7 @@ function setThreadTheme_default(defaultFuncs, _api, ctx) {
|
|
|
89907
90034
|
{ label: 43, queue: "thread_theme", extra: { source: null, payload: null } }
|
|
89908
90035
|
];
|
|
89909
90036
|
const messages = definitions.map(({ label, queue, extra }) => {
|
|
90037
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
89910
90038
|
ctx.wsReqNumber += 1;
|
|
89911
90039
|
return {
|
|
89912
90040
|
app_id: "2220391788200892",
|
|
@@ -90057,15 +90185,8 @@ async function publishThreadTask(ctx, label, queueName, payload, versionId, appI
|
|
|
90057
90185
|
requestId: content.request_id,
|
|
90058
90186
|
extract: (parsed) => {
|
|
90059
90187
|
const body = parsed && parsed.payload;
|
|
90060
|
-
|
|
90061
|
-
|
|
90062
|
-
const err = new Error(
|
|
90063
|
-
typeof error2 === "string" ? error2 : error2.message || "MQTT task was rejected"
|
|
90064
|
-
);
|
|
90065
|
-
err.error = error2;
|
|
90066
|
-
throw err;
|
|
90067
|
-
}
|
|
90068
|
-
return body || { success: true };
|
|
90188
|
+
if (!body || typeof body !== "object") return { success: true };
|
|
90189
|
+
return body;
|
|
90069
90190
|
}
|
|
90070
90191
|
});
|
|
90071
90192
|
}
|
|
@@ -90096,8 +90217,13 @@ function unsendMessage_default(defaultFuncs, _api, ctx) {
|
|
|
90096
90217
|
_resolve = resolve;
|
|
90097
90218
|
_reject = reject;
|
|
90098
90219
|
});
|
|
90220
|
+
returnPromise.catch(() => {
|
|
90221
|
+
});
|
|
90099
90222
|
const done = (err, data2) => {
|
|
90100
|
-
if (cb)
|
|
90223
|
+
if (cb) {
|
|
90224
|
+
cb(err, data2);
|
|
90225
|
+
return;
|
|
90226
|
+
}
|
|
90101
90227
|
if (err) _reject(err);
|
|
90102
90228
|
else _resolve(data2);
|
|
90103
90229
|
};
|
|
@@ -91014,7 +91140,7 @@ var sendMessageMqtt_default = (defaultFuncs, api, ctx) => {
|
|
|
91014
91140
|
attachmentIds = ids;
|
|
91015
91141
|
} catch (err) {
|
|
91016
91142
|
error("Attachment upload failed:", err);
|
|
91017
|
-
|
|
91143
|
+
finish(err);
|
|
91018
91144
|
return done();
|
|
91019
91145
|
}
|
|
91020
91146
|
}
|
|
@@ -92744,15 +92870,8 @@ function changeAdminStatus_default(defaultFuncs, _api, ctx) {
|
|
|
92744
92870
|
requestId: content.request_id,
|
|
92745
92871
|
extract: (parsed) => {
|
|
92746
92872
|
const body = parsed && parsed.payload;
|
|
92747
|
-
|
|
92748
|
-
|
|
92749
|
-
const err = new Error(
|
|
92750
|
-
typeof error2 === "string" ? error2 : error2.message || "admin_status task rejected"
|
|
92751
|
-
);
|
|
92752
|
-
err.error = error2;
|
|
92753
|
-
throw err;
|
|
92754
|
-
}
|
|
92755
|
-
return body || { success: true };
|
|
92873
|
+
if (!body || typeof body !== "object") return { success: true };
|
|
92874
|
+
return body;
|
|
92756
92875
|
}
|
|
92757
92876
|
});
|
|
92758
92877
|
if (cb) cb(null);
|
|
@@ -92943,8 +93062,13 @@ function createPoll_default(_defaultFuncs, _api, ctx) {
|
|
|
92943
93062
|
_resolve = resolve;
|
|
92944
93063
|
_reject = reject;
|
|
92945
93064
|
});
|
|
93065
|
+
promise.catch(() => {
|
|
93066
|
+
});
|
|
92946
93067
|
const done = (err, data2) => {
|
|
92947
|
-
if (cb)
|
|
93068
|
+
if (cb) {
|
|
93069
|
+
cb(err, data2);
|
|
93070
|
+
return;
|
|
93071
|
+
}
|
|
92948
93072
|
if (err) _reject(err);
|
|
92949
93073
|
else _resolve(data2);
|
|
92950
93074
|
};
|
|
@@ -93804,7 +93928,7 @@ function parseDelta(defaultFuncs, api, ctx, globalCallback, v) {
|
|
|
93804
93928
|
if (v.delta.class == "NewMessage") {
|
|
93805
93929
|
if (ctx.globalOptions.pageID && ctx.globalOptions.pageID != v.queue) return;
|
|
93806
93930
|
(function resolveAttachmentUrl(i2) {
|
|
93807
|
-
if (v.delta.attachments
|
|
93931
|
+
if (!v.delta.attachments || !Array.isArray(v.delta.attachments) || i2 >= v.delta.attachments.length) {
|
|
93808
93932
|
let fmtMsg;
|
|
93809
93933
|
try {
|
|
93810
93934
|
fmtMsg = formatDeltaMessage(v);
|
|
@@ -93995,11 +94119,11 @@ function installTeardownGuard() {
|
|
|
93995
94119
|
const isTeardownNoise = (err) => !!err && (err.code === "MQTT_CONNECTION_CLOSED" || /Connection closed|client disconnecting/i.test(String(err && err.message ? err.message : err))) && !/error_gc|1357001|checkpoint/i.test(String(err && err.message ? err.message : err));
|
|
93996
94120
|
process.on("uncaughtException", (err) => {
|
|
93997
94121
|
if (isTeardownNoise(err)) return;
|
|
93998
|
-
|
|
94122
|
+
error("uncaughtException", err);
|
|
93999
94123
|
});
|
|
94000
94124
|
process.on("unhandledRejection", (reason) => {
|
|
94001
94125
|
if (isTeardownNoise(reason)) return;
|
|
94002
|
-
|
|
94126
|
+
error("unhandledRejection", reason);
|
|
94003
94127
|
});
|
|
94004
94128
|
}
|
|
94005
94129
|
var MQTT_TOPICS = [
|
|
@@ -94985,13 +95109,18 @@ async function login(credentials, options, callback) {
|
|
|
94985
95109
|
const finish = (error2, loginApi) => {
|
|
94986
95110
|
if (settled) return;
|
|
94987
95111
|
settled = true;
|
|
95112
|
+
const hasCallback = typeof callback === "function";
|
|
94988
95113
|
try {
|
|
94989
95114
|
callback?.(error2 || null, loginApi);
|
|
94990
95115
|
} catch (callbackError) {
|
|
94991
95116
|
error("login callback", callbackError);
|
|
94992
95117
|
}
|
|
94993
|
-
if (error2)
|
|
94994
|
-
|
|
95118
|
+
if (error2) {
|
|
95119
|
+
if (hasCallback) resolve(loginApi);
|
|
95120
|
+
else reject(error2);
|
|
95121
|
+
} else {
|
|
95122
|
+
resolve(loginApi);
|
|
95123
|
+
}
|
|
94995
95124
|
};
|
|
94996
95125
|
loginHelper(
|
|
94997
95126
|
credentials,
|
package/dist/index.mjs
CHANGED
|
@@ -87452,9 +87452,14 @@ function httpGet_default(defaultFuncs, api, ctx) {
|
|
|
87452
87452
|
return body;
|
|
87453
87453
|
}).catch((err) => {
|
|
87454
87454
|
error("httpGet", err);
|
|
87455
|
-
if (typeof callback === "function")
|
|
87455
|
+
if (typeof callback === "function") {
|
|
87456
|
+
callback(err);
|
|
87457
|
+
return null;
|
|
87458
|
+
}
|
|
87456
87459
|
throw err;
|
|
87457
87460
|
});
|
|
87461
|
+
returnPromise.catch(() => {
|
|
87462
|
+
});
|
|
87458
87463
|
return returnPromise;
|
|
87459
87464
|
};
|
|
87460
87465
|
}
|
|
@@ -87478,9 +87483,14 @@ function httpPost_default(defaultFuncs, api, ctx) {
|
|
|
87478
87483
|
return body;
|
|
87479
87484
|
}).catch((err) => {
|
|
87480
87485
|
error("httpPost", err);
|
|
87481
|
-
if (typeof callback === "function")
|
|
87486
|
+
if (typeof callback === "function") {
|
|
87487
|
+
callback(err);
|
|
87488
|
+
return null;
|
|
87489
|
+
}
|
|
87482
87490
|
throw err;
|
|
87483
87491
|
});
|
|
87492
|
+
returnPromise.catch(() => {
|
|
87493
|
+
});
|
|
87484
87494
|
return returnPromise;
|
|
87485
87495
|
};
|
|
87486
87496
|
}
|
|
@@ -87504,9 +87514,14 @@ function httpPostFormData_default(defaultFuncs, api, ctx) {
|
|
|
87504
87514
|
return body;
|
|
87505
87515
|
}).catch((err) => {
|
|
87506
87516
|
error("httpPostFormData", err);
|
|
87507
|
-
if (typeof callback === "function")
|
|
87517
|
+
if (typeof callback === "function") {
|
|
87518
|
+
callback(err);
|
|
87519
|
+
return null;
|
|
87520
|
+
}
|
|
87508
87521
|
throw err;
|
|
87509
87522
|
});
|
|
87523
|
+
returnPromise.catch(() => {
|
|
87524
|
+
});
|
|
87510
87525
|
return returnPromise;
|
|
87511
87526
|
};
|
|
87512
87527
|
}
|
|
@@ -87869,37 +87884,72 @@ function enableAutoSaveAppState_default(_defaultFuncs, api, ctx) {
|
|
|
87869
87884
|
}
|
|
87870
87885
|
|
|
87871
87886
|
// src/deltas/apis/messaging/editMessage.ts
|
|
87887
|
+
function extractEditedMessage(message) {
|
|
87888
|
+
try {
|
|
87889
|
+
const candidate = message?.payload?.step?.[1]?.[2]?.[2]?.[1];
|
|
87890
|
+
const messageID = String(candidate?.[2] || "");
|
|
87891
|
+
const body = String(candidate?.[4] || "");
|
|
87892
|
+
return { messageID: messageID || void 0, body: body || void 0 };
|
|
87893
|
+
} catch {
|
|
87894
|
+
return {};
|
|
87895
|
+
}
|
|
87896
|
+
}
|
|
87872
87897
|
function editMessage_default(_defaultFuncs, _api, ctx) {
|
|
87873
|
-
return
|
|
87898
|
+
return function editMessage(text3, messageID, callback) {
|
|
87874
87899
|
const cb = typeof callback === "function" ? callback : void 0;
|
|
87875
|
-
|
|
87876
|
-
|
|
87877
|
-
|
|
87900
|
+
const fail = (err) => {
|
|
87901
|
+
error("editMessage", err?.error || err?.message || err);
|
|
87902
|
+
if (cb) {
|
|
87903
|
+
cb(err);
|
|
87904
|
+
return { error: err?.error || err?.message || String(err), success: false };
|
|
87878
87905
|
}
|
|
87879
|
-
|
|
87880
|
-
|
|
87881
|
-
|
|
87882
|
-
|
|
87883
|
-
|
|
87884
|
-
|
|
87885
|
-
|
|
87886
|
-
|
|
87887
|
-
|
|
87888
|
-
|
|
87889
|
-
|
|
87890
|
-
|
|
87891
|
-
|
|
87892
|
-
|
|
87893
|
-
|
|
87894
|
-
|
|
87895
|
-
|
|
87906
|
+
throw err;
|
|
87907
|
+
};
|
|
87908
|
+
if (!ctx.mqttClient || !ctx.mqttClient.connected) {
|
|
87909
|
+
return fail(new Error("Not connected to MQTT"));
|
|
87910
|
+
}
|
|
87911
|
+
if (!text3 || !messageID) {
|
|
87912
|
+
return fail(new Error("text and messageID are required"));
|
|
87913
|
+
}
|
|
87914
|
+
const query = {
|
|
87915
|
+
failure_count: null,
|
|
87916
|
+
label: "742",
|
|
87917
|
+
payload: JSON.stringify({
|
|
87918
|
+
message_id: messageID,
|
|
87919
|
+
text: text3
|
|
87920
|
+
}),
|
|
87921
|
+
queue_name: "edit_message"
|
|
87922
|
+
};
|
|
87923
|
+
const content = buildWsTaskContent(ctx, [query], "6903494529735864");
|
|
87924
|
+
const promise = publishLsRequestWithAck({
|
|
87925
|
+
client: ctx.mqttClient,
|
|
87926
|
+
content,
|
|
87927
|
+
requestId: content.request_id,
|
|
87928
|
+
extract: (parsed) => parsed
|
|
87929
|
+
}).then((parsed) => {
|
|
87930
|
+
const { body } = extractEditedMessage(parsed);
|
|
87931
|
+
if (body && body !== text3) {
|
|
87932
|
+
const error2 = { error: "The message is too old or not from you!", success: false };
|
|
87933
|
+
if (cb) {
|
|
87934
|
+
cb(error2);
|
|
87935
|
+
return error2;
|
|
87936
|
+
}
|
|
87937
|
+
throw error2;
|
|
87938
|
+
}
|
|
87939
|
+
const out = { messageID, text: text3, success: true };
|
|
87896
87940
|
if (cb) cb(null, out);
|
|
87897
87941
|
return out;
|
|
87898
|
-
}
|
|
87942
|
+
}).catch((err) => {
|
|
87899
87943
|
error("editMessage", err?.error || err?.message || err);
|
|
87900
|
-
if (cb)
|
|
87944
|
+
if (cb) {
|
|
87945
|
+
cb(err);
|
|
87946
|
+
return { error: err?.error || err?.message || String(err), success: false };
|
|
87947
|
+
}
|
|
87901
87948
|
throw err;
|
|
87902
|
-
}
|
|
87949
|
+
});
|
|
87950
|
+
promise.catch(() => {
|
|
87951
|
+
});
|
|
87952
|
+
return promise;
|
|
87903
87953
|
};
|
|
87904
87954
|
}
|
|
87905
87955
|
|
|
@@ -88114,6 +88164,8 @@ function emoji_default(defaultFuncs, api, ctx) {
|
|
|
88114
88164
|
_callback = void 0;
|
|
88115
88165
|
_initiatorID = void 0;
|
|
88116
88166
|
}
|
|
88167
|
+
returnPromise.catch(() => {
|
|
88168
|
+
});
|
|
88117
88169
|
if (!_callback) {
|
|
88118
88170
|
_callback = function(__err, __data) {
|
|
88119
88171
|
if (__err) _rejectPromise(__err);
|
|
@@ -88124,7 +88176,7 @@ function emoji_default(defaultFuncs, api, ctx) {
|
|
|
88124
88176
|
_callback = function(__err, __data) {
|
|
88125
88177
|
if (__err) {
|
|
88126
88178
|
originalCallback(__err);
|
|
88127
|
-
|
|
88179
|
+
_resolvePromise(void 0);
|
|
88128
88180
|
} else {
|
|
88129
88181
|
originalCallback(null, __data);
|
|
88130
88182
|
_resolvePromise(__data);
|
|
@@ -88142,6 +88194,8 @@ function emoji_default(defaultFuncs, api, ctx) {
|
|
|
88142
88194
|
if (!ctx.mqttClient) {
|
|
88143
88195
|
return _callback(new Error("Not connected to MQTT"));
|
|
88144
88196
|
}
|
|
88197
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
88198
|
+
if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
|
|
88145
88199
|
ctx.wsReqNumber += 1;
|
|
88146
88200
|
ctx.wsTaskNumber += 1;
|
|
88147
88201
|
const queryPayload = {
|
|
@@ -88323,6 +88377,8 @@ function gcname_default(defaultFuncs, api, ctx) {
|
|
|
88323
88377
|
_callback = void 0;
|
|
88324
88378
|
_initiatorID = void 0;
|
|
88325
88379
|
}
|
|
88380
|
+
returnPromise.catch(() => {
|
|
88381
|
+
});
|
|
88326
88382
|
if (!_callback) {
|
|
88327
88383
|
_callback = function(__err, __data) {
|
|
88328
88384
|
if (__err) _rejectPromise(__err);
|
|
@@ -88333,7 +88389,7 @@ function gcname_default(defaultFuncs, api, ctx) {
|
|
|
88333
88389
|
_callback = function(__err, __data) {
|
|
88334
88390
|
if (__err) {
|
|
88335
88391
|
originalCallback(__err);
|
|
88336
|
-
|
|
88392
|
+
_resolvePromise(void 0);
|
|
88337
88393
|
} else {
|
|
88338
88394
|
originalCallback(null, __data);
|
|
88339
88395
|
_resolvePromise(__data);
|
|
@@ -88351,6 +88407,8 @@ function gcname_default(defaultFuncs, api, ctx) {
|
|
|
88351
88407
|
if (!ctx.mqttClient) {
|
|
88352
88408
|
return _callback(new Error("Not connected to MQTT"));
|
|
88353
88409
|
}
|
|
88410
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
88411
|
+
if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
|
|
88354
88412
|
ctx.wsReqNumber += 1;
|
|
88355
88413
|
ctx.wsTaskNumber += 1;
|
|
88356
88414
|
const queryPayload = {
|
|
@@ -88409,6 +88467,8 @@ function gcrule_default(defaultFuncs, api, ctx) {
|
|
|
88409
88467
|
resolvePromise = resolve;
|
|
88410
88468
|
rejectPromise = reject;
|
|
88411
88469
|
});
|
|
88470
|
+
returnPromise.catch(() => {
|
|
88471
|
+
});
|
|
88412
88472
|
if (typeof _callback != "function") {
|
|
88413
88473
|
_callback = (err, data2) => {
|
|
88414
88474
|
if (err) return rejectPromise(err);
|
|
@@ -88491,28 +88551,41 @@ function gcrule_default(defaultFuncs, api, ctx) {
|
|
|
88491
88551
|
|
|
88492
88552
|
// src/deltas/apis/messaging/markAsDelivered.ts
|
|
88493
88553
|
function markAsDelivered_default(defaultFuncs, api, ctx) {
|
|
88494
|
-
return
|
|
88495
|
-
|
|
88496
|
-
|
|
88554
|
+
return function markAsDelivered(threadID, messageID, callback) {
|
|
88555
|
+
const cb = typeof callback === "function" ? callback : void 0;
|
|
88556
|
+
const fail = (err) => {
|
|
88497
88557
|
error("markAsDelivered", err);
|
|
88498
|
-
|
|
88558
|
+
if (cb) {
|
|
88559
|
+
cb(err);
|
|
88560
|
+
return;
|
|
88561
|
+
}
|
|
88562
|
+
throw err;
|
|
88563
|
+
};
|
|
88564
|
+
if (!threadID || !messageID) {
|
|
88565
|
+
return fail("Error: messageID or threadID is not defined");
|
|
88499
88566
|
}
|
|
88500
88567
|
const form = {};
|
|
88501
88568
|
form["message_ids[0]"] = messageID;
|
|
88502
88569
|
form["thread_ids[" + threadID + "][0]"] = messageID;
|
|
88503
|
-
|
|
88504
|
-
|
|
88505
|
-
|
|
88506
|
-
|
|
88507
|
-
|
|
88508
|
-
|
|
88509
|
-
if (resData
|
|
88510
|
-
|
|
88511
|
-
|
|
88512
|
-
} catch (err) {
|
|
88570
|
+
const promise = defaultFuncs.post(
|
|
88571
|
+
"https://www.facebook.com/ajax/mercury/delivery_receipts.php",
|
|
88572
|
+
ctx.jar,
|
|
88573
|
+
form
|
|
88574
|
+
).then(saveCookies(ctx.jar)).then(parseAndCheckLogin(ctx, defaultFuncs)).then((resData) => {
|
|
88575
|
+
if (resData && resData.error) throw resData;
|
|
88576
|
+
if (cb) cb(null, resData);
|
|
88577
|
+
return resData;
|
|
88578
|
+
}).catch((err) => {
|
|
88513
88579
|
error("markAsDelivered", err);
|
|
88580
|
+
if (cb) {
|
|
88581
|
+
cb(err);
|
|
88582
|
+
return null;
|
|
88583
|
+
}
|
|
88514
88584
|
throw err;
|
|
88515
|
-
}
|
|
88585
|
+
});
|
|
88586
|
+
promise.catch(() => {
|
|
88587
|
+
});
|
|
88588
|
+
return promise;
|
|
88516
88589
|
};
|
|
88517
88590
|
}
|
|
88518
88591
|
|
|
@@ -88600,20 +88673,27 @@ function markAsRead_default(defaultFuncs, api, ctx) {
|
|
|
88600
88673
|
|
|
88601
88674
|
// src/deltas/apis/messaging/markAsReadAll.ts
|
|
88602
88675
|
function markAsReadAll_default(defaultFuncs, api, ctx) {
|
|
88603
|
-
return
|
|
88604
|
-
|
|
88605
|
-
|
|
88606
|
-
|
|
88607
|
-
|
|
88608
|
-
|
|
88609
|
-
|
|
88610
|
-
|
|
88611
|
-
if (
|
|
88612
|
-
return;
|
|
88613
|
-
}
|
|
88676
|
+
return function markAsReadAll(callback) {
|
|
88677
|
+
const cb = typeof callback === "function" ? callback : void 0;
|
|
88678
|
+
const promise = defaultFuncs.post(
|
|
88679
|
+
"https://www.facebook.com/ajax/mercury/mark_folder_as_read.php",
|
|
88680
|
+
ctx.jar,
|
|
88681
|
+
{ folder: "inbox" }
|
|
88682
|
+
).then((resData) => parseAndCheckLogin(ctx, defaultFuncs)(resData)).then((parsedData) => {
|
|
88683
|
+
if (parsedData && parsedData.error) throw parsedData;
|
|
88684
|
+
if (cb) cb(null, parsedData);
|
|
88685
|
+
return parsedData;
|
|
88686
|
+
}).catch((err) => {
|
|
88614
88687
|
error("markAsReadAll", err);
|
|
88688
|
+
if (cb) {
|
|
88689
|
+
cb(err);
|
|
88690
|
+
return null;
|
|
88691
|
+
}
|
|
88615
88692
|
throw err;
|
|
88616
|
-
}
|
|
88693
|
+
});
|
|
88694
|
+
promise.catch(() => {
|
|
88695
|
+
});
|
|
88696
|
+
return promise;
|
|
88617
88697
|
};
|
|
88618
88698
|
}
|
|
88619
88699
|
|
|
@@ -88641,6 +88721,16 @@ function markAsSeen_default(defaultFuncs, api, ctx) {
|
|
|
88641
88721
|
}
|
|
88642
88722
|
resolveFunc(friendList);
|
|
88643
88723
|
};
|
|
88724
|
+
} else {
|
|
88725
|
+
const originalCallback = callback;
|
|
88726
|
+
callback = function(err, data2) {
|
|
88727
|
+
try {
|
|
88728
|
+
originalCallback(err, data2);
|
|
88729
|
+
} finally {
|
|
88730
|
+
if (err) resolveFunc(void 0);
|
|
88731
|
+
else resolveFunc(data2);
|
|
88732
|
+
}
|
|
88733
|
+
};
|
|
88644
88734
|
}
|
|
88645
88735
|
const form = {
|
|
88646
88736
|
seen_timestamp
|
|
@@ -88692,6 +88782,8 @@ function nickname_default(defaultFuncs, api, ctx) {
|
|
|
88692
88782
|
_callback = void 0;
|
|
88693
88783
|
_initiatorID = void 0;
|
|
88694
88784
|
}
|
|
88785
|
+
returnPromise.catch(() => {
|
|
88786
|
+
});
|
|
88695
88787
|
if (!_callback) {
|
|
88696
88788
|
_callback = function(__err, __data) {
|
|
88697
88789
|
if (__err) _rejectPromise(__err);
|
|
@@ -88702,7 +88794,7 @@ function nickname_default(defaultFuncs, api, ctx) {
|
|
|
88702
88794
|
_callback = function(__err, __data) {
|
|
88703
88795
|
if (__err) {
|
|
88704
88796
|
originalCallback(__err);
|
|
88705
|
-
|
|
88797
|
+
_resolvePromise(void 0);
|
|
88706
88798
|
} else {
|
|
88707
88799
|
originalCallback(null, __data);
|
|
88708
88800
|
_resolvePromise(__data);
|
|
@@ -88721,6 +88813,8 @@ function nickname_default(defaultFuncs, api, ctx) {
|
|
|
88721
88813
|
if (!ctx.mqttClient) {
|
|
88722
88814
|
return _callback(new Error("Not connected to MQTT"));
|
|
88723
88815
|
}
|
|
88816
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
88817
|
+
if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
|
|
88724
88818
|
ctx.wsReqNumber += 1;
|
|
88725
88819
|
ctx.wsTaskNumber += 1;
|
|
88726
88820
|
const queryPayload = {
|
|
@@ -89297,8 +89391,9 @@ var sendMessage_default = (defaultFuncs, api, ctx) => {
|
|
|
89297
89391
|
|
|
89298
89392
|
// src/deltas/apis/messaging/sendTypingIndicator.ts
|
|
89299
89393
|
function sendTypingIndicator_default(defaultFuncs, api, ctx) {
|
|
89300
|
-
return
|
|
89394
|
+
return function sendTypingIndicatorV2(sendTyping, threadID, options, callback) {
|
|
89301
89395
|
if (typeof options === "function") {
|
|
89396
|
+
callback = options;
|
|
89302
89397
|
options = {};
|
|
89303
89398
|
}
|
|
89304
89399
|
options = options || {};
|
|
@@ -89311,14 +89406,23 @@ function sendTypingIndicator_default(defaultFuncs, api, ctx) {
|
|
|
89311
89406
|
actualSendTyping = sendTyping;
|
|
89312
89407
|
actualThreadID = threadID;
|
|
89313
89408
|
}
|
|
89409
|
+
const fail = (message) => {
|
|
89410
|
+
const err = new Error(message);
|
|
89411
|
+
if (typeof callback === "function") {
|
|
89412
|
+
callback(err);
|
|
89413
|
+
return Promise.resolve(null);
|
|
89414
|
+
}
|
|
89415
|
+
return Promise.reject(err);
|
|
89416
|
+
};
|
|
89314
89417
|
if (!actualThreadID) {
|
|
89315
|
-
|
|
89418
|
+
return fail("sendTypingIndicator: threadID is required");
|
|
89316
89419
|
}
|
|
89317
89420
|
if (!ctx.mqttClient || !ctx.mqttClient.connected) {
|
|
89318
|
-
|
|
89421
|
+
return fail("sendTypingIndicator: not connected to MQTT");
|
|
89319
89422
|
}
|
|
89320
89423
|
const threadIDs = Array.isArray(actualThreadID) ? actualThreadID : [actualThreadID];
|
|
89321
89424
|
const attribution = options.type || 0;
|
|
89425
|
+
const publishPromises = [];
|
|
89322
89426
|
const publishTyping = (tid, isTyping) => {
|
|
89323
89427
|
ctx.wsReqNumber = (ctx.wsReqNumber || 0) + 1;
|
|
89324
89428
|
const isGroupThread = String(tid).length >= 16 ? 1 : 0;
|
|
@@ -89348,18 +89452,26 @@ function sendTypingIndicator_default(defaultFuncs, api, ctx) {
|
|
|
89348
89452
|
);
|
|
89349
89453
|
});
|
|
89350
89454
|
};
|
|
89351
|
-
await Promise.all(threadIDs.map((tid) => publishTyping(tid, actualSendTyping)));
|
|
89352
89455
|
const duration = options.duration || 1e4;
|
|
89353
89456
|
const autoStop = options.autoStop !== false;
|
|
89354
|
-
|
|
89355
|
-
|
|
89356
|
-
|
|
89357
|
-
|
|
89358
|
-
|
|
89359
|
-
|
|
89457
|
+
threadIDs.forEach((tid) => {
|
|
89458
|
+
const p = publishTyping(tid, actualSendTyping).then(() => {
|
|
89459
|
+
if (actualSendTyping && autoStop) {
|
|
89460
|
+
setTimeout(() => {
|
|
89461
|
+
publishTyping(tid, false).catch(() => {
|
|
89462
|
+
});
|
|
89463
|
+
}, duration);
|
|
89464
|
+
}
|
|
89465
|
+
return true;
|
|
89360
89466
|
});
|
|
89467
|
+
publishPromises.push(p);
|
|
89468
|
+
});
|
|
89469
|
+
const result = Promise.all(publishPromises).then(() => true);
|
|
89470
|
+
if (typeof callback === "function") {
|
|
89471
|
+
result.then(() => callback(null, true)).catch((err) => callback(err));
|
|
89472
|
+
return result.catch(() => null);
|
|
89361
89473
|
}
|
|
89362
|
-
return
|
|
89474
|
+
return result;
|
|
89363
89475
|
};
|
|
89364
89476
|
}
|
|
89365
89477
|
|
|
@@ -89673,11 +89785,22 @@ function theme_default(defaultFuncs, api, ctx) {
|
|
|
89673
89785
|
_callback = void 0;
|
|
89674
89786
|
_initiatorID = void 0;
|
|
89675
89787
|
}
|
|
89788
|
+
finalReturnPromise.catch(() => {
|
|
89789
|
+
});
|
|
89676
89790
|
if (!_callback) {
|
|
89677
89791
|
_callback = function(_err, _data) {
|
|
89678
89792
|
if (_err) _rejectFunc(_err);
|
|
89679
89793
|
else _resolveFunc(_data);
|
|
89680
89794
|
};
|
|
89795
|
+
} else {
|
|
89796
|
+
const originalCallback = _callback;
|
|
89797
|
+
_callback = function(_err, _data) {
|
|
89798
|
+
try {
|
|
89799
|
+
originalCallback(_err, _data);
|
|
89800
|
+
} finally {
|
|
89801
|
+
_resolveFunc(_data);
|
|
89802
|
+
}
|
|
89803
|
+
};
|
|
89681
89804
|
}
|
|
89682
89805
|
_initiatorID = _initiatorID || ctx.userID;
|
|
89683
89806
|
threadID = threadID || ctx.threadID;
|
|
@@ -89748,6 +89871,8 @@ function theme_default(defaultFuncs, api, ctx) {
|
|
|
89748
89871
|
let currentEpochId = parseInt(generateOfflineThreadingID());
|
|
89749
89872
|
const createAndPublish = (label, queueName, payload) => {
|
|
89750
89873
|
currentEpochId = parseInt(generateOfflineThreadingID());
|
|
89874
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
89875
|
+
if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
|
|
89751
89876
|
ctx.wsReqNumber += 1;
|
|
89752
89877
|
ctx.wsTaskNumber += 1;
|
|
89753
89878
|
const request_id = ctx.wsReqNumber;
|
|
@@ -89854,6 +89979,8 @@ function setThreadTheme_default(defaultFuncs, _api, ctx) {
|
|
|
89854
89979
|
}
|
|
89855
89980
|
throw error2;
|
|
89856
89981
|
}
|
|
89982
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
89983
|
+
if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
|
|
89857
89984
|
ctx.wsReqNumber += 1;
|
|
89858
89985
|
let baseTaskNumber = ++ctx.wsTaskNumber;
|
|
89859
89986
|
const makeTask = (label, queueName, extraPayload = {}) => ({
|
|
@@ -89875,6 +90002,7 @@ function setThreadTheme_default(defaultFuncs, _api, ctx) {
|
|
|
89875
90002
|
{ label: 43, queue: "thread_theme", extra: { source: null, payload: null } }
|
|
89876
90003
|
];
|
|
89877
90004
|
const messages = definitions.map(({ label, queue, extra }) => {
|
|
90005
|
+
if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
|
|
89878
90006
|
ctx.wsReqNumber += 1;
|
|
89879
90007
|
return {
|
|
89880
90008
|
app_id: "2220391788200892",
|
|
@@ -90025,15 +90153,8 @@ async function publishThreadTask(ctx, label, queueName, payload, versionId, appI
|
|
|
90025
90153
|
requestId: content.request_id,
|
|
90026
90154
|
extract: (parsed) => {
|
|
90027
90155
|
const body = parsed && parsed.payload;
|
|
90028
|
-
|
|
90029
|
-
|
|
90030
|
-
const err = new Error(
|
|
90031
|
-
typeof error2 === "string" ? error2 : error2.message || "MQTT task was rejected"
|
|
90032
|
-
);
|
|
90033
|
-
err.error = error2;
|
|
90034
|
-
throw err;
|
|
90035
|
-
}
|
|
90036
|
-
return body || { success: true };
|
|
90156
|
+
if (!body || typeof body !== "object") return { success: true };
|
|
90157
|
+
return body;
|
|
90037
90158
|
}
|
|
90038
90159
|
});
|
|
90039
90160
|
}
|
|
@@ -90064,8 +90185,13 @@ function unsendMessage_default(defaultFuncs, _api, ctx) {
|
|
|
90064
90185
|
_resolve = resolve;
|
|
90065
90186
|
_reject = reject;
|
|
90066
90187
|
});
|
|
90188
|
+
returnPromise.catch(() => {
|
|
90189
|
+
});
|
|
90067
90190
|
const done = (err, data2) => {
|
|
90068
|
-
if (cb)
|
|
90191
|
+
if (cb) {
|
|
90192
|
+
cb(err, data2);
|
|
90193
|
+
return;
|
|
90194
|
+
}
|
|
90069
90195
|
if (err) _reject(err);
|
|
90070
90196
|
else _resolve(data2);
|
|
90071
90197
|
};
|
|
@@ -90982,7 +91108,7 @@ var sendMessageMqtt_default = (defaultFuncs, api, ctx) => {
|
|
|
90982
91108
|
attachmentIds = ids;
|
|
90983
91109
|
} catch (err) {
|
|
90984
91110
|
error("Attachment upload failed:", err);
|
|
90985
|
-
|
|
91111
|
+
finish(err);
|
|
90986
91112
|
return done();
|
|
90987
91113
|
}
|
|
90988
91114
|
}
|
|
@@ -92712,15 +92838,8 @@ function changeAdminStatus_default(defaultFuncs, _api, ctx) {
|
|
|
92712
92838
|
requestId: content.request_id,
|
|
92713
92839
|
extract: (parsed) => {
|
|
92714
92840
|
const body = parsed && parsed.payload;
|
|
92715
|
-
|
|
92716
|
-
|
|
92717
|
-
const err = new Error(
|
|
92718
|
-
typeof error2 === "string" ? error2 : error2.message || "admin_status task rejected"
|
|
92719
|
-
);
|
|
92720
|
-
err.error = error2;
|
|
92721
|
-
throw err;
|
|
92722
|
-
}
|
|
92723
|
-
return body || { success: true };
|
|
92841
|
+
if (!body || typeof body !== "object") return { success: true };
|
|
92842
|
+
return body;
|
|
92724
92843
|
}
|
|
92725
92844
|
});
|
|
92726
92845
|
if (cb) cb(null);
|
|
@@ -92911,8 +93030,13 @@ function createPoll_default(_defaultFuncs, _api, ctx) {
|
|
|
92911
93030
|
_resolve = resolve;
|
|
92912
93031
|
_reject = reject;
|
|
92913
93032
|
});
|
|
93033
|
+
promise.catch(() => {
|
|
93034
|
+
});
|
|
92914
93035
|
const done = (err, data2) => {
|
|
92915
|
-
if (cb)
|
|
93036
|
+
if (cb) {
|
|
93037
|
+
cb(err, data2);
|
|
93038
|
+
return;
|
|
93039
|
+
}
|
|
92916
93040
|
if (err) _reject(err);
|
|
92917
93041
|
else _resolve(data2);
|
|
92918
93042
|
};
|
|
@@ -93772,7 +93896,7 @@ function parseDelta(defaultFuncs, api, ctx, globalCallback, v) {
|
|
|
93772
93896
|
if (v.delta.class == "NewMessage") {
|
|
93773
93897
|
if (ctx.globalOptions.pageID && ctx.globalOptions.pageID != v.queue) return;
|
|
93774
93898
|
(function resolveAttachmentUrl(i2) {
|
|
93775
|
-
if (v.delta.attachments
|
|
93899
|
+
if (!v.delta.attachments || !Array.isArray(v.delta.attachments) || i2 >= v.delta.attachments.length) {
|
|
93776
93900
|
let fmtMsg;
|
|
93777
93901
|
try {
|
|
93778
93902
|
fmtMsg = formatDeltaMessage(v);
|
|
@@ -93963,11 +94087,11 @@ function installTeardownGuard() {
|
|
|
93963
94087
|
const isTeardownNoise = (err) => !!err && (err.code === "MQTT_CONNECTION_CLOSED" || /Connection closed|client disconnecting/i.test(String(err && err.message ? err.message : err))) && !/error_gc|1357001|checkpoint/i.test(String(err && err.message ? err.message : err));
|
|
93964
94088
|
process.on("uncaughtException", (err) => {
|
|
93965
94089
|
if (isTeardownNoise(err)) return;
|
|
93966
|
-
|
|
94090
|
+
error("uncaughtException", err);
|
|
93967
94091
|
});
|
|
93968
94092
|
process.on("unhandledRejection", (reason) => {
|
|
93969
94093
|
if (isTeardownNoise(reason)) return;
|
|
93970
|
-
|
|
94094
|
+
error("unhandledRejection", reason);
|
|
93971
94095
|
});
|
|
93972
94096
|
}
|
|
93973
94097
|
var MQTT_TOPICS = [
|
|
@@ -94953,13 +95077,18 @@ async function login(credentials, options, callback) {
|
|
|
94953
95077
|
const finish = (error2, loginApi) => {
|
|
94954
95078
|
if (settled) return;
|
|
94955
95079
|
settled = true;
|
|
95080
|
+
const hasCallback = typeof callback === "function";
|
|
94956
95081
|
try {
|
|
94957
95082
|
callback?.(error2 || null, loginApi);
|
|
94958
95083
|
} catch (callbackError) {
|
|
94959
95084
|
error("login callback", callbackError);
|
|
94960
95085
|
}
|
|
94961
|
-
if (error2)
|
|
94962
|
-
|
|
95086
|
+
if (error2) {
|
|
95087
|
+
if (hasCallback) resolve(loginApi);
|
|
95088
|
+
else reject(error2);
|
|
95089
|
+
} else {
|
|
95090
|
+
resolve(loginApi);
|
|
95091
|
+
}
|
|
94963
95092
|
};
|
|
94964
95093
|
loginHelper(
|
|
94965
95094
|
credentials,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lazyneoaz/metachat",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.9",
|
|
4
4
|
"description": "A modern TypeScript Facebook Chat API client for building reliable Messenger bots, with built-in anti-detection protection, automatic cookie refresh, music search, and AI theme support.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"prepublishOnly": "npm run build",
|
|
58
58
|
"lint": "npm run typecheck",
|
|
59
59
|
"format": "prettier --write \"src/**/*.ts\" \"index.ts\"",
|
|
60
|
-
"test": "npm run build && node test/smoke.test.cjs && node test/smoke.test.mjs && node test/music-search.test.cjs && node test/mqtt-lifecycle.test.cjs && node test/session-reliability.test.cjs && node test/anti-detection.test.cjs && node test/account-safety.test.cjs && node test/liveness.test.cjs && node test/recovery.test.cjs && node test/cookie-acquisition.test.cjs && node test/realtime-health.test.cjs && node test/attachment-resilience.test.cjs && node test/reaction-validation.test.cjs && node test/api-surface-fixes.test.cjs && node test/threadinfo-regression.test.cjs && node test/new-modules.test.cjs && node test/mention-parsing.test.cjs && node test/pending-support.test.cjs && node test/music-token-resilience.test.cjs && node test/send-failure.test.cjs",
|
|
60
|
+
"test": "npm run build && node test/smoke.test.cjs && node test/smoke.test.mjs && node test/music-search.test.cjs && node test/mqtt-lifecycle.test.cjs && node test/session-reliability.test.cjs && node test/anti-detection.test.cjs && node test/account-safety.test.cjs && node test/liveness.test.cjs && node test/recovery.test.cjs && node test/cookie-acquisition.test.cjs && node test/realtime-health.test.cjs && node test/attachment-resilience.test.cjs && node test/reaction-validation.test.cjs && node test/api-surface-fixes.test.cjs && node test/threadinfo-regression.test.cjs && node test/new-modules.test.cjs && node test/mention-parsing.test.cjs && node test/pending-support.test.cjs && node test/music-token-resilience.test.cjs && node test/send-failure.test.cjs && node test/crash-safety.test.cjs",
|
|
61
61
|
"audit": "npm audit",
|
|
62
62
|
"audit:fix": "npm audit fix"
|
|
63
63
|
},
|