mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-09 05:10:45 +08:00
Fix key-alarm IM delivery blocked by DSH session sink.
Run session and WhatsApp/IM sinks in parallel so a failing or slow sticky session no longer skips proactive IM delivery (0.1.34). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
3a731389f0
commit
da08c38949
5 changed files with 157 additions and 15 deletions
33
lib/index.js
33
lib/index.js
|
|
@ -546,6 +546,29 @@ function resetAlarmSession() {
|
|||
disposeSticky(previous);
|
||||
}
|
||||
|
||||
// src/netx/alarm-dispatch.ts
|
||||
async function dispatchAlarmToSinks(ctx, payload, options, sinks = {}) {
|
||||
const toSession = sinks.toSession ?? deliverAlarmToSession;
|
||||
const toIm = sinks.toIm ?? deliverAlarmToIm;
|
||||
const jobs = [];
|
||||
if (options.deliverDsh) {
|
||||
jobs.push(toSession(ctx, payload, options.lang));
|
||||
}
|
||||
const imOptions = {
|
||||
enabled: options.deliverIm,
|
||||
targets: options.imTargets,
|
||||
lang: options.lang
|
||||
};
|
||||
jobs.push(toIm(ctx, payload, imOptions));
|
||||
const results = await Promise.allSettled(jobs);
|
||||
for (const result of results) {
|
||||
if (result.status === "rejected") {
|
||||
ctx.logger.warn("netxops alarm-push: sink failed: %s", result.reason);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
// src/netx/capability-groups.ts
|
||||
var DEFAULT_CAPABILITY_GROUPS = Object.freeze({
|
||||
ops: Object.freeze({ inPreset: true, public: false }),
|
||||
|
|
@ -4558,12 +4581,10 @@ function apply(ctx, config = Config({})) {
|
|||
token,
|
||||
logger: ctx.logger,
|
||||
onAlarm: async (payload) => {
|
||||
if (deliverDsh) {
|
||||
await deliverAlarmToSession(ctx, payload, lang);
|
||||
}
|
||||
await deliverAlarmToIm(ctx, payload, {
|
||||
enabled: deliverIm,
|
||||
targets: imTargets,
|
||||
await dispatchAlarmToSinks(ctx, payload, {
|
||||
deliverDsh,
|
||||
deliverIm,
|
||||
imTargets,
|
||||
lang
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue