@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
|
@@ -18,14 +18,13 @@ const log = logger('app:media:streamingPrewarm');
|
|
|
18
18
|
* being created right now?" semantics.
|
|
19
19
|
*/
|
|
20
20
|
export const ensureStreamingJob = async (storageId) => {
|
|
21
|
-
var _a;
|
|
22
21
|
// Refresh the last-access marker so the daily cleanup job doesn't evict a
|
|
23
22
|
// stream that someone just expressed interest in. Fire-and-forget and
|
|
24
23
|
// debounced; safe to call from many sites.
|
|
25
24
|
void recordStreamAccess(storageId);
|
|
26
25
|
const existing = await getStreamStatus(storageId);
|
|
27
26
|
if (existing) {
|
|
28
|
-
return
|
|
27
|
+
return { storageId, ...existing };
|
|
29
28
|
}
|
|
30
29
|
// Create the directory before enqueueing so any subsequent caller hitting
|
|
31
30
|
// this code path immediately observes `processing` via `getStreamStatus`
|
|
@@ -42,7 +41,7 @@ export const ensureStreamingJob = async (storageId) => {
|
|
|
42
41
|
// next POST will report it as `processing`.
|
|
43
42
|
await queue.remove(jobId).catch(() => undefined);
|
|
44
43
|
await queue.add('transcode', { storageId }, { jobId });
|
|
45
|
-
return (
|
|
44
|
+
return (await buildStream(storageId)) ?? { storageId, status: 'processing' };
|
|
46
45
|
};
|
|
47
46
|
/**
|
|
48
47
|
* Pre-warms HLS streams for any local-storage-hosted videos in the given
|
|
@@ -50,7 +49,6 @@ export const ensureStreamingJob = async (storageId) => {
|
|
|
50
49
|
* skipped.
|
|
51
50
|
*/
|
|
52
51
|
const prewarmVideoAttachments = async (attachments, context) => {
|
|
53
|
-
var _a;
|
|
54
52
|
for (const attachment of attachments) {
|
|
55
53
|
if (!attachment || attachment.type !== 'video' || !attachment.url) {
|
|
56
54
|
continue;
|
|
@@ -66,7 +64,7 @@ const prewarmVideoAttachments = async (attachments, context) => {
|
|
|
66
64
|
}
|
|
67
65
|
catch (e) {
|
|
68
66
|
// A single bad attachment shouldn't block prewarming siblings.
|
|
69
|
-
log.warn(`Failed to prewarm HLS for ${context} attachment ${
|
|
67
|
+
log.warn(`Failed to prewarm HLS for ${context} attachment ${attachment.url ?? '?'}: ${e.message}`);
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
70
|
};
|
|
@@ -76,12 +74,11 @@ const prewarmVideoAttachments = async (attachments, context) => {
|
|
|
76
74
|
* play them the transcoded ladder is already (or nearly) ready.
|
|
77
75
|
*/
|
|
78
76
|
export const prewarmPostStreams = async (rawPost) => {
|
|
79
|
-
var _a, _b;
|
|
80
77
|
const post = rawPost;
|
|
81
|
-
const attachments =
|
|
78
|
+
const attachments = post?.data?.attachments;
|
|
82
79
|
if (!attachments || attachments.length === 0)
|
|
83
80
|
return;
|
|
84
|
-
await prewarmVideoAttachments(attachments, `post ${
|
|
81
|
+
await prewarmVideoAttachments(attachments, `post ${post?.id ?? '?'}`);
|
|
85
82
|
};
|
|
86
83
|
/**
|
|
87
84
|
* Pre-warms HLS for a completed jam recording's video attachment as soon as
|
|
@@ -89,12 +86,11 @@ export const prewarmPostStreams = async (rawPost) => {
|
|
|
89
86
|
* recording post.
|
|
90
87
|
*/
|
|
91
88
|
export const prewarmJamRecordingStream = async (rawRecording) => {
|
|
92
|
-
var _a;
|
|
93
89
|
const recording = rawRecording;
|
|
94
|
-
const attachment = recording
|
|
90
|
+
const attachment = recording?.attachment;
|
|
95
91
|
if (!attachment)
|
|
96
92
|
return;
|
|
97
|
-
await prewarmVideoAttachments([attachment], `jam recording ${
|
|
93
|
+
await prewarmVideoAttachments([attachment], `jam recording ${recording?.id ?? '?'}`);
|
|
98
94
|
};
|
|
99
95
|
/**
|
|
100
96
|
* Registers event handlers that pre-warm HLS streams for post videos and
|
|
@@ -7,6 +7,10 @@ const setUrlToCurrentHost = async (url) => {
|
|
|
7
7
|
parsedUrl.host = (await config()).server.host;
|
|
8
8
|
return parsedUrl.toString();
|
|
9
9
|
};
|
|
10
|
-
export const convertUrls = async (data) => (
|
|
10
|
+
export const convertUrls = async (data) => ({
|
|
11
|
+
...data,
|
|
12
|
+
url: await setUrlToCurrentHost(data.url),
|
|
13
|
+
previewUrl: data.previewUrl
|
|
11
14
|
? await setUrlToCurrentHost(data.previewUrl)
|
|
12
|
-
: null
|
|
15
|
+
: null,
|
|
16
|
+
});
|
|
@@ -16,6 +16,6 @@ export declare const mediaAttachmentsMapping: import("../db/pg/map").Mapping<{
|
|
|
16
16
|
};
|
|
17
17
|
description?: string | undefined;
|
|
18
18
|
blurhash?: string | undefined;
|
|
19
|
-
status?: "
|
|
19
|
+
status?: "failed" | "ready" | "processing" | undefined;
|
|
20
20
|
error?: string | undefined;
|
|
21
21
|
}, MediaAttachment, MediaAttachment>;
|
|
@@ -7,7 +7,7 @@ import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
|
|
|
7
7
|
const eventHandler = async (data) => {
|
|
8
8
|
const post = data;
|
|
9
9
|
for (const recipientProfile of await listProfiles()) {
|
|
10
|
-
if (post.profile.id !==
|
|
10
|
+
if (post.profile.id !== recipientProfile?.id) {
|
|
11
11
|
await maybeCreateNotification(recipientProfile, {
|
|
12
12
|
type: 'announcement',
|
|
13
13
|
postId: post.id,
|
|
@@ -16,23 +16,20 @@ const eventHandler = async (data) => {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
const pushRenderer = async (notification) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
invalidateQueries: [PUSH_INVALIDATE.posts],
|
|
34
|
-
});
|
|
35
|
-
};
|
|
19
|
+
const pushRenderer = async (notification) => ({
|
|
20
|
+
title: `${profileName(notification.post?.profile)} posted an announcement`,
|
|
21
|
+
options: {
|
|
22
|
+
body: notification.post?.data?.content,
|
|
23
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
24
|
+
actions: [
|
|
25
|
+
{
|
|
26
|
+
action: `goto:/posts/${notification.post?.id}`,
|
|
27
|
+
title: 'Go to announcement',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
invalidateQueries: [PUSH_INVALIDATE.posts],
|
|
32
|
+
});
|
|
36
33
|
export default {
|
|
37
34
|
type: 'announcement',
|
|
38
35
|
event: 'postAnnounced',
|
|
@@ -5,9 +5,8 @@ import { getConversationByEnd } from '@openpeepshq/core/posts';
|
|
|
5
5
|
import { communityConfig } from '../../../config/index.js';
|
|
6
6
|
import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
|
|
7
7
|
const eventHandler = async (data) => {
|
|
8
|
-
var _a;
|
|
9
8
|
const post = data;
|
|
10
|
-
if (
|
|
9
|
+
if (post.data?.type === 'event')
|
|
11
10
|
return;
|
|
12
11
|
if (post.visibility === 'direct' && post.audience) {
|
|
13
12
|
for (const recipientProfile of post.audience) {
|
|
@@ -22,12 +21,11 @@ const eventHandler = async (data) => {
|
|
|
22
21
|
}
|
|
23
22
|
};
|
|
24
23
|
const pushRenderer = async (notification) => {
|
|
25
|
-
|
|
26
|
-
const path = `/conversations/${(_a = notification.data.conversationStart) === null || _a === void 0 ? void 0 : _a.id}`;
|
|
24
|
+
const path = `/conversations/${notification.data.conversationStart?.id}`;
|
|
27
25
|
return {
|
|
28
26
|
title: `${profileName(notification.senderProfile)} sent you a direct message`,
|
|
29
27
|
options: {
|
|
30
|
-
body:
|
|
28
|
+
body: notification.post?.data?.content,
|
|
31
29
|
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
32
30
|
data: {
|
|
33
31
|
url: path,
|
|
@@ -47,17 +45,20 @@ const pushRenderer = async (notification) => {
|
|
|
47
45
|
};
|
|
48
46
|
const expander = async (notification) => {
|
|
49
47
|
const { post, recipientProfile } = notification;
|
|
50
|
-
const previousPost = post
|
|
48
|
+
const previousPost = post?.replyTo;
|
|
51
49
|
const conversationStart = post &&
|
|
52
50
|
recipientProfile &&
|
|
53
51
|
(await getConversationByEnd(post, {
|
|
54
52
|
profile: recipientProfile,
|
|
55
53
|
scopes: [],
|
|
56
54
|
}))[0];
|
|
57
|
-
return
|
|
55
|
+
return {
|
|
56
|
+
...notification,
|
|
57
|
+
data: {
|
|
58
58
|
conversationStart,
|
|
59
59
|
previousPost,
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
|
+
};
|
|
61
62
|
};
|
|
62
63
|
export default {
|
|
63
64
|
type: 'directMessage',
|
|
@@ -11,21 +11,18 @@ export default {
|
|
|
11
11
|
type: 'follow',
|
|
12
12
|
fromProfileId: follower.id,
|
|
13
13
|
}),
|
|
14
|
-
pushRenderer: async (notification) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
invalidateQueries: [PUSH_INVALIDATE.profiles],
|
|
29
|
-
});
|
|
30
|
-
},
|
|
14
|
+
pushRenderer: async (notification) => ({
|
|
15
|
+
title: `${profileName(notification.senderProfile)} followed you`,
|
|
16
|
+
options: {
|
|
17
|
+
body: truncateText(markdownPlainText(notification.senderProfile?.bio)),
|
|
18
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
19
|
+
actions: [
|
|
20
|
+
{
|
|
21
|
+
action: `goto:/@${notification.senderProfile?.handle}`,
|
|
22
|
+
title: 'View Profile',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
invalidateQueries: [PUSH_INVALIDATE.profiles],
|
|
27
|
+
}),
|
|
31
28
|
};
|
|
@@ -13,21 +13,18 @@ export default {
|
|
|
13
13
|
groupId: group.id,
|
|
14
14
|
});
|
|
15
15
|
},
|
|
16
|
-
pushRenderer: async (notification) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
31
|
-
});
|
|
32
|
-
},
|
|
16
|
+
pushRenderer: async (notification) => ({
|
|
17
|
+
title: `You've been added to ${groupName(notification.group)}`,
|
|
18
|
+
options: {
|
|
19
|
+
body: 'Welcome to the group!',
|
|
20
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
21
|
+
actions: [
|
|
22
|
+
{
|
|
23
|
+
action: `goto:/groups/@${notification.group?.handle}`,
|
|
24
|
+
title: 'View Group',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
29
|
+
}),
|
|
33
30
|
};
|
|
@@ -9,7 +9,7 @@ export default {
|
|
|
9
9
|
eventHandler: async (...args) => {
|
|
10
10
|
const [group, profile] = args;
|
|
11
11
|
for (const groupAdmin of await listGroupMembers(group).then((members) => members
|
|
12
|
-
.filter((m) =>
|
|
12
|
+
.filter((m) => m.roles?.includes('owner') || m.roles?.includes('admin'))
|
|
13
13
|
.map((m) => m.profile))) {
|
|
14
14
|
await maybeCreateNotification(groupAdmin, {
|
|
15
15
|
type: 'groupMemberJoined',
|
|
@@ -18,21 +18,18 @@ export default {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
pushRenderer: async (notification) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
36
|
-
});
|
|
37
|
-
},
|
|
21
|
+
pushRenderer: async (notification) => ({
|
|
22
|
+
title: `New member ${profileName(notification.senderProfile)} joined ${groupName(notification.group)}`,
|
|
23
|
+
options: {
|
|
24
|
+
body: "Let's welcome them!",
|
|
25
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
26
|
+
actions: [
|
|
27
|
+
{
|
|
28
|
+
action: `goto:/@${notification.senderProfile?.handle}`,
|
|
29
|
+
title: 'View Profile',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
34
|
+
}),
|
|
38
35
|
};
|
|
@@ -9,7 +9,7 @@ export default {
|
|
|
9
9
|
eventHandler: async (...args) => {
|
|
10
10
|
const [group, profile] = args;
|
|
11
11
|
for (const groupAdmin of await listGroupMembers(group).then((members) => members
|
|
12
|
-
.filter((m) =>
|
|
12
|
+
.filter((m) => m.roles?.includes('owner') || m.roles?.includes('admin'))
|
|
13
13
|
.map((m) => m.profile))) {
|
|
14
14
|
await maybeCreateNotification(groupAdmin, {
|
|
15
15
|
type: 'groupMemberLeft',
|
|
@@ -18,21 +18,18 @@ export default {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
pushRenderer: async (notification) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
36
|
-
});
|
|
37
|
-
},
|
|
21
|
+
pushRenderer: async (notification) => ({
|
|
22
|
+
title: `Group member ${profileName(notification.senderProfile)} exited ${groupName(notification.group)}`,
|
|
23
|
+
options: {
|
|
24
|
+
body: "They're no longer a member of the group.",
|
|
25
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
26
|
+
actions: [
|
|
27
|
+
{
|
|
28
|
+
action: `goto:/groups/@${notification.group?.handle}`,
|
|
29
|
+
title: 'View Group',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
34
|
+
}),
|
|
38
35
|
};
|
|
@@ -2,37 +2,44 @@ import { notificationAll, } from '@openpeepshq/common/types';
|
|
|
2
2
|
import { findProfile } from '@openpeepshq/core/profiles';
|
|
3
3
|
import { maybeCreateNotification } from '@openpeepshq/core/notifications';
|
|
4
4
|
import { profileName } from '@openpeepshq/common/lib';
|
|
5
|
+
import { hub } from '../../../events/index.js';
|
|
5
6
|
import { initI18nEmailContext } from '../../../i18n/index.js';
|
|
6
7
|
import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
import { jamModeratorsToNotify } from './recipients.js';
|
|
9
|
+
const notifyModerators = async (post, alreadyInvited) => {
|
|
10
|
+
const jam = post.data?.type === 'event' ? post.data.jam : undefined;
|
|
11
|
+
const profileIds = jamModeratorsToNotify(jam?.moderators, post.profile.id, alreadyInvited);
|
|
12
|
+
for (const profileId of profileIds) {
|
|
13
|
+
const profile = await findProfile(profileId);
|
|
14
|
+
if (!profile)
|
|
15
|
+
continue;
|
|
16
|
+
await maybeCreateNotification(profile, {
|
|
17
|
+
type: 'jamModerator',
|
|
18
|
+
fromProfileId: post.profile.id,
|
|
19
|
+
postId: post.id,
|
|
20
|
+
});
|
|
13
21
|
}
|
|
14
|
-
if (jam.moderators)
|
|
15
|
-
for (const profileId of jam.moderators) {
|
|
16
|
-
const profile = await findProfile(profileId);
|
|
17
|
-
if (profile && post.profile.id !== profileId) {
|
|
18
|
-
await maybeCreateNotification(profile, {
|
|
19
|
-
type: 'jamModerator',
|
|
20
|
-
fromProfileId: post.profile.id,
|
|
21
|
-
postId: post.id,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
22
|
};
|
|
23
|
+
const eventHandler = async (eventData) => {
|
|
24
|
+
await notifyModerators(eventData, []);
|
|
25
|
+
};
|
|
26
|
+
/** Second arg is the moderator id list from before this save. */
|
|
27
|
+
const updatedHandler = async (postArg, previousArg) => {
|
|
28
|
+
const previous = Array.isArray(previousArg)
|
|
29
|
+
? previousArg.filter((id) => typeof id === 'string')
|
|
30
|
+
: [];
|
|
31
|
+
await notifyModerators(postArg, previous);
|
|
32
|
+
};
|
|
33
|
+
hub.once('postUpdated', updatedHandler);
|
|
26
34
|
const pushRenderer = async (notification) => {
|
|
27
|
-
var _a, _b;
|
|
28
35
|
const { t } = await initI18nEmailContext();
|
|
29
36
|
return {
|
|
30
37
|
title: `${profileName(notification.senderProfile)} invited you to moderate a jam`,
|
|
31
38
|
options: {
|
|
32
|
-
body: (
|
|
39
|
+
body: (notification.post?.data).name,
|
|
33
40
|
actions: [
|
|
34
41
|
{
|
|
35
|
-
action: `goto:/posts/${
|
|
42
|
+
action: `goto:/posts/${notification.post?.id}`,
|
|
36
43
|
title: t('emails.jamModerator.cta'),
|
|
37
44
|
},
|
|
38
45
|
],
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Moderators who should get an invite: not the creator, and not already invited. */
|
|
2
|
+
export const jamModeratorsToNotify = (moderatorIds, creatorId, alreadyInvited = []) => {
|
|
3
|
+
const skip = new Set([creatorId, ...alreadyInvited]);
|
|
4
|
+
return [...new Set(moderatorIds ?? [])].filter((id) => id && !skip.has(id));
|
|
5
|
+
};
|
|
@@ -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 =
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 =
|
|
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 !==
|
|
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 ===
|
|
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
|
|
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
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
|
11
|
+
for (const mention of post.mentions ?? []) {
|
|
13
12
|
const profile = mention.profile;
|
|
14
|
-
if (profile
|
|
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(
|
|
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 (
|
|
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 =
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
};
|