@openpeepshq/core 0.1.34 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accessTokens/finders.js +5 -6
- package/dist/accessTokens/mutations.js +1 -1
- package/dist/accessTokens/tokens.js +8 -11
- package/dist/accounts/helpers.js +6 -2
- package/dist/accounts/mutations.js +13 -8
- package/dist/analytics/cache.js +3 -3
- package/dist/analytics/clicks.js +14 -22
- package/dist/analytics/compile.js +1 -2
- package/dist/analytics/dateRange.js +3 -5
- package/dist/analytics/jobs.js +3 -4
- package/dist/analytics/pdfReport.js +45 -61
- package/dist/analytics/privacy.js +1 -1
- package/dist/analytics/read.js +116 -135
- package/dist/analytics/report.d.ts +2 -1
- package/dist/analytics/report.js +2 -3
- package/dist/analytics/settings.js +3 -4
- package/dist/backups/index.js +13 -16
- package/dist/backups/metadata.js +1 -1
- package/dist/config/db.js +2 -4
- package/dist/config/defaults/community.js +1 -0
- package/dist/config/defaults/core.js +13 -8
- package/dist/config/defaults/logs.d.ts +4 -0
- package/dist/config/defaults/logs.js +5 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.js +9 -11
- package/dist/db/explorer/query.js +9 -8
- package/dist/db/explorer/sql.js +8 -8
- package/dist/db/helpers.js +15 -5
- package/dist/db/migration/importCollections.js +15 -18
- package/dist/db/migration/shared.js +15 -35
- package/dist/db/pg/client.js +4 -7
- package/dist/db/pg/filters/index.js +1 -1
- package/dist/db/pg/filters/posts.d.ts +2 -0
- package/dist/db/pg/filters/posts.js +3 -1
- package/dist/db/pg/helpers.js +2 -14
- package/dist/db/pg/map/filters.js +8 -8
- package/dist/db/pg/map/helpers.js +5 -1
- package/dist/db/pg/map/index.js +46 -51
- package/dist/db/pg/map/mutations.js +56 -21
- package/dist/db/pg/map/registry.js +87 -50
- package/dist/db/pg/map/relations.js +67 -63
- package/dist/db/pg/map/search.js +15 -37
- package/dist/db/pg/mappers.js +13 -7
- package/dist/db/pg/migrate.js +2 -3
- package/dist/db/pg/queries/activity.js +2 -2
- package/dist/db/pg/queries/derived.js +8 -12
- package/dist/db/pg/schema/documents.js +119 -18
- package/dist/db/pg/schema/edges.js +7 -1
- package/dist/db/pg/schema/index.js +5 -1
- package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
- package/dist/db/pg/sql/meta/_journal.json +8 -1
- package/dist/db/replaceOrigin.js +1 -1
- package/dist/email/queueStats.js +8 -11
- package/dist/email/render.js +7 -4
- package/dist/email/send.js +19 -17
- package/dist/email/smtpTest.js +10 -6
- package/dist/errors/index.js +1 -1
- package/dist/events/once.js +2 -4
- package/dist/federation/activities.js +1 -2
- package/dist/groups/finders.d.ts +2 -2
- package/dist/groups/helpers.d.ts +6 -6
- package/dist/groups/helpers.js +1 -2
- package/dist/groups/mapping.d.ts +4 -4
- package/dist/groups/mutations.js +1 -1
- package/dist/hashtags/finders.js +2 -2
- package/dist/inviteLinks/mutations.js +2 -3
- package/dist/jams/export.js +5 -7
- package/dist/jams/finders.js +4 -1
- package/dist/jams/health.d.ts +6 -4
- package/dist/jams/health.js +15 -11
- package/dist/jams/helpers.d.ts +2 -2
- package/dist/jams/helpers.js +6 -2
- package/dist/jams/index.js +2 -2
- package/dist/jams/jobs.js +1 -2
- package/dist/jams/livekit.d.ts +2 -2
- package/dist/jams/livekit.js +8 -8
- package/dist/jams/mapping.d.ts +10 -10
- package/dist/jams/mutations.d.ts +2 -2
- package/dist/jams/recording.js +1 -1
- package/dist/jams/token.js +13 -17
- package/dist/jobs/index.js +7 -6
- package/dist/jobs/jobDetail.js +5 -6
- package/dist/jobs/jobLog.js +2 -3
- package/dist/lib/streams.js +4 -39
- package/dist/lib/zodDeepPartial.d.ts +1 -1
- package/dist/lib/zodDeepPartial.js +1 -1
- package/dist/log/index.d.ts +1 -0
- package/dist/log/index.js +14 -29
- package/dist/log/retention.d.ts +9 -0
- package/dist/log/retention.js +83 -0
- package/dist/log/retentionJobs.d.ts +17 -0
- package/dist/log/retentionJobs.js +50 -0
- package/dist/media/index.js +127 -4
- package/dist/media/jobs.js +1 -2
- package/dist/media/openpeeps/index.js +11 -46
- package/dist/media/processing.js +7 -4
- package/dist/media/streaming.js +5 -5
- package/dist/media/streamingCleanupJobs.js +1 -2
- package/dist/media/streamingJobs.js +3 -4
- package/dist/media/streamingPrewarm.js +7 -11
- package/dist/mediaAttachments/index.js +6 -2
- package/dist/mediaAttachments/mapping.d.ts +1 -1
- package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
- package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
- package/dist/notifications/defaultNotifications/follow/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
- package/dist/notifications/defaultNotifications/jamModerator/index.js +27 -20
- package/dist/notifications/defaultNotifications/jamModerator/recipients.d.ts +2 -0
- package/dist/notifications/defaultNotifications/jamModerator/recipients.js +5 -0
- package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
- package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
- package/dist/notifications/defaultNotifications/mention/index.js +20 -24
- package/dist/notifications/defaultNotifications/newGroupPost/index.js +9 -10
- package/dist/notifications/defaultNotifications/newGroupPost/recipients.d.ts +5 -0
- package/dist/notifications/defaultNotifications/newGroupPost/recipients.js +23 -0
- package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
- package/dist/notifications/defaultNotifications/pollEnded/index.js +21 -21
- package/dist/notifications/defaultNotifications/pollEnded/recipients.js +2 -3
- package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
- package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
- package/dist/notifications/defaultNotifications/reply/index.js +21 -22
- package/dist/notifications/defaultNotifications/repost/index.js +16 -20
- package/dist/notifications/defaultNotifications/rsvp/index.js +24 -18
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +20 -13
- package/dist/notifications/eventIcsAttachment.d.ts +6 -0
- package/dist/notifications/eventIcsAttachment.js +32 -0
- package/dist/notifications/fcmCredential.js +1 -1
- package/dist/notifications/finders.js +1 -1
- package/dist/notifications/helpers.d.ts +11 -1
- package/dist/notifications/helpers.js +38 -9
- package/dist/notifications/jobs.js +16 -7
- package/dist/notifications/mutations.js +13 -2
- package/dist/notifications/push.js +11 -16
- package/dist/performance/index.js +3 -3
- package/dist/plugins/helpers.js +3 -6
- package/dist/plugins/index.js +2 -3
- package/dist/plugins/install.js +31 -17
- package/dist/plugins/pluginAuth.js +3 -4
- package/dist/plugins/state.js +2 -3
- package/dist/posts/activity.d.ts +1 -1
- package/dist/posts/activity.js +2 -3
- package/dist/posts/contextClosure.js +1 -2
- package/dist/posts/conversationQueries.js +2 -4
- package/dist/posts/eventAgenda.js +12 -7
- package/dist/posts/eventOccurrences.js +2 -2
- package/dist/posts/finders.d.ts +46 -6
- package/dist/posts/finders.js +21 -9
- package/dist/posts/helpers/filters.js +2 -3
- package/dist/posts/helpers/index.d.ts +170 -18
- package/dist/posts/helpers/index.js +43 -27
- package/dist/posts/mapping.d.ts +616 -84
- package/dist/posts/mapping.js +60 -18
- package/dist/posts/mutations.d.ts +85 -9
- package/dist/posts/mutations.js +47 -34
- package/dist/posts/pollEnd.js +3 -6
- package/dist/posts/rsvpConfirmationEmail.js +18 -8
- package/dist/posts/threadPreview.js +1 -1
- package/dist/processingStats/queries.js +6 -7
- package/dist/profileSettings/cache.js +1 -2
- package/dist/profileSettings/mapping.d.ts +1 -0
- package/dist/profiles/activitySummary.js +23 -28
- package/dist/profiles/cache.js +15 -8
- package/dist/profiles/export.js +30 -39
- package/dist/profiles/finders.js +7 -5
- package/dist/profiles/mapping.d.ts +10 -10
- package/dist/profiles/mutations.js +3 -5
- package/dist/redis/connection.js +1 -1
- package/dist/reports/helpers.js +7 -3
- package/dist/reports/mapping.d.ts +1 -1
- package/dist/roles/mutations.js +20 -21
- package/dist/search/finders.js +15 -3
- package/dist/search/helpers.js +1 -1
- package/dist/sentry/index.js +9 -11
- package/dist/seo/index.d.ts +50 -0
- package/dist/seo/index.js +145 -0
- package/dist/seo/route.d.ts +18 -0
- package/dist/seo/route.js +19 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +16 -11
- package/dist/server/status.js +6 -7
- package/dist/session/index.js +2 -2
- package/dist/stats/finders.js +13 -4
- package/dist/stats/helpers.js +4 -1
- package/dist/stats/mapping.d.ts +43 -5
- package/dist/stats/mapping.js +9 -2
- package/dist/stripe/cache.js +5 -6
- package/dist/stripe/connection.js +3 -4
- package/dist/stripe/helpers.js +15 -20
- package/package.json +5 -6
- package/LICENSE +0 -674
|
@@ -4,15 +4,15 @@ import { maybeCreateNotification } from '@openpeepshq/core/notifications';
|
|
|
4
4
|
import { getGroupAvatar, profileName } from '@openpeepshq/common/lib';
|
|
5
5
|
import { communityConfig } from '../../../config/index.js';
|
|
6
6
|
import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
|
|
7
|
+
import { newGroupPostRecipients } from './recipients.js';
|
|
7
8
|
const eventHandler = async (data) => {
|
|
8
9
|
const post = data;
|
|
9
10
|
if (!post.group) {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
const group = post.group;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.filter((profile) => post.profile.id !== profile.id))) {
|
|
14
|
+
const members = (await listGroupMembers(group)).map((m) => m.profile);
|
|
15
|
+
for (const groupMember of newGroupPostRecipients(post, members)) {
|
|
16
16
|
await maybeCreateNotification(groupMember, {
|
|
17
17
|
type: 'newGroupPost',
|
|
18
18
|
fromProfileId: post.profile.id,
|
|
@@ -22,21 +22,20 @@ const eventHandler = async (data) => {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
const pushRenderer = async (notification) => {
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
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:
|
|
34
|
+
body: preview?.data?.content,
|
|
36
35
|
icon: getGroupAvatar(notification.group, await communityConfig()),
|
|
37
36
|
actions: [
|
|
38
37
|
{
|
|
39
|
-
action: `goto:/groups/@${
|
|
38
|
+
action: `goto:/groups/@${notification.group?.handle}`,
|
|
40
39
|
title: 'Go to post',
|
|
41
40
|
},
|
|
42
41
|
],
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PostWithMeta } from '@openpeepshq/common/types';
|
|
2
|
+
/** Group members to notify. Skips the author and anyone already notified of the reply. */
|
|
3
|
+
export declare const newGroupPostRecipients: <T extends {
|
|
4
|
+
id: string;
|
|
5
|
+
}>(post: PostWithMeta, members: T[]) => T[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parent author already gets a reply notification for this post.
|
|
3
|
+
* Event replies and direct posts do not create one, so they still
|
|
4
|
+
* receive the group notification.
|
|
5
|
+
*/
|
|
6
|
+
const replyNotificationRecipientId = (post) => {
|
|
7
|
+
if (post.data?.type === 'event' || post.visibility === 'direct') {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
if (!post.inReplyToId) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const parentAuthorId = post.replyTo?.profile?.id ?? post.replyTo?.creatorId;
|
|
14
|
+
if (!parentAuthorId || parentAuthorId === post.profile.id) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return parentAuthorId;
|
|
18
|
+
};
|
|
19
|
+
/** Group members to notify. Skips the author and anyone already notified of the reply. */
|
|
20
|
+
export const newGroupPostRecipients = (post, members) => {
|
|
21
|
+
const parentAuthorId = replyNotificationRecipientId(post);
|
|
22
|
+
return members.filter((member) => member.id !== post.profile.id && member.id !== parentAuthorId);
|
|
23
|
+
};
|
|
@@ -20,21 +20,18 @@ export default {
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
-
pushRenderer: async (notification) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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 (
|
|
8
|
+
if (post.data?.type !== 'question') {
|
|
10
9
|
return;
|
|
11
10
|
}
|
|
12
|
-
const fromProfileId =
|
|
11
|
+
const fromProfileId = post.profile?.id;
|
|
13
12
|
for (const recipient of pollEndedRecipientProfiles(post)) {
|
|
14
|
-
await maybeCreateNotification(recipient,
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
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,
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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 &&
|
|
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 (
|
|
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(
|
|
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) => (
|
|
36
|
+
expander: async (notification) => ({
|
|
37
|
+
...notification,
|
|
38
|
+
data: {
|
|
38
39
|
replyPost: await findPost(notification.data.replyPostId),
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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 (
|
|
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 &&
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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) =>
|
|
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
|
|
20
|
+
const cancel = data?.cancel;
|
|
22
21
|
if (!isRsvpCancelNotice(cancel))
|
|
23
22
|
return;
|
|
24
|
-
if (mergedPost.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
|
-
...(
|
|
30
|
-
...(
|
|
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) =>
|
|
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,
|
|
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(
|
|
49
|
-
const when = whenText(
|
|
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/${
|
|
64
|
+
action: `goto:/posts/${notification.post?.id}`,
|
|
58
65
|
title: 'View event',
|
|
59
66
|
},
|
|
60
67
|
],
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EmailAttachment, ExpandedNotification } from '@openpeepshq/common/types';
|
|
2
|
+
/**
|
|
3
|
+
* Calendar file so a notification email about an event can be added to a
|
|
4
|
+
* calendar. Non-event notifications return undefined.
|
|
5
|
+
*/
|
|
6
|
+
export declare const eventIcsEmailAttachment: (notification: ExpandedNotification, rootUrl: string) => EmailAttachment | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { buildEventIcs } from '@openpeepshq/common/lib';
|
|
2
|
+
const isEventPost = (post) => post?.type === 'event' && post.data?.type === 'event';
|
|
3
|
+
/** The event this notification is about: the post itself, or the post it reposts. */
|
|
4
|
+
const eventPostOf = (notification) => {
|
|
5
|
+
const post = notification.post;
|
|
6
|
+
if (!post)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (isEventPost(post))
|
|
9
|
+
return post;
|
|
10
|
+
if (isEventPost(post.repost))
|
|
11
|
+
return post.repost;
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Calendar file so a notification email about an event can be added to a
|
|
16
|
+
* calendar. Non-event notifications return undefined.
|
|
17
|
+
*/
|
|
18
|
+
export const eventIcsEmailAttachment = (notification, rootUrl) => {
|
|
19
|
+
const post = eventPostOf(notification);
|
|
20
|
+
if (!post)
|
|
21
|
+
return undefined;
|
|
22
|
+
const ics = buildEventIcs(post, {
|
|
23
|
+
postUrl: `${rootUrl}/posts/${post.id}`,
|
|
24
|
+
});
|
|
25
|
+
if (!ics)
|
|
26
|
+
return undefined;
|
|
27
|
+
return {
|
|
28
|
+
filename: 'event.ics',
|
|
29
|
+
content: ics,
|
|
30
|
+
contentType: 'text/calendar; method=PUBLISH; charset=utf-8',
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -51,7 +51,7 @@ export const createFcmCredential = (serviceAccount, agent) => {
|
|
|
51
51
|
return {
|
|
52
52
|
getAccessToken: async () => {
|
|
53
53
|
const now = Date.now();
|
|
54
|
-
if (cached && cached.expiresAt > now +
|
|
54
|
+
if (cached && cached.expiresAt > now + 60_000) {
|
|
55
55
|
return {
|
|
56
56
|
access_token: cached.access_token,
|
|
57
57
|
expires_in: Math.floor((cached.expiresAt - now) / 1000),
|
|
@@ -3,7 +3,7 @@ import { addStart, filterAndTransform } from '../db/helpers.js';
|
|
|
3
3
|
import { baseListNotifications, expandNotification, unreadNotifications, unseenNotifications, } from './helpers.js';
|
|
4
4
|
export const findNotification = (profile, notificationId) => allpeepDb()
|
|
5
5
|
.then(({ db }) => baseListNotifications(profile).find(db, notificationId))
|
|
6
|
-
.then((notification) =>
|
|
6
|
+
.then((notification) => notification?.profileId === profile.id
|
|
7
7
|
? expandNotification(notification)
|
|
8
8
|
: undefined);
|
|
9
9
|
export const listNotificationsByProfile = (profile, { start, limit = 100 } = { limit: 100 }) => allpeepDb().then(({ db }) => filterAndTransform(addStart(baseListNotifications(profile), start), db, { transform: expandNotification, limit }));
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { NotificationData, ProfileWithMeta, ProfileNotificationSettings, ExpandedNotification, DbNotification, ProfileSettings } from '@openpeepshq/common/types';
|
|
1
|
+
import { NotificationData, ProfileWithMeta, ProfileNotificationSettings, ExpandedNotification, DbNotification, ProfileSettings, GroupNotificationLevel } from '@openpeepshq/common/types';
|
|
2
2
|
import type { Mapping } from '../db/pg/map';
|
|
3
3
|
export declare const baseListNotifications: (profile: ProfileWithMeta) => Mapping<NotificationData, DbNotification>;
|
|
4
4
|
export declare const notificationSettings: (profileSettings: ProfileSettings, type: NotificationData["type"]) => ProfileNotificationSettings;
|
|
5
|
+
export declare const groupNotificationLevelFor: (profileSettings: ProfileSettings | undefined, groupId?: string | null) => GroupNotificationLevel;
|
|
6
|
+
/**
|
|
7
|
+
* `mostRelevant` keeps posts from people the member follows. Membership
|
|
8
|
+
* changes are only included at `all` — there is no separate relevance rank.
|
|
9
|
+
*/
|
|
10
|
+
export declare const allowsGroupNotification: ({ level, type, followsAuthor, }: {
|
|
11
|
+
level: GroupNotificationLevel;
|
|
12
|
+
type: string;
|
|
13
|
+
followsAuthor: boolean;
|
|
14
|
+
}) => boolean;
|
|
5
15
|
export declare const expandNotification: (notification: DbNotification) => Promise<ExpandedNotification>;
|
|
6
16
|
export declare const unseenNotifications: (profile: ProfileWithMeta) => Promise<number>;
|
|
7
17
|
export declare const unreadNotifications: (profile: ProfileWithMeta) => Promise<number>;
|