app: email and WhatsApp's backend (APP-1.0-PLAN §8)
The church's one set of settings from Accounts (messaging.get; the SMTP password and WAWP token sealed with the link's secret, kept encrypted in AppSetting messaging_settings), fetched when the App links to Accounts, on Accounts' signed messaging.changed, once a day and on the admin's Fetch again. messages-send (every minute): the outbox by email (nodemailer) and WhatsApp (WAWP), STOP checked before every WhatsApp (the member and anyone with the same number), email instead for what a member asked for (never announcements), retries after 2, 4, 8 and 16 minutes, a reminder never after its slot started, nothing more than 3 days late. announcement-sends and devotional-sends queue "Also send it" at the publish time and today's devotional at each member's time. Members' choices (NotificationSettings), news consent kept from Accounts, MessageCount for the heartbeat's messages, the admin's Email and WhatsApp API with Send a test. Migration messaging (checked on PostgreSQL 18). 110 backend tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,9 +3,10 @@
|
||||
* however many processes run, and timers in this process if the queue can't start.
|
||||
* JOBS_ENABLED=false turns them all off.
|
||||
*
|
||||
* The Hub heartbeat and the House of Prayer's reminders and renewal notices (prayer/jobs.ts). The
|
||||
* modules add theirs (APP-1.0-PLAN §1): the event feed, Cross Code's devotionals (the next 2 weeks, today included, once a night, §6),
|
||||
* announcement and devotional sends, and the nightly backup.
|
||||
* The Hub heartbeat, the event feed, Cross Code's devotionals (the next 2 weeks, today included, once
|
||||
* a night, §6), the House of Prayer's reminders and renewal notices (prayer/jobs.ts), tidying prayer
|
||||
* requests, and email and WhatsApp (§8, messaging/send.ts): sending what's queued, and queuing
|
||||
* announcements and the day's devotional. The nightly backup comes with the admin (§10).
|
||||
*
|
||||
* Settings → Background jobs (§10) shows each job's schedule and last runs, runs one now, and
|
||||
* switches one on or off or changes its schedule. That choice is kept in the database
|
||||
@@ -21,6 +22,7 @@ import { tidyRequests } from './requests/service.js';
|
||||
import { nightlySync } from './content/devotionals.js';
|
||||
import { syncAll } from './events/feed.js';
|
||||
import { DELETE_AFTER_CLOSED_DAYS } from './requests/settings.js';
|
||||
import { queueAnnouncements, queueDevotionals, sendOutbox } from './messaging/send.js';
|
||||
|
||||
export type Job = { name: string; label: string; cron: string; env: string | null; run: (ctx: Ctx) => Promise<unknown> };
|
||||
|
||||
@@ -30,6 +32,9 @@ export const JOBS: Job[] = [
|
||||
{ name: 'crosscode-devotionals', label: 'Cross Code\'s devotionals from the Hub (the next 2 weeks)', cron: '15 1 * * *', env: null, run: (ctx) => nightlySync(ctx) },
|
||||
{ name: 'prayer-reminders', label: 'House of Prayer: slot reminders', cron: '* * * * *', env: 'PRAYER_REMINDERS_ENABLED', run: (ctx) => sendReminders(ctx) },
|
||||
{ name: 'prayer-requests-tidy', label: 'Prayer requests: close after their days, delete 12 months after closing', cron: '30 3 * * *', env: null, run: (ctx) => tidyRequests(ctx, DELETE_AFTER_CLOSED_DAYS) },
|
||||
{ name: 'messages-send', label: 'Email and WhatsApp: send what\'s queued (reminders, notices, announcements, devotionals)', cron: '* * * * *', env: 'MESSAGES_ENABLED', run: (ctx) => sendOutbox(ctx) },
|
||||
{ name: 'announcement-sends', label: 'Announcements: queue "Also send it" at the publish time', cron: '* * * * *', env: null, run: (ctx) => queueAnnouncements(ctx) },
|
||||
{ name: 'devotional-sends', label: 'Today\'s devotional: queue it at each member\'s time', cron: '*/5 * * * *', env: null, run: (ctx) => queueDevotionals(ctx) },
|
||||
{ name: 'prayer-renewals', label: 'House of Prayer: renewal notices (14 and 3 days before the end)', cron: '0 9 * * *', env: 'PRAYER_RENEWALS_ENABLED', run: (ctx) => sendRenewalNotices(ctx) },
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user