@anthusai/papyrus 5.135.0-next.6 → 5.135.0
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/amplify/plugins/notifications/config.js +16 -2
- package/amplify/plugins/notifications/config.ts +23 -2
- package/amplify/plugins/notifications/papyrus.plugin.js +8 -1
- package/amplify/plugins/notifications/papyrus.plugin.ts +8 -1
- package/lib/notifications-api.ts +43 -5
- package/package.json +1 -1
- package/routes.manifest.json +1 -1
|
@@ -2,9 +2,9 @@ import { COMPUTE_ROLE_ARN_ENVIRONMENT_VARIABLE, environmentOrConfigured } from "
|
|
|
2
2
|
import { COMPUTE_ROLE_ARN, HOSTNAME, LOCAL_PART, NEWSLETTER_LIST_ID, NEWSLETTER_SITE_ID, SES_NAME, basePath, itemUrlStyle, matching, origin, record, resolveRule, resolveTheme, text, } from "../newsletter/config.js";
|
|
3
3
|
const KNOWN_KEYS = [
|
|
4
4
|
"name", "siteId", "siteOrigin", "basePath", "computeRoleArn", "sendingDomain", "fromAddress", "fromName", "theme", "lists",
|
|
5
|
-
"itemUrlStyle", "configurationSet", "consent", "confirmWindowHours",
|
|
5
|
+
"itemUrlStyle", "configurationSet", "consent", "confirmWindowHours", "legacyNewsletterLinks",
|
|
6
6
|
];
|
|
7
|
-
const LIST_KEYS = ["id", "name", "description", "rule", "approval", "family", "cadence", "sendAt", "timeZone"];
|
|
7
|
+
const LIST_KEYS = ["id", "name", "description", "rule", "approval", "kind", "family", "cadence", "sendAt", "timeZone"];
|
|
8
8
|
const CADENCES = ["each", "daily", "weekly"];
|
|
9
9
|
const WEEKDAYS = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
|
|
10
10
|
/** The helpers shared with the newsletter word their errors for it; this plugin says its own name. */
|
|
@@ -27,6 +27,11 @@ function resolveList(raw, index) {
|
|
|
27
27
|
const approval = list.approval === undefined ? "admin" : list.approval;
|
|
28
28
|
if (approval !== "admin" && approval !== "none")
|
|
29
29
|
fail(`${label}.approval must be "admin" or "none"`);
|
|
30
|
+
const kind = list.kind === undefined ? undefined : list.kind;
|
|
31
|
+
if (kind !== undefined && kind !== "story.published" && kind !== "roundup")
|
|
32
|
+
fail(`${label}.kind must be "story.published" or "roundup"`);
|
|
33
|
+
if (kind === "roundup" && list.rule !== undefined)
|
|
34
|
+
fail(`${label} is a roundup list, which is never sent each story, so it names no rule`);
|
|
30
35
|
const family = list.family === undefined ? undefined : matching(list.family, `${label}.family`, NEWSLETTER_LIST_ID, "lowercase letters, digits and hyphens, starting with a letter");
|
|
31
36
|
const cadence = list.cadence === undefined ? undefined : list.cadence;
|
|
32
37
|
if (cadence !== undefined && !CADENCES.includes(cadence))
|
|
@@ -50,6 +55,7 @@ function resolveList(raw, index) {
|
|
|
50
55
|
description: text(list.description, `${label}.description`, 300, { optional: true, fallback: "" }),
|
|
51
56
|
rule: resolveRule(list.rule, `${label}.rule`),
|
|
52
57
|
approval,
|
|
58
|
+
...(kind === undefined ? {} : { kind: kind }),
|
|
53
59
|
...(family === undefined ? {} : { family }),
|
|
54
60
|
...(cadence === undefined ? {} : { cadence: cadence }),
|
|
55
61
|
...(periodic ? { sendAt: list.sendAt, timeZone: list.timeZone } : {}),
|
|
@@ -63,6 +69,13 @@ function confirmWindowHours(raw) {
|
|
|
63
69
|
fail("confirmWindowHours must be a whole number of hours, at least 1");
|
|
64
70
|
return raw;
|
|
65
71
|
}
|
|
72
|
+
function legacyNewsletterLinks(raw) {
|
|
73
|
+
if (raw === undefined)
|
|
74
|
+
return false;
|
|
75
|
+
if (typeof raw !== "boolean")
|
|
76
|
+
fail("legacyNewsletterLinks must be true or false");
|
|
77
|
+
return raw;
|
|
78
|
+
}
|
|
66
79
|
export function resolveNotificationsConfig(request) {
|
|
67
80
|
return inThisPlugin(() => {
|
|
68
81
|
const raw = record(typeof request === "string" ? { name: request } : request, "settings", KNOWN_KEYS);
|
|
@@ -97,6 +110,7 @@ export function resolveNotificationsConfig(request) {
|
|
|
97
110
|
confirmWindowHours: confirmWindowHours(raw.confirmWindowHours),
|
|
98
111
|
itemUrlStyle: itemUrlStyle(raw.itemUrlStyle),
|
|
99
112
|
configurationSet: matching(raw.configurationSet, "configurationSet", SES_NAME, "an SES configuration set name", `papyrus-${siteId}`),
|
|
113
|
+
legacyNewsletterLinks: legacyNewsletterLinks(raw.legacyNewsletterLinks),
|
|
100
114
|
};
|
|
101
115
|
});
|
|
102
116
|
}
|
|
@@ -29,6 +29,11 @@ export type NotificationsList = {
|
|
|
29
29
|
description: string;
|
|
30
30
|
rule: NewsletterRule;
|
|
31
31
|
approval: "admin" | "none";
|
|
32
|
+
/**
|
|
33
|
+
* What the list is for. `story.published` (the default) sends each matching story. `roundup` is a periodic issue's list: it is never
|
|
34
|
+
* sent each story, so it carries no rule. A newsletter roundup list keeps its id and becomes a `roundup` list when its subscribers move (PPY-6b2d35).
|
|
35
|
+
*/
|
|
36
|
+
kind?: "story.published" | "roundup";
|
|
32
37
|
/** The cadence family: lists that carry the same items at different cadences share one, and a reader holds one list of a family. None: its own family. */
|
|
33
38
|
family?: string;
|
|
34
39
|
/** `each`, `daily` or `weekly`, as in the site's `lists` document. A reader's switch between lists of a family waits for the next period start of its periodic list. */
|
|
@@ -59,13 +64,18 @@ export type NotificationsConfig = {
|
|
|
59
64
|
itemUrlStyle: ItemUrlStyle;
|
|
60
65
|
/** `papyrus-<siteId>` unless overridden: the sending stack's configuration set, shared with the newsletter. */
|
|
61
66
|
configurationSet: string;
|
|
67
|
+
/**
|
|
68
|
+
* Honour the old newsletter's manage and unsubscribe links (they were mailed with the newsletter's tokens) until the date the migration
|
|
69
|
+
* gave them. Dated: set only while that period runs, and removed with `src/papyrus_content/notifications/legacy_links.py` (see that file).
|
|
70
|
+
*/
|
|
71
|
+
legacyNewsletterLinks: boolean;
|
|
62
72
|
};
|
|
63
73
|
|
|
64
74
|
const KNOWN_KEYS = [
|
|
65
75
|
"name", "siteId", "siteOrigin", "basePath", "computeRoleArn", "sendingDomain", "fromAddress", "fromName", "theme", "lists",
|
|
66
|
-
"itemUrlStyle", "configurationSet", "consent", "confirmWindowHours",
|
|
76
|
+
"itemUrlStyle", "configurationSet", "consent", "confirmWindowHours", "legacyNewsletterLinks",
|
|
67
77
|
];
|
|
68
|
-
const LIST_KEYS = ["id", "name", "description", "rule", "approval", "family", "cadence", "sendAt", "timeZone"];
|
|
78
|
+
const LIST_KEYS = ["id", "name", "description", "rule", "approval", "kind", "family", "cadence", "sendAt", "timeZone"];
|
|
69
79
|
const CADENCES = ["each", "daily", "weekly"];
|
|
70
80
|
const WEEKDAYS = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
|
|
71
81
|
|
|
@@ -88,6 +98,9 @@ function resolveList(raw: unknown, index: number): NotificationsList {
|
|
|
88
98
|
const list = record(raw, label, LIST_KEYS);
|
|
89
99
|
const approval = list.approval === undefined ? "admin" : list.approval;
|
|
90
100
|
if (approval !== "admin" && approval !== "none") fail(`${label}.approval must be "admin" or "none"`);
|
|
101
|
+
const kind = list.kind === undefined ? undefined : list.kind;
|
|
102
|
+
if (kind !== undefined && kind !== "story.published" && kind !== "roundup") fail(`${label}.kind must be "story.published" or "roundup"`);
|
|
103
|
+
if (kind === "roundup" && list.rule !== undefined) fail(`${label} is a roundup list, which is never sent each story, so it names no rule`);
|
|
91
104
|
const family = list.family === undefined ? undefined : matching(list.family, `${label}.family`, NEWSLETTER_LIST_ID, "lowercase letters, digits and hyphens, starting with a letter");
|
|
92
105
|
const cadence = list.cadence === undefined ? undefined : list.cadence;
|
|
93
106
|
if (cadence !== undefined && !CADENCES.includes(cadence as string)) fail(`${label}.cadence must be one of: ${CADENCES.join(", ")}`);
|
|
@@ -107,6 +120,7 @@ function resolveList(raw: unknown, index: number): NotificationsList {
|
|
|
107
120
|
description: text(list.description, `${label}.description`, 300, { optional: true, fallback: "" }),
|
|
108
121
|
rule: resolveRule(list.rule, `${label}.rule`),
|
|
109
122
|
approval,
|
|
123
|
+
...(kind === undefined ? {} : { kind: kind as NotificationsList["kind"] }),
|
|
110
124
|
...(family === undefined ? {} : { family }),
|
|
111
125
|
...(cadence === undefined ? {} : { cadence: cadence as NotificationsList["cadence"] }),
|
|
112
126
|
...(periodic ? { sendAt: list.sendAt as NotificationsList["sendAt"], timeZone: list.timeZone as string } : {}),
|
|
@@ -120,6 +134,12 @@ function confirmWindowHours(raw: unknown): number {
|
|
|
120
134
|
return raw;
|
|
121
135
|
}
|
|
122
136
|
|
|
137
|
+
function legacyNewsletterLinks(raw: unknown): boolean {
|
|
138
|
+
if (raw === undefined) return false;
|
|
139
|
+
if (typeof raw !== "boolean") fail("legacyNewsletterLinks must be true or false");
|
|
140
|
+
return raw;
|
|
141
|
+
}
|
|
142
|
+
|
|
123
143
|
export function resolveNotificationsConfig(request: PluginRequest): NotificationsConfig {
|
|
124
144
|
return inThisPlugin(() => {
|
|
125
145
|
const raw = record(typeof request === "string" ? { name: request } : request, "settings", KNOWN_KEYS);
|
|
@@ -152,6 +172,7 @@ export function resolveNotificationsConfig(request: PluginRequest): Notification
|
|
|
152
172
|
confirmWindowHours: confirmWindowHours(raw.confirmWindowHours),
|
|
153
173
|
itemUrlStyle: itemUrlStyle(raw.itemUrlStyle),
|
|
154
174
|
configurationSet: matching(raw.configurationSet, "configurationSet", SES_NAME, "an SES configuration set name", `papyrus-${siteId}`),
|
|
175
|
+
legacyNewsletterLinks: legacyNewsletterLinks(raw.legacyNewsletterLinks),
|
|
155
176
|
};
|
|
156
177
|
});
|
|
157
178
|
}
|
|
@@ -58,6 +58,8 @@ export const notificationsTableName = (siteId) => `papyrus-notifications-${siteI
|
|
|
58
58
|
export const notificationsOperatorsParameterName = (siteId) => `/papyrus/${siteId}/notifications/operators`;
|
|
59
59
|
/** Generated once by the stack; the addresses' recipient keys are derived from it. */
|
|
60
60
|
export const notificationsKeyParameterName = (siteId) => `/papyrus/${siteId}/notifications/recipient-key`;
|
|
61
|
+
/** Where the newsletter plugin generated its key (it is retained when that plugin is removed): read only while old newsletter links are honoured. */
|
|
62
|
+
export const legacyNewsletterKeyParameterName = (siteId) => `/papyrus/${siteId}/newsletter-key`;
|
|
61
63
|
export const notificationsAlarmNames = (siteId) => ({
|
|
62
64
|
emailDeadLetters: `papyrus-notifications-${siteId}-email-dlq`,
|
|
63
65
|
routerDeadLetters: `papyrus-notifications-${siteId}-router-dlq`,
|
|
@@ -87,11 +89,12 @@ export function notificationsEnvironment(config, names) {
|
|
|
87
89
|
FROM_NAME: config.fromName,
|
|
88
90
|
CONFIGURATION_SET: config.configurationSet,
|
|
89
91
|
ITEM_URL_STYLE: config.itemUrlStyle,
|
|
90
|
-
LISTS_JSON: JSON.stringify(config.lists.map((list) => ({ id: list.id, name: list.name, description: list.description, rule: list.rule, approval: list.approval, family: list.family, cadence: list.cadence, sendAt: list.sendAt, timeZone: list.timeZone }))),
|
|
92
|
+
LISTS_JSON: JSON.stringify(config.lists.map((list) => ({ id: list.id, name: list.name, description: list.description, rule: list.rule, approval: list.approval, kind: list.kind, family: list.family, cadence: list.cadence, sendAt: list.sendAt, timeZone: list.timeZone }))),
|
|
91
93
|
THEME_JSON: JSON.stringify(config.theme),
|
|
92
94
|
CONSENT: config.consent,
|
|
93
95
|
CONFIRM_WINDOW_SECONDS: String(config.confirmWindowHours * 3600),
|
|
94
96
|
METRIC_NAMESPACE: `Caducus/papyrus-${config.siteId}`,
|
|
97
|
+
...(config.legacyNewsletterLinks ? { LEGACY_NEWSLETTER_KEY_PARAMETER: legacyNewsletterKeyParameterName(config.siteId) } : {}),
|
|
95
98
|
};
|
|
96
99
|
}
|
|
97
100
|
export const notificationsPlugin = {
|
|
@@ -247,6 +250,10 @@ export const notificationsPlugin = {
|
|
|
247
250
|
`arn:${stack.partition}:ssm:${stack.region}:${stack.account}:parameter${operatorsParameter}`,
|
|
248
251
|
keyParameter.parameterArn,
|
|
249
252
|
];
|
|
253
|
+
// Old newsletter links (dated; legacy_links.py): every function builds the same runtime, so each may read the old key.
|
|
254
|
+
if (config.legacyNewsletterLinks) {
|
|
255
|
+
parameterArns.push(`arn:${stack.partition}:ssm:${stack.region}:${stack.account}:parameter${legacyNewsletterKeyParameterName(config.siteId)}`);
|
|
256
|
+
}
|
|
250
257
|
// Every function builds the same runtime (the audience needs the recipient key), and the SES events suppress readers.
|
|
251
258
|
for (const fn of [router, email, flush, sesEvents]) {
|
|
252
259
|
table.grantReadWriteData(fn); // includes the table key's encrypt and decrypt
|
|
@@ -66,6 +66,8 @@ export const notificationsTableName = (siteId: string) => `papyrus-notifications
|
|
|
66
66
|
export const notificationsOperatorsParameterName = (siteId: string) => `/papyrus/${siteId}/notifications/operators`;
|
|
67
67
|
/** Generated once by the stack; the addresses' recipient keys are derived from it. */
|
|
68
68
|
export const notificationsKeyParameterName = (siteId: string) => `/papyrus/${siteId}/notifications/recipient-key`;
|
|
69
|
+
/** Where the newsletter plugin generated its key (it is retained when that plugin is removed): read only while old newsletter links are honoured. */
|
|
70
|
+
export const legacyNewsletterKeyParameterName = (siteId: string) => `/papyrus/${siteId}/newsletter-key`;
|
|
69
71
|
export const notificationsAlarmNames = (siteId: string) => ({
|
|
70
72
|
emailDeadLetters: `papyrus-notifications-${siteId}-email-dlq`,
|
|
71
73
|
routerDeadLetters: `papyrus-notifications-${siteId}-router-dlq`,
|
|
@@ -98,11 +100,12 @@ export function notificationsEnvironment(config: NotificationsConfig, names: { t
|
|
|
98
100
|
FROM_NAME: config.fromName,
|
|
99
101
|
CONFIGURATION_SET: config.configurationSet,
|
|
100
102
|
ITEM_URL_STYLE: config.itemUrlStyle,
|
|
101
|
-
LISTS_JSON: JSON.stringify(config.lists.map((list) => ({ id: list.id, name: list.name, description: list.description, rule: list.rule, approval: list.approval, family: list.family, cadence: list.cadence, sendAt: list.sendAt, timeZone: list.timeZone }))),
|
|
103
|
+
LISTS_JSON: JSON.stringify(config.lists.map((list) => ({ id: list.id, name: list.name, description: list.description, rule: list.rule, approval: list.approval, kind: list.kind, family: list.family, cadence: list.cadence, sendAt: list.sendAt, timeZone: list.timeZone }))),
|
|
102
104
|
THEME_JSON: JSON.stringify(config.theme),
|
|
103
105
|
CONSENT: config.consent,
|
|
104
106
|
CONFIRM_WINDOW_SECONDS: String(config.confirmWindowHours * 3600),
|
|
105
107
|
METRIC_NAMESPACE: `Caducus/papyrus-${config.siteId}`,
|
|
108
|
+
...(config.legacyNewsletterLinks ? { LEGACY_NEWSLETTER_KEY_PARAMETER: legacyNewsletterKeyParameterName(config.siteId) } : {}),
|
|
106
109
|
};
|
|
107
110
|
}
|
|
108
111
|
|
|
@@ -268,6 +271,10 @@ export const notificationsPlugin: PapyrusPlugin<NotificationsConfig, Record<stri
|
|
|
268
271
|
`arn:${stack.partition}:ssm:${stack.region}:${stack.account}:parameter${operatorsParameter}`,
|
|
269
272
|
keyParameter.parameterArn,
|
|
270
273
|
];
|
|
274
|
+
// Old newsletter links (dated; legacy_links.py): every function builds the same runtime, so each may read the old key.
|
|
275
|
+
if (config.legacyNewsletterLinks) {
|
|
276
|
+
parameterArns.push(`arn:${stack.partition}:ssm:${stack.region}:${stack.account}:parameter${legacyNewsletterKeyParameterName(config.siteId)}`);
|
|
277
|
+
}
|
|
271
278
|
// Every function builds the same runtime (the audience needs the recipient key), and the SES events suppress readers.
|
|
272
279
|
for (const fn of [router, email, flush, sesEvents]) {
|
|
273
280
|
table.grantReadWriteData(fn); // includes the table key's encrypt and decrypt
|
package/lib/notifications-api.ts
CHANGED
|
@@ -213,7 +213,7 @@ export async function handleNotificationsUnsubscribe(request: NextRequest, optio
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
const PREFERENCE_MESSAGES = new Set(["saved", "unsubscribed"]);
|
|
216
|
+
const PREFERENCE_MESSAGES = new Set(["saved", "unsubscribed", "check_email"]);
|
|
217
217
|
|
|
218
218
|
/** /api/notifications/preferences. POST (same-origin form) saves, unsubscribes from everything, or deletes after a confirm step; GET redirects. */
|
|
219
219
|
export async function handleNotificationsPreferences(request: NextRequest, options: NotificationsApiOptions = {}): Promise<NextResponse> {
|
|
@@ -233,9 +233,21 @@ export async function handleNotificationsPreferences(request: NextRequest, optio
|
|
|
233
233
|
if (!token || !plugin.functionName) return to.go("expired");
|
|
234
234
|
const action = form.get("action");
|
|
235
235
|
if (action === "delete" && form.get("confirm") !== "1") return to.go("preferences", { token, step: "delete" });
|
|
236
|
+
// Joining a family the reader does not hold needs their consent: the page shows the site's wording and posts it back with the form, the page and the network as
|
|
237
|
+
// evidence, as the subscribe form does. The function uses them only for a new family; a cadence change inside a family the reader holds ignores them.
|
|
236
238
|
const operation =
|
|
237
239
|
action === "save"
|
|
238
|
-
? {
|
|
240
|
+
? {
|
|
241
|
+
action: "update_preferences",
|
|
242
|
+
token,
|
|
243
|
+
lists: form.getAll("l").slice(0, MAXIMUM_LISTS).filter((id) => LIST_ID.test(id)),
|
|
244
|
+
consent: limited(form.get("consent"), 500),
|
|
245
|
+
formId: "notifications-preferences",
|
|
246
|
+
page: `${to.origin}${basePathOf(plugin)}/notifications/preferences/`,
|
|
247
|
+
origin: to.origin,
|
|
248
|
+
ip: clientAddress(request.headers),
|
|
249
|
+
userAgent: limited(request.headers.get("user-agent"), NEWSLETTER_USER_AGENT_CHARACTERS),
|
|
250
|
+
}
|
|
239
251
|
: action === "unsubscribe_all"
|
|
240
252
|
? { action: "unsubscribe", token }
|
|
241
253
|
: action === "delete"
|
|
@@ -243,10 +255,11 @@ export async function handleNotificationsPreferences(request: NextRequest, optio
|
|
|
243
255
|
: null;
|
|
244
256
|
if (!operation) return failure(400, "invalid_action", "Choose save, unsubscribe from everything, or delete.");
|
|
245
257
|
try {
|
|
246
|
-
const
|
|
258
|
+
const { body: answer } = await call(options, plugin.functionName, operation);
|
|
259
|
+
const status = answer.status;
|
|
247
260
|
if (status === "deleted") return to.go("preferences", { msg: "deleted" });
|
|
248
261
|
if (typeof status !== "string" || !PREFERENCE_MESSAGES.has(status)) return to.go("expired");
|
|
249
|
-
return to.go("preferences", { token, msg: status });
|
|
262
|
+
return to.go("preferences", { token, msg: status, ...(status === "check_email" ? { confirming: (Array.isArray(answer.confirming) ? answer.confirming : []).filter((id): id is string => typeof id === "string" && LIST_ID.test(id)).join(",") } : {}) });
|
|
250
263
|
} catch (error) {
|
|
251
264
|
console.error(`Notifications preferences save failed (${error instanceof Error ? error.name : "error"}).`);
|
|
252
265
|
return to.go("expired");
|
|
@@ -261,6 +274,17 @@ function configuredLists(plugin: Enabled, ids: string[]): Array<{ id: string; na
|
|
|
261
274
|
});
|
|
262
275
|
}
|
|
263
276
|
|
|
277
|
+
/** What the preferences page needs to group lists into families: the site's public settings, nothing about any reader. A list that names no family is its own. */
|
|
278
|
+
function familiesOf(plugin: Enabled): Record<string, { family: string; cadence: string }> {
|
|
279
|
+
const known = Array.isArray(plugin.settings.lists) ? (plugin.settings.lists as Array<{ id?: unknown; family?: unknown; cadence?: unknown }>) : [];
|
|
280
|
+
const result: Record<string, { family: string; cadence: string }> = {};
|
|
281
|
+
for (const entry of known) {
|
|
282
|
+
if (typeof entry.id !== "string") continue;
|
|
283
|
+
result[entry.id] = { family: typeof entry.family === "string" ? entry.family : entry.id, cadence: typeof entry.cadence === "string" ? entry.cadence : "" };
|
|
284
|
+
}
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
|
|
264
288
|
function offeredLists(plugin: Enabled): Array<{ id: string; name: string; description: string }> {
|
|
265
289
|
const known = Array.isArray(plugin.settings.lists) ? (plugin.settings.lists as Array<{ id?: unknown; name?: unknown; description?: unknown }>) : [];
|
|
266
290
|
return known.flatMap((entry) =>
|
|
@@ -294,10 +318,24 @@ export async function handleNotificationsState(request: NextRequest, options: No
|
|
|
294
318
|
if (result.body.status !== "ready") return json(400, { status: "invalid" });
|
|
295
319
|
const lists = Array.isArray(result.body.lists) ? (result.body.lists as Array<Record<string, unknown>>) : [];
|
|
296
320
|
if (kind === "confirm") return json(200, { status: "ready", lists: lists.flatMap((entry) => (typeof entry.name === "string" ? [{ name: entry.name }] : [])) });
|
|
321
|
+
const known = familiesOf(plugin);
|
|
322
|
+
// The wording the page shows, and posts back, when the reader chooses a family they do not hold: the same sentence as the subscribe form.
|
|
323
|
+
const consent = typeof plugin.settings.consent === "string" ? plugin.settings.consent : "";
|
|
297
324
|
return json(200, {
|
|
298
325
|
status: "ready",
|
|
299
326
|
email: typeof result.body.email === "string" ? result.body.email : "",
|
|
300
|
-
|
|
327
|
+
consent,
|
|
328
|
+
lists: lists.map((entry) => {
|
|
329
|
+
const own = typeof entry.id === "string" ? known[entry.id] : undefined;
|
|
330
|
+
return {
|
|
331
|
+
id: entry.id,
|
|
332
|
+
name: entry.name,
|
|
333
|
+
description: entry.description ?? "",
|
|
334
|
+
subscribed: entry.subscribed === true,
|
|
335
|
+
family: own?.family ?? entry.id,
|
|
336
|
+
cadence: own?.cadence ?? "",
|
|
337
|
+
};
|
|
338
|
+
}),
|
|
301
339
|
});
|
|
302
340
|
} catch (error) {
|
|
303
341
|
console.error(`Notifications state failed (${error instanceof Error ? error.name : "error"}).`);
|
package/package.json
CHANGED
package/routes.manifest.json
CHANGED