@snagset/server 0.1.65 → 0.1.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mail/account.js +65 -0
- package/dist/mail/account.js.map +1 -0
- package/dist/mail/assigned.js +44 -7
- package/dist/mail/assigned.js.map +1 -1
- package/dist/mail/digest.js +37 -5
- package/dist/mail/digest.js.map +1 -1
- package/dist/mail/html.js +147 -0
- package/dist/mail/html.js.map +1 -0
- package/dist/mail/notify.js +39 -13
- package/dist/mail/notify.js.map +1 -1
- package/dist/mail/unsubscribe.js +5 -1
- package/dist/mail/unsubscribe.js.map +1 -1
- package/dist/routes/instance.js +3 -6
- package/dist/routes/instance.js.map +1 -1
- package/dist/routes/invites.js +3 -6
- package/dist/routes/invites.js.map +1 -1
- package/dist/routes/passwordReset.js +2 -17
- package/dist/routes/passwordReset.js.map +1 -1
- package/package.json +1 -1
- package/static/widget/build.json +2 -2
- package/static/widget/snag.js +1 -1
- package/static/widget/snag.runtime.js +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { withArticle } from "../vendor/types/roles.js";
|
|
2
|
+
import { button, esc, footer, h1, hostOf, layout, p, small, url } from "./html.js";
|
|
3
|
+
const pasteable = (address) => small(`Or paste this address into your browser:<br>${url(address)}`, "20px 0 0");
|
|
4
|
+
/** "<who> invited you to <studio>": the first mail a new teammate gets. */
|
|
5
|
+
export function inviteMail(o) {
|
|
6
|
+
const { who, studio, link } = o;
|
|
7
|
+
const day = o.expires.toISOString().slice(0, 10);
|
|
8
|
+
const subject = `${who} invited you to ${studio}`;
|
|
9
|
+
return {
|
|
10
|
+
subject,
|
|
11
|
+
text: `${who} has invited you to join ${studio} as ${withArticle(o.role)}.\n\n` +
|
|
12
|
+
`Open this link to join:\n${link}\n\n` +
|
|
13
|
+
`It works once and expires on ${day}. ` +
|
|
14
|
+
`If you were not expecting it, you can ignore this email.\n`,
|
|
15
|
+
html: layout({
|
|
16
|
+
subject,
|
|
17
|
+
preheader: `${who} has invited you to join ${studio} as ${withArticle(o.role)}.`,
|
|
18
|
+
body: h1(`Join ${esc(studio)}`) +
|
|
19
|
+
p(`${esc(who)} has invited you to join <strong>${esc(studio)}</strong> as ${esc(withArticle(o.role))}.`) +
|
|
20
|
+
button("Join the studio", link) +
|
|
21
|
+
small(`It works once and expires on ${esc(day)}. If you were not expecting it, you can ignore this email.`, "20px 0 0") +
|
|
22
|
+
pasteable(link),
|
|
23
|
+
footer: footer({ why: "You get this because someone invited this address to a studio.", base: o.base }),
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** "Reset your Snagset password" — self-hosted only; Cloud is passwordless. */
|
|
28
|
+
export function resetMail(o) {
|
|
29
|
+
const { email, link, base } = o;
|
|
30
|
+
const subject = "Reset your Snagset password";
|
|
31
|
+
return {
|
|
32
|
+
subject,
|
|
33
|
+
text: `Somebody asked to reset the password for ${email} on ${hostOf(base)}.\n\n` +
|
|
34
|
+
`Open this link to choose a new one:\n${link}\n\n` +
|
|
35
|
+
`It works once and expires in an hour. ` +
|
|
36
|
+
`If that was not you, ignore this email: nothing changes unless the link is used.\n`,
|
|
37
|
+
html: layout({
|
|
38
|
+
subject,
|
|
39
|
+
preheader: "Open the link to choose a new password. It works once and expires in an hour.",
|
|
40
|
+
body: h1("Reset your password") +
|
|
41
|
+
p(`Somebody asked to reset the password for <strong>${esc(email)}</strong> on ${esc(hostOf(base))}.`) +
|
|
42
|
+
button("Choose a new password", link) +
|
|
43
|
+
small("It works once and expires in an hour. If that was not you, ignore this email: nothing changes unless the link is used.", "20px 0 0") +
|
|
44
|
+
pasteable(link),
|
|
45
|
+
footer: footer({ why: "You get this because someone asked to reset the password for this address.", base }),
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** "Snagset can send mail": the operator's test, from Studio › General. No link, so no button. */
|
|
50
|
+
export function testMail(o) {
|
|
51
|
+
const subject = "Snagset can send mail";
|
|
52
|
+
const said = "This is the test message from Studio › General. If you are reading it, notifications " +
|
|
53
|
+
"from this instance will arrive the same way.";
|
|
54
|
+
return {
|
|
55
|
+
subject,
|
|
56
|
+
text: `${said}\n`,
|
|
57
|
+
html: layout({
|
|
58
|
+
subject,
|
|
59
|
+
preheader: said,
|
|
60
|
+
body: h1("Snagset can send mail") + p(esc(said), "0"),
|
|
61
|
+
footer: footer({ why: "You get this because you sent a test message from Studio › General.", base: o.base }),
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/mail/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAqBnF,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,KAAK,CAAC,+CAA+C,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;AAExH,2EAA2E;AAC3E,MAAM,UAAU,UAAU,CAAC,CAA2F;IACpH,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,GAAG,GAAG,mBAAmB,MAAM,EAAE,CAAC;IAClD,OAAO;QACL,OAAO;QACP,IAAI,EACF,GAAG,GAAG,4BAA4B,MAAM,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;YACzE,4BAA4B,IAAI,MAAM;YACtC,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G,MAAM,CAAC,uBAAuB,EAAE,IAAI,CAAC;gBACrC,KAAK,CAAC,wHAAwH,EAAE,UAAU,CAAC;gBAC3I,SAAS,CAAC,IAAI,CAAC;YACjB,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,4EAA4E,EAAE,IAAI,EAAE,CAAC;SAC5G,CAAC;KACH,CAAC;AACJ,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,QAAQ,CAAC,CAA0B;IACjD,MAAM,OAAO,GAAG,uBAAuB,CAAC;IACxC,MAAM,IAAI,GACR,uFAAuF;QACvF,8CAA8C,CAAC;IACjD,OAAO;QACL,OAAO;QACP,IAAI,EAAE,GAAG,IAAI,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC;YACX,OAAO;YACP,SAAS,EAAE,IAAI;YACf,IAAI,EAAE,EAAE,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC;YACrD,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,qEAAqE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;SAC7G,CAAC;KACH,CAAC;AACJ,CAAC"}
|
package/dist/mail/assigned.js
CHANGED
|
@@ -2,7 +2,8 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { sanitise, sanitiseWithRedactor } from "../vendor/adapters/index.js";
|
|
3
3
|
import { redactText } from "../vendor/widget/predicates.js";
|
|
4
4
|
import { noteQueued } from "../jobs/soon.js";
|
|
5
|
-
import { threadUrl } from "./links.js";
|
|
5
|
+
import { dashboardUrl, threadUrl } from "./links.js";
|
|
6
|
+
import { button, esc, footer, h1, h2, items as list, layout, p, quote, small } from "./html.js";
|
|
6
7
|
/**
|
|
7
8
|
* "This snag is yours now", and deliberately NOT sent at the click.
|
|
8
9
|
*
|
|
@@ -286,11 +287,16 @@ export async function liveAssignments(sql, rows) {
|
|
|
286
287
|
return { live, dropped };
|
|
287
288
|
}
|
|
288
289
|
/**
|
|
289
|
-
* The mail.
|
|
290
|
-
*
|
|
291
|
-
*
|
|
290
|
+
* The mail. One snag reads as a sentence; several read as a list, grouped by
|
|
291
|
+
* site, each with its key, the first line of what was said, and the link that
|
|
292
|
+
* opens it. The plain text is the message; the HTML beside it says the same
|
|
293
|
+
* in the house layout (`html.ts`), every string escaped there. One snag's
|
|
294
|
+
* button opens it; a list's opens the dashboard, its entries each linked.
|
|
295
|
+
* `stop` is the opt-out page the `List-Unsubscribe` header names, for the
|
|
296
|
+
* footer; null when the mail carries no header.
|
|
292
297
|
*/
|
|
293
|
-
export function renderAssigned(items, to, baseUrl) {
|
|
298
|
+
export function renderAssigned(items, to, baseUrl, stop = null) {
|
|
299
|
+
const foot = footer({ why: "You get this because a snag was assigned to you.", stop, base: baseUrl });
|
|
294
300
|
const plain = (s, max) => sanitise(s, "plain", { singleLine: true, max });
|
|
295
301
|
const sites = [...new Set(items.map((i) => i.siteUid))];
|
|
296
302
|
const siteName = plain(items[0].site, NAME_MAX);
|
|
@@ -298,9 +304,13 @@ export function renderAssigned(items, to, baseUrl) {
|
|
|
298
304
|
if (n === 1) {
|
|
299
305
|
const it = items[0];
|
|
300
306
|
const key = plain(it.threadKey, 24);
|
|
307
|
+
const actor = plain(it.actorName, NAME_MAX);
|
|
308
|
+
const excerpt = it.excerpt ? plain(it.excerpt, EXCERPT_MAX + 1) : "";
|
|
309
|
+
const open = threadUrl(baseUrl, it.siteUid, it.threadKey, it.round);
|
|
310
|
+
const subject = `${key} was assigned to you on ${siteName}`;
|
|
301
311
|
return {
|
|
302
312
|
to,
|
|
303
|
-
subject
|
|
313
|
+
subject,
|
|
304
314
|
text: [
|
|
305
315
|
`${plain(it.actorName, NAME_MAX)} assigned ${key} to you on ${siteName}.`,
|
|
306
316
|
"",
|
|
@@ -310,19 +320,46 @@ export function renderAssigned(items, to, baseUrl) {
|
|
|
310
320
|
"— Snagset",
|
|
311
321
|
"Sent an hour after the assignment, unless it moved on or you had already answered it.",
|
|
312
322
|
].join("\n"),
|
|
323
|
+
html: layout({
|
|
324
|
+
subject,
|
|
325
|
+
preheader: `${actor} assigned ${key} to you on ${siteName}.`,
|
|
326
|
+
body: h1(`${esc(key)} was assigned to you`) +
|
|
327
|
+
p(`${esc(actor)} assigned ${esc(key)} to you on <strong>${esc(siteName)}</strong>.`) +
|
|
328
|
+
(excerpt ? quote(`“${excerpt}”`) : "") +
|
|
329
|
+
button("Open it", open) +
|
|
330
|
+
small("Sent an hour after the assignment, unless it moved on or you had already answered it.", "20px 0 0"),
|
|
331
|
+
footer: foot,
|
|
332
|
+
}),
|
|
313
333
|
};
|
|
314
334
|
}
|
|
315
335
|
const subject = sites.length === 1 ? `${n} snags assigned to you on ${siteName}` : `${n} snags assigned to you across ${sites.length} sites`;
|
|
316
336
|
const lines = [`${n} snags were assigned to you.`, ""];
|
|
337
|
+
let body = h1(`${n} snags were assigned to you`);
|
|
317
338
|
for (const uid of sites) {
|
|
318
339
|
const mine = items.filter((i) => i.siteUid === uid);
|
|
319
340
|
lines.push(`${plain(mine[0].site, NAME_MAX)} (${mine.length})`);
|
|
341
|
+
body +=
|
|
342
|
+
h2(`${esc(plain(mine[0].site, NAME_MAX))} (${mine.length})`) +
|
|
343
|
+
list(mine.map((it) => ({
|
|
344
|
+
title: plain(it.threadKey, 24),
|
|
345
|
+
href: threadUrl(baseUrl, it.siteUid, it.threadKey, it.round),
|
|
346
|
+
meta: `from ${plain(it.actorName, NAME_MAX)}`,
|
|
347
|
+
...(it.excerpt ? { excerpt: plain(it.excerpt, EXCERPT_MAX + 1) } : {}),
|
|
348
|
+
})));
|
|
320
349
|
for (const it of mine) {
|
|
321
350
|
lines.push(` ${plain(it.threadKey, 24)} · from ${plain(it.actorName, NAME_MAX)}${it.excerpt ? `: ${plain(it.excerpt, EXCERPT_MAX + 1)}` : ""}`, ` ${threadUrl(baseUrl, it.siteUid, it.threadKey, it.round)}`);
|
|
322
351
|
}
|
|
323
352
|
lines.push("");
|
|
324
353
|
}
|
|
325
354
|
lines.push("— Snagset", "Assignments are gathered for an hour and sent together, leaving out any that moved on or that you had already answered.");
|
|
326
|
-
|
|
355
|
+
body +=
|
|
356
|
+
button("Open the dashboard", dashboardUrl(baseUrl)) +
|
|
357
|
+
small("Assignments are gathered for an hour and sent together, leaving out any that moved on or that you had already answered.", "20px 0 0");
|
|
358
|
+
return {
|
|
359
|
+
to,
|
|
360
|
+
subject,
|
|
361
|
+
text: lines.join("\n"),
|
|
362
|
+
html: layout({ subject, preheader: `${n} snags were assigned to you.`, body, footer: foot }),
|
|
363
|
+
};
|
|
327
364
|
}
|
|
328
365
|
//# sourceMappingURL=assigned.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assigned.js","sourceRoot":"","sources":["../../src/mail/assigned.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"assigned.js","sourceRoot":"","sources":["../../src/mail/assigned.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,IAA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AC;QACJ,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,IAAI,CACR,WAAW,EACX,yHAAyH,CAC1H,CAAC;IACF,IAAI;QACF,MAAM,CAAC,oBAAoB,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;YACnD,KAAK,CAAC,yHAAyH,EAAE,UAAU,CAAC,CAAC;IAC/I,OAAO;QACL,EAAE;QACF,OAAO;QACP,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,8BAA8B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;KAC7F,CAAC;AACJ,CAAC"}
|
package/dist/mail/digest.js
CHANGED
|
@@ -3,6 +3,7 @@ import { sanitise, sanitiseWithRedactor } from "../vendor/adapters/index.js";
|
|
|
3
3
|
import { redactText } from "../vendor/widget/predicates.js";
|
|
4
4
|
import { isConfigured } from "./mailer.js";
|
|
5
5
|
import { dashboardUrl, threadUrl } from "./links.js";
|
|
6
|
+
import { button, esc, footer, h1, h2, items as list, layout, p, small } from "./html.js";
|
|
6
7
|
/**
|
|
7
8
|
* The daily digest, on the maintainer's "we don't need to send the email every
|
|
8
9
|
* time there is a comment, maybe once in a while".
|
|
@@ -257,8 +258,8 @@ export async function pruneDigest(sql, orgId, event) {
|
|
|
257
258
|
return { ...event, sites, total: sites.reduce((n, s) => n + s.count, 0) };
|
|
258
259
|
}
|
|
259
260
|
/**
|
|
260
|
-
* The digest mail
|
|
261
|
-
*
|
|
261
|
+
* The digest mail: the plain text, and beside it the same list in the house
|
|
262
|
+
* layout (`html.ts`), each entry linked to its thread.
|
|
262
263
|
*
|
|
263
264
|
* Every stored string is sanitised again on the way out, as the per-comment
|
|
264
265
|
* mail does. The excerpt was already redacted at fold time; sanitising it a
|
|
@@ -273,9 +274,21 @@ export function renderDigest(event, to, baseUrl) {
|
|
|
273
274
|
? `${comments} on ${plain(sites[0].name, NAME_MAX)}`
|
|
274
275
|
: `${comments} across ${sites.length} sites`;
|
|
275
276
|
const lines = [`${comments} since the last digest.`, ""];
|
|
277
|
+
// The HTML beside the text (the house layout, `html.ts`): the same list as
|
|
278
|
+
// ruled entries, each linked to its thread, every string escaped there.
|
|
279
|
+
let body = h1(esc(comments)) + p("Since the last digest.", "0 0 4px");
|
|
276
280
|
let listed = 0;
|
|
277
281
|
for (const site of sites) {
|
|
278
282
|
lines.push(`${plain(site.name, NAME_MAX)} (${site.count})`);
|
|
283
|
+
body +=
|
|
284
|
+
h2(`${esc(plain(site.name, NAME_MAX))} (${site.count})`) +
|
|
285
|
+
list(site.items.map((item) => ({
|
|
286
|
+
title: plain(item.threadKey, 24),
|
|
287
|
+
href: threadUrl(baseUrl, site.uid, item.threadKey, item.round),
|
|
288
|
+
meta: plain(item.author, NAME_MAX),
|
|
289
|
+
excerpt: plain(item.excerpt, EXCERPT_MAX + 1),
|
|
290
|
+
...(item.page ? { page: plain(item.page, PAGE_MAX) } : {}),
|
|
291
|
+
})));
|
|
279
292
|
for (const item of site.items) {
|
|
280
293
|
listed++;
|
|
281
294
|
const key = plain(item.threadKey, 24);
|
|
@@ -283,9 +296,28 @@ export function renderDigest(event, to, baseUrl) {
|
|
|
283
296
|
}
|
|
284
297
|
lines.push("");
|
|
285
298
|
}
|
|
286
|
-
if (n > listed)
|
|
299
|
+
if (n > listed) {
|
|
287
300
|
lines.push(`…and ${n - listed} more not listed here.`, "");
|
|
288
|
-
|
|
289
|
-
|
|
301
|
+
body += p(`…and ${n - listed} more not listed here.`, "8px 0 16px");
|
|
302
|
+
}
|
|
303
|
+
body +=
|
|
304
|
+
button("Open the dashboard", dashboardUrl(baseUrl)) +
|
|
305
|
+
small("You get this at most once a day.", "20px 0 0");
|
|
306
|
+
lines.push(`Open the dashboard: ${dashboardUrl(baseUrl)}`, "", "— Snagset",
|
|
307
|
+
// No way to change it: the reader is the studio owner, and the only switch
|
|
308
|
+
// is SNAGSET_MAIL_NOTIFY, which is the operator's and the whole instance's.
|
|
309
|
+
// On Cloud and on a shared self-host nobody reading this can set it.
|
|
310
|
+
"You get this at most once a day.");
|
|
311
|
+
return {
|
|
312
|
+
to,
|
|
313
|
+
subject,
|
|
314
|
+
text: lines.join("\n"),
|
|
315
|
+
html: layout({
|
|
316
|
+
subject,
|
|
317
|
+
preheader: `${comments} since the last digest.`,
|
|
318
|
+
body,
|
|
319
|
+
footer: footer({ why: "You get this because you own this studio.", base: baseUrl }),
|
|
320
|
+
}),
|
|
321
|
+
};
|
|
290
322
|
}
|
|
291
323
|
//# sourceMappingURL=digest.js.map
|
package/dist/mail/digest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digest.js","sourceRoot":"","sources":["../../src/mail/digest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAqB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"digest.js","sourceRoot":"","sources":["../../src/mail/digest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAqB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,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;IACtE,CAAC;IACD,IAAI;QACF,MAAM,CAAC,oBAAoB,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;YACnD,KAAK,CAAC,kCAAkC,EAAE,UAAU,CAAC,CAAC;IACxD,KAAK,CAAC,IAAI,CACR,uBAAuB,YAAY,CAAC,OAAO,CAAC,EAAE,EAC9C,EAAE,EACF,WAAW;IACX,2EAA2E;IAC3E,4EAA4E;IAC5E,qEAAqE;IACrE,kCAAkC,CACnC,CAAC;IACF,OAAO;QACL,EAAE;QACF,OAAO;QACP,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC;YACX,OAAO;YACP,SAAS,EAAE,GAAG,QAAQ,yBAAyB;YAC/C,IAAI;YACJ,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,2CAA2C,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;SACpF,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The house layout for the engine's mails, in HTML: the mark and the wordmark
|
|
3
|
+
* centred over one white card on mist, the card's words left-aligned, one dark
|
|
4
|
+
* button, a short centred footer in small type.
|
|
5
|
+
*
|
|
6
|
+
* Ported from Snagset Cloud's `src/mailHtml.js` rather than imported, so the
|
|
7
|
+
* engine depends on nothing outside this repository and a Cloud user gets
|
|
8
|
+
* one family of mail from both: the cloud's own (the sign-in code, the
|
|
9
|
+
* onboarding) and the engine's (invites, comments, assignments, the digest).
|
|
10
|
+
* A change to one should be made to the other.
|
|
11
|
+
*
|
|
12
|
+
* No image, no remote font, no tracking pixel: the mark is two boxes (Outlook
|
|
13
|
+
* shows them square), the fonts are the reader's system's. Tables, because
|
|
14
|
+
* Gmail and Outlook lay out nothing else reliably. Dark mode is the mail
|
|
15
|
+
* program's: Apple Mail reads the `prefers-color-scheme` block, Gmail inverts
|
|
16
|
+
* light colours on its own. Every mail that uses this also goes with its
|
|
17
|
+
* plain text beside it (`Mail.text`), which stays the authority: the HTML
|
|
18
|
+
* says the same things and adds no sign-off.
|
|
19
|
+
*
|
|
20
|
+
* THE PARTS TAKE HTML. Anything a person typed — a name, a studio's or a
|
|
21
|
+
* site's name, a comment, an address — goes through `esc` before it reaches
|
|
22
|
+
* one; the parts that take an address or a code escape their own argument.
|
|
23
|
+
*/
|
|
24
|
+
/** Escape for HTML text and for a double-quoted attribute. */
|
|
25
|
+
export function esc(s) {
|
|
26
|
+
return s.replace(/[&<>"']/g, (ch) => ch === "&" ? "&" : ch === "<" ? "<" : ch === ">" ? ">" : ch === '"' ? """ : "'");
|
|
27
|
+
}
|
|
28
|
+
/** The colours: the Ruled direction's paper and inks, and the pencil for links (its night tint, #aabdff, in dark mode). */
|
|
29
|
+
export const C = {
|
|
30
|
+
bg: "#f4f6f5",
|
|
31
|
+
card: "#ffffff",
|
|
32
|
+
ink: "#241e1e",
|
|
33
|
+
ink2: "#3d3535",
|
|
34
|
+
soft: "#6b7570",
|
|
35
|
+
line: "#e6ebe8",
|
|
36
|
+
code: "#f4f6f5",
|
|
37
|
+
pencil: "#3d61d9",
|
|
38
|
+
};
|
|
39
|
+
export const FONT = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif";
|
|
40
|
+
const MONO = "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
|
|
41
|
+
/** Only http(s) addresses become links: a `javascript:` or `data:` href from a stored value is the one thing escaping does not stop. */
|
|
42
|
+
export function isWebUrl(s) {
|
|
43
|
+
return /^https?:\/\/[^\s"<>]+$/i.test(s);
|
|
44
|
+
}
|
|
45
|
+
/** An address for an `href`, escaped; anything that is not http(s) becomes `#`. */
|
|
46
|
+
const href = (url) => (isWebUrl(url) ? esc(url) : "#");
|
|
47
|
+
export const h1 = (html) => `<h1 class="ink" style="margin:0 0 12px;font:600 22px/1.25 ${FONT};letter-spacing:-0.02em;color:${C.ink};">${html}</h1>`;
|
|
48
|
+
export const p = (html, margin = "0 0 16px") => `<p class="ink2" style="margin:${margin};font:400 15px/1.55 ${FONT};color:${C.ink2};">${html}</p>`;
|
|
49
|
+
export const small = (html, margin = "16px 0 0") => `<p class="soft" style="margin:${margin};font:400 13px/1.5 ${FONT};color:${C.soft};">${html}</p>`;
|
|
50
|
+
/** A small heading over a group (a site in a list). */
|
|
51
|
+
export const h2 = (html, margin = "20px 0 4px") => `<p class="soft" style="margin:${margin};font:600 12px/1.4 ${FONT};letter-spacing:0.04em;text-transform:uppercase;color:${C.soft};">${html}</p>`;
|
|
52
|
+
/** Inline code. Escapes its argument. */
|
|
53
|
+
export const tt = (text) => `<code style="font:400 13px ${MONO};">${esc(text)}</code>`;
|
|
54
|
+
/**
|
|
55
|
+
* Words somebody wrote (a comment), in a ruled box, line breaks kept.
|
|
56
|
+
* Escapes its argument.
|
|
57
|
+
*/
|
|
58
|
+
export const quote = (text) => `<div class="codebox ink2" style="margin:0 0 16px;padding:12px 14px;background:${C.code};border:1px solid ${C.line};border-radius:10px;font:400 15px/1.55 ${FONT};color:${C.ink2};white-space:pre-wrap;word-wrap:break-word;overflow-wrap:anywhere;">${esc(text)}</div>`;
|
|
59
|
+
/** A link in the pencil, never broken across two lines (labels are a few words). Escapes the address; the label is HTML. */
|
|
60
|
+
export const link = (url, html) => `<a href="${href(url)}" class="pencil" style="color:${C.pencil};text-decoration:none;white-space:nowrap;">${html}</a>`;
|
|
61
|
+
/**
|
|
62
|
+
* An address shown whole as its own label, allowed to break anywhere so a
|
|
63
|
+
* long one never pushes the card wider than a phone. Not an http(s) address
|
|
64
|
+
* (or one clipped short, ending in "…"), it is shown and not linked.
|
|
65
|
+
*/
|
|
66
|
+
export const url = (address) => isWebUrl(address) && !address.endsWith("…")
|
|
67
|
+
? `<a href="${esc(address)}" class="pencil" style="color:${C.pencil};text-decoration:none;word-break:break-all;">${esc(address)}</a>`
|
|
68
|
+
: `<span style="word-break:break-all;">${esc(address)}</span>`;
|
|
69
|
+
/** The one button a mail has. Escapes the label and the address. */
|
|
70
|
+
export const button = (label, address) => `<table role="presentation" cellpadding="0" cellspacing="0" border="0" style="margin:8px 0 0;"><tr><td class="btn" style="border-radius:10px;background:${C.ink};"><a href="${href(address)}" style="display:inline-block;padding:12px 20px;font:600 15px/1 ${FONT};color:#ffffff;text-decoration:none;border-radius:10px;white-space:nowrap;">${esc(label)}</a></td></tr></table>`;
|
|
71
|
+
/** A ruled list of entries — the digest's comments, a batch of assignments. */
|
|
72
|
+
export const items = (list) => `<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin:0 0 8px;">${list
|
|
73
|
+
.map((it) => `<tr><td class="rule" style="padding:10px 0;border-top:1px solid ${C.line};">` +
|
|
74
|
+
`<p style="margin:0;font:400 14px/1.45 ${FONT};"><a href="${href(it.href)}" class="ink" style="color:${C.ink};font-weight:600;text-decoration:none;">${esc(it.title)}</a>` +
|
|
75
|
+
(it.meta ? `<span class="soft" style="color:${C.soft};"> · ${esc(it.meta)}</span>` : "") +
|
|
76
|
+
`</p>` +
|
|
77
|
+
(it.excerpt
|
|
78
|
+
? `<p class="ink2" style="margin:2px 0 0;font:400 14px/1.45 ${FONT};color:${C.ink2};overflow-wrap:anywhere;">${esc(it.excerpt)}</p>`
|
|
79
|
+
: "") +
|
|
80
|
+
(it.page ? `<p class="soft" style="margin:2px 0 0;font:400 12px/1.45 ${FONT};color:${C.soft};">${url(it.page)}</p>` : "") +
|
|
81
|
+
`</td></tr>`)
|
|
82
|
+
.join("")}</table>`;
|
|
83
|
+
/** A link in the footer's small grey. Escapes the address; the label is HTML. */
|
|
84
|
+
export const footLink = (address, html) => `<a href="${href(address)}" class="soft" style="color:${C.soft};">${html}</a>`;
|
|
85
|
+
/**
|
|
86
|
+
* The footer: why the mail came (text, escaped), a way to stop it when there
|
|
87
|
+
* is one, and the instance it came from. One item a line, as the cloud's.
|
|
88
|
+
*/
|
|
89
|
+
export function footer(o) {
|
|
90
|
+
const lines = [];
|
|
91
|
+
if (o.why)
|
|
92
|
+
lines.push(esc(o.why));
|
|
93
|
+
if (o.stop)
|
|
94
|
+
lines.push(footLink(o.stop, "Stop these emails"));
|
|
95
|
+
const host = o.base ? hostOf(o.base) : null;
|
|
96
|
+
lines.push(host && o.base ? `Snagset · ${footLink(o.base, esc(host))}` : "Snagset");
|
|
97
|
+
return lines.join("<br><br>");
|
|
98
|
+
}
|
|
99
|
+
/** The host of an address, for a footer or a sentence; the address itself if it does not parse. */
|
|
100
|
+
export function hostOf(base) {
|
|
101
|
+
try {
|
|
102
|
+
return new URL(base).host;
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return base;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The whole mail. `body` and `footer` are HTML; `subject` and `preheader`
|
|
110
|
+
* are text (escaped here).
|
|
111
|
+
*/
|
|
112
|
+
export function layout(m) {
|
|
113
|
+
return `<!doctype html>
|
|
114
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
115
|
+
<meta name="color-scheme" content="light dark"><meta name="supported-color-schemes" content="light dark">
|
|
116
|
+
<title>${esc(m.subject)}</title>
|
|
117
|
+
<style>
|
|
118
|
+
@media (prefers-color-scheme: dark) {
|
|
119
|
+
.bg { background:#121010 !important; } .card { background:#1a1616 !important; border-color:#312a2a !important; }
|
|
120
|
+
.ink, .ink a, a.ink { color:#f3f5f4 !important; } .ink2 { color:#d9dfdb !important; } .soft, .soft a, a.soft { color:#a4ada7 !important; } .rule { border-color:#312a2a !important; }
|
|
121
|
+
.mark { background:#f3f5f4 !important; } .btn { background:#f3f5f4 !important; } .btn a { color:#161212 !important; }
|
|
122
|
+
.codebox { background:#121010 !important; border-color:#312a2a !important; }
|
|
123
|
+
a.pencil, .soft a.pencil, .ink2 a.pencil { color:#aabdff !important; }
|
|
124
|
+
}
|
|
125
|
+
@media (max-width: 520px) { .pad { padding:28px 22px !important; } }
|
|
126
|
+
</style></head>
|
|
127
|
+
<body class="bg" style="margin:0;padding:0;background:${C.bg};">
|
|
128
|
+
<div style="display:none;max-height:0;overflow:hidden;opacity:0;">${esc(m.preheader)}</div>
|
|
129
|
+
<table role="presentation" class="bg" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:${C.bg};">
|
|
130
|
+
<tr><td align="center" style="padding:40px 16px;">
|
|
131
|
+
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="max-width:520px;">
|
|
132
|
+
<tr><td align="center" style="padding:0 4px 24px;text-align:center;">
|
|
133
|
+
<table role="presentation" align="center" cellpadding="0" cellspacing="0" border="0" style="margin:0 auto;"><tr>
|
|
134
|
+
<td style="vertical-align:middle;padding-right:8px;">
|
|
135
|
+
<div class="mark" style="width:15px;height:15px;background:${C.ink};border-radius:8px 8px 8px 0;font-size:0;line-height:0;"> </div>
|
|
136
|
+
<div class="mark" style="width:20px;height:2px;margin-top:3px;background:${C.ink};font-size:0;line-height:0;"> </div>
|
|
137
|
+
</td>
|
|
138
|
+
<td class="ink" style="vertical-align:middle;font:600 18px/1 ${FONT};letter-spacing:-0.02em;color:${C.ink};">Snagset</td>
|
|
139
|
+
</tr></table>
|
|
140
|
+
</td></tr>
|
|
141
|
+
<tr><td class="card pad" style="background:${C.card};border:1px solid ${C.line};border-radius:14px;padding:36px 36px 32px;">${m.body}</td></tr>
|
|
142
|
+
<tr><td class="soft" align="center" style="padding:24px 4px 0;text-align:center;font:400 12px/1.6 ${FONT};color:${C.soft};">${m.footer}</td></tr>
|
|
143
|
+
</table>
|
|
144
|
+
</td></tr></table>
|
|
145
|
+
</body></html>`;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/mail/html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,8DAA8D;AAC9D,MAAM,UAAU,GAAG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AG;iFACS,CAAC,CAAC,GAAG;;mEAEnB,IAAI,iCAAiC,CAAC,CAAC,GAAG;;;6CAGhE,CAAC,CAAC,IAAI,qBAAqB,CAAC,CAAC,IAAI,gDAAgD,CAAC,CAAC,IAAI;oGAChC,IAAI,UAAU,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,MAAM;;;eAGvH,CAAC;AAChB,CAAC"}
|
package/dist/mail/notify.js
CHANGED
|
@@ -4,7 +4,8 @@ import { sanitise, sanitiseWithRedactor } from "../vendor/adapters/index.js";
|
|
|
4
4
|
import { redactText } from "../vendor/widget/predicates.js";
|
|
5
5
|
import { noteQueued } from "../jobs/soon.js";
|
|
6
6
|
import { isConfigured } from "./mailer.js";
|
|
7
|
-
import { unsubscribeHeaders, unsubscribeToken } from "./unsubscribe.js";
|
|
7
|
+
import { unsubscribeHeaders, unsubscribeToken, unsubscribeUrl } from "./unsubscribe.js";
|
|
8
|
+
import { button, esc, footer, h1, layout, p, quote, small, url } from "./html.js";
|
|
8
9
|
import { DIGEST_TOPIC, pruneDigest, renderDigest } from "./digest.js";
|
|
9
10
|
import { threadLink } from "./links.js";
|
|
10
11
|
import { ASSIGNED_TOPIC, assignedRecipient, claimSiblings, liveAssignments, renderAssigned, } from "./assigned.js";
|
|
@@ -361,7 +362,7 @@ export function deliverEmail(mailer, address, keys, notify = "each", caps = noCa
|
|
|
361
362
|
// is the database's problem, not a send to back off from.
|
|
362
363
|
const mail = digest
|
|
363
364
|
? renderDigest(digest, to.email, baseUrl)
|
|
364
|
-
:
|
|
365
|
+
: renderNotice(row, to.email, await threadLink(sql, row.thread_id, baseUrl), baseUrl, to.stop ?? null);
|
|
365
366
|
try {
|
|
366
367
|
await mailer.send({ ...mail, ...(to.headers ? { headers: to.headers } : {}) });
|
|
367
368
|
await sql `
|
|
@@ -426,10 +427,11 @@ async function deliverAssigned(sql, row, o) {
|
|
|
426
427
|
const n = await deferDay(sql, row.org_id, ids, day, now, o.notify);
|
|
427
428
|
return { did: 0, more: true, note: `${n} mail(s) deferred — studio over its daily mail` };
|
|
428
429
|
}
|
|
429
|
-
const mail = renderAssigned(live, to.email, o.baseUrl);
|
|
430
430
|
// The opt-out is the reviewer row's (B2) — this mail's own row. A studio
|
|
431
431
|
// member is a reviewer too, so the link works for them as for a client.
|
|
432
|
-
const
|
|
432
|
+
const token = o.keys ? unsubscribeToken(o.keys, to.reviewerId) : null;
|
|
433
|
+
const headers = token ? unsubscribeHeaders(o.baseUrl, token) : undefined;
|
|
434
|
+
const mail = renderAssigned(live, to.email, o.baseUrl, token ? unsubscribeUrl(o.baseUrl, token) : null);
|
|
433
435
|
try {
|
|
434
436
|
await o.mailer.send({ ...mail, ...(headers ? { headers } : {}) });
|
|
435
437
|
await sql `
|
|
@@ -545,9 +547,10 @@ async function recipient(sql, row, keys, baseUrl) {
|
|
|
545
547
|
// No keyring means no signable link, and an unsubscribe header we cannot
|
|
546
548
|
// honour is worse than none: send the mail without it rather than mint a
|
|
547
549
|
// URL that 404s.
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
550
|
+
if (!keys)
|
|
551
|
+
return { email: r.email };
|
|
552
|
+
const token = unsubscribeToken(keys, reviewerId);
|
|
553
|
+
return { email: r.email, headers: unsubscribeHeaders(baseUrl, token), stop: unsubscribeUrl(baseUrl, token) };
|
|
551
554
|
}
|
|
552
555
|
const owner = await ownerOf(sql, row.org_id);
|
|
553
556
|
return owner ? { email: owner.email } : null;
|
|
@@ -561,15 +564,24 @@ async function recipient(sql, row, keys, baseUrl) {
|
|
|
561
564
|
* body additionally gets the redactor, because a comment can contain anything
|
|
562
565
|
* the reviewer typed, including an address or a token they pasted in.
|
|
563
566
|
*
|
|
564
|
-
*
|
|
565
|
-
* the
|
|
566
|
-
*
|
|
567
|
+
* The plain text is the message; the HTML beside it (the house layout,
|
|
568
|
+
* `html.ts`) says the same in the card, with the comment in a box and the
|
|
569
|
+
* thread as the one button. Every string that reaches the HTML is escaped
|
|
570
|
+
* there, on top of the sanitising above, which is for a different channel.
|
|
571
|
+
* Its footer carries the opt-out link when the mail carries the header
|
|
572
|
+
* (`stop`) — reviewers only, as `recipient` explains.
|
|
567
573
|
*/
|
|
568
|
-
function
|
|
574
|
+
export function renderNotice(row, to, link, baseUrl, stop) {
|
|
569
575
|
const key = sanitise(row.event.threadKey ?? "a snag", "plain", { singleLine: true, max: 24 });
|
|
570
576
|
const author = sanitise(row.event.authorName ?? "Someone", "plain", { singleLine: true, max: 60 });
|
|
571
577
|
const body = sanitiseWithRedactor(row.event.body ?? "", "plain", redactText, { max: 2000 });
|
|
572
578
|
const page = row.event.pageUrl ?? "";
|
|
579
|
+
const foot = footer({
|
|
580
|
+
why: row.event.toReviewer ? "You get this because you took part in this thread." : "You get this because you own this studio.",
|
|
581
|
+
stop,
|
|
582
|
+
base: baseUrl,
|
|
583
|
+
});
|
|
584
|
+
const onPage = page ? small(`On the page: ${url(page)}`, "0 0 16px") : "";
|
|
573
585
|
/**
|
|
574
586
|
* `thread.resolved` — a different message, not the comment one with a
|
|
575
587
|
* different noun. It carries NO body, because there is no new text: the
|
|
@@ -578,9 +590,10 @@ function render(row, to, link) {
|
|
|
578
590
|
*/
|
|
579
591
|
if (row.event.resolved) {
|
|
580
592
|
const actor = sanitise(row.event.actorName ?? "Someone", "plain", { singleLine: true, max: 60 });
|
|
593
|
+
const subject = `${key} was marked resolved`;
|
|
581
594
|
return {
|
|
582
595
|
to,
|
|
583
|
-
subject
|
|
596
|
+
subject,
|
|
584
597
|
text: [
|
|
585
598
|
`${actor} marked ${key} resolved.`,
|
|
586
599
|
"",
|
|
@@ -591,11 +604,18 @@ function render(row, to, link) {
|
|
|
591
604
|
]
|
|
592
605
|
.filter((line, i, all) => !(line === "" && all[i - 1] === ""))
|
|
593
606
|
.join("\n"),
|
|
607
|
+
html: layout({
|
|
608
|
+
subject,
|
|
609
|
+
preheader: `${actor} marked ${key} resolved.`,
|
|
610
|
+
body: h1(`${esc(key)} was marked resolved`) + p(`${esc(actor)} marked ${esc(key)} resolved.`) + onPage + button("See the thread", link),
|
|
611
|
+
footer: foot,
|
|
612
|
+
}),
|
|
594
613
|
};
|
|
595
614
|
}
|
|
615
|
+
const subject = `${key}: new comment from ${author}`;
|
|
596
616
|
return {
|
|
597
617
|
to,
|
|
598
|
-
subject
|
|
618
|
+
subject,
|
|
599
619
|
text: [
|
|
600
620
|
`${author} commented on ${key}:`,
|
|
601
621
|
"",
|
|
@@ -608,6 +628,12 @@ function render(row, to, link) {
|
|
|
608
628
|
]
|
|
609
629
|
.filter((line, i, all) => !(line === "" && all[i - 1] === ""))
|
|
610
630
|
.join("\n"),
|
|
631
|
+
html: layout({
|
|
632
|
+
subject,
|
|
633
|
+
preheader: body.split("\n")[0] ?? "",
|
|
634
|
+
body: h1(`${esc(author)} commented on ${esc(key)}`) + (body ? quote(body) : "") + onPage + button("Open the thread", link),
|
|
635
|
+
footer: foot,
|
|
636
|
+
}),
|
|
611
637
|
};
|
|
612
638
|
}
|
|
613
639
|
//# sourceMappingURL=notify.js.map
|