gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitb37875ccb37875ccident mission 012 part 3: real-Chrome fixes (brand 44 px, identity form width), e2e walk, report, logmreb37875cc/lib/delivery-helpers.hl

2.5 KB

  1. // lib/delivery-helpers.hl — what lib/delivery.hl looks up: the local date, the clock (with the gates' test clock),
  2. // the two mails' subject and text. No table access. Statics only.
  3. import { now } from 'hl:time'
  4. import { env } from 'hl:proc'
  5. import { readFile, exists } from 'hl:fs'
  6. static NL = '
  7. '
  8. // where the mails' "open your inbox" link points (the container sets it; unset = no link)
  9. static publicUrl = env('IDENT_PUBLIC_URL') != null && env('IDENT_PUBLIC_URL') != '' ? env('IDENT_PUBLIC_URL') : null
  10. // THE CLOCK OF DELIVERY. IDENT_TEST_CLOCK (THE GATES ONLY, never set in the container) names a file holding an
  11. // epoch-ms instant: delivery then takes that as "now" — the gate moves it to Vienna's, New York's, Tokyo's 17:00, a
  12. // DST day. No file / no number in it = the real clock. Only delivery reads it; everything else keeps now().
  13. static clockFile = env('IDENT_TEST_CLOCK') != null && env('IDENT_TEST_CLOCK') != '' ? env('IDENT_TEST_CLOCK') : null
  14. static clockNow = () => {
  15. if (clockFile == null || !exists(clockFile)) { return now() }
  16. n = toNumber(('' + readFile(clockFile)).trim())
  17. return n == null ? now() : n
  18. }
  19. // a `local()` reading → 'YYYY-MM-DD'
  20. static pad2 = (n) => { return n < 10 ? '0' + n : '' + n }
  21. static dateOf = (l) => { return l.year + '-' + pad2(l.month) + '-' + pad2(l.day) }
  22. static plural = (n, one, many) => { return n == 1 ? '1 ' + one : n + ' ' + many }
  23. static indented = (text) => { return ' ' + text.replaceAll(NL, NL + ' ') }
  24. static entry = (r) => {
  25. head = '* ' + r.name + ' — ' + r.app + ' · ' + r.identity + (r.urgent ? ' (urgent)' : '')
  26. return head + NL + indented(r.text) + NL + (r.link != '' ? ' ' + r.link + NL : '')
  27. }
  28. static footer = () => {
  29. inbox = publicUrl != null ? 'Your inbox: ' + publicUrl + '/inbox' + NL : ''
  30. return '--' + NL + inbox + 'Which notifications are mailed is up to you: open an app in your ident inbox and switch them.' + NL
  31. }
  32. // THE DAILY MAIL: `rows` = lib/notify.hl pendingDaily, `date` = the user's local date
  33. static digestSubject = (rows, date) => { return 'ident: ' + plural(rows.length, 'notification', 'notifications') + ' (' + date + ')' }
  34. static digestText = (rows, date, zone) => {
  35. let t = 'Hi,' + NL + NL + 'your notifications for ' + date + ' (17:00, ' + zone + '):' + NL + NL
  36. for (r of rows) { t = t + entry(r) + NL }
  37. return t + footer()
  38. }
  39. // AN URGENT ONE, at once: `r` = one row as in the daily mail
  40. static urgentSubject = (r) => { return r.app + ': ' + r.name }
  41. static urgentText = (r) => { return 'Hi,' + NL + NL + 'an urgent notification:' + NL + NL + entry(r) + NL + footer() }

Branches

Latest commits

  • 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
  • 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