@openpeepshq/core 0.1.32 → 0.1.34

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 (261) hide show
  1. package/dist/accessTokens/helpers.d.ts +2 -2
  2. package/dist/accessTokens/tokens.js +14 -7
  3. package/dist/accounts/mutations.d.ts +2 -2
  4. package/dist/accounts/mutations.js +33 -35
  5. package/dist/analytics/cache.js +12 -7
  6. package/dist/analytics/compile.js +16 -10
  7. package/dist/analytics/pdfReport.d.ts +1 -0
  8. package/dist/analytics/pdfReport.js +5 -4
  9. package/dist/analytics/privacy.d.ts +18 -0
  10. package/dist/analytics/privacy.js +10 -0
  11. package/dist/analytics/read.js +75 -19
  12. package/dist/analytics/report.d.ts +21 -1
  13. package/dist/analytics/report.js +9 -2
  14. package/dist/backups/index.js +78 -15
  15. package/dist/backups/metadata.d.ts +8 -2
  16. package/dist/backups/metadata.js +6 -2
  17. package/dist/config/defaults/capabilities.js +13 -2
  18. package/dist/config/defaults/community.js +7 -9
  19. package/dist/config/defaults/core.d.ts +1 -1
  20. package/dist/config/defaults/core.js +3 -0
  21. package/dist/config/defaults/db.d.ts +0 -2
  22. package/dist/config/defaults/db.js +0 -2
  23. package/dist/config/index.d.ts +25 -3
  24. package/dist/config/index.js +7 -1
  25. package/dist/db/helpers.d.ts +7 -28
  26. package/dist/db/helpers.js +30 -152
  27. package/dist/db/index.d.ts +3 -1
  28. package/dist/db/index.js +5 -0
  29. package/dist/db/init.js +2 -2
  30. package/dist/db/migration/importCollections.d.ts +15 -10
  31. package/dist/db/migration/importCollections.js +121 -155
  32. package/dist/db/migration/shared.d.ts +2 -37
  33. package/dist/db/migration/shared.js +2 -59
  34. package/dist/db/pg/client.js +4 -0
  35. package/dist/db/pg/collections.d.ts +2 -2
  36. package/dist/db/pg/collections.js +2 -2
  37. package/dist/db/pg/filters/edges.d.ts +1 -1
  38. package/dist/db/pg/filters/edges.js +1 -1
  39. package/dist/db/pg/filters/posts.d.ts +11 -0
  40. package/dist/db/pg/filters/posts.js +37 -3
  41. package/dist/db/pg/filters/profiles.d.ts +1 -0
  42. package/dist/db/pg/filters/profiles.js +2 -1
  43. package/dist/db/pg/map/filters.js +37 -2
  44. package/dist/db/pg/map/mutations.js +13 -8
  45. package/dist/db/pg/map/registry.d.ts +5 -0
  46. package/dist/db/pg/map/registry.js +64 -24
  47. package/dist/db/pg/map/relations.d.ts +1 -1
  48. package/dist/db/pg/map/relations.js +98 -46
  49. package/dist/db/pg/migrate.d.ts +22 -0
  50. package/dist/db/pg/migrate.js +88 -2
  51. package/dist/db/pg/queries/activity.js +3 -3
  52. package/dist/db/pg/queries/sorts.d.ts +1 -0
  53. package/dist/db/pg/queries/sorts.js +4 -0
  54. package/dist/db/pg/schema/documents.d.ts +422 -41
  55. package/dist/db/pg/schema/documents.js +43 -9
  56. package/dist/db/pg/schema/edges.d.ts +117 -7
  57. package/dist/db/pg/schema/edges.js +4 -2
  58. package/dist/db/pg/schema/index.d.ts +505 -15
  59. package/dist/db/pg/sql/0007_shallow_oracle.sql +3 -0
  60. package/dist/db/pg/sql/0008_group_owner_roles.sql +31 -0
  61. package/dist/db/pg/sql/0009_event_occurrences.sql +26 -0
  62. package/dist/db/pg/sql/0010_user_group_membership_roles.sql +16 -0
  63. package/dist/db/pg/sql/0011_drop_data_migrations.sql +1 -0
  64. package/dist/db/pg/sql/0012_posts_last_activity_at.sql +5 -0
  65. package/dist/db/pg/sql/0013_add_blocks_edge.sql +12 -0
  66. package/dist/db/pg/sql/0014_federation_datamodel.sql +59 -0
  67. package/dist/db/pg/sql/0015_profile_hashtags.sql +12 -0
  68. package/dist/db/pg/sql/meta/{0006_snapshot.json → 0015_snapshot.json} +393 -39
  69. package/dist/db/pg/sql/meta/_journal.json +64 -1
  70. package/dist/db/replaceOrigin.js +6 -0
  71. package/dist/db/types.d.ts +0 -4
  72. package/dist/email/render.js +11 -3
  73. package/dist/events/index.d.ts +6 -1
  74. package/dist/events/index.js +55 -33
  75. package/dist/federation/activities.d.ts +17 -0
  76. package/dist/federation/activities.js +26 -0
  77. package/dist/federation/identity.d.ts +16 -0
  78. package/dist/federation/identity.js +52 -0
  79. package/dist/federation/index.d.ts +4 -0
  80. package/dist/federation/index.js +3 -0
  81. package/dist/federation/profiles.d.ts +3 -0
  82. package/dist/federation/profiles.js +14 -0
  83. package/dist/groups/finders.d.ts +3 -2
  84. package/dist/groups/helpers.d.ts +24 -6
  85. package/dist/groups/mapping.d.ts +6 -4
  86. package/dist/groups/mapping.js +2 -2
  87. package/dist/groups/mutations.js +1 -1
  88. package/dist/hashtags/finders.d.ts +6 -3
  89. package/dist/hashtags/finders.js +2 -0
  90. package/dist/hashtags/helpers.d.ts +8 -0
  91. package/dist/hashtags/helpers.js +4 -0
  92. package/dist/hashtags/index.d.ts +2 -0
  93. package/dist/hashtags/index.js +2 -0
  94. package/dist/hashtags/mutations.d.ts +3 -0
  95. package/dist/hashtags/mutations.js +13 -1
  96. package/dist/i18n/index.d.ts +1 -1
  97. package/dist/i18n/index.js +3 -1
  98. package/dist/i18n/pluginLocales.d.ts +6 -0
  99. package/dist/i18n/pluginLocales.js +15 -0
  100. package/dist/inviteLinks/helpers.d.ts +4 -4
  101. package/dist/jams/cache.d.ts +1 -1
  102. package/dist/jams/cache.js +2 -1
  103. package/dist/jams/export.d.ts +19 -0
  104. package/dist/jams/export.js +60 -0
  105. package/dist/jams/finders.d.ts +2 -1
  106. package/dist/jams/finders.js +18 -7
  107. package/dist/jams/health.d.ts +8 -0
  108. package/dist/jams/health.js +46 -0
  109. package/dist/jams/helpers.d.ts +6 -2
  110. package/dist/jams/index.d.ts +6 -3
  111. package/dist/jams/index.js +41 -27
  112. package/dist/jams/jobs.js +1 -1
  113. package/dist/jams/livekit.d.ts +93 -10
  114. package/dist/jams/livekit.js +151 -52
  115. package/dist/jams/mapping.d.ts +17 -7
  116. package/dist/jams/mutations.d.ts +3 -1
  117. package/dist/jams/recording.d.ts +10 -0
  118. package/dist/jams/recording.js +32 -0
  119. package/dist/jams/rtmp.d.ts +5 -0
  120. package/dist/jams/rtmp.js +8 -0
  121. package/dist/jams/token.d.ts +15 -3
  122. package/dist/jams/token.js +30 -16
  123. package/dist/jams/waitingRoom.d.ts +6 -6
  124. package/dist/jams/waitingRoom.js +24 -23
  125. package/dist/jobs/index.d.ts +1 -0
  126. package/dist/jobs/index.js +6 -1
  127. package/dist/jobs/jobDetail.js +1 -6
  128. package/dist/media/index.d.ts +1 -1
  129. package/dist/media/index.js +23 -8
  130. package/dist/media/processing.js +18 -7
  131. package/dist/notifications/defaultNotifications/follow/index.js +2 -2
  132. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +3 -1
  133. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +3 -1
  134. package/dist/notifications/defaultNotifications/index.js +4 -0
  135. package/dist/notifications/defaultNotifications/newGroupPost/index.js +12 -6
  136. package/dist/notifications/defaultNotifications/pollEnded/index.d.ts +19 -0
  137. package/dist/notifications/defaultNotifications/pollEnded/index.js +39 -0
  138. package/dist/notifications/defaultNotifications/pollEnded/recipients.d.ts +3 -0
  139. package/dist/notifications/defaultNotifications/pollEnded/recipients.js +18 -0
  140. package/dist/notifications/defaultNotifications/rsvp/index.d.ts +6 -1
  141. package/dist/notifications/defaultNotifications/rsvp/index.js +7 -0
  142. package/dist/notifications/defaultNotifications/rsvpCanceled/index.d.ts +24 -0
  143. package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +75 -0
  144. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.d.ts +4 -0
  145. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.js +11 -0
  146. package/dist/notifications/helpers.js +6 -2
  147. package/dist/notifications/jobs.js +3 -1
  148. package/dist/notifications/mutations.js +4 -0
  149. package/dist/notifications/push.js +11 -4
  150. package/dist/plugins/helpers.d.ts +1 -0
  151. package/dist/plugins/helpers.js +1 -8
  152. package/dist/plugins/index.d.ts +5 -0
  153. package/dist/plugins/index.js +78 -5
  154. package/dist/plugins/install.d.ts +39 -0
  155. package/dist/plugins/install.js +455 -0
  156. package/dist/plugins/pluginAuth.d.ts +1 -1
  157. package/dist/plugins/pluginAuth.js +10 -6
  158. package/dist/plugins/state.d.ts +4 -0
  159. package/dist/plugins/state.js +29 -0
  160. package/dist/posts/activity.d.ts +9 -0
  161. package/dist/posts/activity.js +35 -0
  162. package/dist/posts/contextClosure.d.ts +1 -9
  163. package/dist/posts/contextClosure.js +15 -44
  164. package/dist/posts/conversationQueries.d.ts +7 -0
  165. package/dist/posts/conversationQueries.js +76 -2
  166. package/dist/posts/eventAgenda.d.ts +166 -0
  167. package/dist/posts/eventAgenda.js +126 -0
  168. package/dist/posts/eventOccurrenceJobs.d.ts +4 -0
  169. package/dist/posts/eventOccurrenceJobs.js +28 -0
  170. package/dist/posts/eventOccurrences.d.ts +10 -0
  171. package/dist/posts/eventOccurrences.js +61 -0
  172. package/dist/posts/finders.d.ts +47 -16
  173. package/dist/posts/finders.js +93 -62
  174. package/dist/posts/helpers/filters.js +14 -9
  175. package/dist/posts/helpers/index.d.ts +129 -30
  176. package/dist/posts/helpers/index.js +66 -33
  177. package/dist/posts/index.d.ts +7 -1
  178. package/dist/posts/index.js +7 -1
  179. package/dist/posts/mapping.d.ts +491 -13
  180. package/dist/posts/mapping.js +45 -10
  181. package/dist/posts/mutations.d.ts +441 -4
  182. package/dist/posts/mutations.js +177 -43
  183. package/dist/posts/pollEnd.d.ts +3 -0
  184. package/dist/posts/pollEnd.js +7 -0
  185. package/dist/posts/pollEndJobs.d.ts +8 -0
  186. package/dist/posts/pollEndJobs.js +49 -0
  187. package/dist/posts/replyClosure.d.ts +10 -0
  188. package/dist/posts/replyClosure.js +43 -0
  189. package/dist/posts/rsvpConfirmationEmail.js +14 -15
  190. package/dist/posts/threadPreview.d.ts +8 -0
  191. package/dist/posts/threadPreview.js +44 -0
  192. package/dist/posts/unseenCounts.d.ts +2 -0
  193. package/dist/posts/unseenCounts.js +28 -8
  194. package/dist/profileSettings/cache.js +22 -5
  195. package/dist/profileSettings/mapping.d.ts +2 -0
  196. package/dist/profiles/activityQueries.d.ts +5 -0
  197. package/dist/profiles/activityQueries.js +85 -0
  198. package/dist/profiles/activitySummary.d.ts +3 -0
  199. package/dist/profiles/activitySummary.js +87 -0
  200. package/dist/profiles/blocks.d.ts +12 -0
  201. package/dist/profiles/blocks.js +73 -0
  202. package/dist/profiles/cache.d.ts +4 -1
  203. package/dist/profiles/cache.js +28 -7
  204. package/dist/profiles/finders.d.ts +2 -1
  205. package/dist/profiles/finders.js +8 -3
  206. package/dist/profiles/helpers.d.ts +7 -5
  207. package/dist/profiles/index.d.ts +3 -1
  208. package/dist/profiles/index.js +3 -1
  209. package/dist/profiles/mapping.d.ts +10 -5
  210. package/dist/profiles/mapping.js +13 -1
  211. package/dist/profiles/mutations.d.ts +8 -4
  212. package/dist/profiles/mutations.js +42 -15
  213. package/dist/pushSubscriptions/helpers.d.ts +2 -2
  214. package/dist/pushSubscriptions/mutations.js +13 -1
  215. package/dist/redis/connection.d.ts +2 -0
  216. package/dist/redis/connection.js +25 -6
  217. package/dist/reports/helpers.d.ts +6 -6
  218. package/dist/roles/index.d.ts +1 -1
  219. package/dist/roles/index.js +1 -1
  220. package/dist/roles/mapping.d.ts +1 -0
  221. package/dist/roles/mutations.js +86 -3
  222. package/dist/search/mapping.d.ts +1 -1
  223. package/dist/search/mapping.js +6 -2
  224. package/dist/server/index.d.ts +19 -1
  225. package/dist/server/index.js +37 -18
  226. package/dist/server/stablePublicServerInfo.d.ts +17 -0
  227. package/dist/server/stablePublicServerInfo.js +37 -0
  228. package/dist/server/status.d.ts +25 -0
  229. package/dist/server/status.js +98 -0
  230. package/dist/stats/finders.d.ts +1 -16131
  231. package/dist/stats/finders.js +9 -5
  232. package/dist/stats/mapping.d.ts +21 -1
  233. package/dist/stats/mapping.js +0 -3
  234. package/package.json +6 -12
  235. package/dist/db/arango.d.ts +0 -2
  236. package/dist/db/arango.js +0 -110
  237. package/dist/db/migration/autoMigrate.d.ts +0 -2
  238. package/dist/db/migration/autoMigrate.js +0 -111
  239. package/dist/db/migration/cli.d.ts +0 -1
  240. package/dist/db/migration/cli.js +0 -56
  241. package/dist/db/migration/detect.d.ts +0 -6
  242. package/dist/db/migration/detect.js +0 -87
  243. package/dist/db/migration/exportArango.d.ts +0 -4
  244. package/dist/db/migration/exportArango.js +0 -80
  245. package/dist/db/migration/importPostgres.d.ts +0 -3
  246. package/dist/db/migration/importPostgres.js +0 -18
  247. package/dist/db/migration/transform.d.ts +0 -18
  248. package/dist/db/migration/transform.js +0 -209
  249. package/dist/db/migration/validate.d.ts +0 -18
  250. package/dist/db/migration/validate.js +0 -69
  251. package/dist/db/pg/sql/meta/0000_snapshot.json +0 -3380
  252. package/dist/db/pg/sql/meta/0004_snapshot.json +0 -4114
  253. package/dist/db/pg/sql/meta/0005_snapshot.json +0 -4179
  254. package/dist/mastodon/index.d.ts +0 -4
  255. package/dist/mastodon/index.js +0 -51
  256. package/dist/mastodon/types.d.ts +0 -7579
  257. package/dist/mastodon/types.js +0 -523
  258. package/dist/mastodon/typescript.d.ts +0 -1578
  259. package/dist/mastodon/typescript.js +0 -1
  260. package/dist/roles/defaults.d.ts +0 -2
  261. package/dist/roles/defaults.js +0 -94
@@ -1,12 +1,13 @@
1
+ import { jamRoomName } from '@openpeepshq/common/lib';
1
2
  import { publicProfileSchema, } from '@openpeepshq/common/types';
2
3
  import { assertJamRsvpAllowed, createJamToken } from './token.js';
3
4
  import { disconnect, getConnection, getSharedConnection, } from '../redis/connection.js';
4
- const waitingRoomKey = (event) => `jams:waiting-room:${event.id}`;
5
- const admittanceKey = (event) => `jams:admitted:${event.id}`;
5
+ const waitingRoomKey = (event, recurrenceId) => `jams:waiting-room:${jamRoomName(event.id, recurrenceId)}`;
6
+ const admittanceKey = (event, recurrenceId) => `jams:admitted:${jamRoomName(event.id, recurrenceId)}`;
6
7
  /** Keep admissions around for the length of a long jam / mobile backgrounding. */
7
8
  const ADMITTANCE_TTL_SEC = 12 * 60 * 60;
8
- const currentWaitingRoom = (event) => getSharedConnection()
9
- .then((conn) => conn.hGetAll(waitingRoomKey(event)))
9
+ const currentWaitingRoom = (event, recurrenceId) => getSharedConnection()
10
+ .then((conn) => conn.hGetAll(waitingRoomKey(event, recurrenceId)))
10
11
  .then((wrRaw) => Object.entries(wrRaw))
11
12
  .then((entries) => entries.filter((e) => e[0] && e[1]))
12
13
  .then((entries) => entries.map(([key, value]) => [
@@ -14,25 +15,25 @@ const currentWaitingRoom = (event) => getSharedConnection()
14
15
  publicProfileSchema.partial().parse(JSON.parse(value)),
15
16
  ]))
16
17
  .then((entries) => Object.fromEntries(entries));
17
- const currentAdmittance = (event) => getSharedConnection().then((conn) => conn.hGetAll(admittanceKey(event)));
18
- export const isAdmittedToJam = async (event, profileId) => {
18
+ const currentAdmittance = (event, recurrenceId) => getSharedConnection().then((conn) => conn.hGetAll(admittanceKey(event, recurrenceId)));
19
+ export const isAdmittedToJam = async (event, profileId, recurrenceId) => {
19
20
  const conn = await getSharedConnection();
20
- return Boolean(await conn.hExists(admittanceKey(event), profileId));
21
+ return Boolean(await conn.hExists(admittanceKey(event, recurrenceId), profileId));
21
22
  };
22
- export const clearJamAdmittance = async (event) => {
23
- await getSharedConnection().then((conn) => conn.del(admittanceKey(event)));
23
+ export const clearJamAdmittance = async (event, recurrenceId) => {
24
+ await getSharedConnection().then((conn) => conn.del(admittanceKey(event, recurrenceId)));
24
25
  };
25
- export const currentWaitingRoomWatch = (jamEvent, onChange) => currentWaitingRoom(jamEvent)
26
+ export const currentWaitingRoomWatch = (jamEvent, onChange, recurrenceId) => currentWaitingRoom(jamEvent, recurrenceId)
26
27
  .then(onChange)
27
28
  .then(() => getConnection())
28
29
  .then((conn) => conn
29
- .subscribe(`__keyspace@0__:${waitingRoomKey(jamEvent)}`, (event) => {
30
+ .subscribe(`__keyspace@0__:${waitingRoomKey(jamEvent, recurrenceId)}`, (event) => {
30
31
  if (['hset', 'hdel'].includes(event)) {
31
- currentWaitingRoom(jamEvent).then(onChange);
32
+ currentWaitingRoom(jamEvent, recurrenceId).then(onChange);
32
33
  }
33
34
  })
34
35
  .then(() => () => disconnect(conn)));
35
- export const admittanceWatch = (jamEvent, profileId, onToken) => currentAdmittance(jamEvent)
36
+ export const admittanceWatch = (jamEvent, profileId, onToken, recurrenceId) => currentAdmittance(jamEvent, recurrenceId)
36
37
  .then((admittance) => {
37
38
  if (admittance[profileId]) {
38
39
  return onToken(admittance[profileId]);
@@ -40,9 +41,9 @@ export const admittanceWatch = (jamEvent, profileId, onToken) => currentAdmittan
40
41
  })
41
42
  .then(() => getConnection())
42
43
  .then((conn) => conn
43
- .subscribe(`__keyspace@0__:${admittanceKey(jamEvent)}`, async (event) => {
44
+ .subscribe(`__keyspace@0__:${admittanceKey(jamEvent, recurrenceId)}`, async (event) => {
44
45
  if ('hset' === event) {
45
- const token = await getSharedConnection().then((c) => c.hGet(admittanceKey(jamEvent), profileId));
46
+ const token = await getSharedConnection().then((c) => c.hGet(admittanceKey(jamEvent, recurrenceId), profileId));
46
47
  if (token) {
47
48
  await disconnect(conn);
48
49
  return onToken(token);
@@ -50,20 +51,20 @@ export const admittanceWatch = (jamEvent, profileId, onToken) => currentAdmittan
50
51
  }
51
52
  })
52
53
  .then(() => async () => {
53
- await getSharedConnection().then((c) => c.hDel(waitingRoomKey(jamEvent), profileId));
54
+ await getSharedConnection().then((c) => c.hDel(waitingRoomKey(jamEvent, recurrenceId), profileId));
54
55
  await disconnect(conn);
55
56
  }));
56
- export const joinWaitingRoom = async (event, profile) => {
57
- assertJamRsvpAllowed(event, profile);
57
+ export const joinWaitingRoom = async (event, profile, recurrenceId) => {
58
+ assertJamRsvpAllowed(event, profile, recurrenceId);
58
59
  const conn = await getSharedConnection();
59
- const wrKey = waitingRoomKey(event);
60
+ const wrKey = waitingRoomKey(event, recurrenceId);
60
61
  // Do not clear admittance here — once admitted, the guest may reconnect
61
62
  // (mobile idle / tab freeze) without a second moderator approval.
62
63
  await conn.hSet(wrKey, { [profile.id]: JSON.stringify(profile) });
63
64
  };
64
- export const acceptFromWaitingRoom = async (event, profileId) => {
65
+ export const acceptFromWaitingRoom = async (event, profileId, recurrenceId) => {
65
66
  const conn = await getSharedConnection();
66
- const wrKey = waitingRoomKey(event);
67
+ const wrKey = waitingRoomKey(event, recurrenceId);
67
68
  const profile = await publicProfileSchema
68
69
  .parseAsync(JSON.parse((await conn.hGet(wrKey, profileId)) || 'undefined'))
69
70
  .catch(() => undefined);
@@ -71,9 +72,9 @@ export const acceptFromWaitingRoom = async (event, profileId) => {
71
72
  if (!event || !profile) {
72
73
  return undefined;
73
74
  }
74
- const aKey = admittanceKey(event);
75
+ const aKey = admittanceKey(event, recurrenceId);
75
76
  await conn.hSet(aKey, {
76
- [profile.id]: await createJamToken(event, profile),
77
+ [profile.id]: await createJamToken(event, profile, { recurrenceId }),
77
78
  });
78
79
  await conn.expire(aKey, ADMITTANCE_TTL_SEC);
79
80
  };
@@ -6,5 +6,6 @@ export declare const connection: {
6
6
  export declare const queues: Record<string, Queue>;
7
7
  export declare const closeQueues: () => Promise<void>;
8
8
  export declare const queueAndWorker: <Input, Output = undefined>(queueName: string, processor: Processor<Input, Output>, queueOptions?: Omit<QueueOptions, "connection">) => [() => Queue, () => Worker];
9
+ export declare const getOrCreateQueue: (queueName: string) => Queue;
9
10
  export { getJobDetail } from './jobDetail';
10
11
  export { jobLogger, logStep, logFailure, formatErrorDetail, type JobLog, } from './jobLog';
@@ -1,4 +1,4 @@
1
- import { Queue, Worker } from 'bullmq';
1
+ import { MetricsTime, Queue, Worker } from 'bullmq';
2
2
  export const connection = {
3
3
  host: process.env.REDIS_HOST || 'localhost',
4
4
  port: Number(process.env.REDIS_PORT) || 6379,
@@ -54,7 +54,12 @@ export const queueAndWorker = (queueName, processor, queueOptions) => [
54
54
  () => new Worker(queueName, processor, {
55
55
  connection,
56
56
  concurrency: 5,
57
+ metrics: { maxDataPoints: MetricsTime.ONE_WEEK },
57
58
  }),
58
59
  ];
60
+ export const getOrCreateQueue = (queueName) => {
61
+ var _a;
62
+ return (_a = queues[queueName]) !== null && _a !== void 0 ? _a : (queues[queueName] = new Queue(queueName, { connection }));
63
+ };
59
64
  export { getJobDetail } from './jobDetail.js';
60
65
  export { jobLogger, logStep, logFailure, formatErrorDetail, } from './jobLog.js';
@@ -1,9 +1,4 @@
1
- import { Queue } from 'bullmq';
2
- import { connection, queues } from './index.js';
3
- const getOrCreateQueue = (queueName) => {
4
- var _a;
5
- return (_a = queues[queueName]) !== null && _a !== void 0 ? _a : (queues[queueName] = new Queue(queueName, { connection }));
6
- };
1
+ import { getOrCreateQueue } from './index.js';
7
2
  export const getJobDetail = async (queueName, jobId) => {
8
3
  var _a, _b, _c, _d, _e;
9
4
  const queue = getOrCreateQueue(queueName);
@@ -12,7 +12,7 @@ export interface MediaFile {
12
12
  }
13
13
  /**
14
14
  * Stream a web `ReadableStream` to a temp file, preserving the original
15
- * extension so format-sniffing tools (audiowaveform, sharp) behave. Peak
15
+ * extension so format-sniffing tools (ffmpeg, sharp) behave. Peak
16
16
  * memory is bounded by the write stream's highWaterMark, not the file size.
17
17
  */
18
18
  export declare const writeStreamToTemp: (stream: ReadableStream, name: string) => Promise<string>;
@@ -9,7 +9,6 @@ import { createReadStream, createWriteStream } from 'node:fs';
9
9
  import { Readable } from 'node:stream';
10
10
  import { pipeline } from 'node:stream/promises';
11
11
  import { getTheme, randomString } from '@openpeepshq/common/lib';
12
- import { execSync } from 'node:child_process';
13
12
  import { logger } from '../log/index.js';
14
13
  import { hub } from '../events/index.js';
15
14
  let storagePromise = null;
@@ -33,7 +32,7 @@ export const mediaStorage = () => {
33
32
  const tempPathFor = (name) => join(tmpdir(), `media-${randomString(16)}${path.extname(name)}`);
34
33
  /**
35
34
  * Stream a web `ReadableStream` to a temp file, preserving the original
36
- * extension so format-sniffing tools (audiowaveform, sharp) behave. Peak
35
+ * extension so format-sniffing tools (ffmpeg, sharp) behave. Peak
37
36
  * memory is bounded by the write stream's highWaterMark, not the file size.
38
37
  */
39
38
  export const writeStreamToTemp = async (stream, name) => {
@@ -159,15 +158,31 @@ const getVideoStreamInfo = (filePath) => new Promise((resolve, reject) => {
159
158
  resolve({ width: stream.width, height: stream.height, duration });
160
159
  });
161
160
  });
161
+ const waveformColor = (hex) => {
162
+ const bare = hex.replace('#', '');
163
+ return /^[0-9a-fA-F]{6}$/.test(bare) ? `0x${bare}` : '0x15678a';
164
+ };
165
+ /**
166
+ * Waveform still via ffmpeg. `audiowaveform` is not a project dependency and
167
+ * is often missing locally; ffmpeg already is, because video processing uses it.
168
+ */
169
+ const renderWaveform = (inputPath, outputPath, color) => new Promise((resolve, reject) => {
170
+ const size = `${previewMaxWidth}x${previewMaxWidth}`;
171
+ ffmpeg(inputPath)
172
+ .noVideo()
173
+ .outputOptions('-filter_complex', `aformat=channel_layouts=mono,showwavespic=s=${size}:colors=${color}`)
174
+ .outputOptions('-frames:v', '1')
175
+ .outputOptions('-update', '1')
176
+ .output(outputPath)
177
+ .on('end', () => resolve())
178
+ .on('error', (error) => reject(error))
179
+ .run();
180
+ });
162
181
  const createAudioPreview = async (inputPath) => {
163
182
  const outputPath = join(tmpdir(), `preview-${randomString(16)}.png`);
183
+ const color = waveformColor(getTheme(await communityConfig()).primaryHex);
164
184
  try {
165
- const duration = await getMediaDuration(inputPath);
166
- const pixelsPerSecond = Math.floor(700 / duration);
167
- execSync(`audiowaveform -i ${inputPath} -o ${outputPath} \
168
- --background-color ffffff88 --waveform-color ${getTheme(await communityConfig()).primaryHex.slice(1)} \
169
- -w ${previewMaxWidth} -h ${previewMaxWidth} --pixels-per-second ${pixelsPerSecond} \
170
- --no-axis-labels -q`);
185
+ await renderWaveform(inputPath, outputPath, color);
171
186
  return { path: outputPath, mimetype: 'image/png' };
172
187
  }
173
188
  catch (error) {
@@ -43,15 +43,26 @@ const runProcessingBody = async ({ mediaAttachmentId, sourceStorageKey, thumbnai
43
43
  previewMimetype = thumbnail.type;
44
44
  previewName = thumbnail.name;
45
45
  }
46
- const preview = await createPreview(previewInputPath, previewMimetype, previewName);
47
- if (preview.path !== sourcePath && preview.path !== previewInputPath) {
48
- temps.add(preview.path);
49
- }
50
- const { key: previewStorageKey } = await storeFromPath(preview.path);
51
46
  const normalizedFilename = encodeURIComponent(transcoded.filename);
52
- const thumbnailFilename = `thumbnail-${normalizedFilename}${normalizedFilename.endsWith('.webp') ? '' : '.webp'}`;
53
47
  const url = storage.getPath(fileStorageKey, normalizedFilename);
54
- const previewUrl = storage.getPath(previewStorageKey, thumbnailFilename);
48
+ // A waveform is a preview, not the audio itself. A missing or broken
49
+ // waveform tool must not leave the attachment stuck in `processing`.
50
+ let previewUrl = null;
51
+ try {
52
+ const preview = await createPreview(previewInputPath, previewMimetype, previewName);
53
+ if (preview.path !== sourcePath && preview.path !== previewInputPath) {
54
+ temps.add(preview.path);
55
+ }
56
+ const { key: previewStorageKey } = await storeFromPath(preview.path);
57
+ const thumbnailFilename = `thumbnail-${normalizedFilename}${normalizedFilename.endsWith('.webp') ? '' : '.webp'}`;
58
+ previewUrl = storage.getPath(previewStorageKey, thumbnailFilename);
59
+ }
60
+ catch (error) {
61
+ if (filetype !== 'audio')
62
+ throw error;
63
+ const message = error instanceof Error ? error.message : String(error);
64
+ log.error(`Audio waveform skipped for ${mediaAttachmentId}: ${message}`);
65
+ }
55
66
  const updated = await updateMediaAttachment(mediaAttachmentId, {
56
67
  url,
57
68
  previewUrl,
@@ -1,6 +1,6 @@
1
1
  import { notificationAll, } from '@openpeepshq/common/types';
2
2
  import { maybeCreateNotification } from '@openpeepshq/core/notifications';
3
- import { getProfileAvatar, profileName, truncateText, } from '@openpeepshq/common/lib';
3
+ import { getProfileAvatar, markdownPlainText, profileName, truncateText, } from '@openpeepshq/common/lib';
4
4
  import { communityConfig } from '../../../config/index.js';
5
5
  import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
6
6
  export default {
@@ -16,7 +16,7 @@ export default {
16
16
  return ({
17
17
  title: `${profileName(notification.senderProfile)} followed you`,
18
18
  options: {
19
- body: truncateText((_a = notification.senderProfile) === null || _a === void 0 ? void 0 : _a.bio),
19
+ body: truncateText(markdownPlainText((_a = notification.senderProfile) === null || _a === void 0 ? void 0 : _a.bio)),
20
20
  icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
21
21
  actions: [
22
22
  {
@@ -8,7 +8,9 @@ export default {
8
8
  event: 'groupMemberJoined',
9
9
  eventHandler: async (...args) => {
10
10
  const [group, profile] = args;
11
- for (const groupAdmin of await listGroupMembers(group).then((members) => members.filter((m) => { var _a; return (_a = m.roles) === null || _a === void 0 ? void 0 : _a.includes('admin'); }).map((m) => m.profile))) {
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')); })
13
+ .map((m) => m.profile))) {
12
14
  await maybeCreateNotification(groupAdmin, {
13
15
  type: 'groupMemberJoined',
14
16
  fromProfileId: profile.id,
@@ -8,7 +8,9 @@ export default {
8
8
  event: 'groupMemberLeft',
9
9
  eventHandler: async (...args) => {
10
10
  const [group, profile] = args;
11
- for (const groupAdmin of await listGroupMembers(group).then((members) => members.filter((m) => { var _a; return (_a = m.roles) === null || _a === void 0 ? void 0 : _a.includes('admin'); }).map((m) => m.profile))) {
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')); })
13
+ .map((m) => m.profile))) {
12
14
  await maybeCreateNotification(groupAdmin, {
13
15
  type: 'groupMemberLeft',
14
16
  fromProfileId: profile.id,
@@ -14,8 +14,10 @@ import { default as groupAdded } from './groupAdded/index.js';
14
14
  import { default as groupMemberJoined } from './groupMemberJoined/index.js';
15
15
  import { default as groupMemberLeft } from './groupMemberLeft/index.js';
16
16
  import { default as pollVote } from './pollVote/index.js';
17
+ import { default as pollEnded } from './pollEnded/index.js';
17
18
  import { default as newGroupPost } from './newGroupPost/index.js';
18
19
  import { default as rsvp } from './rsvp/index.js';
20
+ import { default as rsvpCanceled } from './rsvpCanceled/index.js';
19
21
  const defaultNotificationsHandlers = [
20
22
  announcement,
21
23
  directMessage,
@@ -32,8 +34,10 @@ const defaultNotificationsHandlers = [
32
34
  groupMemberJoined,
33
35
  groupMemberLeft,
34
36
  pollVote,
37
+ pollEnded,
35
38
  newGroupPost,
36
39
  rsvp,
40
+ rsvpCanceled,
37
41
  ];
38
42
  export const defaultNotificationTypes = defaultNotificationsHandlers.map((handler) => pick(handler, 'type', 'requiredCapabilities', 'defaultSettings'));
39
43
  export const registerDefaultNotifications = async () => {
@@ -22,21 +22,27 @@ const eventHandler = async (data) => {
22
22
  }
23
23
  };
24
24
  const pushRenderer = async (notification) => {
25
- var _a, _b, _c, _d, _e;
26
- return ({
27
- title: `${profileName((_a = notification.post) === null || _a === void 0 ? void 0 : _a.profile)} made a post in ${(_b = notification === null || notification === void 0 ? void 0 : notification.group) === null || _b === void 0 ? void 0 : _b.displayName}`,
25
+ var _a, _b, _c, _d, _e, _f, _g;
26
+ const isRepost = !!((_a = notification.post) === null || _a === void 0 ? void 0 : _a.repost);
27
+ const preview = (_c = (_b = notification.post) === null || _b === void 0 ? void 0 : _b.repost) !== null && _c !== void 0 ? _c : notification.post;
28
+ const name = profileName((_d = notification.post) === null || _d === void 0 ? void 0 : _d.profile);
29
+ const group = (_e = notification.group) === null || _e === void 0 ? void 0 : _e.displayName;
30
+ return {
31
+ title: isRepost
32
+ ? `${name} reposted a post in ${group}`
33
+ : `${name} made a post in ${group}`,
28
34
  options: {
29
- body: (_d = (_c = notification.post) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.content,
35
+ body: (_f = preview === null || preview === void 0 ? void 0 : preview.data) === null || _f === void 0 ? void 0 : _f.content,
30
36
  icon: getGroupAvatar(notification.group, await communityConfig()),
31
37
  actions: [
32
38
  {
33
- action: `goto:/groups/@${(_e = notification.group) === null || _e === void 0 ? void 0 : _e.handle}`,
39
+ action: `goto:/groups/@${(_g = notification.group) === null || _g === void 0 ? void 0 : _g.handle}`,
34
40
  title: 'Go to post',
35
41
  },
36
42
  ],
37
43
  },
38
44
  invalidateQueries: [PUSH_INVALIDATE.posts, PUSH_INVALIDATE.unseenCounts],
39
- });
45
+ };
40
46
  };
41
47
  export default {
42
48
  type: 'newGroupPost',
@@ -0,0 +1,19 @@
1
+ import type { ExpandedNotification } from '@openpeepshq/common/types';
2
+ declare const _default: {
3
+ type: string;
4
+ event: string;
5
+ eventHandler: (data: unknown) => Promise<void>;
6
+ pushRenderer: (notification: ExpandedNotification) => Promise<{
7
+ title: string;
8
+ options: {
9
+ body: string | undefined;
10
+ icon: string;
11
+ actions: {
12
+ action: string;
13
+ title: string;
14
+ }[];
15
+ };
16
+ invalidateQueries: string[][];
17
+ }>;
18
+ };
19
+ export default _default;
@@ -0,0 +1,39 @@
1
+ import { maybeCreateNotification } from '@openpeepshq/core/notifications';
2
+ import { getProfileAvatar } from '@openpeepshq/common/lib';
3
+ import { communityConfig } from '../../../config/index.js';
4
+ import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
5
+ import { pollEndedRecipientProfiles } from './recipients.js';
6
+ const eventHandler = async (data) => {
7
+ var _a, _b;
8
+ const post = data;
9
+ if (((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) !== 'question') {
10
+ return;
11
+ }
12
+ const fromProfileId = (_b = post.profile) === null || _b === void 0 ? void 0 : _b.id;
13
+ for (const recipient of pollEndedRecipientProfiles(post)) {
14
+ await maybeCreateNotification(recipient, Object.assign({ type: 'pollEnded', postId: post.id }, (fromProfileId ? { fromProfileId } : {})));
15
+ }
16
+ };
17
+ const pushRenderer = async (notification) => {
18
+ var _a, _b, _c, _d, _e;
19
+ return ({
20
+ title: 'A poll has ended',
21
+ options: {
22
+ body: (_b = (_a = notification.post) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content,
23
+ icon: getProfileAvatar((_c = notification.senderProfile) !== null && _c !== void 0 ? _c : (_d = notification.post) === null || _d === void 0 ? void 0 : _d.profile, await communityConfig()),
24
+ actions: [
25
+ {
26
+ action: `goto:/posts/${(_e = notification.post) === null || _e === void 0 ? void 0 : _e.id}`,
27
+ title: 'See Results',
28
+ },
29
+ ],
30
+ },
31
+ invalidateQueries: [PUSH_INVALIDATE.posts],
32
+ });
33
+ };
34
+ export default {
35
+ type: 'pollEnded',
36
+ event: 'pollEnded',
37
+ eventHandler,
38
+ pushRenderer,
39
+ };
@@ -0,0 +1,3 @@
1
+ import type { PostWithMeta, PublicProfile } from '@openpeepshq/common/types';
2
+ /** Poll author, voters, and parent post author when the poll is a reply. */
3
+ export declare const pollEndedRecipientProfiles: (post: PostWithMeta) => PublicProfile[];
@@ -0,0 +1,18 @@
1
+ import { collectVotes } from '@openpeepshq/common/lib';
2
+ const addProfile = (byId, profile) => {
3
+ if (profile === null || profile === void 0 ? void 0 : profile.id) {
4
+ byId.set(profile.id, profile);
5
+ }
6
+ };
7
+ /** Poll author, voters, and parent post author when the poll is a reply. */
8
+ export const pollEndedRecipientProfiles = (post) => {
9
+ var _a;
10
+ const byId = new Map();
11
+ addProfile(byId, post.profile);
12
+ addProfile(byId, (_a = post.replyTo) === null || _a === void 0 ? void 0 : _a.profile);
13
+ const { votes } = collectVotes(post);
14
+ for (const vote of votes) {
15
+ addProfile(byId, vote.profile);
16
+ }
17
+ return [...byId.values()];
18
+ };
@@ -1,7 +1,12 @@
1
- import type { ExpandedNotification } from '@openpeepshq/common/types';
1
+ import { type ExpandedNotification } from '@openpeepshq/common/types';
2
2
  declare const _default: {
3
3
  type: string;
4
4
  event: string;
5
+ defaultSettings: {
6
+ readonly create: true;
7
+ readonly push: true;
8
+ readonly email: true;
9
+ };
5
10
  eventHandler: (senderProfile: unknown, post: unknown, data: unknown) => Promise<void>;
6
11
  pushRenderer: (notification: ExpandedNotification) => Promise<{
7
12
  title: string;
@@ -1,3 +1,4 @@
1
+ import { notificationAll, } from '@openpeepshq/common/types';
1
2
  import { maybeCreateNotification } from '@openpeepshq/core/notifications';
2
3
  import { getProfileAvatar, profileName } from '@openpeepshq/common/lib';
3
4
  import { communityConfig } from '../../../config/index.js';
@@ -9,6 +10,11 @@ const eventHandler = async (senderProfile, post, data) => {
9
10
  if (entryData.type !== 'rsvp') {
10
11
  return;
11
12
  }
13
+ // Cancellations use rsvpCanceled. A plain "no" or organizer removal is not an RSVP.
14
+ const response = entryData.data.response;
15
+ if (response !== 'yes' && response !== 'tentative') {
16
+ return;
17
+ }
12
18
  await maybeCreateNotification(mergedPost.profile, {
13
19
  type: 'rsvp',
14
20
  postId: mergedPost.id,
@@ -35,6 +41,7 @@ const pushRenderer = async (notification) => {
35
41
  export default {
36
42
  type: 'rsvp',
37
43
  event: 'rsvpCreated',
44
+ defaultSettings: notificationAll,
38
45
  eventHandler,
39
46
  pushRenderer,
40
47
  };
@@ -0,0 +1,24 @@
1
+ import { type ExpandedNotification } from '@openpeepshq/common/types';
2
+ declare const _default: {
3
+ type: string;
4
+ event: string;
5
+ defaultSettings: {
6
+ readonly create: true;
7
+ readonly push: true;
8
+ readonly email: true;
9
+ };
10
+ eventHandler: (senderProfile: unknown, post: unknown, data: unknown) => Promise<void>;
11
+ pushRenderer: (notification: ExpandedNotification) => Promise<{
12
+ title: string;
13
+ options: {
14
+ body: string;
15
+ icon: string;
16
+ actions: {
17
+ action: string;
18
+ title: string;
19
+ }[];
20
+ };
21
+ invalidateQueries: string[][];
22
+ }>;
23
+ };
24
+ export default _default;
@@ -0,0 +1,75 @@
1
+ import { notificationAll, } from '@openpeepshq/common/types';
2
+ import { getProfileAvatar, isRsvpCancelNotice, profileName, rsvpCancelWhenLabels, } from '@openpeepshq/common/lib';
3
+ import { maybeCreateNotification } from '@openpeepshq/core/notifications';
4
+ import { findProfile, listGroupMembers } from '@openpeepshq/core/profiles';
5
+ import { communityConfig } from '../../../config/index.js';
6
+ import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
7
+ import { rsvpCancelRecipients } from './recipients.js';
8
+ const eventName = (post) => { var _a, _b; return ((_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' ? (_b = post.data.name) === null || _b === void 0 ? void 0 : _b.trim() : undefined; };
9
+ const whenText = (post, notice) => {
10
+ if (!post)
11
+ return '';
12
+ const when = rsvpCancelWhenLabels(post, notice);
13
+ if (when.series)
14
+ return 'All dates in the series';
15
+ return when.labels.join(', ');
16
+ };
17
+ const eventHandler = async (senderProfile, post, data) => {
18
+ var _a, _b, _c, _d;
19
+ const mergedPost = post;
20
+ const fromProfile = senderProfile;
21
+ const cancel = data === null || data === void 0 ? void 0 : data.cancel;
22
+ if (!isRsvpCancelNotice(cancel))
23
+ return;
24
+ if (mergedPost.type !== 'event' || ((_a = mergedPost.data) === null || _a === void 0 ? void 0 : _a.type) !== 'event') {
25
+ return;
26
+ }
27
+ const event = mergedPost.data;
28
+ const moderatorIds = [
29
+ ...((_b = event.moderators) !== null && _b !== void 0 ? _b : []),
30
+ ...((_d = (_c = event.jam) === null || _c === void 0 ? void 0 : _c.moderators) !== null && _d !== void 0 ? _d : []),
31
+ ];
32
+ const moderators = (await Promise.all(moderatorIds.map((id) => findProfile(id)))).filter((profile) => !!profile);
33
+ const groupAdmins = mergedPost.group
34
+ ? (await listGroupMembers(mergedPost.group))
35
+ .filter((member) => { var _a, _b; return ((_a = member.roles) === null || _a === void 0 ? void 0 : _a.includes('owner')) || ((_b = member.roles) === null || _b === void 0 ? void 0 : _b.includes('admin')); })
36
+ .map((member) => member.profile)
37
+ : [];
38
+ const recipients = rsvpCancelRecipients([mergedPost.profile, ...moderators, ...groupAdmins], fromProfile.id);
39
+ for (const recipient of recipients) {
40
+ await maybeCreateNotification(recipient, Object.assign(Object.assign({ type: 'rsvpCanceled', postId: mergedPost.id, fromProfileId: fromProfile.id }, (mergedPost.groupId ? { groupId: mergedPost.groupId } : {})), { data: cancel }));
41
+ }
42
+ };
43
+ const pushRenderer = async (notification) => {
44
+ var _a, _b, _c;
45
+ const notice = isRsvpCancelNotice(notification.data)
46
+ ? notification.data
47
+ : { occurrenceIds: [], series: false };
48
+ const name = eventName((_a = notification.post) !== null && _a !== void 0 ? _a : undefined);
49
+ const when = whenText((_b = notification.post) !== null && _b !== void 0 ? _b : undefined, notice);
50
+ return {
51
+ title: `${profileName(notification.senderProfile)} canceled their RSVP`,
52
+ options: {
53
+ body: [name, when].filter(Boolean).join(' · '),
54
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
55
+ actions: [
56
+ {
57
+ action: `goto:/posts/${(_c = notification.post) === null || _c === void 0 ? void 0 : _c.id}`,
58
+ title: 'View event',
59
+ },
60
+ ],
61
+ },
62
+ invalidateQueries: [
63
+ PUSH_INVALIDATE.posts,
64
+ PUSH_INVALIDATE.notifications,
65
+ PUSH_INVALIDATE.notificationStats,
66
+ ],
67
+ };
68
+ };
69
+ export default {
70
+ type: 'rsvpCanceled',
71
+ event: 'rsvpCreated',
72
+ defaultSettings: notificationAll,
73
+ eventHandler,
74
+ pushRenderer,
75
+ };
@@ -0,0 +1,4 @@
1
+ /** One notification per person. The member who canceled is not notified. */
2
+ export declare const rsvpCancelRecipients: <T extends {
3
+ id: string;
4
+ }>(profiles: T[], actorId: string) => T[];
@@ -0,0 +1,11 @@
1
+ /** One notification per person. The member who canceled is not notified. */
2
+ export const rsvpCancelRecipients = (profiles, actorId) => {
3
+ const seen = new Set();
4
+ return profiles.filter((profile) => {
5
+ if (!profile.id || profile.id === actorId || seen.has(profile.id)) {
6
+ return false;
7
+ }
8
+ seen.add(profile.id);
9
+ return true;
10
+ });
11
+ };
@@ -14,8 +14,12 @@ export const notificationSettings = (profileSettings, type) => {
14
14
  };
15
15
  export const expandNotification = async (notification) => {
16
16
  var _a, _b;
17
- const intermediateNotification = Object.assign(Object.assign({}, notification), { senderProfile: notification.fromProfileId
18
- ? anonymizeProfileIfDeleted(await getProfile(notification.fromProfileId))
17
+ const intermediateNotification = Object.assign(Object.assign({}, notification), {
18
+ // Include soft-deleted senders so anonymizeProfileIfDeleted can tombstone
19
+ // them; otherwise fromProfileId resolves to undefined and the UI falls
20
+ // back to an uninterpolated "{{profileName}} …" string.
21
+ senderProfile: notification.fromProfileId
22
+ ? anonymizeProfileIfDeleted(await getProfile(notification.fromProfileId, true))
19
23
  : undefined, post: notification.post
20
24
  ? await transformPost(notification.post)
21
25
  : undefined, recipientProfile: (await getProfile(notification.profileId)) });
@@ -42,7 +42,9 @@ const [notificationQueue, notificationWorker] = queueAndWorker('process-notifica
42
42
  await mailer.send({
43
43
  template: `notification-${notification.type}`,
44
44
  to: account.email,
45
- locals: notification,
45
+ locals: Object.assign(Object.assign({}, notification), (profileSettings.timeZone
46
+ ? { timeZone: profileSettings.timeZone }
47
+ : {})),
46
48
  });
47
49
  await logStep(jobLog, log, `Queued email notification to ${account.email}`);
48
50
  }
@@ -4,6 +4,7 @@ import { notificationFilters } from '../db/pg/filters/index.js';
4
4
  import { baseListNotifications, expandNotification, notificationSettings, } from './helpers.js';
5
5
  import { hub } from '../events/index.js';
6
6
  import { findProfile } from '../profiles/index.js';
7
+ import { isBlockedPair } from '@openpeepshq/common/lib';
7
8
  import { logger } from '../log/index.js';
8
9
  import { findProfileSettings } from '../profileSettings/index.js';
9
10
  const log = logger('openpeeps:notifications');
@@ -25,6 +26,9 @@ export const maybeCreateNotification = async (profile, data) => {
25
26
  log.error(`Profile ${profile.id} not found`);
26
27
  return;
27
28
  }
29
+ if (data.fromProfileId && isBlockedPair(fullProfile, data.fromProfileId)) {
30
+ return;
31
+ }
28
32
  const profileSettings = await findProfileSettings(profile.id);
29
33
  if (!profileSettings) {
30
34
  log.error(`profileSettings ${profile.id} not found`);