gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit1e1dd7b41e1dd7b4ident#34: the access page keeps its lead class string (the page has no ident-card, so its lead line was never muted; a shared rule would change the look)mre1e1dd7b4/plugins/smtp/Mailer.hl

3.4 KB

  1. \* hl:smtp — the SMTP submission client.
  2. import { Mailer } from 'hl:smtp'
  3. m = new Mailer('mail.example.com', 587, {
  4. user = '[email protected]'
  5. pass = '…'
  6. from = '[email protected]'
  7. })
  8. m.send({ to = '[email protected]' subject = 'Hello' text = 'Hi' })
  9. Non-blocking: send() answers a job id, the OUTCOME arrives later — drain
  10. it with `for (r of m.results())`, or deliver() it as the declared events
  11. below while the program keeps running. *\
  12. /* The first three declared properties ARE the positional signature (SPEC.md
  13. "The file root is the constructor"), so `new Mailer(host, port, options)`
  14. reads as written. */
  15. \* One send was ACCEPTED by the server. r = { id, ok, code, stage, message,
  16. secure, to }. *\
  17. emit sent(
  18. Hybrid r \\ the result record for one message
  19. )
  20. \* One send FAILED — refused, TLS problem, timeout. Same record shape;
  21. `stage` names where it died. *\
  22. emit failed(
  23. Hybrid r \\ the result record for one message
  24. )
  25. String host = "127.0.0.1" \\ the submission server
  26. Number port = 587 \\ 587 STARTTLS, 465 implicit TLS
  27. Hybrid options = null \\ { user, pass, from, … } — credentials and defaults
  28. \* The plugin's handle for this mailer — set by the run body; a send() before
  29. construction finished is impossible, the root IS the constructor. *\
  30. Number handle = 0
  31. \* SEND — non-blocking. Validated and rendered HERE, on this thread, so a
  32. refusal (a line break in to/subject, a missing recipient, an address
  33. without an @) is a located error at YOUR line, through `on Error` like any
  34. plugin failure. Answers the job id; the outcome arrives on the result
  35. source. msg: { to (String or list), subject, text, html, from }. *\
  36. send(
  37. Hybrid msg \\ the message — to/subject/text/html/from
  38. ) {
  39. return __native("smtp.send", handle, msg)
  40. }
  41. \* THE RESULT SOURCE, drained: `for (r of m.results())` yields one result per
  42. accepted send and ENDS when every send is answered — which is what lets a
  43. script that only sends mail terminate. *\
  44. results() {
  45. return __native("smtp.results", handle)
  46. }
  47. \* THE RESULT SOURCE, delivered: results arrive as the declared sent/failed
  48. events while the program goes on — a server keeps serving with mail in
  49. flight. Use this OR results(), never both: they take from one queue. *\
  50. deliver() {
  51. __native("smtp.mark_registered", handle)
  52. __native("eventloop.register", __native("smtp.results", handle), "mail")
  53. }
  54. \* How many sends have not been answered yet. *\
  55. pending() {
  56. return __native("smtp.pending", handle)
  57. }
  58. \* Stop the sender thread. A job already in conversation finishes. *\
  59. close() {
  60. __native("smtp.close", handle)
  61. handle = 0
  62. }
  63. // The split every caller of deliver() wants: one event per outcome. `mail`
  64. // is delivered at THIS instance by the loop, and the re-emit dispatches at
  65. // it too, so an instance-scoped `on m.sent(r)` in the constructing program
  66. // hears it.
  67. on mail(r) {
  68. if (r.ok == true) {
  69. emit sent(r)
  70. } else {
  71. emit failed(r)
  72. }
  73. }
  74. // Open the mailer and start its sender thread. A METHOD, called from the run
  75. // body — never a root assignment: a bare `handle = …` at the root would be a
  76. // property INITIALIZER, and initializers run BEFORE positional args bind
  77. // (construction order 1 vs 4) — it would open a mailer for the DEFAULT host.
  78. // Same shape as hl:http1's listen().
  79. open() {
  80. handle = __native("smtp.open", host, port, options)
  81. }
  82. // Run body — the constructor's last act.
  83. open()

Branches

Latest commits

  • 1e1dd7b4ident#34: the access page keeps its lead class string (the page has no ident-card, so its lead line was never muted; a shared rule would change the look)mre
  • 89ac6553ident#34: the lead, message and notice lines are named with Style.pLead / pMessage / pNotice (shared bodies in lib/looks.hl) instead of class stringsmre
  • e84be3deident#34: browser gate lists the Edit/Delete buttons by namemre
  • fb7111faident#34: access page: unstyled test-hook classes (idrow, never, who, whoname, appname, neverrevoke) dropped; the tests use element/name selectorsmre
  • 9f2ad803ident#34: notification switches: push/email by name=..., locked by aria-disabled, the switch look is the role=switch button (no switch/push/email/locked classes)mre
  • e0f0ddaaident#34: inbox: the Mark read/unread button is styled as the button of its note-foot, the icon is found as the row's img (no toggle/icon classes)mre
  • 16b49756ident#34: unused row classes (choice, usedrow, kind, shortid) droppedmre
  • f9d6fb38ident#34: apps and identity rows: the Edit/New secret/Delete buttons carry name=..., the API key is found by its element; unused row classes (app, identity, shortid) droppedmre
  • b323265aMerge branch 'f5-styles' into mainIdent
  • 9ced53c3|||PR ident#33 ident#35 every component's styles live in its own Style block; styles.hl keeps the page-wide rest; the account bar is phone first (min-width: 60rem block); the avatar preview is hidden with the hidden attribute (ident#34 in part)mre
  • f28333e4ident#33 ident#35: styles.hl keeps only the accent, the page column and the shared patterns; the account bar is written phone first (base rule + one min-width: 60rem block) instead of a max-width overridemre
  • 5b4541fcident#33: the selector sign-in frame's rules move into embed.hl's Stylemre
  • 00235f21ident#33: the per-app notification switches move into appsettings.hl's Stylemre
  • 2249945cident#33: the inbox and connection list rules move into inbox.hl's Stylemre
  • f2d9f79fident#33: the apps list and the secret box move into apps.hl's Stylemre
  • 8370b748ident#33: the app request box moves into home.hl's Stylemre
  • 40bf3b97ident#33: the 404 page's home link rule moves into notfound.hlmre
  • 40627a89ident#33: the time zone section's spacing moves into timezone.hlmre
  • d389db08ident#33: the identity page's rules and the Notif. chip move into identity.hl's Stylemre
  • ddda0b5bident#33: the identity row's parts move into identitylist.hl's Stylemre