@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
@@ -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,20 @@ const eventHandler = async (data) => {
22
22
  }
23
23
  };
24
24
  const pushRenderer = async (notification) => {
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;
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;
30
29
  return {
31
30
  title: isRepost
32
31
  ? `${name} reposted a post in ${group}`
33
32
  : `${name} made a post in ${group}`,
34
33
  options: {
35
- body: (_f = preview === null || preview === void 0 ? void 0 : preview.data) === null || _f === void 0 ? void 0 : _f.content,
34
+ body: preview?.data?.content,
36
35
  icon: getGroupAvatar(notification.group, await communityConfig()),
37
36
  actions: [
38
37
  {
39
- action: `goto:/groups/@${(_g = notification.group) === null || _g === void 0 ? void 0 : _g.handle}`,
38
+ action: `goto:/groups/@${notification.group?.handle}`,
40
39
  title: 'Go to post',
41
40
  },
42
41
  ],
@@ -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
  };
@@ -4,33 +4,33 @@ import { communityConfig } from '../../../config/index.js';
4
4
  import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
5
5
  import { pollEndedRecipientProfiles } from './recipients.js';
6
6
  const eventHandler = async (data) => {
7
- var _a, _b;
8
7
  const post = data;
9
- if (((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) !== 'question') {
8
+ if (post.data?.type !== 'question') {
10
9
  return;
11
10
  }
12
- const fromProfileId = (_b = post.profile) === null || _b === void 0 ? void 0 : _b.id;
11
+ const fromProfileId = post.profile?.id;
13
12
  for (const recipient of pollEndedRecipientProfiles(post)) {
14
- await maybeCreateNotification(recipient, Object.assign({ type: 'pollEnded', postId: post.id }, (fromProfileId ? { fromProfileId } : {})));
13
+ await maybeCreateNotification(recipient, {
14
+ type: 'pollEnded',
15
+ postId: post.id,
16
+ ...(fromProfileId ? { fromProfileId } : {}),
17
+ });
15
18
  }
16
19
  };
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
- };
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
34
  export default {
35
35
  type: 'pollEnded',
36
36
  event: 'pollEnded',
@@ -1,15 +1,14 @@
1
1
  import { collectVotes } from '@openpeepshq/common/lib';
2
2
  const addProfile = (byId, profile) => {
3
- if (profile === null || profile === void 0 ? void 0 : profile.id) {
3
+ if (profile?.id) {
4
4
  byId.set(profile.id, profile);
5
5
  }
6
6
  };
7
7
  /** Poll author, voters, and parent post author when the poll is a reply. */
8
8
  export const pollEndedRecipientProfiles = (post) => {
9
- var _a;
10
9
  const byId = new Map();
11
10
  addProfile(byId, post.profile);
12
- addProfile(byId, (_a = post.replyTo) === null || _a === void 0 ? void 0 : _a.profile);
11
+ addProfile(byId, post.replyTo?.profile);
13
12
  const { votes } = collectVotes(post);
14
13
  for (const vote of votes) {
15
14
  addProfile(byId, vote.profile);
@@ -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,6 +1,6 @@
1
1
  import { notificationAll, } from '@openpeepshq/common/types';
2
2
  import { maybeCreateNotification } from '@openpeepshq/core/notifications';
3
- import { getProfileAvatar, profileName } from '@openpeepshq/common/lib';
3
+ import { getProfileAvatar, profileName, rsvpTargetsPastEvent, } from '@openpeepshq/common/lib';
4
4
  import { communityConfig } from '../../../config/index.js';
5
5
  import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
6
6
  const eventHandler = async (senderProfile, post, data) => {
@@ -15,29 +15,35 @@ const eventHandler = async (senderProfile, post, data) => {
15
15
  if (response !== 'yes' && response !== 'tentative') {
16
16
  return;
17
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
+ }
18
27
  await maybeCreateNotification(mergedPost.profile, {
19
28
  type: 'rsvp',
20
29
  postId: mergedPost.id,
21
30
  fromProfileId: fromProfile.id,
22
31
  });
23
32
  };
24
- const pushRenderer = async (notification) => {
25
- var _a, _b, _c;
26
- return ({
27
- title: `${profileName(notification.senderProfile)} RSVP'd to your event`,
28
- options: {
29
- body: (_b = (_a = notification.post) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content,
30
- icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
31
- actions: [
32
- {
33
- action: `goto:/posts/${(_c = notification.post) === null || _c === void 0 ? void 0 : _c.id}`,
34
- title: 'View RSVP',
35
- },
36
- ],
37
- },
38
- invalidateQueries: [PUSH_INVALIDATE.posts],
39
- });
40
- };
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
+ });
41
47
  export default {
42
48
  type: 'rsvp',
43
49
  event: 'rsvpCreated',
@@ -1,11 +1,11 @@
1
1
  import { notificationAll, } from '@openpeepshq/common/types';
2
- import { getProfileAvatar, isRsvpCancelNotice, profileName, rsvpCancelWhenLabels, } from '@openpeepshq/common/lib';
2
+ import { getProfileAvatar, isRsvpCancelNotice, profileName, rsvpCancelWhenLabels, rsvpTargetsPastEvent, } from '@openpeepshq/common/lib';
3
3
  import { maybeCreateNotification } from '@openpeepshq/core/notifications';
4
4
  import { findProfile, listGroupMembers } from '@openpeepshq/core/profiles';
5
5
  import { communityConfig } from '../../../config/index.js';
6
6
  import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
7
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; };
8
+ const eventName = (post) => post?.data?.type === 'event' ? post.data.name?.trim() : undefined;
9
9
  const whenText = (post, notice) => {
10
10
  if (!post)
11
11
  return '';
@@ -15,38 +15,45 @@ const whenText = (post, notice) => {
15
15
  return when.labels.join(', ');
16
16
  };
17
17
  const eventHandler = async (senderProfile, post, data) => {
18
- var _a, _b, _c, _d;
19
18
  const mergedPost = post;
20
19
  const fromProfile = senderProfile;
21
- const cancel = data === null || data === void 0 ? void 0 : data.cancel;
20
+ const cancel = data?.cancel;
22
21
  if (!isRsvpCancelNotice(cancel))
23
22
  return;
24
- if (mergedPost.type !== 'event' || ((_a = mergedPost.data) === null || _a === void 0 ? void 0 : _a.type) !== 'event') {
23
+ if (mergedPost.type !== 'event' || mergedPost.data?.type !== 'event') {
25
24
  return;
26
25
  }
27
26
  const event = mergedPost.data;
27
+ if (rsvpTargetsPastEvent(event, cancel.series ? undefined : { occurrenceIds: cancel.occurrenceIds })) {
28
+ return;
29
+ }
28
30
  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
+ ...(event.moderators ?? []),
32
+ ...(event.jam?.moderators ?? []),
31
33
  ];
32
34
  const moderators = (await Promise.all(moderatorIds.map((id) => findProfile(id)))).filter((profile) => !!profile);
33
35
  const groupAdmins = mergedPost.group
34
36
  ? (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')); })
37
+ .filter((member) => member.roles?.includes('owner') || member.roles?.includes('admin'))
36
38
  .map((member) => member.profile)
37
39
  : [];
38
40
  const recipients = rsvpCancelRecipients([mergedPost.profile, ...moderators, ...groupAdmins], fromProfile.id);
39
41
  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 }));
42
+ await maybeCreateNotification(recipient, {
43
+ type: 'rsvpCanceled',
44
+ postId: mergedPost.id,
45
+ fromProfileId: fromProfile.id,
46
+ ...(mergedPost.groupId ? { groupId: mergedPost.groupId } : {}),
47
+ data: cancel,
48
+ });
41
49
  }
42
50
  };
43
51
  const pushRenderer = async (notification) => {
44
- var _a, _b, _c;
45
52
  const notice = isRsvpCancelNotice(notification.data)
46
53
  ? notification.data
47
54
  : { 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);
55
+ const name = eventName(notification.post ?? undefined);
56
+ const when = whenText(notification.post ?? undefined, notice);
50
57
  return {
51
58
  title: `${profileName(notification.senderProfile)} canceled their RSVP`,
52
59
  options: {
@@ -54,7 +61,7 @@ const pushRenderer = async (notification) => {
54
61
  icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
55
62
  actions: [
56
63
  {
57
- action: `goto:/posts/${(_c = notification.post) === null || _c === void 0 ? void 0 : _c.id}`,
64
+ action: `goto:/posts/${notification.post?.id}`,
58
65
  title: 'View event',
59
66
  },
60
67
  ],