ident
All repositories: gitoria
2.5 KB
// lib/delivery-helpers.hl — what lib/delivery.hl looks up: the local date, the clock (with the gates' test clock),// the two mails' subject and text. No table access. Statics only.import { now } from 'hl:time'import { env } from 'hl:proc'import { readFile, exists } from 'hl:fs'static NL = ''// where the mails' "open your inbox" link points (the container sets it; unset = no link)static publicUrl = env('IDENT_PUBLIC_URL') != null && env('IDENT_PUBLIC_URL') != '' ? env('IDENT_PUBLIC_URL') : null// THE CLOCK OF DELIVERY. IDENT_TEST_CLOCK (THE GATES ONLY, never set in the container) names a file holding an// epoch-ms instant: delivery then takes that as "now" — the gate moves it to Vienna's, New York's, Tokyo's 17:00, a// DST day. No file / no number in it = the real clock. Only delivery reads it; everything else keeps now().static clockFile = env('IDENT_TEST_CLOCK') != null && env('IDENT_TEST_CLOCK') != '' ? env('IDENT_TEST_CLOCK') : nullstatic clockNow = () => {if (clockFile == null || !exists(clockFile)) { return now() }n = toNumber(('' + readFile(clockFile)).trim())return n == null ? now() : n}// a `local()` reading → 'YYYY-MM-DD'static pad2 = (n) => { return n < 10 ? '0' + n : '' + n }static dateOf = (l) => { return l.year + '-' + pad2(l.month) + '-' + pad2(l.day) }static plural = (n, one, many) => { return n == 1 ? '1 ' + one : n + ' ' + many }static indented = (text) => { return ' ' + text.replaceAll(NL, NL + ' ') }static entry = (r) => {head = '* ' + r.name + ' — ' + r.app + ' · ' + r.identity + (r.urgent ? ' (urgent)' : '')return head + NL + indented(r.text) + NL + (r.link != '' ? ' ' + r.link + NL : '')}static footer = () => {inbox = publicUrl != null ? 'Your inbox: ' + publicUrl + '/inbox' + NL : ''return '--' + NL + inbox + 'Which notifications are mailed is up to you: open an app in your ident inbox and switch them.' + NL}// THE DAILY MAIL: `rows` = lib/notify.hl pendingDaily, `date` = the user's local datestatic digestSubject = (rows, date) => { return 'ident: ' + plural(rows.length, 'notification', 'notifications') + ' (' + date + ')' }static digestText = (rows, date, zone) => {let t = 'Hi,' + NL + NL + 'your notifications for ' + date + ' (17:00, ' + zone + '):' + NL + NLfor (r of rows) { t = t + entry(r) + NL }return t + footer()}// AN URGENT ONE, at once: `r` = one row as in the daily mailstatic urgentSubject = (r) => { return r.app + ': ' + r.name }static urgentText = (r) => { return 'Hi,' + NL + NL + 'an urgent notification:' + NL + NL + entry(r) + NL + footer() }
Branches
Latest commits
- eff734f3ident mission 013: in-place sign-out also closes the code step (no leftover code form); checksmre
- b7a61546ident mission 013: e2e — in-place main-menu mark kept as a known gapmre
- 59b43d81ident mission 013: sign out everywhere keeps this browser's own (signed-out) session so the page goes on in placemre
- 716e14ffident mission 013: browser gate — Bob signs out everywhere (no second code request)mre
- 5885f1c9ident mission 013 step 2: stopgap reload removed (in-place sign-in/out reach the shell via emit, notices back, route-marked main menu), gates updatedmre
- 734ac0a9ident mission 013 step 1: re-vendor Hybriel ce6f2e0a (plugins whole; bin/ is git-ignored)mre
- b37875ccident mission 012 part 3: real-Chrome fixes (brand 44 px, identity form width), e2e walk, report, logmre
- f989c2ebident mission 012: stopgap reload after in-place sign-in/sign-out (until hybriel#193), gates wait for cold start, welcome end reloadsmre
- 443291d4ident mission 012: /start on its own shell (no account), browser gate 152/0, reportmre
- 021dd0fcident mission 012: browser gate waits cold start (IDENT_COLD_MS), header selectors, e2e checks; shell events from a page do not reach it (probe), current not marked, account-bar link 44 pxmre
- 97f77b07ident mission 012 (WIP): onto the layouts theme dbe3de7, shell on AppHeader/MainMenu/UserMenu/Sidebar + ContentFirst, styles cut, check-theme gatemre
- 8e4f435bpaths: projects moved into /media/STORAGE/projects/WorldAPI/mre
- fa288f63ident mission 011: report wording (Intl zone names)mre
- 961fae01ident mission 011: report, LOG, STATUSmre
- 65348039ident#7: delivery gate — console check split at the gate's own server restart (49 checks)mre
- dfa7b783ident#7: README (Delivery, env, gate, files, data), deploy.sh runs tests/delivery.mjsmre
- ab6331f4ident#7: tests/delivery.mjs — fake clock gate: Vienna/New York/Tokyo/UTC 17:00, urgent, mail off, restart, DST days, zone changemre
- 7869f57bident#7: delivery — the daily mail at 17:00 in the user's zone (digests table, once per local day, test clock IDENT_TEST_CLOCK), urgent mailed at once, push hookmre
- 371ef1b5ident#7: lib/mail.hl sendNotificationMail (sink: <sink>.mail, one JSON line per mail)mre
- 39749e0bident#7: time zones through hl:time — server checks isZone, an account without a known zone reads as UTC, allAccountsmre