import type { Notification } from './types'; // The visible text, composed HERE from the category — never sent by a producer and never carrying // content. This is what stops "Re: your invoice from Acme" reaching Apple or Google. // // It has to exist somewhere: APNs and FCM both need a title/body to render a banner, so "send nothing" // is not an option. What we control is that the string is generic and derived from `type` alone, so the // most either service learns is the category and the timing. The app can render its own copy from the // same data payload if it wants better wording; this is the fallback that goes over the wire. export function renderTitle(n: Notification): string { switch (n.type) { case 'job': return n.ok === false ? 'Job failed' : 'Job finished'; case 'mail': return n.count && n.count > 1 ? `${n.count} new emails` : 'New email'; case 'agent': return 'Agent finished'; case 'download': return 'Download complete'; case 'test': return 'Officer'; } } /** * Deliberately empty for most categories. A banner with a title and no body is the least we can send * while still being a usable notification, and every word added is a word Apple and Google get to read. */ export function renderBody(n: Notification): string { return n.type === 'test' ? 'Test notification' : ''; }