@openpeepshq/common 0.3.1 → 0.4.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.
@@ -21,8 +21,9 @@ export declare const expandEventOccurrences: (event: Event, window: {
21
21
  to: Date;
22
22
  }) => ExpandedOccurrence[];
23
23
  export declare const occurrencesForIndex: (event: Event, now?: Date) => ExpandedOccurrence[];
24
- export declare const listRsvpOccurrences: (event: Event, now?: Date) => ExpandedOccurrence[];
25
24
  export declare const occurrenceHasEnded: (start: string, end?: string, now?: Date) => boolean;
25
+ /** Occurrences that have not ended, including one that is already underway. */
26
+ export declare const listRsvpOccurrences: (event: Event, now?: Date) => ExpandedOccurrence[];
26
27
  export type EventRsvpOpenOptions = {
27
28
  recurrenceId?: string;
28
29
  lockToOccurrence?: boolean;
@@ -174,10 +174,6 @@ export const occurrencesForIndex = (event, now = new Date()) => {
174
174
  to: new Date(now.getTime() + OCCURRENCE_HORIZON_MS),
175
175
  });
176
176
  };
177
- export const listRsvpOccurrences = (event, now = new Date()) => expandEventOccurrences(event, {
178
- from: now,
179
- to: new Date(now.getTime() + OCCURRENCE_HORIZON_MS),
180
- }).filter((occurrence) => !occurrence.cancelled);
181
177
  /** Matches the agenda: a missing end is one hour after start, not open forever. */
182
178
  const IMPLIED_EVENT_DURATION_MS = 60 * 60 * 1000;
183
179
  export const occurrenceHasEnded = (start, end, now = new Date()) => {
@@ -190,6 +186,12 @@ export const occurrenceHasEnded = (start, end, now = new Date()) => {
190
186
  : startMs + IMPLIED_EVENT_DURATION_MS;
191
187
  return endMs < now.getTime();
192
188
  };
189
+ /** Occurrences that have not ended, including one that is already underway. */
190
+ export const listRsvpOccurrences = (event, now = new Date()) => expandEventOccurrences(event, {
191
+ from: new Date(now.getTime() - OCCURRENCE_HORIZON_MS),
192
+ to: new Date(now.getTime() + OCCURRENCE_HORIZON_MS),
193
+ }).filter((occurrence) => !occurrence.cancelled &&
194
+ !occurrenceHasEnded(occurrence.start, occurrence.end, now));
193
195
  const findExpandedOccurrence = (event, recurrenceId) => {
194
196
  const anchor = new Date(recurrenceId).getTime();
195
197
  if (!Number.isFinite(anchor))
@@ -5,6 +5,11 @@ type CapabilitySet = {
5
5
  remove?: string[];
6
6
  };
7
7
  export declare const groupName: (group?: GroupData) => string;
8
+ export type GroupSection = 'posts' | 'events' | 'resources' | 'description';
9
+ /** `#events` selects that tab. Missing or unknown hashes stay on posts. */
10
+ export declare const groupSectionFromHash: (hash: string) => GroupSection;
11
+ /** Shareable group path. Posts is the canonical URL, without a hash. */
12
+ export declare const groupSectionPath: (handle: string, section?: GroupSection) => string;
8
13
  export declare const matchesGroupQuery: (group: GroupData, query: string, queryOptions?: {
9
14
  handle: boolean;
10
15
  displayName: boolean;
@@ -13,6 +13,22 @@ const adminCapabilities = {
13
13
  };
14
14
  const containsIgnoreCase = (candidate, query) => candidate.toLowerCase().indexOf(query.toLowerCase()) > -1;
15
15
  export const groupName = (group) => group?.displayName || group?.handle || '';
16
+ /** `#events` selects that tab. Missing or unknown hashes stay on posts. */
17
+ export const groupSectionFromHash = (hash) => {
18
+ const name = hash.replace(/^#/, '').split(/[/?&]/)[0];
19
+ if (name === 'events' ||
20
+ name === 'resources' ||
21
+ name === 'description' ||
22
+ name === 'posts') {
23
+ return name;
24
+ }
25
+ return 'posts';
26
+ };
27
+ /** Shareable group path. Posts is the canonical URL, without a hash. */
28
+ export const groupSectionPath = (handle, section = 'posts') => {
29
+ const base = `/groups/@${handle.replace(/^@/, '')}`;
30
+ return section === 'posts' ? base : `${base}#${section}`;
31
+ };
16
32
  export const matchesGroupQuery = (group, query, queryOptions = { handle: true, displayName: true, description: false }) => (queryOptions.handle && containsIgnoreCase(group.handle, query)) ||
17
33
  (queryOptions.displayName &&
18
34
  group.displayName &&
@@ -50,11 +50,11 @@ export declare const isExternalLink: (href: string, origin?: string) => boolean;
50
50
  /** Convert a same-origin path or URL to a `goto:` deep-link for RN navigation. */
51
51
  export declare const toGotoUrl: (url: string, origin: string) => string;
52
52
  /**
53
- * Tags, attrs and forbits shared by both the web (DOMPurify config) and
53
+ * Tags, attrs and forits shared by both the web (DOMPurify config) and
54
54
  * RN (custom HTML token renderers) so both platforms apply the same policy.
55
55
  */
56
56
  export declare const MARKDOWN_HTML_ALLOWED_TAGS: readonly ["b", "i", "em", "strong", "a", "p", "br", "ul", "ol", "li", "blockquote", "code", "pre", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "img", "iframe", "video", "source", "picture", "figcaption"];
57
- export declare const MARKDOWN_HTML_ALLOWED_ATTRS: readonly ["href", "src", "title", "alt", "target", "rel", "width", "height", "loading", "sandbox", "frameborder", "allowfullscreen", "referrerpolicy", "style"];
57
+ export declare const MARKDOWN_HTML_ALLOWED_ATTRS: readonly ["href", "src", "title", "alt", "target", "rel", "width", "height", "loading", "sandbox", "frameborder", "allowfullscreen", "referrerpolicy", "allow", "style"];
58
58
  export declare const MARKDOWN_HTML_FORBIDDEN_TAGS: readonly ["script", "style", "form", "object", "embed"];
59
59
  export declare const MARKDOWN_HTML_FORBIDDEN_ATTRS: readonly ["onload", "onerror", "onclick", "onmouseover"];
60
60
  /** Extract all iframe `src` URLs found in an HTML string. */
@@ -63,5 +63,11 @@ export declare const extractIframeSrcs: (html: string) => string[];
63
63
  * Inject safety attributes onto `<iframe>` tags so they can't break out of
64
64
  * their container or execute script navigation. Runs after sanitization
65
65
  * (so attackers can't smuggle attributes through), before DOM injection.
66
+ *
67
+ * We grant a broad Permissions Policy (`allow`) covering autoplay, encrypted
68
+ * media, and picture-in-picture, plus `allow-popups-to-escape-sandbox` in the
69
+ * sandbox itself. Without these, embedded players (YouTube, Vimeo, etc.)
70
+ * report Error 153 (autoplay blocked) because the browser denies the
71
+ * Permissions Policy the player requests.
66
72
  */
67
73
  export declare const injectIframeSafetyAttrs: (html: string) => string;
@@ -173,7 +173,7 @@ export const toGotoUrl = (url, origin) => {
173
173
  /* HTML sanitization helpers (shared allowlist + iframe safety) */
174
174
  /* ------------------------------------------------------------------ */
175
175
  /**
176
- * Tags, attrs and forbits shared by both the web (DOMPurify config) and
176
+ * Tags, attrs and forits shared by both the web (DOMPurify config) and
177
177
  * RN (custom HTML token renderers) so both platforms apply the same policy.
178
178
  */
179
179
  export const MARKDOWN_HTML_ALLOWED_TAGS = [
@@ -218,6 +218,7 @@ export const MARKDOWN_HTML_ALLOWED_ATTRS = [
218
218
  'frameborder',
219
219
  'allowfullscreen',
220
220
  'referrerpolicy',
221
+ 'allow',
221
222
  'style',
222
223
  ];
223
224
  export const MARKDOWN_HTML_FORBIDDEN_TAGS = [
@@ -248,6 +249,12 @@ export const extractIframeSrcs = (html) => {
248
249
  * Inject safety attributes onto `<iframe>` tags so they can't break out of
249
250
  * their container or execute script navigation. Runs after sanitization
250
251
  * (so attackers can't smuggle attributes through), before DOM injection.
252
+ *
253
+ * We grant a broad Permissions Policy (`allow`) covering autoplay, encrypted
254
+ * media, and picture-in-picture, plus `allow-popups-to-escape-sandbox` in the
255
+ * sandbox itself. Without these, embedded players (YouTube, Vimeo, etc.)
256
+ * report Error 153 (autoplay blocked) because the browser denies the
257
+ * Permissions Policy the player requests.
251
258
  */
252
259
  export const injectIframeSafetyAttrs = (html) => {
253
260
  return html.replace(/<iframe([^>]*?)>/gi, (match, attrs) => {
@@ -257,7 +264,7 @@ export const injectIframeSafetyAttrs = (html) => {
257
264
  }
258
265
  if (!/sandbox\s*=/.test(safeAttrs)) {
259
266
  safeAttrs +=
260
- ' sandbox="allow-scripts allow-same-origin allow-popups allow-presentation"';
267
+ ' sandbox="allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-presentation"';
261
268
  }
262
269
  if (!/referrerpolicy\s*=/.test(safeAttrs)) {
263
270
  safeAttrs += ' referrerpolicy="no-referrer"';
@@ -265,6 +272,9 @@ export const injectIframeSafetyAttrs = (html) => {
265
272
  if (!/style\s*=/.test(safeAttrs)) {
266
273
  safeAttrs += ' style="max-width:100%;width:100%;border:0;display:block;"';
267
274
  }
275
+ if (!/\ballow\s*=/.test(safeAttrs)) {
276
+ safeAttrs += ' allow="autoplay; encrypted-media; picture-in-picture"';
277
+ }
268
278
  return `<iframe${safeAttrs}>`;
269
279
  });
270
280
  };
@@ -272,8 +272,7 @@ export const seriesYesBlockedByCapacity = (post, profileId, now = new Date()) =>
272
272
  if (!event || !maxAttendees || !event.recurrence)
273
273
  return false;
274
274
  const occurrences = listRsvpOccurrences(event, now);
275
- // When there are no upcoming occurrences (e.g. a live jam whose current
276
- // occurrence started before `now`), fall back to the series-level count.
275
+ // No open date left (the current one has ended and nothing follows).
277
276
  if (occurrences.length === 0) {
278
277
  const current = getEffectiveRsvp(post, profileId);
279
278
  if (current?.response !== 'yes' &&
package/dist/types/api.js CHANGED
@@ -139,7 +139,7 @@ const basePublicPostSchema = publicReplyPostSchema.extend({
139
139
  /** Newest conversation descendants for a nested timeline preview. */
140
140
  latestReplies: publicReplyPostSchema.array().optional(),
141
141
  latestRepliesHasMore: z.boolean().optional(),
142
- /** Last reply or reaction on the conversation root; feeds sort by this. */
142
+ /** Last reply on the conversation root; feeds sort by this. */
143
143
  lastActivityAt: z.string().datetime().optional(),
144
144
  application: publicApplicationSchema.optional(),
145
145
  mentions: z.array(mentionWithPublicProfileSchema),
@@ -113,6 +113,10 @@ export declare const coreConfigSchemaFactory: (sanitize?: boolean) => z.ZodObjec
113
113
  local: z.ZodObject<{
114
114
  path: z.ZodString;
115
115
  }, z.core.$strip>;
116
+ retention: z.ZodObject<{
117
+ zipAfterDays: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
118
+ deleteAfterDays: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
119
+ }, z.core.$strip>;
116
120
  }, z.core.$strip>;
117
121
  media: z.ZodObject<{
118
122
  maxUploadMb: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
@@ -292,6 +296,10 @@ export declare const coreConfigSchema: z.ZodObject<{
292
296
  local: z.ZodObject<{
293
297
  path: z.ZodString;
294
298
  }, z.core.$strip>;
299
+ retention: z.ZodObject<{
300
+ zipAfterDays: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
301
+ deleteAfterDays: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
302
+ }, z.core.$strip>;
295
303
  }, z.core.$strip>;
296
304
  media: z.ZodObject<{
297
305
  maxUploadMb: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
@@ -471,6 +479,10 @@ export declare const coreConfigSanitizedSchema: z.ZodObject<{
471
479
  local: z.ZodObject<{
472
480
  path: z.ZodString;
473
481
  }, z.core.$strip>;
482
+ retention: z.ZodObject<{
483
+ zipAfterDays: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
484
+ deleteAfterDays: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
485
+ }, z.core.$strip>;
474
486
  }, z.core.$strip>;
475
487
  media: z.ZodObject<{
476
488
  maxUploadMb: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
@@ -76,11 +76,17 @@ export const coreConfigSchemaFactory = (sanitize) => z.object({
76
76
  host: z.string(),
77
77
  }), sanitize),
78
78
  email: emailConfigSchemaFactory(sanitize).describe('hidden'),
79
- logs: fixed(z.object({
79
+ logs: z.object({
80
80
  local: fixed(z.object({
81
81
  path: z.string(),
82
82
  }), sanitize),
83
- }), sanitize),
83
+ retention: z.object({
84
+ /** Age in days at which a daily log file is zipped. */
85
+ zipAfterDays: z.number().int().min(1).default(7).catch(7),
86
+ /** Age in days at which log files (and their zips) are deleted. */
87
+ deleteAfterDays: z.number().int().min(1).default(30).catch(30),
88
+ }),
89
+ }),
84
90
  media: z.object({
85
91
  maxUploadMb: z
86
92
  .number()
@@ -107,6 +107,14 @@ export declare const profileNotificationSettings: z.ZodObject<{
107
107
  email: z.ZodBoolean;
108
108
  }, z.core.$strip>;
109
109
  export type ProfileNotificationSettings = z.infer<typeof profileNotificationSettings>;
110
+ /** Per-group activity level. Unset means `all`, matching account settings. */
111
+ export declare const groupNotificationLevelOptions: readonly ["all", "mostRelevant", "off"];
112
+ export declare const groupNotificationLevelSchema: z.ZodEnum<{
113
+ all: "all";
114
+ mostRelevant: "mostRelevant";
115
+ off: "off";
116
+ }>;
117
+ export type GroupNotificationLevel = z.infer<typeof groupNotificationLevelSchema>;
110
118
  export declare const jamSettingsSchema: z.ZodObject<{
111
119
  backgroundObfuscation: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
112
120
  type: z.ZodLiteral<"blur">;
@@ -154,6 +162,11 @@ export declare const profileSettingsDataSchema: z.ZodObject<{
154
162
  push: z.ZodBoolean;
155
163
  email: z.ZodBoolean;
156
164
  }, z.core.$strip>>>;
165
+ groupNotificationLevels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
166
+ all: "all";
167
+ mostRelevant: "mostRelevant";
168
+ off: "off";
169
+ }>>>;
157
170
  jamSettings: z.ZodOptional<z.ZodObject<{
158
171
  backgroundObfuscation: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
159
172
  type: z.ZodLiteral<"blur">;
@@ -205,6 +218,11 @@ export declare const profileSettingsSchema: z.ZodObject<{
205
218
  push: z.ZodBoolean;
206
219
  email: z.ZodBoolean;
207
220
  }, z.core.$strip>>>;
221
+ groupNotificationLevels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
222
+ all: "all";
223
+ mostRelevant: "mostRelevant";
224
+ off: "off";
225
+ }>>>;
208
226
  jamSettings: z.ZodOptional<z.ZodObject<{
209
227
  backgroundObfuscation: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
210
228
  type: z.ZodLiteral<"blur">;
@@ -91,6 +91,13 @@ export const profileNotificationSettings = z.object({
91
91
  push: z.boolean(),
92
92
  email: z.boolean(),
93
93
  });
94
+ /** Per-group activity level. Unset means `all`, matching account settings. */
95
+ export const groupNotificationLevelOptions = [
96
+ 'all',
97
+ 'mostRelevant',
98
+ 'off',
99
+ ];
100
+ export const groupNotificationLevelSchema = z.enum(groupNotificationLevelOptions);
94
101
  export const jamSettingsSchema = z.object({
95
102
  backgroundObfuscation: z
96
103
  .discriminatedUnion('type', [
@@ -121,6 +128,10 @@ export const profileSettingsDataSchema = z.object({
121
128
  theme: ThemeOptionsSchema.optional(),
122
129
  defaults: profileSettingsDefaultsSchema.optional(),
123
130
  notifications: z.record(z.string(), profileNotificationSettings).optional(),
131
+ /** Per-group level. A missing group id means all activity for that group. */
132
+ groupNotificationLevels: z
133
+ .record(z.string(), groupNotificationLevelSchema)
134
+ .optional(),
124
135
  jamSettings: jamSettingsSchema.optional(),
125
136
  stripeSettings: z
126
137
  .object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/common",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -236,15 +236,6 @@ export const occurrencesForIndex = (
236
236
  });
237
237
  };
238
238
 
239
- export const listRsvpOccurrences = (
240
- event: Event,
241
- now = new Date(),
242
- ): ExpandedOccurrence[] =>
243
- expandEventOccurrences(event, {
244
- from: now,
245
- to: new Date(now.getTime() + OCCURRENCE_HORIZON_MS),
246
- }).filter((occurrence) => !occurrence.cancelled);
247
-
248
239
  /** Matches the agenda: a missing end is one hour after start, not open forever. */
249
240
  const IMPLIED_EVENT_DURATION_MS = 60 * 60 * 1000;
250
241
 
@@ -262,6 +253,20 @@ export const occurrenceHasEnded = (
262
253
  return endMs < now.getTime();
263
254
  };
264
255
 
256
+ /** Occurrences that have not ended, including one that is already underway. */
257
+ export const listRsvpOccurrences = (
258
+ event: Event,
259
+ now = new Date(),
260
+ ): ExpandedOccurrence[] =>
261
+ expandEventOccurrences(event, {
262
+ from: new Date(now.getTime() - OCCURRENCE_HORIZON_MS),
263
+ to: new Date(now.getTime() + OCCURRENCE_HORIZON_MS),
264
+ }).filter(
265
+ (occurrence) =>
266
+ !occurrence.cancelled &&
267
+ !occurrenceHasEnded(occurrence.start, occurrence.end, now),
268
+ );
269
+
265
270
  const findExpandedOccurrence = (
266
271
  event: Event,
267
272
  recurrenceId: string,
@@ -37,6 +37,31 @@ const containsIgnoreCase = (candidate: string, query: string) =>
37
37
  export const groupName = (group?: GroupData) =>
38
38
  group?.displayName || group?.handle || '';
39
39
 
40
+ export type GroupSection = 'posts' | 'events' | 'resources' | 'description';
41
+
42
+ /** `#events` selects that tab. Missing or unknown hashes stay on posts. */
43
+ export const groupSectionFromHash = (hash: string): GroupSection => {
44
+ const name = hash.replace(/^#/, '').split(/[/?&]/)[0];
45
+ if (
46
+ name === 'events' ||
47
+ name === 'resources' ||
48
+ name === 'description' ||
49
+ name === 'posts'
50
+ ) {
51
+ return name;
52
+ }
53
+ return 'posts';
54
+ };
55
+
56
+ /** Shareable group path. Posts is the canonical URL, without a hash. */
57
+ export const groupSectionPath = (
58
+ handle: string,
59
+ section: GroupSection = 'posts',
60
+ ): string => {
61
+ const base = `/groups/@${handle.replace(/^@/, '')}`;
62
+ return section === 'posts' ? base : `${base}#${section}`;
63
+ };
64
+
40
65
  export const matchesGroupQuery = (
41
66
  group: GroupData,
42
67
  query: string,
@@ -228,7 +228,7 @@ export const toGotoUrl = (url: string, origin: string): string => {
228
228
  /* ------------------------------------------------------------------ */
229
229
 
230
230
  /**
231
- * Tags, attrs and forbits shared by both the web (DOMPurify config) and
231
+ * Tags, attrs and forits shared by both the web (DOMPurify config) and
232
232
  * RN (custom HTML token renderers) so both platforms apply the same policy.
233
233
  */
234
234
  export const MARKDOWN_HTML_ALLOWED_TAGS = [
@@ -274,6 +274,7 @@ export const MARKDOWN_HTML_ALLOWED_ATTRS = [
274
274
  'frameborder',
275
275
  'allowfullscreen',
276
276
  'referrerpolicy',
277
+ 'allow',
277
278
  'style',
278
279
  ] as const;
279
280
 
@@ -310,6 +311,12 @@ export const extractIframeSrcs = (html: string): string[] => {
310
311
  * Inject safety attributes onto `<iframe>` tags so they can't break out of
311
312
  * their container or execute script navigation. Runs after sanitization
312
313
  * (so attackers can't smuggle attributes through), before DOM injection.
314
+ *
315
+ * We grant a broad Permissions Policy (`allow`) covering autoplay, encrypted
316
+ * media, and picture-in-picture, plus `allow-popups-to-escape-sandbox` in the
317
+ * sandbox itself. Without these, embedded players (YouTube, Vimeo, etc.)
318
+ * report Error 153 (autoplay blocked) because the browser denies the
319
+ * Permissions Policy the player requests.
313
320
  */
314
321
  export const injectIframeSafetyAttrs = (html: string): string => {
315
322
  return html.replace(/<iframe([^>]*?)>/gi, (match, attrs: string) => {
@@ -319,7 +326,7 @@ export const injectIframeSafetyAttrs = (html: string): string => {
319
326
  }
320
327
  if (!/sandbox\s*=/.test(safeAttrs)) {
321
328
  safeAttrs +=
322
- ' sandbox="allow-scripts allow-same-origin allow-popups allow-presentation"';
329
+ ' sandbox="allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-presentation"';
323
330
  }
324
331
  if (!/referrerpolicy\s*=/.test(safeAttrs)) {
325
332
  safeAttrs += ' referrerpolicy="no-referrer"';
@@ -327,6 +334,9 @@ export const injectIframeSafetyAttrs = (html: string): string => {
327
334
  if (!/style\s*=/.test(safeAttrs)) {
328
335
  safeAttrs += ' style="max-width:100%;width:100%;border:0;display:block;"';
329
336
  }
337
+ if (!/\ballow\s*=/.test(safeAttrs)) {
338
+ safeAttrs += ' allow="autoplay; encrypted-media; picture-in-picture"';
339
+ }
330
340
  return `<iframe${safeAttrs}>`;
331
341
  });
332
342
  };
@@ -436,8 +436,7 @@ export const seriesYesBlockedByCapacity = (
436
436
  const maxAttendees = event?.maxAttendees;
437
437
  if (!event || !maxAttendees || !event.recurrence) return false;
438
438
  const occurrences = listRsvpOccurrences(event, now);
439
- // When there are no upcoming occurrences (e.g. a live jam whose current
440
- // occurrence started before `now`), fall back to the series-level count.
439
+ // No open date left (the current one has ended and nothing follows).
441
440
  if (occurrences.length === 0) {
442
441
  const current = getEffectiveRsvp(post, profileId);
443
442
  if (
package/src/types/api.ts CHANGED
@@ -231,7 +231,7 @@ const basePublicPostSchema = publicReplyPostSchema.extend({
231
231
  /** Newest conversation descendants for a nested timeline preview. */
232
232
  latestReplies: publicReplyPostSchema.array().optional(),
233
233
  latestRepliesHasMore: z.boolean().optional(),
234
- /** Last reply or reaction on the conversation root; feeds sort by this. */
234
+ /** Last reply on the conversation root; feeds sort by this. */
235
235
  lastActivityAt: z.string().datetime().optional(),
236
236
  application: publicApplicationSchema.optional(),
237
237
  mentions: z.array(mentionWithPublicProfileSchema),
@@ -134,17 +134,20 @@ export const coreConfigSchemaFactory = (sanitize?: boolean) =>
134
134
  sanitize,
135
135
  ),
136
136
  email: emailConfigSchemaFactory(sanitize).describe('hidden'),
137
- logs: fixed(
138
- z.object({
139
- local: fixed(
140
- z.object({
141
- path: z.string(),
142
- }),
143
- sanitize,
144
- ),
137
+ logs: z.object({
138
+ local: fixed(
139
+ z.object({
140
+ path: z.string(),
141
+ }),
142
+ sanitize,
143
+ ),
144
+ retention: z.object({
145
+ /** Age in days at which a daily log file is zipped. */
146
+ zipAfterDays: z.number().int().min(1).default(7).catch(7),
147
+ /** Age in days at which log files (and their zips) are deleted. */
148
+ deleteAfterDays: z.number().int().min(1).default(30).catch(30),
145
149
  }),
146
- sanitize,
147
- ),
150
+ }),
148
151
  media: z.object({
149
152
  maxUploadMb: z
150
153
  .number()
@@ -137,6 +137,19 @@ export const profileNotificationSettings = z.object({
137
137
  export type ProfileNotificationSettings = z.infer<
138
138
  typeof profileNotificationSettings
139
139
  >;
140
+
141
+ /** Per-group activity level. Unset means `all`, matching account settings. */
142
+ export const groupNotificationLevelOptions = [
143
+ 'all',
144
+ 'mostRelevant',
145
+ 'off',
146
+ ] as const;
147
+ export const groupNotificationLevelSchema = z.enum(
148
+ groupNotificationLevelOptions,
149
+ );
150
+ export type GroupNotificationLevel = z.infer<
151
+ typeof groupNotificationLevelSchema
152
+ >;
140
153
  export const jamSettingsSchema = z.object({
141
154
  backgroundObfuscation: z
142
155
  .discriminatedUnion('type', [
@@ -170,6 +183,10 @@ export const profileSettingsDataSchema = z.object({
170
183
  theme: ThemeOptionsSchema.optional(),
171
184
  defaults: profileSettingsDefaultsSchema.optional(),
172
185
  notifications: z.record(z.string(), profileNotificationSettings).optional(),
186
+ /** Per-group level. A missing group id means all activity for that group. */
187
+ groupNotificationLevels: z
188
+ .record(z.string(), groupNotificationLevelSchema)
189
+ .optional(),
173
190
  jamSettings: jamSettingsSchema.optional(),
174
191
  stripeSettings: z
175
192
  .object({