Alerts: backup-contact phrasing; correct backup countdown; include per-position pay link; deep-link route rendering in-place; single-position view via deep-link; ARB alias; backup test message alignment
This commit is contained in:
@@ -8,6 +8,39 @@ export interface ScheduleArgs {
|
||||
headers?: Record<string, string>;
|
||||
}
|
||||
|
||||
// Schedule a backup-email specific test (uses backupEmail target)
|
||||
export async function scheduleTestBackupNotification(settings: NotificationSettings): Promise<ScheduleResult> {
|
||||
const scheduler = settings.scheduler || 'schedy';
|
||||
if (scheduler !== 'schedy') throw new Error('Only Schedy is supported for tests');
|
||||
const backup = (settings.backupEmail || '').trim();
|
||||
if (!backup) throw new Error('Please set a backup email');
|
||||
|
||||
if (settings.provider !== 'ntfy') {
|
||||
throw new Error('Backup test currently supports ntfy provider only');
|
||||
}
|
||||
|
||||
const topic = (settings.ntfyTopic || '').trim();
|
||||
const base = (settings.ntfyServer || process.env.NEXT_PUBLIC_NTFY_URL || '/ntfy').replace(/\/$/, '');
|
||||
if (!base || !topic) throw new Error('ntfy server or topic missing');
|
||||
|
||||
const relUrl = `${base}/${encodeURIComponent(topic)}`;
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const runAtEpoch = now + 120; // 2 minutes
|
||||
const primary = (settings.email || '').trim();
|
||||
const prefix = `You are the backup contact for this position. Please contact the primary contact${primary ? ' ' + primary : ''} immediately. If they do not respond, please pay down the debt to avoid liquidation in a timely manner.`;
|
||||
const body = `${prefix}\n\n(MortgageFi backup email test at ${new Date().toISOString()})`;
|
||||
return schedySchedule((settings.schedyBaseUrl || ENV_SCHEDY).replace(/\/$/, ''), settings.schedyApiKey || '', {
|
||||
runAtEpoch,
|
||||
method: 'POST',
|
||||
url: relUrl,
|
||||
body,
|
||||
headers: {
|
||||
'Content-Type': 'text/plain',
|
||||
'X-Email': backup,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export interface ScheduleResult { jobId: string; scheduledRunAtUtc: number }
|
||||
|
||||
// Resolve an absolute callback URL for schedulers that execute webhooks server-side
|
||||
|
||||
Reference in New Issue
Block a user