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
- 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
- 7a54fe72mission brief 011mre
- a6a874cdident mission 010: vendor hybriel 0f396652 (plugins + compose cache volume/tmpfs + deploy URL wait + report)mre
- 4e7cf78emission brief 010mre
- e8b2b0f7docker-compose: init: true (hybriel#156, PID 1 ignored SIGTERM, every restart waited 10 s)mre
- 5fdbb6b2ident mission 009: report — scratch folder notemre
- 74235815ident mission 009 (4/4): docs (README files map + same-output test, STATUS, LOG), report, tests/letcount.py + realdata-baseline/comparemre
- fe183516ident mission 009 (3/4): let only where reassigned — 293 never-reassigned lets are plain declarations; kept: reassigned, loop bodies, names of a file member, a name declared twice in one function; same outputmre
- d2e7f91bident mission 009 (2/4): one lib file per topic (login, accounts, identities, apps, invites, selector, notify + helpers, util), function routes as thin wrappers in lib/api.hl, project.hl = the map; same outputmre
- 91017164ident mission 009 (1/4): file moves — the root .hl files into lib/ (api.hl → lib/api-helpers.hl), styles.hl → components/styles.hl; imports adjusted, no other changemre
- f8bdcbc2ident: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); all gates greenmre