gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitbf1980f2bf1980f2Merge branch 'v56-day56' into mainIdentbf1980f2/lib/delivery-helpers.hl

2.4 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 { envString } from './util.hl'
  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 = envString('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 = envString('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

  • bf1980f2Merge branch 'v56-day56' into mainIdent
  • 62ae0adf|||PR ident: vendor Hybriel day56mre
  • 0d18abc4Merge branch 'f13-avatar' into mainIdent
  • 2a99730a|||PR ident#37 avatar in hlmre
  • fa4ed25bMerge branch 'f11-upsert' into mainIdent
  • 8f3d9bc9|||PR ident#42 keyed upsert and removemre
  • 675493b1ident#42: editing an identity upserts the one edited row (face editIdentity answers { identity, row }); a create or delete keeps the whole list because the rows' position-dependent parts (default, Delete, Identity n) changemre
  • 45e55303ident#42: an app write patches one row: upsert on create, edit and new secret, one-argument remove on delete; the faces answer the changed app (or the deleted id), not the whole listmre
  • 991641d4Merge branch 'f10-access' into mainIdent
  • e56d8273|||PR ident#34 part 4: access and inbox fixed classesmre
  • df7696dbident#34: tests: access ticks selector quoting fixmre
  • 7215903eident#34: access: the unstyled classes all, app, tick, apptick, plus are dropped; the gate finds the app ticks by input[name=app]mre
  • 69b0a0ceident#34: access: the pick buttons use Style.pickCard instead of class pickmre
  • dc702419Merge branch 'f9-choose' into mainIdent
  • 8caec771|||PR ident#34 restore .choose hookmre
  • 0dbff960Merge branch 'f8-shared' into mainIdent
  • d69665f6|||PR ident#34 part 3: shared look classes (wide, avatar, chip/used, conn, choose, who, inboxlink) moved to statics or droppedmre
  • 3a64dc48ident#34: chipLook: radius as the same var() string (a bare token name in a static does not compile); selector gate selectormre
  • eb039073ident#34: tests: signin and migration find the choice without the classmre
  • 4b94a594ident#34: tests: fix selector of the identity choicemre