@openpeepshq/core 0.1.34 → 0.1.35

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.
Files changed (165) hide show
  1. package/dist/accessTokens/finders.js +5 -6
  2. package/dist/accessTokens/mutations.js +1 -1
  3. package/dist/accessTokens/tokens.js +8 -11
  4. package/dist/accounts/helpers.js +6 -2
  5. package/dist/accounts/mutations.js +13 -8
  6. package/dist/analytics/cache.js +3 -3
  7. package/dist/analytics/clicks.js +14 -22
  8. package/dist/analytics/compile.js +1 -2
  9. package/dist/analytics/dateRange.js +3 -5
  10. package/dist/analytics/jobs.js +3 -4
  11. package/dist/analytics/pdfReport.js +45 -61
  12. package/dist/analytics/privacy.js +1 -1
  13. package/dist/analytics/read.js +116 -135
  14. package/dist/analytics/report.d.ts +2 -1
  15. package/dist/analytics/report.js +2 -3
  16. package/dist/analytics/settings.js +3 -4
  17. package/dist/backups/index.js +13 -16
  18. package/dist/backups/metadata.js +1 -1
  19. package/dist/config/db.js +2 -4
  20. package/dist/config/defaults/community.js +1 -0
  21. package/dist/config/defaults/core.js +13 -8
  22. package/dist/config/index.d.ts +1 -0
  23. package/dist/config/index.js +9 -11
  24. package/dist/db/explorer/query.js +9 -8
  25. package/dist/db/explorer/sql.js +8 -8
  26. package/dist/db/helpers.js +15 -5
  27. package/dist/db/migration/importCollections.js +15 -18
  28. package/dist/db/migration/shared.js +15 -35
  29. package/dist/db/pg/client.js +4 -7
  30. package/dist/db/pg/filters/index.js +1 -1
  31. package/dist/db/pg/filters/posts.d.ts +2 -0
  32. package/dist/db/pg/filters/posts.js +2 -0
  33. package/dist/db/pg/helpers.js +2 -14
  34. package/dist/db/pg/map/filters.js +8 -8
  35. package/dist/db/pg/map/helpers.js +5 -1
  36. package/dist/db/pg/map/index.js +46 -51
  37. package/dist/db/pg/map/mutations.js +56 -21
  38. package/dist/db/pg/map/registry.js +87 -50
  39. package/dist/db/pg/map/relations.js +67 -63
  40. package/dist/db/pg/map/search.js +15 -37
  41. package/dist/db/pg/mappers.js +13 -7
  42. package/dist/db/pg/migrate.js +2 -3
  43. package/dist/db/pg/queries/activity.js +2 -2
  44. package/dist/db/pg/queries/derived.js +8 -12
  45. package/dist/db/pg/schema/documents.js +119 -18
  46. package/dist/db/pg/schema/edges.js +7 -1
  47. package/dist/db/pg/schema/index.js +5 -1
  48. package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
  49. package/dist/db/pg/sql/meta/_journal.json +8 -1
  50. package/dist/db/replaceOrigin.js +1 -1
  51. package/dist/email/queueStats.js +8 -11
  52. package/dist/email/render.js +7 -4
  53. package/dist/email/send.js +19 -17
  54. package/dist/email/smtpTest.js +10 -6
  55. package/dist/errors/index.js +1 -1
  56. package/dist/events/once.js +2 -4
  57. package/dist/federation/activities.js +1 -2
  58. package/dist/groups/helpers.js +1 -2
  59. package/dist/groups/mutations.js +1 -1
  60. package/dist/hashtags/finders.js +2 -2
  61. package/dist/inviteLinks/mutations.js +2 -3
  62. package/dist/jams/export.js +5 -7
  63. package/dist/jams/finders.js +4 -1
  64. package/dist/jams/health.d.ts +6 -4
  65. package/dist/jams/health.js +15 -11
  66. package/dist/jams/helpers.js +6 -2
  67. package/dist/jams/index.js +2 -2
  68. package/dist/jams/jobs.js +1 -2
  69. package/dist/jams/livekit.js +8 -8
  70. package/dist/jams/recording.js +1 -1
  71. package/dist/jams/token.js +13 -17
  72. package/dist/jobs/index.js +7 -6
  73. package/dist/jobs/jobDetail.js +5 -6
  74. package/dist/jobs/jobLog.js +2 -3
  75. package/dist/lib/streams.js +4 -39
  76. package/dist/lib/zodDeepPartial.d.ts +1 -1
  77. package/dist/lib/zodDeepPartial.js +1 -1
  78. package/dist/log/index.js +13 -29
  79. package/dist/media/index.js +50 -4
  80. package/dist/media/jobs.js +1 -2
  81. package/dist/media/openpeeps/index.js +11 -46
  82. package/dist/media/processing.js +7 -4
  83. package/dist/media/streaming.js +5 -5
  84. package/dist/media/streamingCleanupJobs.js +1 -2
  85. package/dist/media/streamingJobs.js +3 -4
  86. package/dist/media/streamingPrewarm.js +7 -11
  87. package/dist/mediaAttachments/index.js +6 -2
  88. package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
  89. package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
  90. package/dist/notifications/defaultNotifications/follow/index.js +14 -17
  91. package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
  92. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
  93. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
  94. package/dist/notifications/defaultNotifications/jamModerator/index.js +3 -5
  95. package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
  96. package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
  97. package/dist/notifications/defaultNotifications/mention/index.js +20 -24
  98. package/dist/notifications/defaultNotifications/newGroupPost/index.js +6 -7
  99. package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
  100. package/dist/notifications/defaultNotifications/pollEnded/index.js +21 -21
  101. package/dist/notifications/defaultNotifications/pollEnded/recipients.js +2 -3
  102. package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
  103. package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
  104. package/dist/notifications/defaultNotifications/reply/index.js +21 -22
  105. package/dist/notifications/defaultNotifications/repost/index.js +16 -20
  106. package/dist/notifications/defaultNotifications/rsvp/index.js +24 -18
  107. package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +20 -13
  108. package/dist/notifications/fcmCredential.js +1 -1
  109. package/dist/notifications/finders.js +1 -1
  110. package/dist/notifications/helpers.js +13 -10
  111. package/dist/notifications/jobs.js +10 -7
  112. package/dist/notifications/mutations.js +4 -1
  113. package/dist/notifications/push.js +11 -16
  114. package/dist/performance/index.js +3 -3
  115. package/dist/plugins/helpers.js +3 -6
  116. package/dist/plugins/index.js +2 -3
  117. package/dist/plugins/install.js +31 -17
  118. package/dist/plugins/pluginAuth.js +3 -4
  119. package/dist/plugins/state.js +2 -3
  120. package/dist/posts/activity.js +1 -2
  121. package/dist/posts/contextClosure.js +1 -2
  122. package/dist/posts/conversationQueries.js +2 -4
  123. package/dist/posts/eventAgenda.js +8 -5
  124. package/dist/posts/eventOccurrences.js +2 -2
  125. package/dist/posts/finders.d.ts +42 -2
  126. package/dist/posts/finders.js +21 -9
  127. package/dist/posts/helpers/filters.js +2 -3
  128. package/dist/posts/helpers/index.d.ts +152 -0
  129. package/dist/posts/helpers/index.js +43 -27
  130. package/dist/posts/mapping.d.ts +546 -14
  131. package/dist/posts/mapping.js +60 -18
  132. package/dist/posts/mutations.d.ts +76 -0
  133. package/dist/posts/mutations.js +46 -31
  134. package/dist/posts/pollEnd.js +3 -6
  135. package/dist/posts/rsvpConfirmationEmail.js +18 -8
  136. package/dist/posts/threadPreview.js +1 -1
  137. package/dist/processingStats/queries.js +6 -7
  138. package/dist/profileSettings/cache.js +1 -2
  139. package/dist/profiles/activitySummary.js +23 -28
  140. package/dist/profiles/cache.js +15 -8
  141. package/dist/profiles/export.js +30 -39
  142. package/dist/profiles/finders.js +7 -5
  143. package/dist/profiles/mutations.js +3 -5
  144. package/dist/redis/connection.js +1 -1
  145. package/dist/reports/helpers.js +7 -3
  146. package/dist/roles/mutations.js +20 -21
  147. package/dist/search/finders.js +15 -3
  148. package/dist/search/helpers.js +1 -1
  149. package/dist/sentry/index.js +9 -11
  150. package/dist/seo/index.d.ts +50 -0
  151. package/dist/seo/index.js +145 -0
  152. package/dist/seo/route.d.ts +18 -0
  153. package/dist/seo/route.js +19 -0
  154. package/dist/server/index.d.ts +1 -0
  155. package/dist/server/index.js +16 -11
  156. package/dist/server/status.js +6 -7
  157. package/dist/session/index.js +2 -2
  158. package/dist/stats/finders.js +13 -4
  159. package/dist/stats/helpers.js +4 -1
  160. package/dist/stats/mapping.d.ts +39 -1
  161. package/dist/stats/mapping.js +9 -2
  162. package/dist/stripe/cache.js +5 -6
  163. package/dist/stripe/connection.js +3 -4
  164. package/dist/stripe/helpers.js +15 -20
  165. package/package.json +5 -6
@@ -1,23 +1,3 @@
1
- var __asyncValues = (this && this.__asyncValues) || function (o) {
2
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
3
- var m = o[Symbol.asyncIterator], i;
4
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
5
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
6
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
7
- };
8
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
9
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
10
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
11
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
12
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
13
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
14
- function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
15
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
16
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
17
- function fulfill(value) { resume("next", value); }
18
- function reject(value) { resume("throw", value); }
19
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
20
- };
21
1
  import { createHash, randomBytes } from 'node:crypto';
22
2
  import { createReadStream, createWriteStream } from 'node:fs';
23
3
  import fs from 'node:fs/promises';
@@ -48,32 +28,17 @@ const allpeepStorage = async (params) => {
48
28
  let size = 0;
49
29
  const source = Readable.fromWeb(stream);
50
30
  try {
51
- await pipeline(source, function (input) {
52
- return __asyncGenerator(this, arguments, function* () {
53
- var _a, e_1, _b, _c;
54
- try {
55
- for (var _d = true, input_1 = __asyncValues(input), input_1_1; input_1_1 = yield __await(input_1.next()), _a = input_1_1.done, !_a; _d = true) {
56
- _c = input_1_1.value;
57
- _d = false;
58
- const chunk = _c;
59
- // pipeline can yield Buffer or string depending on encoding; force
60
- // through the Buffer path so the hash and byte count are correct.
61
- const buf = chunk instanceof Buffer
62
- ? chunk
63
- : Buffer.from(chunk);
64
- hash.update(buf);
65
- size += buf.length;
66
- yield yield __await(buf);
67
- }
68
- }
69
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
70
- finally {
71
- try {
72
- if (!_d && !_a && (_b = input_1.return)) yield __await(_b.call(input_1));
73
- }
74
- finally { if (e_1) throw e_1.error; }
75
- }
76
- });
31
+ await pipeline(source, async function* (input) {
32
+ for await (const chunk of input) {
33
+ // pipeline can yield Buffer or string depending on encoding; force
34
+ // through the Buffer path so the hash and byte count are correct.
35
+ const buf = chunk instanceof Buffer
36
+ ? chunk
37
+ : Buffer.from(chunk);
38
+ hash.update(buf);
39
+ size += buf.length;
40
+ yield buf;
41
+ }
77
42
  }, createWriteStream(tempPath));
78
43
  }
79
44
  catch (err) {
@@ -16,7 +16,6 @@ export const runProcessing = async (input) => withSpan('worker.media.processing'
16
16
  mediaAttachmentId: input.mediaAttachmentId,
17
17
  });
18
18
  const runProcessingBody = async ({ mediaAttachmentId, sourceStorageKey, thumbnail, }) => {
19
- var _a, _b;
20
19
  const startedAt = Date.now();
21
20
  const attachment = await findMediaAttachment(mediaAttachmentId);
22
21
  if (!attachment) {
@@ -24,7 +23,7 @@ const runProcessingBody = async ({ mediaAttachmentId, sourceStorageKey, thumbnai
24
23
  }
25
24
  const filetype = attachment.type;
26
25
  const originalName = attachment.filename;
27
- const sourceMimetype = (_a = attachment.meta.mimetype) !== null && _a !== void 0 ? _a : '';
26
+ const sourceMimetype = attachment.meta.mimetype ?? '';
28
27
  const temps = new Set();
29
28
  try {
30
29
  const storage = await mediaStorage();
@@ -66,14 +65,18 @@ const runProcessingBody = async ({ mediaAttachmentId, sourceStorageKey, thumbnai
66
65
  const updated = await updateMediaAttachment(mediaAttachmentId, {
67
66
  url,
68
67
  previewUrl,
69
- meta: Object.assign(Object.assign({}, attachment.meta), { mimetype: transcoded.mimetype, size: storedSize }),
68
+ meta: {
69
+ ...attachment.meta,
70
+ mimetype: transcoded.mimetype,
71
+ size: storedSize,
72
+ },
70
73
  status: 'ready',
71
74
  error: undefined,
72
75
  });
73
76
  const durationMs = Date.now() - startedAt;
74
77
  await recordProcessingStats({
75
78
  mediaAttachmentId,
76
- filesize: (_b = attachment.meta.size) !== null && _b !== void 0 ? _b : storedSize,
79
+ filesize: attachment.meta.size ?? storedSize,
77
80
  filetype,
78
81
  durationMs,
79
82
  }).catch((e) => log.error('Failed to record processing stats', e));
@@ -13,7 +13,7 @@ const STREAM_ACCESS_KEY = 'media:streaming:lastAccess';
13
13
  // segments and we don't need to hammer Redis with a write for each. The
14
14
  // debounce is per-process; multiple app/worker processes will each issue at
15
15
  // most one write per window which is still fine.
16
- const ACCESS_WRITE_DEBOUNCE_MS = 60000;
16
+ const ACCESS_WRITE_DEBOUNCE_MS = 60_000;
17
17
  const lastAccessWriteCache = new Map();
18
18
  const getStorageParams = async () => (await config()).media.storage.params;
19
19
  const getHlsRoot = async () => {
@@ -47,7 +47,7 @@ export const parseLocalStorageUrl = async (rawUrl) => {
47
47
  try {
48
48
  url = new URL(rawUrl);
49
49
  }
50
- catch (_a) {
50
+ catch {
51
51
  return null;
52
52
  }
53
53
  const rootUrl = await serverRootUrl();
@@ -115,7 +115,7 @@ export const getStreamStatus = async (storageId) => {
115
115
  return null;
116
116
  }
117
117
  }
118
- catch (_a) {
118
+ catch {
119
119
  return null;
120
120
  }
121
121
  const errorsPath = join(streamDir, HLS_ERRORS_LOG);
@@ -140,7 +140,7 @@ export const buildStream = async (storageId) => {
140
140
  if (!status) {
141
141
  return null;
142
142
  }
143
- return Object.assign({ storageId }, status);
143
+ return { storageId, ...status };
144
144
  };
145
145
  export const ensureStreamDir = async (storageId) => {
146
146
  const streamDir = await getStreamDir(storageId);
@@ -225,7 +225,7 @@ export const cleanupStaleStreams = async (maxAgeMs) => {
225
225
  try {
226
226
  stat = await fs.stat(fullPath);
227
227
  }
228
- catch (_a) {
228
+ catch {
229
229
  continue;
230
230
  }
231
231
  if (!stat.isDirectory())
@@ -10,8 +10,7 @@ export const STREAM_CLEANUP_CRON = '0 3 * * *';
10
10
  const SCHEDULER_ID = 'streaming-cleanup-daily';
11
11
  const JOB_NAME = 'cleanup';
12
12
  const [mediaStreamingCleanupQueue, mediaStreamingCleanupWorker] = queueAndWorker('media-streaming-cleanup', async (job) => {
13
- var _a;
14
- const maxAgeMs = (_a = job.data.maxAgeMs) !== null && _a !== void 0 ? _a : STREAM_INACTIVITY_TTL_MS;
13
+ const maxAgeMs = job.data.maxAgeMs ?? STREAM_INACTIVITY_TTL_MS;
15
14
  log.info(`Running stream cleanup (maxAgeMs=${maxAgeMs}, ~${Math.round(maxAgeMs / DAY_MS)}d)`);
16
15
  const result = await cleanupStaleStreams(maxAgeMs);
17
16
  log.info(`Stream cleanup done: deleted=${result.deleted.length}, ` +
@@ -45,7 +45,6 @@ const SOURCE_BITRATE_FALLBACK_KBPS = {
45
45
  };
46
46
  const probeSource = (inputPath) => new Promise((resolve, reject) => {
47
47
  ffmpeg.ffprobe(inputPath, (err, metadata) => {
48
- var _a, _b;
49
48
  if (err) {
50
49
  reject(err);
51
50
  return;
@@ -72,10 +71,10 @@ const probeSource = (inputPath) => new Promise((resolve, reject) => {
72
71
  }
73
72
  if (!videoBitrateKbps) {
74
73
  const shorter = Math.min(video.width, video.height);
75
- const fallback = (_b = (_a = Object.entries(SOURCE_BITRATE_FALLBACK_KBPS)
74
+ const fallback = Object.entries(SOURCE_BITRATE_FALLBACK_KBPS)
76
75
  .map(([s, kbps]) => ({ s: Number(s), kbps }))
77
76
  .filter(({ s }) => s <= shorter)
78
- .sort((a, b) => b.s - a.s)[0]) === null || _a === void 0 ? void 0 : _a.kbps) !== null && _b !== void 0 ? _b : 500;
77
+ .sort((a, b) => b.s - a.s)[0]?.kbps ?? 500;
79
78
  videoBitrateKbps = fallback;
80
79
  }
81
80
  resolve({
@@ -246,7 +245,7 @@ const runHls = async (inputPath, streamDir, source, variants) => {
246
245
  // Conversion failed!" — the actual diagnostic is in stderr. We attach
247
246
  // the last ~40 lines so the worker log (and errors.log) show what
248
247
  // ffmpeg actually complained about instead of a useless exit code.
249
- const tail = String(stderr !== null && stderr !== void 0 ? stderr : '')
248
+ const tail = String(stderr ?? '')
250
249
  .trim()
251
250
  .split(/\r?\n/)
252
251
  .slice(-40)
@@ -18,14 +18,13 @@ const log = logger('app:media:streamingPrewarm');
18
18
  * being created right now?" semantics.
19
19
  */
20
20
  export const ensureStreamingJob = async (storageId) => {
21
- var _a;
22
21
  // Refresh the last-access marker so the daily cleanup job doesn't evict a
23
22
  // stream that someone just expressed interest in. Fire-and-forget and
24
23
  // debounced; safe to call from many sites.
25
24
  void recordStreamAccess(storageId);
26
25
  const existing = await getStreamStatus(storageId);
27
26
  if (existing) {
28
- return Object.assign({ storageId }, existing);
27
+ return { storageId, ...existing };
29
28
  }
30
29
  // Create the directory before enqueueing so any subsequent caller hitting
31
30
  // this code path immediately observes `processing` via `getStreamStatus`
@@ -42,7 +41,7 @@ export const ensureStreamingJob = async (storageId) => {
42
41
  // next POST will report it as `processing`.
43
42
  await queue.remove(jobId).catch(() => undefined);
44
43
  await queue.add('transcode', { storageId }, { jobId });
45
- return (_a = (await buildStream(storageId))) !== null && _a !== void 0 ? _a : { storageId, status: 'processing' };
44
+ return (await buildStream(storageId)) ?? { storageId, status: 'processing' };
46
45
  };
47
46
  /**
48
47
  * Pre-warms HLS streams for any local-storage-hosted videos in the given
@@ -50,7 +49,6 @@ export const ensureStreamingJob = async (storageId) => {
50
49
  * skipped.
51
50
  */
52
51
  const prewarmVideoAttachments = async (attachments, context) => {
53
- var _a;
54
52
  for (const attachment of attachments) {
55
53
  if (!attachment || attachment.type !== 'video' || !attachment.url) {
56
54
  continue;
@@ -66,7 +64,7 @@ const prewarmVideoAttachments = async (attachments, context) => {
66
64
  }
67
65
  catch (e) {
68
66
  // A single bad attachment shouldn't block prewarming siblings.
69
- log.warn(`Failed to prewarm HLS for ${context} attachment ${(_a = attachment.url) !== null && _a !== void 0 ? _a : '?'}: ${e.message}`);
67
+ log.warn(`Failed to prewarm HLS for ${context} attachment ${attachment.url ?? '?'}: ${e.message}`);
70
68
  }
71
69
  }
72
70
  };
@@ -76,12 +74,11 @@ const prewarmVideoAttachments = async (attachments, context) => {
76
74
  * play them the transcoded ladder is already (or nearly) ready.
77
75
  */
78
76
  export const prewarmPostStreams = async (rawPost) => {
79
- var _a, _b;
80
77
  const post = rawPost;
81
- const attachments = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.attachments;
78
+ const attachments = post?.data?.attachments;
82
79
  if (!attachments || attachments.length === 0)
83
80
  return;
84
- await prewarmVideoAttachments(attachments, `post ${(_b = post === null || post === void 0 ? void 0 : post.id) !== null && _b !== void 0 ? _b : '?'}`);
81
+ await prewarmVideoAttachments(attachments, `post ${post?.id ?? '?'}`);
85
82
  };
86
83
  /**
87
84
  * Pre-warms HLS for a completed jam recording's video attachment as soon as
@@ -89,12 +86,11 @@ export const prewarmPostStreams = async (rawPost) => {
89
86
  * recording post.
90
87
  */
91
88
  export const prewarmJamRecordingStream = async (rawRecording) => {
92
- var _a;
93
89
  const recording = rawRecording;
94
- const attachment = recording === null || recording === void 0 ? void 0 : recording.attachment;
90
+ const attachment = recording?.attachment;
95
91
  if (!attachment)
96
92
  return;
97
- await prewarmVideoAttachments([attachment], `jam recording ${(_a = recording === null || recording === void 0 ? void 0 : recording.id) !== null && _a !== void 0 ? _a : '?'}`);
93
+ await prewarmVideoAttachments([attachment], `jam recording ${recording?.id ?? '?'}`);
98
94
  };
99
95
  /**
100
96
  * Registers event handlers that pre-warm HLS streams for post videos and
@@ -7,6 +7,10 @@ const setUrlToCurrentHost = async (url) => {
7
7
  parsedUrl.host = (await config()).server.host;
8
8
  return parsedUrl.toString();
9
9
  };
10
- export const convertUrls = async (data) => (Object.assign(Object.assign({}, data), { url: await setUrlToCurrentHost(data.url), previewUrl: data.previewUrl
10
+ export const convertUrls = async (data) => ({
11
+ ...data,
12
+ url: await setUrlToCurrentHost(data.url),
13
+ previewUrl: data.previewUrl
11
14
  ? await setUrlToCurrentHost(data.previewUrl)
12
- : null }));
15
+ : null,
16
+ });
@@ -7,7 +7,7 @@ import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
7
7
  const eventHandler = async (data) => {
8
8
  const post = data;
9
9
  for (const recipientProfile of await listProfiles()) {
10
- if (post.profile.id !== (recipientProfile === null || recipientProfile === void 0 ? void 0 : recipientProfile.id)) {
10
+ if (post.profile.id !== recipientProfile?.id) {
11
11
  await maybeCreateNotification(recipientProfile, {
12
12
  type: 'announcement',
13
13
  postId: post.id,
@@ -16,23 +16,20 @@ const eventHandler = async (data) => {
16
16
  }
17
17
  }
18
18
  };
19
- const pushRenderer = async (notification) => {
20
- var _a, _b, _c, _d;
21
- return ({
22
- title: `${profileName((_a = notification.post) === null || _a === void 0 ? void 0 : _a.profile)} posted an announcement`,
23
- options: {
24
- body: (_c = (_b = notification.post) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.content,
25
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
26
- actions: [
27
- {
28
- action: `goto:/posts/${(_d = notification.post) === null || _d === void 0 ? void 0 : _d.id}`,
29
- title: 'Go to announcement',
30
- },
31
- ],
32
- },
33
- invalidateQueries: [PUSH_INVALIDATE.posts],
34
- });
35
- };
19
+ const pushRenderer = async (notification) => ({
20
+ title: `${profileName(notification.post?.profile)} posted an announcement`,
21
+ options: {
22
+ body: notification.post?.data?.content,
23
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
24
+ actions: [
25
+ {
26
+ action: `goto:/posts/${notification.post?.id}`,
27
+ title: 'Go to announcement',
28
+ },
29
+ ],
30
+ },
31
+ invalidateQueries: [PUSH_INVALIDATE.posts],
32
+ });
36
33
  export default {
37
34
  type: 'announcement',
38
35
  event: 'postAnnounced',
@@ -5,9 +5,8 @@ import { getConversationByEnd } from '@openpeepshq/core/posts';
5
5
  import { communityConfig } from '../../../config/index.js';
6
6
  import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
7
7
  const eventHandler = async (data) => {
8
- var _a;
9
8
  const post = data;
10
- if (((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) === 'event')
9
+ if (post.data?.type === 'event')
11
10
  return;
12
11
  if (post.visibility === 'direct' && post.audience) {
13
12
  for (const recipientProfile of post.audience) {
@@ -22,12 +21,11 @@ const eventHandler = async (data) => {
22
21
  }
23
22
  };
24
23
  const pushRenderer = async (notification) => {
25
- var _a, _b, _c;
26
- const path = `/conversations/${(_a = notification.data.conversationStart) === null || _a === void 0 ? void 0 : _a.id}`;
24
+ const path = `/conversations/${notification.data.conversationStart?.id}`;
27
25
  return {
28
26
  title: `${profileName(notification.senderProfile)} sent you a direct message`,
29
27
  options: {
30
- body: (_c = (_b = notification.post) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.content,
28
+ body: notification.post?.data?.content,
31
29
  icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
32
30
  data: {
33
31
  url: path,
@@ -47,17 +45,20 @@ const pushRenderer = async (notification) => {
47
45
  };
48
46
  const expander = async (notification) => {
49
47
  const { post, recipientProfile } = notification;
50
- const previousPost = post === null || post === void 0 ? void 0 : post.replyTo;
48
+ const previousPost = post?.replyTo;
51
49
  const conversationStart = post &&
52
50
  recipientProfile &&
53
51
  (await getConversationByEnd(post, {
54
52
  profile: recipientProfile,
55
53
  scopes: [],
56
54
  }))[0];
57
- return Object.assign(Object.assign({}, notification), { data: {
55
+ return {
56
+ ...notification,
57
+ data: {
58
58
  conversationStart,
59
59
  previousPost,
60
- } });
60
+ },
61
+ };
61
62
  };
62
63
  export default {
63
64
  type: 'directMessage',
@@ -11,21 +11,18 @@ export default {
11
11
  type: 'follow',
12
12
  fromProfileId: follower.id,
13
13
  }),
14
- pushRenderer: async (notification) => {
15
- var _a, _b;
16
- return ({
17
- title: `${profileName(notification.senderProfile)} followed you`,
18
- options: {
19
- body: truncateText(markdownPlainText((_a = notification.senderProfile) === null || _a === void 0 ? void 0 : _a.bio)),
20
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
21
- actions: [
22
- {
23
- action: `goto:/@${(_b = notification.senderProfile) === null || _b === void 0 ? void 0 : _b.handle}`,
24
- title: 'View Profile',
25
- },
26
- ],
27
- },
28
- invalidateQueries: [PUSH_INVALIDATE.profiles],
29
- });
30
- },
14
+ pushRenderer: async (notification) => ({
15
+ title: `${profileName(notification.senderProfile)} followed you`,
16
+ options: {
17
+ body: truncateText(markdownPlainText(notification.senderProfile?.bio)),
18
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
19
+ actions: [
20
+ {
21
+ action: `goto:/@${notification.senderProfile?.handle}`,
22
+ title: 'View Profile',
23
+ },
24
+ ],
25
+ },
26
+ invalidateQueries: [PUSH_INVALIDATE.profiles],
27
+ }),
31
28
  };
@@ -13,21 +13,18 @@ export default {
13
13
  groupId: group.id,
14
14
  });
15
15
  },
16
- pushRenderer: async (notification) => {
17
- var _a;
18
- return ({
19
- title: `You've been added to ${groupName(notification.group)}`,
20
- options: {
21
- body: 'Welcome to the group!',
22
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
23
- actions: [
24
- {
25
- action: `goto:/groups/@${(_a = notification.group) === null || _a === void 0 ? void 0 : _a.handle}`,
26
- title: 'View Group',
27
- },
28
- ],
29
- },
30
- invalidateQueries: [PUSH_INVALIDATE.groups],
31
- });
32
- },
16
+ pushRenderer: async (notification) => ({
17
+ title: `You've been added to ${groupName(notification.group)}`,
18
+ options: {
19
+ body: 'Welcome to the group!',
20
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
21
+ actions: [
22
+ {
23
+ action: `goto:/groups/@${notification.group?.handle}`,
24
+ title: 'View Group',
25
+ },
26
+ ],
27
+ },
28
+ invalidateQueries: [PUSH_INVALIDATE.groups],
29
+ }),
33
30
  };
@@ -9,7 +9,7 @@ export default {
9
9
  eventHandler: async (...args) => {
10
10
  const [group, profile] = args;
11
11
  for (const groupAdmin of await listGroupMembers(group).then((members) => members
12
- .filter((m) => { var _a, _b; return ((_a = m.roles) === null || _a === void 0 ? void 0 : _a.includes('owner')) || ((_b = m.roles) === null || _b === void 0 ? void 0 : _b.includes('admin')); })
12
+ .filter((m) => m.roles?.includes('owner') || m.roles?.includes('admin'))
13
13
  .map((m) => m.profile))) {
14
14
  await maybeCreateNotification(groupAdmin, {
15
15
  type: 'groupMemberJoined',
@@ -18,21 +18,18 @@ export default {
18
18
  });
19
19
  }
20
20
  },
21
- pushRenderer: async (notification) => {
22
- var _a;
23
- return ({
24
- title: `New member ${profileName(notification.senderProfile)} joined ${groupName(notification.group)}`,
25
- options: {
26
- body: "Let's welcome them!",
27
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
28
- actions: [
29
- {
30
- action: `goto:/@${(_a = notification.senderProfile) === null || _a === void 0 ? void 0 : _a.handle}`,
31
- title: 'View Profile',
32
- },
33
- ],
34
- },
35
- invalidateQueries: [PUSH_INVALIDATE.groups],
36
- });
37
- },
21
+ pushRenderer: async (notification) => ({
22
+ title: `New member ${profileName(notification.senderProfile)} joined ${groupName(notification.group)}`,
23
+ options: {
24
+ body: "Let's welcome them!",
25
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
26
+ actions: [
27
+ {
28
+ action: `goto:/@${notification.senderProfile?.handle}`,
29
+ title: 'View Profile',
30
+ },
31
+ ],
32
+ },
33
+ invalidateQueries: [PUSH_INVALIDATE.groups],
34
+ }),
38
35
  };
@@ -9,7 +9,7 @@ export default {
9
9
  eventHandler: async (...args) => {
10
10
  const [group, profile] = args;
11
11
  for (const groupAdmin of await listGroupMembers(group).then((members) => members
12
- .filter((m) => { var _a, _b; return ((_a = m.roles) === null || _a === void 0 ? void 0 : _a.includes('owner')) || ((_b = m.roles) === null || _b === void 0 ? void 0 : _b.includes('admin')); })
12
+ .filter((m) => m.roles?.includes('owner') || m.roles?.includes('admin'))
13
13
  .map((m) => m.profile))) {
14
14
  await maybeCreateNotification(groupAdmin, {
15
15
  type: 'groupMemberLeft',
@@ -18,21 +18,18 @@ export default {
18
18
  });
19
19
  }
20
20
  },
21
- pushRenderer: async (notification) => {
22
- var _a;
23
- return ({
24
- title: `Group member ${profileName(notification.senderProfile)} exited ${groupName(notification.group)}`,
25
- options: {
26
- body: "They're no longer a member of the group.",
27
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
28
- actions: [
29
- {
30
- action: `goto:/groups/@${(_a = notification.group) === null || _a === void 0 ? void 0 : _a.handle}`,
31
- title: 'View Group',
32
- },
33
- ],
34
- },
35
- invalidateQueries: [PUSH_INVALIDATE.groups],
36
- });
37
- },
21
+ pushRenderer: async (notification) => ({
22
+ title: `Group member ${profileName(notification.senderProfile)} exited ${groupName(notification.group)}`,
23
+ options: {
24
+ body: "They're no longer a member of the group.",
25
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
26
+ actions: [
27
+ {
28
+ action: `goto:/groups/@${notification.group?.handle}`,
29
+ title: 'View Group',
30
+ },
31
+ ],
32
+ },
33
+ invalidateQueries: [PUSH_INVALIDATE.groups],
34
+ }),
38
35
  };
@@ -5,9 +5,8 @@ import { profileName } from '@openpeepshq/common/lib';
5
5
  import { initI18nEmailContext } from '../../../i18n/index.js';
6
6
  import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
7
7
  const eventHandler = async (eventData) => {
8
- var _a, _b;
9
8
  const post = eventData;
10
- const jam = ((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' && ((_b = post.data) === null || _b === void 0 ? void 0 : _b.jam);
9
+ const jam = post.data?.type === 'event' && post.data?.jam;
11
10
  if (!jam) {
12
11
  return;
13
12
  }
@@ -24,15 +23,14 @@ const eventHandler = async (eventData) => {
24
23
  }
25
24
  };
26
25
  const pushRenderer = async (notification) => {
27
- var _a, _b;
28
26
  const { t } = await initI18nEmailContext();
29
27
  return {
30
28
  title: `${profileName(notification.senderProfile)} invited you to moderate a jam`,
31
29
  options: {
32
- body: ((_a = notification.post) === null || _a === void 0 ? void 0 : _a.data).name,
30
+ body: (notification.post?.data).name,
33
31
  actions: [
34
32
  {
35
- action: `goto:/posts/${(_b = notification.post) === null || _b === void 0 ? void 0 : _b.id}`,
33
+ action: `goto:/posts/${notification.post?.id}`,
36
34
  title: t('emails.jamModerator.cta'),
37
35
  },
38
36
  ],
@@ -4,9 +4,8 @@ import { maybeCreateNotification } from '@openpeepshq/core/notifications';
4
4
  import { profileName } from '@openpeepshq/common/lib';
5
5
  import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
6
6
  const eventHandler = async (eventData) => {
7
- var _a, _b;
8
7
  const post = eventData;
9
- const jam = ((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' && ((_b = post.data) === null || _b === void 0 ? void 0 : _b.jam);
8
+ const jam = post.data?.type === 'event' && post.data?.jam;
10
9
  if (!jam) {
11
10
  return;
12
11
  }
@@ -22,22 +21,19 @@ const eventHandler = async (eventData) => {
22
21
  }
23
22
  }
24
23
  };
25
- const pushRenderer = async (notification) => {
26
- var _a, _b;
27
- return ({
28
- title: `${profileName(notification.senderProfile)} invited you to speak at a jam`,
29
- options: {
30
- body: ((_a = notification.post) === null || _a === void 0 ? void 0 : _a.data).name,
31
- actions: [
32
- {
33
- action: `goto:/events/${(_b = notification.post) === null || _b === void 0 ? void 0 : _b.id}/jam`,
34
- title: 'Join Jam',
35
- },
36
- ],
37
- },
38
- invalidateQueries: [PUSH_INVALIDATE.posts],
39
- });
40
- };
24
+ const pushRenderer = async (notification) => ({
25
+ title: `${profileName(notification.senderProfile)} invited you to speak at a jam`,
26
+ options: {
27
+ body: (notification.post?.data).name,
28
+ actions: [
29
+ {
30
+ action: `goto:/events/${notification.post?.id}/jam`,
31
+ title: 'Join Jam',
32
+ },
33
+ ],
34
+ },
35
+ invalidateQueries: [PUSH_INVALIDATE.posts],
36
+ });
41
37
  export default {
42
38
  event: 'postCreated',
43
39
  type: 'jamSpeaker',