feat(mail-ingest): tell every address holder once when the import stops

A plan without the import switches it off from outside the server, and an
admin can switch it off too; the plan promises a "mail import paused" note.
An hourly job sends mail_ingest_paused to each holder of a live address with
their own import on, notes the pause first, and forgets it once it is back.
This commit is contained in:
Maurice
2026-11-13 17:11:30 +01:00
parent 1d052f725f
commit 44f669cd0e
72 changed files with 429 additions and 3 deletions
@@ -48,6 +48,7 @@ export type NotifEventType =
| 'wanderer_source_hint'
| 'mail_booking_added'
| 'mail_booking_pending'
| 'mail_ingest_paused'
| 'plugin_notification';
/** Every event, in the order the preferences UI lists them. */
@@ -72,6 +73,7 @@ export const ALL_EVENT_TYPES: NotifEventType[] = [
'wanderer_source_hint',
'mail_booking_added',
'mail_booking_pending',
'mail_ingest_paused',
'plugin_notification',
];
@@ -137,6 +137,7 @@ export class NotificationPreferencesService {
return (await resolveAppSetting(this.appSettings, 'flight_live_enabled')) !== 'false';
case 'mail_booking_added':
case 'mail_booking_pending':
case 'mail_ingest_paused':
return (await resolveAppSetting(this.appSettings, 'mail_ingest_enabled')) === 'true';
default:
return true;
@@ -306,6 +306,14 @@ const EVENT_NOTIFICATION_CONFIG: Record<string, EventNotifConfig> = {
navigateTextKey: 'notif.action.review',
navigateTarget: () => '/dashboard?inbox=mail',
},
// The import stopped (a plan without it, or an admin switched it off): every
// person with an address hears it once, with nothing to open.
mail_ingest_paused: {
inAppType: 'simple',
titleKey: 'notif.mail_ingest_paused.title',
textKey: 'notif.mail_ingest_paused.text',
navigateTarget: () => null,
},
synology_session_cleared: {
inAppType: 'simple',
titleKey: 'notifications.synologySessionCleared.title',
@@ -41,6 +41,7 @@ const NTFY_EVENT_META: Partial<Record<NotifEventType, { priority: 1 | 2 | 3 | 4
wanderer_source_hint: { priority: 2, tags: ['hiking_boot'] },
mail_booking_added: { priority: 3, tags: ['envelope'] },
mail_booking_pending: { priority: 2, tags: ['envelope'] },
mail_ingest_paused: { priority: 3, tags: ['pause_button'] },
};
const NTFY_DEFAULT_META = { priority: 3 as const, tags: [] as string[] };