mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Scan bounded pending-intent batches after startup, advance past failed and busy rows, and coordinate immediate delivery and recovery through renewable per-intent reservations. Resume saved plans or prepare the first plan from an unchanged persisted activity; retain unresolved orphans without recreating activities. Validated with 14 Node/MongoDB cases, three additional Node suites, four full-app Meteor cases and twelve Chromium scenarios including scheduled local SMTP recovery. Operator controls and payload retention remain open. Thanks to xet7.
22 lines
1.2 KiB
JavaScript
22 lines
1.2 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { Mongo } from 'meteor/mongo';
|
|
import Activities from '/models/activities';
|
|
import { ensureIndex } from '/server/lib/mongoStartup';
|
|
const { ensureActivityNotificationIntent, completeActivityNotificationIntent } = require('/server/lib/activityNotificationIntent');
|
|
|
|
export const ActivityNotificationIntents = new Mongo.Collection('activityNotificationIntents');
|
|
ActivityNotificationIntents.deny({ insert: () => true, update: () => true, remove: () => true });
|
|
Meteor.startup(async () => {
|
|
await ensureIndex(ActivityNotificationIntents, { state: 1, _id: 1 });
|
|
});
|
|
const options = (activity, dispatchUserId) => ({ activity, dispatchUserId,
|
|
intents: ActivityNotificationIntents.rawCollection(), activities: Activities.rawCollection(),
|
|
assertCurrent: async () => {},
|
|
});
|
|
export function captureActivityNotificationIntent(activity, dispatchUserId) {
|
|
return ensureActivityNotificationIntent(options(activity, dispatchUserId ?? null));
|
|
}
|
|
export function acknowledgeActivityNotifications(activity, dispatchUserId, assertCurrent = async () => {}) {
|
|
return completeActivityNotificationIntent({ ...options(activity, dispatchUserId ?? null), assertCurrent });
|
|
}
|