@openpeepshq/core 0.1.33 → 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 (297) 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 +36 -33
  6. package/dist/analytics/cache.js +3 -3
  7. package/dist/analytics/clicks.js +14 -22
  8. package/dist/analytics/compile.js +17 -12
  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 +164 -140
  14. package/dist/analytics/report.d.ts +22 -1
  15. package/dist/analytics/report.js +2 -3
  16. package/dist/analytics/settings.js +3 -4
  17. package/dist/backups/index.js +82 -25
  18. package/dist/backups/metadata.d.ts +2 -3
  19. package/dist/backups/metadata.js +6 -2
  20. package/dist/config/db.js +2 -4
  21. package/dist/config/defaults/capabilities.js +13 -2
  22. package/dist/config/defaults/community.js +8 -3
  23. package/dist/config/defaults/core.d.ts +1 -1
  24. package/dist/config/defaults/core.js +16 -8
  25. package/dist/config/index.d.ts +22 -0
  26. package/dist/config/index.js +15 -11
  27. package/dist/db/explorer/query.js +9 -8
  28. package/dist/db/explorer/sql.js +8 -8
  29. package/dist/db/helpers.d.ts +1 -0
  30. package/dist/db/helpers.js +25 -7
  31. package/dist/db/index.d.ts +1 -1
  32. package/dist/db/index.js +1 -0
  33. package/dist/db/init.js +2 -3
  34. package/dist/db/migration/importCollections.d.ts +14 -9
  35. package/dist/db/migration/importCollections.js +121 -174
  36. package/dist/db/migration/shared.d.ts +2 -33
  37. package/dist/db/migration/shared.js +17 -87
  38. package/dist/db/pg/client.js +4 -7
  39. package/dist/db/pg/collections.d.ts +2 -2
  40. package/dist/db/pg/collections.js +2 -2
  41. package/dist/db/pg/filters/index.js +1 -1
  42. package/dist/db/pg/filters/posts.d.ts +12 -0
  43. package/dist/db/pg/filters/posts.js +30 -4
  44. package/dist/db/pg/filters/profiles.d.ts +1 -0
  45. package/dist/db/pg/filters/profiles.js +2 -1
  46. package/dist/db/pg/helpers.js +2 -14
  47. package/dist/db/pg/map/filters.js +40 -10
  48. package/dist/db/pg/map/helpers.js +5 -1
  49. package/dist/db/pg/map/index.js +46 -51
  50. package/dist/db/pg/map/mutations.js +65 -25
  51. package/dist/db/pg/map/registry.d.ts +5 -0
  52. package/dist/db/pg/map/registry.js +133 -56
  53. package/dist/db/pg/map/relations.js +76 -68
  54. package/dist/db/pg/map/search.js +15 -37
  55. package/dist/db/pg/mappers.js +13 -7
  56. package/dist/db/pg/migrate.d.ts +1 -2
  57. package/dist/db/pg/migrate.js +8 -9
  58. package/dist/db/pg/queries/activity.js +5 -5
  59. package/dist/db/pg/queries/derived.js +8 -12
  60. package/dist/db/pg/queries/sorts.d.ts +1 -0
  61. package/dist/db/pg/queries/sorts.js +4 -0
  62. package/dist/db/pg/schema/documents.d.ts +279 -41
  63. package/dist/db/pg/schema/documents.js +136 -22
  64. package/dist/db/pg/schema/edges.d.ts +116 -7
  65. package/dist/db/pg/schema/edges.js +9 -2
  66. package/dist/db/pg/schema/index.d.ts +362 -15
  67. package/dist/db/pg/schema/index.js +5 -1
  68. package/dist/db/pg/sql/0010_user_group_membership_roles.sql +16 -0
  69. package/dist/db/pg/sql/0011_drop_data_migrations.sql +1 -0
  70. package/dist/db/pg/sql/0012_posts_last_activity_at.sql +5 -0
  71. package/dist/db/pg/sql/0013_add_blocks_edge.sql +12 -0
  72. package/dist/db/pg/sql/0014_federation_datamodel.sql +59 -0
  73. package/dist/db/pg/sql/0015_profile_hashtags.sql +12 -0
  74. package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
  75. package/dist/db/pg/sql/meta/{0009_snapshot.json → 0015_snapshot.json} +291 -36
  76. package/dist/db/pg/sql/meta/_journal.json +49 -0
  77. package/dist/db/replaceOrigin.js +1 -1
  78. package/dist/email/queueStats.js +8 -11
  79. package/dist/email/render.js +14 -3
  80. package/dist/email/send.js +19 -17
  81. package/dist/email/smtpTest.js +10 -6
  82. package/dist/errors/index.js +1 -1
  83. package/dist/events/index.d.ts +4 -0
  84. package/dist/events/index.js +1 -0
  85. package/dist/events/once.js +2 -4
  86. package/dist/federation/activities.d.ts +17 -0
  87. package/dist/federation/activities.js +25 -0
  88. package/dist/federation/identity.d.ts +16 -0
  89. package/dist/federation/identity.js +52 -0
  90. package/dist/federation/index.d.ts +4 -0
  91. package/dist/federation/index.js +3 -0
  92. package/dist/federation/profiles.d.ts +3 -0
  93. package/dist/federation/profiles.js +14 -0
  94. package/dist/groups/finders.d.ts +2 -1
  95. package/dist/groups/helpers.d.ts +18 -0
  96. package/dist/groups/helpers.js +1 -2
  97. package/dist/groups/mapping.d.ts +4 -2
  98. package/dist/groups/mutations.js +1 -1
  99. package/dist/hashtags/finders.d.ts +6 -3
  100. package/dist/hashtags/finders.js +2 -0
  101. package/dist/hashtags/helpers.d.ts +8 -0
  102. package/dist/hashtags/helpers.js +4 -0
  103. package/dist/hashtags/index.d.ts +2 -0
  104. package/dist/hashtags/index.js +2 -0
  105. package/dist/hashtags/mutations.d.ts +3 -0
  106. package/dist/hashtags/mutations.js +13 -1
  107. package/dist/i18n/index.d.ts +1 -1
  108. package/dist/i18n/index.js +3 -1
  109. package/dist/i18n/pluginLocales.d.ts +6 -0
  110. package/dist/i18n/pluginLocales.js +15 -0
  111. package/dist/inviteLinks/mutations.js +2 -3
  112. package/dist/jams/export.d.ts +19 -0
  113. package/dist/jams/export.js +58 -0
  114. package/dist/jams/finders.js +4 -1
  115. package/dist/jams/health.d.ts +10 -0
  116. package/dist/jams/health.js +50 -0
  117. package/dist/jams/helpers.d.ts +2 -2
  118. package/dist/jams/helpers.js +6 -2
  119. package/dist/jams/index.d.ts +2 -0
  120. package/dist/jams/index.js +25 -18
  121. package/dist/jams/jobs.js +2 -3
  122. package/dist/jams/livekit.d.ts +49 -4
  123. package/dist/jams/livekit.js +62 -45
  124. package/dist/jams/mapping.d.ts +3 -3
  125. package/dist/jams/mutations.d.ts +1 -1
  126. package/dist/jams/recording.d.ts +10 -0
  127. package/dist/jams/recording.js +33 -1
  128. package/dist/jams/token.d.ts +13 -1
  129. package/dist/jams/token.js +25 -18
  130. package/dist/jams/waitingRoom.js +1 -1
  131. package/dist/jobs/index.d.ts +1 -0
  132. package/dist/jobs/index.js +9 -3
  133. package/dist/jobs/jobDetail.js +6 -12
  134. package/dist/jobs/jobLog.js +2 -3
  135. package/dist/lib/streams.js +4 -39
  136. package/dist/lib/zodDeepPartial.d.ts +1 -1
  137. package/dist/lib/zodDeepPartial.js +1 -1
  138. package/dist/log/index.js +13 -29
  139. package/dist/media/index.d.ts +1 -1
  140. package/dist/media/index.js +73 -12
  141. package/dist/media/jobs.js +1 -2
  142. package/dist/media/openpeeps/index.js +11 -46
  143. package/dist/media/processing.js +25 -11
  144. package/dist/media/streaming.js +5 -5
  145. package/dist/media/streamingCleanupJobs.js +1 -2
  146. package/dist/media/streamingJobs.js +3 -4
  147. package/dist/media/streamingPrewarm.js +7 -11
  148. package/dist/mediaAttachments/index.js +6 -2
  149. package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
  150. package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
  151. package/dist/notifications/defaultNotifications/follow/index.js +15 -18
  152. package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
  153. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
  154. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
  155. package/dist/notifications/defaultNotifications/index.js +4 -0
  156. package/dist/notifications/defaultNotifications/jamModerator/index.js +3 -5
  157. package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
  158. package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
  159. package/dist/notifications/defaultNotifications/mention/index.js +20 -24
  160. package/dist/notifications/defaultNotifications/newGroupPost/index.js +11 -6
  161. package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
  162. package/dist/notifications/defaultNotifications/pollEnded/index.d.ts +19 -0
  163. package/dist/notifications/defaultNotifications/pollEnded/index.js +39 -0
  164. package/dist/notifications/defaultNotifications/pollEnded/recipients.d.ts +3 -0
  165. package/dist/notifications/defaultNotifications/pollEnded/recipients.js +17 -0
  166. package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
  167. package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
  168. package/dist/notifications/defaultNotifications/reply/index.js +21 -22
  169. package/dist/notifications/defaultNotifications/repost/index.js +16 -20
  170. package/dist/notifications/defaultNotifications/rsvp/index.d.ts +6 -1
  171. package/dist/notifications/defaultNotifications/rsvp/index.js +31 -18
  172. package/dist/notifications/defaultNotifications/rsvpCanceled/index.d.ts +24 -0
  173. package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +82 -0
  174. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.d.ts +4 -0
  175. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.js +11 -0
  176. package/dist/notifications/fcmCredential.js +1 -1
  177. package/dist/notifications/finders.js +1 -1
  178. package/dist/notifications/helpers.js +13 -10
  179. package/dist/notifications/jobs.js +10 -5
  180. package/dist/notifications/mutations.js +8 -1
  181. package/dist/notifications/push.js +11 -16
  182. package/dist/performance/index.js +3 -3
  183. package/dist/plugins/helpers.js +3 -6
  184. package/dist/plugins/index.js +39 -4
  185. package/dist/plugins/install.d.ts +28 -9
  186. package/dist/plugins/install.js +302 -56
  187. package/dist/plugins/pluginAuth.d.ts +1 -1
  188. package/dist/plugins/pluginAuth.js +13 -10
  189. package/dist/plugins/state.js +2 -3
  190. package/dist/posts/activity.d.ts +9 -0
  191. package/dist/posts/activity.js +34 -0
  192. package/dist/posts/contextClosure.d.ts +1 -9
  193. package/dist/posts/contextClosure.js +14 -44
  194. package/dist/posts/conversationQueries.d.ts +7 -0
  195. package/dist/posts/conversationQueries.js +76 -4
  196. package/dist/posts/eventAgenda.d.ts +1 -0
  197. package/dist/posts/eventAgenda.js +17 -8
  198. package/dist/posts/eventOccurrenceJobs.js +7 -2
  199. package/dist/posts/eventOccurrences.d.ts +6 -0
  200. package/dist/posts/eventOccurrences.js +22 -1
  201. package/dist/posts/finders.d.ts +56 -9
  202. package/dist/posts/finders.js +84 -23
  203. package/dist/posts/helpers/filters.js +13 -9
  204. package/dist/posts/helpers/index.d.ts +179 -14
  205. package/dist/posts/helpers/index.js +70 -34
  206. package/dist/posts/index.d.ts +5 -2
  207. package/dist/posts/index.js +5 -2
  208. package/dist/posts/mapping.d.ts +765 -30
  209. package/dist/posts/mapping.js +74 -31
  210. package/dist/posts/mutations.d.ts +516 -3
  211. package/dist/posts/mutations.js +179 -41
  212. package/dist/posts/pollEnd.d.ts +3 -0
  213. package/dist/posts/pollEnd.js +4 -0
  214. package/dist/posts/pollEndJobs.d.ts +8 -0
  215. package/dist/posts/pollEndJobs.js +49 -0
  216. package/dist/posts/replyClosure.d.ts +10 -0
  217. package/dist/posts/replyClosure.js +43 -0
  218. package/dist/posts/rsvpConfirmationEmail.js +23 -15
  219. package/dist/posts/threadPreview.d.ts +8 -0
  220. package/dist/posts/threadPreview.js +44 -0
  221. package/dist/posts/unseenCounts.js +4 -1
  222. package/dist/processingStats/queries.js +6 -7
  223. package/dist/profileSettings/cache.js +21 -5
  224. package/dist/profileSettings/mapping.d.ts +2 -0
  225. package/dist/profiles/activityQueries.d.ts +5 -0
  226. package/dist/profiles/activityQueries.js +85 -0
  227. package/dist/profiles/activitySummary.d.ts +3 -0
  228. package/dist/profiles/activitySummary.js +82 -0
  229. package/dist/profiles/blocks.d.ts +12 -0
  230. package/dist/profiles/blocks.js +73 -0
  231. package/dist/profiles/cache.d.ts +1 -0
  232. package/dist/profiles/cache.js +30 -10
  233. package/dist/profiles/export.js +30 -39
  234. package/dist/profiles/finders.d.ts +2 -1
  235. package/dist/profiles/finders.js +15 -8
  236. package/dist/profiles/helpers.d.ts +2 -0
  237. package/dist/profiles/index.d.ts +2 -0
  238. package/dist/profiles/index.js +2 -0
  239. package/dist/profiles/mapping.d.ts +10 -5
  240. package/dist/profiles/mapping.js +13 -1
  241. package/dist/profiles/mutations.d.ts +8 -4
  242. package/dist/profiles/mutations.js +31 -4
  243. package/dist/redis/connection.d.ts +2 -0
  244. package/dist/redis/connection.js +25 -6
  245. package/dist/reports/helpers.js +7 -3
  246. package/dist/roles/index.d.ts +1 -1
  247. package/dist/roles/index.js +1 -1
  248. package/dist/roles/mapping.d.ts +1 -0
  249. package/dist/roles/mutations.js +85 -3
  250. package/dist/search/finders.js +15 -3
  251. package/dist/search/helpers.js +1 -1
  252. package/dist/search/mapping.d.ts +1 -1
  253. package/dist/search/mapping.js +6 -2
  254. package/dist/sentry/index.js +9 -11
  255. package/dist/seo/index.d.ts +50 -0
  256. package/dist/seo/index.js +145 -0
  257. package/dist/seo/route.d.ts +18 -0
  258. package/dist/seo/route.js +19 -0
  259. package/dist/server/index.d.ts +19 -0
  260. package/dist/server/index.js +31 -14
  261. package/dist/server/stablePublicServerInfo.d.ts +17 -0
  262. package/dist/server/stablePublicServerInfo.js +37 -0
  263. package/dist/server/status.d.ts +25 -0
  264. package/dist/server/status.js +97 -0
  265. package/dist/session/index.js +2 -2
  266. package/dist/stats/finders.d.ts +1 -17681
  267. package/dist/stats/finders.js +22 -9
  268. package/dist/stats/helpers.js +4 -1
  269. package/dist/stats/mapping.d.ts +39 -2
  270. package/dist/stats/mapping.js +8 -4
  271. package/dist/stripe/cache.js +5 -6
  272. package/dist/stripe/connection.js +3 -4
  273. package/dist/stripe/helpers.js +15 -20
  274. package/package.json +5 -7
  275. package/dist/db/migration/detect.d.ts +0 -3
  276. package/dist/db/migration/detect.js +0 -33
  277. package/dist/db/migration/importPostgres.d.ts +0 -3
  278. package/dist/db/migration/importPostgres.js +0 -18
  279. package/dist/db/migration/transform.d.ts +0 -20
  280. package/dist/db/migration/transform.js +0 -232
  281. package/dist/db/migration/validate.d.ts +0 -18
  282. package/dist/db/migration/validate.js +0 -69
  283. package/dist/db/pg/sql/meta/0000_snapshot.json +0 -3380
  284. package/dist/db/pg/sql/meta/0004_snapshot.json +0 -4114
  285. package/dist/db/pg/sql/meta/0005_snapshot.json +0 -4179
  286. package/dist/db/pg/sql/meta/0006_snapshot.json +0 -4200
  287. package/dist/db/pg/sql/meta/0007_snapshot.json +0 -4179
  288. package/dist/mastodon/index.d.ts +0 -4
  289. package/dist/mastodon/index.js +0 -51
  290. package/dist/mastodon/types.d.ts +0 -7579
  291. package/dist/mastodon/types.js +0 -523
  292. package/dist/mastodon/typescript.d.ts +0 -1578
  293. package/dist/mastodon/typescript.js +0 -1
  294. package/dist/migration/index.d.ts +0 -4
  295. package/dist/migration/index.js +0 -4
  296. package/dist/roles/defaults.d.ts +0 -2
  297. package/dist/roles/defaults.js +0 -95
@@ -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',
@@ -3,15 +3,14 @@ import { maybeCreateNotification } from '@openpeepshq/core/notifications';
3
3
  import { profileName } from '@openpeepshq/common/lib';
4
4
  import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
5
5
  const eventHandler = async (...args) => {
6
- var _a, _b;
7
6
  const [profile, post] = args;
8
- 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);
7
+ const jam = post.data?.type === 'event' && post.data?.jam;
9
8
  if (!jam) {
10
9
  return;
11
10
  }
12
11
  if (['local', 'public'].includes(post.visibility)) {
13
12
  for (const recipientProfile of await listProfiles()) {
14
- if (profile.id !== (recipientProfile === null || recipientProfile === void 0 ? void 0 : recipientProfile.id)) {
13
+ if (profile.id !== recipientProfile?.id) {
15
14
  await maybeCreateNotification(recipientProfile, {
16
15
  type: 'jamStarted',
17
16
  fromProfileId: profile.id,
@@ -24,7 +23,7 @@ const eventHandler = async (...args) => {
24
23
  const recipients = new Set();
25
24
  const skipRecipient = (recipient) => !profile ||
26
25
  !recipient ||
27
- profile.id === (recipient === null || recipient === void 0 ? void 0 : recipient.id) ||
26
+ profile.id === recipient?.id ||
28
27
  recipients.has(recipient);
29
28
  if (jam.moderators) {
30
29
  for (const id of [...jam.moderators, ...(jam.speakers || [])]) {
@@ -36,7 +35,7 @@ const eventHandler = async (...args) => {
36
35
  }
37
36
  if (post.audience) {
38
37
  for (const audience of post.audience) {
39
- const audienceProfile = await findProfile(audience === null || audience === void 0 ? void 0 : audience.id);
38
+ const audienceProfile = await findProfile(audience?.id);
40
39
  if (skipRecipient(audienceProfile))
41
40
  continue;
42
41
  recipients.add(audienceProfile);
@@ -44,7 +43,7 @@ const eventHandler = async (...args) => {
44
43
  }
45
44
  if (post.visibility === 'group' && post.group) {
46
45
  for (const { profile: recipient } of await listGroupMembers(post.group)) {
47
- const recipientProfile = await findProfile(recipient === null || recipient === void 0 ? void 0 : recipient.id);
46
+ const recipientProfile = await findProfile(recipient?.id);
48
47
  if (skipRecipient(recipientProfile))
49
48
  continue;
50
49
  recipients.add(recipientProfile);
@@ -58,22 +57,19 @@ const eventHandler = async (...args) => {
58
57
  });
59
58
  }
60
59
  };
61
- const pushRenderer = async (notification) => {
62
- var _a, _b, _c;
63
- return ({
64
- title: `${profileName(notification.senderProfile)} started a jam`,
65
- options: {
66
- body: (_b = (_a = notification.post) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.name,
67
- actions: [
68
- {
69
- action: `goto:/events/${(_c = notification.post) === null || _c === void 0 ? void 0 : _c.id}/jam`,
70
- title: 'Join Jam',
71
- },
72
- ],
73
- },
74
- invalidateQueries: [PUSH_INVALIDATE.posts],
75
- });
76
- };
60
+ const pushRenderer = async (notification) => ({
61
+ title: `${profileName(notification.senderProfile)} started a jam`,
62
+ options: {
63
+ body: notification.post?.data?.name,
64
+ actions: [
65
+ {
66
+ action: `goto:/events/${notification.post?.id}/jam`,
67
+ title: 'Join Jam',
68
+ },
69
+ ],
70
+ },
71
+ invalidateQueries: [PUSH_INVALIDATE.posts],
72
+ });
77
73
  export default {
78
74
  event: 'jamStarted',
79
75
  type: 'jamStarted',
@@ -7,16 +7,15 @@ import { getProfileAvatar, profileName } from '@openpeepshq/common/lib';
7
7
  import { communityConfig } from '../../../config/index.js';
8
8
  import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
9
9
  const getMentionedProfiles = async (post) => {
10
- var _a, _b;
11
10
  const byId = new Map();
12
- for (const mention of (_a = post.mentions) !== null && _a !== void 0 ? _a : []) {
11
+ for (const mention of post.mentions ?? []) {
13
12
  const profile = mention.profile;
14
- if (profile === null || profile === void 0 ? void 0 : profile.id) {
13
+ if (profile?.id) {
15
14
  byId.set(profile.id, profile);
16
15
  }
17
16
  }
18
17
  if (byId.size === 0) {
19
- for (const handle of extractMentionHandles((_b = post.data) === null || _b === void 0 ? void 0 : _b.content)) {
18
+ for (const handle of extractMentionHandles(post.data?.content)) {
20
19
  const profile = await findProfileByHandle(handle);
21
20
  if (profile) {
22
21
  byId.set(profile.id, profile);
@@ -30,9 +29,8 @@ export default {
30
29
  event: 'postCreated',
31
30
  defaultSettings: notificationAll,
32
31
  eventHandler: async (data) => {
33
- var _a, _b;
34
32
  const post = data;
35
- if (((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) === 'event') {
33
+ if (post.data?.type === 'event') {
36
34
  return;
37
35
  }
38
36
  if (post.visibility === 'direct') {
@@ -45,7 +43,8 @@ export default {
45
43
  let replyTargetProfileId;
46
44
  if (post.inReplyToId) {
47
45
  const repliedPost = await findPost(post.inReplyToId);
48
- replyTargetProfileId = (_b = repliedPost === null || repliedPost === void 0 ? void 0 : repliedPost.profile) === null || _b === void 0 ? void 0 : _b.id;
46
+ replyTargetProfileId = repliedPost?.profile
47
+ ?.id;
49
48
  }
50
49
  const notified = new Set();
51
50
  for (const mentionedProfile of mentionedProfiles) {
@@ -69,21 +68,18 @@ export default {
69
68
  }
70
69
  }
71
70
  },
72
- pushRenderer: async (notification) => {
73
- var _a, _b, _c;
74
- return ({
75
- title: `${profileName(notification.senderProfile)} mentioned you`,
76
- options: {
77
- body: (_b = (_a = notification.post) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content,
78
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
79
- actions: [
80
- {
81
- action: `goto:/posts/${(_c = notification.post) === null || _c === void 0 ? void 0 : _c.id}`,
82
- title: 'Go to post',
83
- },
84
- ],
85
- },
86
- invalidateQueries: [PUSH_INVALIDATE.posts],
87
- });
88
- },
71
+ pushRenderer: async (notification) => ({
72
+ title: `${profileName(notification.senderProfile)} mentioned you`,
73
+ options: {
74
+ body: notification.post?.data?.content,
75
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
76
+ actions: [
77
+ {
78
+ action: `goto:/posts/${notification.post?.id}`,
79
+ title: 'Go to post',
80
+ },
81
+ ],
82
+ },
83
+ invalidateQueries: [PUSH_INVALIDATE.posts],
84
+ }),
89
85
  };
@@ -22,21 +22,26 @@ 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
+ const isRepost = !!notification.post?.repost;
26
+ const preview = notification.post?.repost ?? notification.post;
27
+ const name = profileName(notification.post?.profile);
28
+ const group = notification.group?.displayName;
29
+ return {
30
+ title: isRepost
31
+ ? `${name} reposted a post in ${group}`
32
+ : `${name} made a post in ${group}`,
28
33
  options: {
29
- body: (_d = (_c = notification.post) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.content,
34
+ body: preview?.data?.content,
30
35
  icon: getGroupAvatar(notification.group, await communityConfig()),
31
36
  actions: [
32
37
  {
33
- action: `goto:/groups/@${(_e = notification.group) === null || _e === void 0 ? void 0 : _e.handle}`,
38
+ action: `goto:/groups/@${notification.group?.handle}`,
34
39
  title: 'Go to post',
35
40
  },
36
41
  ],
37
42
  },
38
43
  invalidateQueries: [PUSH_INVALIDATE.posts, PUSH_INVALIDATE.unseenCounts],
39
- });
44
+ };
40
45
  };
41
46
  export default {
42
47
  type: 'newGroupPost',
@@ -20,21 +20,18 @@ export default {
20
20
  });
21
21
  }
22
22
  },
23
- pushRenderer: async (notification) => {
24
- var _a;
25
- return ({
26
- title: `New user ${profileName(notification.senderProfile)} joined`,
27
- options: {
28
- body: "Let's welcome them!",
29
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
30
- actions: [
31
- {
32
- action: `goto:/@${(_a = notification.senderProfile) === null || _a === void 0 ? void 0 : _a.handle}`,
33
- title: 'View Profile',
34
- },
35
- ],
36
- },
37
- invalidateQueries: [PUSH_INVALIDATE.profiles],
38
- });
39
- },
23
+ pushRenderer: async (notification) => ({
24
+ title: `New user ${profileName(notification.senderProfile)} joined`,
25
+ options: {
26
+ body: "Let's welcome them!",
27
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
28
+ actions: [
29
+ {
30
+ action: `goto:/@${notification.senderProfile?.handle}`,
31
+ title: 'View Profile',
32
+ },
33
+ ],
34
+ },
35
+ invalidateQueries: [PUSH_INVALIDATE.profiles],
36
+ }),
40
37
  };
@@ -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
+ const post = data;
8
+ if (post.data?.type !== 'question') {
9
+ return;
10
+ }
11
+ const fromProfileId = post.profile?.id;
12
+ for (const recipient of pollEndedRecipientProfiles(post)) {
13
+ await maybeCreateNotification(recipient, {
14
+ type: 'pollEnded',
15
+ postId: post.id,
16
+ ...(fromProfileId ? { fromProfileId } : {}),
17
+ });
18
+ }
19
+ };
20
+ const pushRenderer = async (notification) => ({
21
+ title: 'A poll has ended',
22
+ options: {
23
+ body: notification.post?.data?.content,
24
+ icon: getProfileAvatar(notification.senderProfile ?? notification.post?.profile, await communityConfig()),
25
+ actions: [
26
+ {
27
+ action: `goto:/posts/${notification.post?.id}`,
28
+ title: 'See Results',
29
+ },
30
+ ],
31
+ },
32
+ invalidateQueries: [PUSH_INVALIDATE.posts],
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,17 @@
1
+ import { collectVotes } from '@openpeepshq/common/lib';
2
+ const addProfile = (byId, profile) => {
3
+ if (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
+ const byId = new Map();
10
+ addProfile(byId, post.profile);
11
+ addProfile(byId, post.replyTo?.profile);
12
+ const { votes } = collectVotes(post);
13
+ for (const vote of votes) {
14
+ addProfile(byId, vote.profile);
15
+ }
16
+ return [...byId.values()];
17
+ };
@@ -15,23 +15,20 @@ const eventHandler = async (senderProfile, post, data) => {
15
15
  fromProfileId: fromProfile.id,
16
16
  });
17
17
  };
18
- const pushRenderer = async (notification) => {
19
- var _a, _b, _c;
20
- return ({
21
- title: `New vote on your poll by ${profileName(notification.senderProfile)}`,
22
- options: {
23
- body: (_b = (_a = notification.post) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content,
24
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
25
- actions: [
26
- {
27
- action: `goto:/posts/${(_c = notification.post) === null || _c === void 0 ? void 0 : _c.id}`,
28
- title: 'View Poll',
29
- },
30
- ],
31
- },
32
- invalidateQueries: [PUSH_INVALIDATE.posts],
33
- });
34
- };
18
+ const pushRenderer = async (notification) => ({
19
+ title: `New vote on your poll by ${profileName(notification.senderProfile)}`,
20
+ options: {
21
+ body: notification.post?.data?.content,
22
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
23
+ actions: [
24
+ {
25
+ action: `goto:/posts/${notification.post?.id}`,
26
+ title: 'View Poll',
27
+ },
28
+ ],
29
+ },
30
+ invalidateQueries: [PUSH_INVALIDATE.posts],
31
+ });
35
32
  export default {
36
33
  type: 'pollVote',
37
34
  event: 'entryCreated',
@@ -6,30 +6,27 @@ import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
6
6
  export default {
7
7
  type: 'reaction',
8
8
  event: 'reactionCreated',
9
- pushRenderer: async (notification) => {
10
- var _a, _b, _c;
11
- return ({
12
- title: profileName(notification.senderProfile) +
13
- ' reacted with ' +
14
- notification.data.reaction +
15
- ' to your post',
16
- options: {
17
- body: (_b = (_a = notification.post) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content,
18
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
19
- actions: [
20
- {
21
- action: `goto:/posts/${(_c = notification.post) === null || _c === void 0 ? void 0 : _c.id}`,
22
- title: 'Go to post',
23
- },
24
- ],
25
- },
26
- invalidateQueries: [PUSH_INVALIDATE.posts],
27
- });
28
- },
9
+ pushRenderer: async (notification) => ({
10
+ title: profileName(notification.senderProfile) +
11
+ ' reacted with ' +
12
+ notification.data.reaction +
13
+ ' to your post',
14
+ options: {
15
+ body: notification.post?.data?.content,
16
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
17
+ actions: [
18
+ {
19
+ action: `goto:/posts/${notification.post?.id}`,
20
+ title: 'Go to post',
21
+ },
22
+ ],
23
+ },
24
+ invalidateQueries: [PUSH_INVALIDATE.posts],
25
+ }),
29
26
  eventHandler: async (...eventData) => {
30
27
  const [profile, post, data] = eventData;
31
28
  const recipientProfile = await findProfile(post.profile.id);
32
- if (recipientProfile && (recipientProfile === null || recipientProfile === void 0 ? void 0 : recipientProfile.id) !== profile.id) {
29
+ if (recipientProfile && recipientProfile?.id !== profile.id) {
33
30
  await maybeCreateNotification(recipientProfile, {
34
31
  type: 'reaction',
35
32
  fromProfileId: profile.id,
@@ -10,9 +10,8 @@ export default {
10
10
  event: 'postCreated',
11
11
  defaultSettings: notificationAll,
12
12
  eventHandler: async (data) => {
13
- var _a, _b, _c;
14
13
  const post = data;
15
- if (((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) === 'event') {
14
+ if (post.data?.type === 'event') {
16
15
  return;
17
16
  }
18
17
  if (post.visibility === 'direct') {
@@ -22,7 +21,7 @@ export default {
22
21
  return;
23
22
  }
24
23
  const repliedPost = await findPost(post.inReplyToId);
25
- const targetProfile = await findProfile((_c = (_b = repliedPost === null || repliedPost === void 0 ? void 0 : repliedPost.profile) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '');
24
+ const targetProfile = await findProfile(repliedPost?.profile?.id ?? '');
26
25
  if (targetProfile && targetProfile.id !== post.profile.id) {
27
26
  await maybeCreateNotification(targetProfile, {
28
27
  type: 'reply',
@@ -34,24 +33,24 @@ export default {
34
33
  });
35
34
  }
36
35
  },
37
- expander: async (notification) => (Object.assign(Object.assign({}, notification), { data: {
36
+ expander: async (notification) => ({
37
+ ...notification,
38
+ data: {
38
39
  replyPost: await findPost(notification.data.replyPostId),
39
- } })),
40
- pushRenderer: async (notification) => {
41
- var _a, _b, _c;
42
- return ({
43
- title: `${profileName(notification.senderProfile)} replied your post`,
44
- options: {
45
- body: (_b = (_a = notification.post) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content,
46
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
47
- actions: [
48
- {
49
- action: `goto:/posts/${(_c = notification.post) === null || _c === void 0 ? void 0 : _c.id}`,
50
- title: 'Go to post',
51
- },
52
- ],
53
- },
54
- invalidateQueries: [PUSH_INVALIDATE.posts],
55
- });
56
- },
40
+ },
41
+ }),
42
+ pushRenderer: async (notification) => ({
43
+ title: `${profileName(notification.senderProfile)} replied your post`,
44
+ options: {
45
+ body: notification.post?.data?.content,
46
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
47
+ actions: [
48
+ {
49
+ action: `goto:/posts/${notification.post?.id}`,
50
+ title: 'Go to post',
51
+ },
52
+ ],
53
+ },
54
+ invalidateQueries: [PUSH_INVALIDATE.posts],
55
+ }),
57
56
  };
@@ -7,13 +7,12 @@ export default {
7
7
  type: 'repost',
8
8
  event: 'postCreated',
9
9
  eventHandler: async (data) => {
10
- var _a;
11
10
  const post = data;
12
- if (((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) === 'event')
11
+ if (post.data?.type === 'event')
13
12
  return;
14
13
  if (post.repost) {
15
14
  const recipientProfile = await findProfile(post.repost.profile.id);
16
- if (recipientProfile && (recipientProfile === null || recipientProfile === void 0 ? void 0 : recipientProfile.id) !== post.profile.id) {
15
+ if (recipientProfile && recipientProfile?.id !== post.profile.id) {
17
16
  await maybeCreateNotification(recipientProfile, {
18
17
  type: 'repost',
19
18
  postId: post.repost.id,
@@ -22,21 +21,18 @@ export default {
22
21
  }
23
22
  }
24
23
  },
25
- pushRenderer: async (notification) => {
26
- var _a, _b, _c;
27
- return ({
28
- title: `${profileName(notification.senderProfile)} reposted your post`,
29
- options: {
30
- body: (_b = (_a = notification.post) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content,
31
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
32
- actions: [
33
- {
34
- action: `goto:/posts/${(_c = notification.post) === null || _c === void 0 ? void 0 : _c.id}`,
35
- title: 'Go to post',
36
- },
37
- ],
38
- },
39
- invalidateQueries: [PUSH_INVALIDATE.posts],
40
- });
41
- },
24
+ pushRenderer: async (notification) => ({
25
+ title: `${profileName(notification.senderProfile)} reposted your post`,
26
+ options: {
27
+ body: notification.post?.data?.content,
28
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
29
+ actions: [
30
+ {
31
+ action: `goto:/posts/${notification.post?.id}`,
32
+ title: 'Go to post',
33
+ },
34
+ ],
35
+ },
36
+ invalidateQueries: [PUSH_INVALIDATE.posts],
37
+ }),
42
38
  };
@@ -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,5 +1,6 @@
1
+ import { notificationAll, } from '@openpeepshq/common/types';
1
2
  import { maybeCreateNotification } from '@openpeepshq/core/notifications';
2
- import { getProfileAvatar, profileName } from '@openpeepshq/common/lib';
3
+ import { getProfileAvatar, profileName, rsvpTargetsPastEvent, } from '@openpeepshq/common/lib';
3
4
  import { communityConfig } from '../../../config/index.js';
4
5
  import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
5
6
  const eventHandler = async (senderProfile, post, data) => {
@@ -9,32 +10,44 @@ 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
+ }
18
+ // RSVPs to a finished event are still stored; they just should not notify.
19
+ const payload = data;
20
+ if (mergedPost.data?.type === 'event' &&
21
+ rsvpTargetsPastEvent(mergedPost.data, {
22
+ occurrenceIds: payload.occurrenceIds,
23
+ recurrenceId: entryData.data.recurrenceId,
24
+ })) {
25
+ return;
26
+ }
12
27
  await maybeCreateNotification(mergedPost.profile, {
13
28
  type: 'rsvp',
14
29
  postId: mergedPost.id,
15
30
  fromProfileId: fromProfile.id,
16
31
  });
17
32
  };
18
- const pushRenderer = async (notification) => {
19
- var _a, _b, _c;
20
- return ({
21
- title: `${profileName(notification.senderProfile)} RSVP'd to your event`,
22
- options: {
23
- body: (_b = (_a = notification.post) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content,
24
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
25
- actions: [
26
- {
27
- action: `goto:/posts/${(_c = notification.post) === null || _c === void 0 ? void 0 : _c.id}`,
28
- title: 'View RSVP',
29
- },
30
- ],
31
- },
32
- invalidateQueries: [PUSH_INVALIDATE.posts],
33
- });
34
- };
33
+ const pushRenderer = async (notification) => ({
34
+ title: `${profileName(notification.senderProfile)} RSVP'd to your event`,
35
+ options: {
36
+ body: notification.post?.data?.content,
37
+ icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
38
+ actions: [
39
+ {
40
+ action: `goto:/posts/${notification.post?.id}`,
41
+ title: 'View RSVP',
42
+ },
43
+ ],
44
+ },
45
+ invalidateQueries: [PUSH_INVALIDATE.posts],
46
+ });
35
47
  export default {
36
48
  type: 'rsvp',
37
49
  event: 'rsvpCreated',
50
+ defaultSettings: notificationAll,
38
51
  eventHandler,
39
52
  pushRenderer,
40
53
  };