@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
package/dist/posts/mapping.js
CHANGED
|
@@ -3,7 +3,7 @@ import { postFilters } from '../db/pg/filters/index.js';
|
|
|
3
3
|
import { postDerived } from '../db/pg/queries/index.js';
|
|
4
4
|
import { collectionInfos } from '../db/index.js';
|
|
5
5
|
import { groupsMapping } from '../groups/mapping.js';
|
|
6
|
-
const seenBatchByCurrentProfileDerivedProperty = (profile) => postDerived.seenBatch(profile
|
|
6
|
+
const seenBatchByCurrentProfileDerivedProperty = (profile) => postDerived.seenBatch(profile?.id);
|
|
7
7
|
export const entriesRelation = {
|
|
8
8
|
alias: 'entries',
|
|
9
9
|
edgeCollection: 'entries',
|
|
@@ -114,7 +114,10 @@ const preFilterMapData = {
|
|
|
114
114
|
collection: 'posts',
|
|
115
115
|
softDelete: true,
|
|
116
116
|
};
|
|
117
|
-
const basePostMapData =
|
|
117
|
+
const basePostMapData = {
|
|
118
|
+
...preFilterMapData,
|
|
119
|
+
postFilterRelations: basePostFilterRelations,
|
|
120
|
+
postFilterDerivedProperties: [
|
|
118
121
|
{
|
|
119
122
|
alias: 'inReplyToId',
|
|
120
123
|
resolve: postDerived.inReplyToId,
|
|
@@ -123,11 +126,15 @@ const basePostMapData = Object.assign(Object.assign({}, preFilterMapData), { pos
|
|
|
123
126
|
alias: 'groupId',
|
|
124
127
|
resolve: postDerived.groupId,
|
|
125
128
|
},
|
|
126
|
-
]
|
|
127
|
-
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
const basePostMapDataForProfile = (profile) => ({
|
|
132
|
+
...basePostMapData,
|
|
133
|
+
postFilterDerivedProperties: [
|
|
128
134
|
...(basePostMapData.postFilterDerivedProperties || []),
|
|
129
135
|
seenBatchByCurrentProfileDerivedProperty(profile),
|
|
130
|
-
]
|
|
136
|
+
],
|
|
137
|
+
});
|
|
131
138
|
// Keep soft-deleted parents so replies can render a tombstone / deleted post.
|
|
132
139
|
const replyPostMapData = {
|
|
133
140
|
collection: 'posts',
|
|
@@ -160,26 +167,44 @@ export const repostRelation = {
|
|
|
160
167
|
direction: 'OUTBOUND',
|
|
161
168
|
skipEdge: true,
|
|
162
169
|
cardinality: 'one',
|
|
163
|
-
mapping:
|
|
170
|
+
mapping: {
|
|
171
|
+
...basePostMapData,
|
|
172
|
+
postFilterRelations: [...basePostFilterRelations, replyToRelation],
|
|
173
|
+
},
|
|
164
174
|
};
|
|
165
|
-
export const repostRelationForProfile = (profile) => (
|
|
175
|
+
export const repostRelationForProfile = (profile) => ({
|
|
176
|
+
...repostRelation,
|
|
177
|
+
mapping: {
|
|
178
|
+
...basePostMapDataForProfile(profile),
|
|
179
|
+
postFilterRelations: [...basePostFilterRelations, replyToRelation],
|
|
180
|
+
},
|
|
181
|
+
});
|
|
166
182
|
export const repostsOfPostRelation = {
|
|
167
183
|
alias: 'reposts',
|
|
168
184
|
edgeCollection: 'repost',
|
|
169
185
|
direction: 'INBOUND',
|
|
170
186
|
skipEdge: true,
|
|
171
187
|
cardinality: 'many',
|
|
172
|
-
mapping:
|
|
188
|
+
mapping: {
|
|
189
|
+
...basePostMapData,
|
|
190
|
+
postFilterRelations: [
|
|
173
191
|
...basePostFilterRelations,
|
|
174
192
|
repostRelation,
|
|
175
193
|
replyToRelation,
|
|
176
|
-
]
|
|
194
|
+
],
|
|
195
|
+
},
|
|
177
196
|
};
|
|
178
|
-
export const repostsOfPostRelationForProfile = (profile) => (
|
|
197
|
+
export const repostsOfPostRelationForProfile = (profile) => ({
|
|
198
|
+
...repostsOfPostRelation,
|
|
199
|
+
mapping: {
|
|
200
|
+
...basePostMapDataForProfile(profile),
|
|
201
|
+
postFilterRelations: [
|
|
179
202
|
...basePostFilterRelations,
|
|
180
203
|
repostRelationForProfile(profile),
|
|
181
204
|
replyToRelation,
|
|
182
|
-
]
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
});
|
|
183
208
|
export const postsWithReplyCountMapping = map({
|
|
184
209
|
collection: 'posts',
|
|
185
210
|
relations: [replyCountRelation],
|
|
@@ -197,18 +222,27 @@ export const postsWithReplyToCountMapping = map({
|
|
|
197
222
|
},
|
|
198
223
|
],
|
|
199
224
|
});
|
|
200
|
-
export const postsMapping = map(
|
|
225
|
+
export const postsMapping = map({
|
|
226
|
+
...basePostMapData,
|
|
227
|
+
postFilterRelations: [
|
|
201
228
|
...basePostFilterRelations,
|
|
202
229
|
repostRelation,
|
|
203
230
|
replyToRelation,
|
|
204
|
-
]
|
|
231
|
+
],
|
|
232
|
+
});
|
|
205
233
|
/** Auth / mark-seen: post graph without nested replyTo/repost hydrate. */
|
|
206
|
-
export const postsAuthMapping = map(
|
|
207
|
-
|
|
234
|
+
export const postsAuthMapping = map({
|
|
235
|
+
...basePostMapData,
|
|
236
|
+
postFilterRelations: basePostFilterRelations,
|
|
237
|
+
});
|
|
238
|
+
export const postsMappingForProfile = (profile) => map({
|
|
239
|
+
...basePostMapDataForProfile(profile),
|
|
240
|
+
postFilterRelations: [
|
|
208
241
|
...basePostFilterRelations,
|
|
209
242
|
repostRelationForProfile(profile),
|
|
210
243
|
replyToRelation,
|
|
211
|
-
]
|
|
244
|
+
],
|
|
245
|
+
});
|
|
212
246
|
/** Lean mapping for post detail context — skips nested repost. Audience is
|
|
213
247
|
* required so direct replies stay readable to the thread's recipients. */
|
|
214
248
|
const contextPostFilterRelations = [
|
|
@@ -252,6 +286,14 @@ const conversationLeafFilters = [
|
|
|
252
286
|
postFilters.replyCountZero(),
|
|
253
287
|
postFilters.isDirect(),
|
|
254
288
|
];
|
|
255
|
-
export const conversationLeavesMapping = map(
|
|
256
|
-
|
|
289
|
+
export const conversationLeavesMapping = map({
|
|
290
|
+
...basePostMapData,
|
|
291
|
+
relations: [replyCountRelation],
|
|
292
|
+
filters: conversationLeafFilters,
|
|
293
|
+
});
|
|
294
|
+
export const conversationLeavesMappingForProfile = (profile) => map({
|
|
295
|
+
...basePostMapDataForProfile(profile),
|
|
296
|
+
relations: [replyCountRelation],
|
|
297
|
+
filters: conversationLeafFilters,
|
|
298
|
+
});
|
|
257
299
|
export const postIdsMapping = map(preFilterMapData);
|
|
@@ -32,7 +32,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile) =>
|
|
|
32
32
|
};
|
|
33
33
|
description?: string | undefined;
|
|
34
34
|
blurhash?: string | undefined;
|
|
35
|
-
status?: "failed" | "
|
|
35
|
+
status?: "failed" | "ready" | "processing" | undefined;
|
|
36
36
|
error?: string | undefined;
|
|
37
37
|
}[] | undefined;
|
|
38
38
|
customEmojis?: {
|
|
@@ -69,7 +69,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile) =>
|
|
|
69
69
|
};
|
|
70
70
|
description?: string | undefined;
|
|
71
71
|
blurhash?: string | undefined;
|
|
72
|
-
status?: "failed" | "
|
|
72
|
+
status?: "failed" | "ready" | "processing" | undefined;
|
|
73
73
|
error?: string | undefined;
|
|
74
74
|
}[] | undefined;
|
|
75
75
|
customEmojis?: {
|
|
@@ -107,7 +107,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile) =>
|
|
|
107
107
|
};
|
|
108
108
|
description?: string | undefined;
|
|
109
109
|
blurhash?: string | undefined;
|
|
110
|
-
status?: "failed" | "
|
|
110
|
+
status?: "failed" | "ready" | "processing" | undefined;
|
|
111
111
|
error?: string | undefined;
|
|
112
112
|
}[] | undefined;
|
|
113
113
|
customEmojis?: {
|
|
@@ -189,7 +189,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile) =>
|
|
|
189
189
|
};
|
|
190
190
|
description?: string | undefined;
|
|
191
191
|
blurhash?: string | undefined;
|
|
192
|
-
status?: "failed" | "
|
|
192
|
+
status?: "failed" | "ready" | "processing" | undefined;
|
|
193
193
|
error?: string | undefined;
|
|
194
194
|
}[] | undefined;
|
|
195
195
|
customEmojis?: {
|
|
@@ -202,6 +202,44 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile) =>
|
|
|
202
202
|
language?: string | undefined;
|
|
203
203
|
image?: string | undefined;
|
|
204
204
|
title?: string | undefined;
|
|
205
|
+
} | {
|
|
206
|
+
type: "resource";
|
|
207
|
+
title: string;
|
|
208
|
+
resourceKind: "file" | "link" | "video" | "gallery" | "audio";
|
|
209
|
+
content?: string | undefined;
|
|
210
|
+
sensitive?: boolean | undefined;
|
|
211
|
+
spoilerText?: string | undefined;
|
|
212
|
+
attachments?: {
|
|
213
|
+
type: string;
|
|
214
|
+
url: string;
|
|
215
|
+
previewUrl: string | null;
|
|
216
|
+
textUrl: null;
|
|
217
|
+
filename: string;
|
|
218
|
+
meta: {
|
|
219
|
+
usage?: string | undefined;
|
|
220
|
+
focus?: {
|
|
221
|
+
x: number;
|
|
222
|
+
y: number;
|
|
223
|
+
} | undefined;
|
|
224
|
+
mimetype?: string | undefined;
|
|
225
|
+
size?: number | undefined;
|
|
226
|
+
};
|
|
227
|
+
description?: string | undefined;
|
|
228
|
+
blurhash?: string | undefined;
|
|
229
|
+
status?: "failed" | "ready" | "processing" | undefined;
|
|
230
|
+
error?: string | undefined;
|
|
231
|
+
}[] | undefined;
|
|
232
|
+
customEmojis?: {
|
|
233
|
+
shortcode: string;
|
|
234
|
+
url: string;
|
|
235
|
+
staticUrl: string;
|
|
236
|
+
visibleInPicker: boolean;
|
|
237
|
+
category: string;
|
|
238
|
+
}[] | undefined;
|
|
239
|
+
language?: string | undefined;
|
|
240
|
+
tags?: string[] | undefined;
|
|
241
|
+
categoryPath?: string[] | undefined;
|
|
242
|
+
url?: string | undefined;
|
|
205
243
|
};
|
|
206
244
|
} | {
|
|
207
245
|
type: "edit";
|
|
@@ -227,7 +265,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile) =>
|
|
|
227
265
|
};
|
|
228
266
|
description?: string | undefined;
|
|
229
267
|
blurhash?: string | undefined;
|
|
230
|
-
status?: "failed" | "
|
|
268
|
+
status?: "failed" | "ready" | "processing" | undefined;
|
|
231
269
|
error?: string | undefined;
|
|
232
270
|
}[] | undefined;
|
|
233
271
|
customEmojis?: {
|
|
@@ -264,7 +302,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile) =>
|
|
|
264
302
|
};
|
|
265
303
|
description?: string | undefined;
|
|
266
304
|
blurhash?: string | undefined;
|
|
267
|
-
status?: "failed" | "
|
|
305
|
+
status?: "failed" | "ready" | "processing" | undefined;
|
|
268
306
|
error?: string | undefined;
|
|
269
307
|
}[] | undefined;
|
|
270
308
|
customEmojis?: {
|
|
@@ -302,7 +340,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile) =>
|
|
|
302
340
|
};
|
|
303
341
|
description?: string | undefined;
|
|
304
342
|
blurhash?: string | undefined;
|
|
305
|
-
status?: "failed" | "
|
|
343
|
+
status?: "failed" | "ready" | "processing" | undefined;
|
|
306
344
|
error?: string | undefined;
|
|
307
345
|
}[] | undefined;
|
|
308
346
|
customEmojis?: {
|
|
@@ -384,7 +422,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile) =>
|
|
|
384
422
|
};
|
|
385
423
|
description?: string | undefined;
|
|
386
424
|
blurhash?: string | undefined;
|
|
387
|
-
status?: "failed" | "
|
|
425
|
+
status?: "failed" | "ready" | "processing" | undefined;
|
|
388
426
|
error?: string | undefined;
|
|
389
427
|
}[] | undefined;
|
|
390
428
|
customEmojis?: {
|
|
@@ -397,6 +435,44 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile) =>
|
|
|
397
435
|
language?: string | undefined;
|
|
398
436
|
image?: string | undefined;
|
|
399
437
|
title?: string | undefined;
|
|
438
|
+
} | {
|
|
439
|
+
type: "resource";
|
|
440
|
+
title: string;
|
|
441
|
+
resourceKind: "file" | "link" | "video" | "gallery" | "audio";
|
|
442
|
+
content?: string | undefined;
|
|
443
|
+
sensitive?: boolean | undefined;
|
|
444
|
+
spoilerText?: string | undefined;
|
|
445
|
+
attachments?: {
|
|
446
|
+
type: string;
|
|
447
|
+
url: string;
|
|
448
|
+
previewUrl: string | null;
|
|
449
|
+
textUrl: null;
|
|
450
|
+
filename: string;
|
|
451
|
+
meta: {
|
|
452
|
+
usage?: string | undefined;
|
|
453
|
+
focus?: {
|
|
454
|
+
x: number;
|
|
455
|
+
y: number;
|
|
456
|
+
} | undefined;
|
|
457
|
+
mimetype?: string | undefined;
|
|
458
|
+
size?: number | undefined;
|
|
459
|
+
};
|
|
460
|
+
description?: string | undefined;
|
|
461
|
+
blurhash?: string | undefined;
|
|
462
|
+
status?: "failed" | "ready" | "processing" | undefined;
|
|
463
|
+
error?: string | undefined;
|
|
464
|
+
}[] | undefined;
|
|
465
|
+
customEmojis?: {
|
|
466
|
+
shortcode: string;
|
|
467
|
+
url: string;
|
|
468
|
+
staticUrl: string;
|
|
469
|
+
visibleInPicker: boolean;
|
|
470
|
+
category: string;
|
|
471
|
+
}[] | undefined;
|
|
472
|
+
language?: string | undefined;
|
|
473
|
+
tags?: string[] | undefined;
|
|
474
|
+
categoryPath?: string[] | undefined;
|
|
475
|
+
url?: string | undefined;
|
|
400
476
|
};
|
|
401
477
|
} | {
|
|
402
478
|
type: "delete";
|
|
@@ -409,7 +485,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile) =>
|
|
|
409
485
|
} | {
|
|
410
486
|
type: "rsvp";
|
|
411
487
|
data: {
|
|
412
|
-
response: "
|
|
488
|
+
response: "no" | "yes" | "tentative" | "removed";
|
|
413
489
|
recurrenceId?: string | undefined;
|
|
414
490
|
};
|
|
415
491
|
} | {
|
package/dist/posts/mutations.js
CHANGED
|
@@ -21,7 +21,6 @@ import { cancelPollEnd, schedulePollEnd } from './pollEndJobs.js';
|
|
|
21
21
|
import { config } from '../config/index.js';
|
|
22
22
|
import { localObjectScalars } from '../federation/identity.js';
|
|
23
23
|
export const createPost = async (data, profile, postData, relations = {}) => {
|
|
24
|
-
var _a, _b;
|
|
25
24
|
if (data.type === 'event') {
|
|
26
25
|
data = normalizeEventDataForSave(data);
|
|
27
26
|
}
|
|
@@ -41,23 +40,30 @@ export const createPost = async (data, profile, postData, relations = {}) => {
|
|
|
41
40
|
}
|
|
42
41
|
const audienceIds = [
|
|
43
42
|
profile.id,
|
|
44
|
-
...(
|
|
43
|
+
...(relations.audience ?? []).map((member) => member.id),
|
|
45
44
|
];
|
|
46
45
|
if (await hasBlockAmong(db, audienceIds)) {
|
|
47
46
|
throw forbidden({ errorKey: 'error.cannotInteractBlocked' });
|
|
48
47
|
}
|
|
49
|
-
const group = await (
|
|
48
|
+
const group = await (repliedToPost?.group ||
|
|
50
49
|
(relations.groupId ? findGroup(relations.groupId) : undefined));
|
|
51
50
|
// Group-linked posts always use visibility=group so community/local feeds
|
|
52
51
|
// (which only include public/local) never surface them incorrectly.
|
|
53
52
|
if (group) {
|
|
54
|
-
postData =
|
|
53
|
+
postData = { ...postData, visibility: 'group' };
|
|
55
54
|
}
|
|
56
55
|
const hashtags = extractHashtags(data);
|
|
57
56
|
const id = uuidv7();
|
|
58
57
|
const domain = (await config()).activityPub.defaultDomain;
|
|
59
58
|
const object = localObjectScalars(id, domain, relations.inReplyToId);
|
|
60
|
-
const post = await postsMapping.removeDefaultFilter().create(db,
|
|
59
|
+
const post = await postsMapping.removeDefaultFilter().create(db, {
|
|
60
|
+
id,
|
|
61
|
+
...postData,
|
|
62
|
+
...object,
|
|
63
|
+
data,
|
|
64
|
+
type: data.type,
|
|
65
|
+
creatorId: profile.id,
|
|
66
|
+
});
|
|
61
67
|
await entryConnector(db, profile, post, {
|
|
62
68
|
type: 'create',
|
|
63
69
|
data,
|
|
@@ -80,10 +86,10 @@ export const createPost = async (data, profile, postData, relations = {}) => {
|
|
|
80
86
|
if (mentions.length) {
|
|
81
87
|
await Promise.all(mentions.map(async (mention) => mentionConnector(db, post, mention.profile, { text: mention.text })));
|
|
82
88
|
}
|
|
83
|
-
const audienceToLink =
|
|
89
|
+
const audienceToLink = relations.audience?.length
|
|
84
90
|
? relations.audience
|
|
85
|
-
: repliedToPost
|
|
86
|
-
if (audienceToLink
|
|
91
|
+
: repliedToPost?.audience;
|
|
92
|
+
if (audienceToLink?.length) {
|
|
87
93
|
await Promise.all(audienceToLink.map(async (member) => {
|
|
88
94
|
await audienceConnector(db, post, member);
|
|
89
95
|
}));
|
|
@@ -100,8 +106,7 @@ export const createPost = async (data, profile, postData, relations = {}) => {
|
|
|
100
106
|
return transformedPost;
|
|
101
107
|
};
|
|
102
108
|
export const updatePost = async (post, profile, data) => {
|
|
103
|
-
|
|
104
|
-
const previousEvent = ((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' ? post.data : undefined;
|
|
109
|
+
const previousEvent = post.data?.type === 'event' ? post.data : undefined;
|
|
105
110
|
const normalized = data.type === 'event' ? normalizeEventDataForSave(data) : data;
|
|
106
111
|
const dataForDb = normalized.type === 'event'
|
|
107
112
|
? eventDataForDbUpdate(previousEvent, normalized)
|
|
@@ -132,15 +137,16 @@ export const updatePost = async (post, profile, data) => {
|
|
|
132
137
|
else {
|
|
133
138
|
await cancelPollEnd(post.id);
|
|
134
139
|
}
|
|
135
|
-
hub.emit('postUpdated', newPost);
|
|
140
|
+
hub.emit('postUpdated', newPost, previousEvent?.jam?.moderators ?? []);
|
|
136
141
|
return newPost;
|
|
137
142
|
};
|
|
138
143
|
export const reactToPost = async (post, profile, data) => allpeepDb().then(({ db }) => entryConnector(db, profile, post, {
|
|
139
144
|
type: 'reaction',
|
|
140
145
|
data: { reaction: data.reaction },
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
|
|
146
|
+
}).then(() => hub.emit('reactionCreated', profile, post, {
|
|
147
|
+
type: 'reaction',
|
|
148
|
+
...data,
|
|
149
|
+
})));
|
|
144
150
|
export const retractReaction = async (post, profile) => allpeepDb().then(({ db }) => entryConnector(db, profile, post, {
|
|
145
151
|
type: 'unreaction',
|
|
146
152
|
data: { reaction: AP_LIKE_REACTION },
|
|
@@ -178,7 +184,10 @@ export const deletePost = async (post, profile) => {
|
|
|
178
184
|
type: 'tombstone',
|
|
179
185
|
},
|
|
180
186
|
});
|
|
181
|
-
await postsMapping.deleteRelations(db, post.id,
|
|
187
|
+
await postsMapping.deleteRelations(db, post.id, {
|
|
188
|
+
...repostRelation,
|
|
189
|
+
direction: 'INBOUND',
|
|
190
|
+
});
|
|
182
191
|
await postsMapping.delete(db, post.id);
|
|
183
192
|
if (post.type === 'event') {
|
|
184
193
|
await clearEventOccurrences(post.id);
|
|
@@ -194,19 +203,17 @@ export const vote = (profile, post, data) => allpeepDb().then(({ db }) => entryC
|
|
|
194
203
|
}).then(() => hub.emit('entryCreated', profile, post, { type: 'answer', data })));
|
|
195
204
|
const attendingRsvp = (response) => response === 'yes' || response === 'tentative';
|
|
196
205
|
const rsvpOccurrenceIds = (data) => {
|
|
197
|
-
|
|
198
|
-
if ((_a = data.recurrenceIds) === null || _a === void 0 ? void 0 : _a.length)
|
|
206
|
+
if (data.recurrenceIds?.length)
|
|
199
207
|
return data.recurrenceIds;
|
|
200
208
|
if (data.recurrenceId)
|
|
201
209
|
return [data.recurrenceId];
|
|
202
210
|
return undefined;
|
|
203
211
|
};
|
|
204
212
|
export const rsvpRespond = async (profile, post, data) => {
|
|
205
|
-
var _a, _b, _c, _d;
|
|
206
213
|
if (profile.id === post.profile.id) {
|
|
207
214
|
return;
|
|
208
215
|
}
|
|
209
|
-
if (post.type !== 'event' ||
|
|
216
|
+
if (post.type !== 'event' || post.data?.type !== 'event') {
|
|
210
217
|
throw unprocessableRequest({ errorKey: 'error.unprocessableRequest' });
|
|
211
218
|
}
|
|
212
219
|
// `removed` is an organizer-only status; users cannot set it on themselves,
|
|
@@ -215,7 +222,7 @@ export const rsvpRespond = async (profile, post, data) => {
|
|
|
215
222
|
if (data.response === 'removed') {
|
|
216
223
|
throw forbidden({ errorKey: 'error.rsvpRemovedForbidden' });
|
|
217
224
|
}
|
|
218
|
-
if (
|
|
225
|
+
if (getEffectiveRsvp(post, profile.id)?.response === 'removed') {
|
|
219
226
|
throw forbidden({ errorKey: 'error.rsvpRemoved' });
|
|
220
227
|
}
|
|
221
228
|
const occurrenceIds = rsvpOccurrenceIds(data);
|
|
@@ -233,10 +240,10 @@ export const rsvpRespond = async (profile, post, data) => {
|
|
|
233
240
|
}
|
|
234
241
|
}
|
|
235
242
|
else {
|
|
236
|
-
const ids = occurrenceIds
|
|
243
|
+
const ids = occurrenceIds ?? [undefined];
|
|
237
244
|
for (const recurrenceId of ids) {
|
|
238
245
|
const currentRsvp = getEffectiveRsvp(post, profile.id, recurrenceId);
|
|
239
|
-
if (
|
|
246
|
+
if (currentRsvp?.response !== 'yes' &&
|
|
240
247
|
countYesRsvps(post, recurrenceId) >= maxAttendees) {
|
|
241
248
|
throw unprocessableRequest({ errorKey: 'error.eventAtCapacity' });
|
|
242
249
|
}
|
|
@@ -246,16 +253,16 @@ export const rsvpRespond = async (profile, post, data) => {
|
|
|
246
253
|
}
|
|
247
254
|
const { db } = await allpeepDb();
|
|
248
255
|
const previousResponses = occurrenceIds
|
|
249
|
-
? occurrenceIds.map((id) =>
|
|
256
|
+
? occurrenceIds.map((id) => getEffectiveRsvp(post, profile.id, id)?.response)
|
|
250
257
|
: undefined;
|
|
251
258
|
const previousResponse = previousResponses
|
|
252
259
|
? previousResponses.every(attendingRsvp)
|
|
253
260
|
? previousResponses[0]
|
|
254
261
|
: previousResponses.find((response) => !attendingRsvp(response))
|
|
255
|
-
:
|
|
262
|
+
: [...(post.rsvps ?? [])]
|
|
256
263
|
.filter((rsvp) => rsvp.profile.id === profile.id)
|
|
257
264
|
.filter((rsvp) => !rsvp.recurrenceId)
|
|
258
|
-
.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))[0]
|
|
265
|
+
.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))[0]?.response;
|
|
259
266
|
const writes = occurrenceIds
|
|
260
267
|
? occurrenceIds.map((recurrenceId) => ({
|
|
261
268
|
response: data.response,
|
|
@@ -269,13 +276,20 @@ export const rsvpRespond = async (profile, post, data) => {
|
|
|
269
276
|
});
|
|
270
277
|
}
|
|
271
278
|
const cancel = rsvpCancelNotice(post, profile.id, data.response, occurrenceIds);
|
|
272
|
-
hub.emit('rsvpCreated', profile, post,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
279
|
+
hub.emit('rsvpCreated', profile, post, {
|
|
280
|
+
type: 'rsvp',
|
|
281
|
+
data: {
|
|
282
|
+
response: data.response,
|
|
283
|
+
...(occurrenceIds?.length === 1
|
|
284
|
+
? { recurrenceId: occurrenceIds[0] }
|
|
285
|
+
: {}),
|
|
286
|
+
},
|
|
287
|
+
occurrenceIds,
|
|
288
|
+
previousResponse,
|
|
289
|
+
...(cancel ? { cancel } : {}),
|
|
290
|
+
});
|
|
276
291
|
};
|
|
277
292
|
export const rsvpManageByOrganizer = async (actingProfile, targetProfile, post, response, recurrenceId) => {
|
|
278
|
-
var _a, _b;
|
|
279
293
|
if (!canManageEventRsvps(actingProfile, post)) {
|
|
280
294
|
throw forbidden({ errorKey: 'forbidden' });
|
|
281
295
|
}
|
|
@@ -287,13 +301,13 @@ export const rsvpManageByOrganizer = async (actingProfile, targetProfile, post,
|
|
|
287
301
|
}
|
|
288
302
|
const data = { response, recurrenceId };
|
|
289
303
|
const { db } = await allpeepDb();
|
|
290
|
-
const previousResponse =
|
|
304
|
+
const previousResponse = [...(post.rsvps ?? [])]
|
|
291
305
|
.filter((rsvp) => rsvp.profile.id === targetProfile.id)
|
|
292
306
|
.filter((rsvp) => recurrenceId
|
|
293
307
|
? sameRecurrenceId(rsvp.recurrenceId, recurrenceId) ||
|
|
294
308
|
!rsvp.recurrenceId
|
|
295
309
|
: !rsvp.recurrenceId)
|
|
296
|
-
.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))[0]
|
|
310
|
+
.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))[0]?.response;
|
|
297
311
|
await entryConnector(db, targetProfile, post, {
|
|
298
312
|
type: 'rsvp',
|
|
299
313
|
data,
|
|
@@ -322,7 +336,6 @@ export const rsvpManageByOrganizer = async (actingProfile, targetProfile, post,
|
|
|
322
336
|
* tab, detected by posts they authored but are not in.
|
|
323
337
|
*/
|
|
324
338
|
export const leaveConversation = async (rootPost, profile) => {
|
|
325
|
-
var _a, _b;
|
|
326
339
|
const { db } = await allpeepDb();
|
|
327
340
|
const lastPostId = await findLatestThreadPostId(rootPost.id);
|
|
328
341
|
const [lastPost] = lastPostId === rootPost.id
|
|
@@ -330,7 +343,7 @@ export const leaveConversation = async (rootPost, profile) => {
|
|
|
330
343
|
: await findPostsForAuth([lastPostId]);
|
|
331
344
|
if (!lastPost)
|
|
332
345
|
return;
|
|
333
|
-
const remainingAudience =
|
|
346
|
+
const remainingAudience = lastPost.audience?.filter((p) => p.id !== profile.id) ?? [];
|
|
334
347
|
if (remainingAudience.length > 0) {
|
|
335
348
|
await createPost({ type: 'note', content: '' }, profile, { type: 'note', visibility: 'direct', creatorId: profile.id }, {
|
|
336
349
|
inReplyToId: lastPost.id,
|
package/dist/posts/pollEnd.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export const pollEndDelayMs = (expiresAt, now = Date.now()) => new Date(expiresAt).getTime() - now;
|
|
2
|
-
export const shouldEmitPollEnded = (post, scheduledExpiresAt) =>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) === 'question' &&
|
|
6
|
-
post.data.expiresAt === scheduledExpiresAt;
|
|
7
|
-
};
|
|
2
|
+
export const shouldEmitPollEnded = (post, scheduledExpiresAt) => !!post &&
|
|
3
|
+
post.data?.type === 'question' &&
|
|
4
|
+
post.data.expiresAt === scheduledExpiresAt;
|
|
@@ -14,14 +14,13 @@ const attendingResponses = ['yes', 'tentative'];
|
|
|
14
14
|
* avoid re-sending when someone toggles between yes/maybe.
|
|
15
15
|
*/
|
|
16
16
|
const handleRsvpCreated = async (profileArg, postArg, payloadArg) => {
|
|
17
|
-
var _a, _b, _c;
|
|
18
17
|
const profile = profileArg;
|
|
19
18
|
const post = postArg;
|
|
20
19
|
const payload = payloadArg;
|
|
21
|
-
if (
|
|
20
|
+
if (payload?.type !== 'rsvp') {
|
|
22
21
|
return;
|
|
23
22
|
}
|
|
24
|
-
const response =
|
|
23
|
+
const response = payload.data?.response;
|
|
25
24
|
if (!response || !attendingResponses.includes(response)) {
|
|
26
25
|
return;
|
|
27
26
|
}
|
|
@@ -29,12 +28,13 @@ const handleRsvpCreated = async (profileArg, postArg, payloadArg) => {
|
|
|
29
28
|
attendingResponses.includes(payload.previousResponse)) {
|
|
30
29
|
return;
|
|
31
30
|
}
|
|
32
|
-
if (post.type !== 'event' ||
|
|
31
|
+
if (post.type !== 'event' || post.data?.type !== 'event') {
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
34
|
const rootUrl = await serverRootUrl();
|
|
36
35
|
const postUrl = `${rootUrl}/posts/${post.id}`;
|
|
37
|
-
const occurrenceIds =
|
|
36
|
+
const occurrenceIds = payload.occurrenceIds ??
|
|
37
|
+
(payload.data.recurrenceId ? [payload.data.recurrenceId] : undefined);
|
|
38
38
|
const confirmation = rsvpConfirmationContent(post, {
|
|
39
39
|
postUrl,
|
|
40
40
|
occurrenceIds,
|
|
@@ -56,9 +56,19 @@ const handleRsvpCreated = async (profileArg, postArg, payloadArg) => {
|
|
|
56
56
|
.send({
|
|
57
57
|
to: account.email,
|
|
58
58
|
template: 'eventRsvpConfirmation',
|
|
59
|
-
locals:
|
|
60
|
-
|
|
61
|
-
:
|
|
59
|
+
locals: {
|
|
60
|
+
eventName: confirmation.eventName,
|
|
61
|
+
eventUrl: postUrl,
|
|
62
|
+
response,
|
|
63
|
+
start: confirmation.start,
|
|
64
|
+
end: confirmation.end,
|
|
65
|
+
location: confirmation.location,
|
|
66
|
+
allDay: confirmation.allDay,
|
|
67
|
+
occurrenceCount: confirmation.occurrenceCount,
|
|
68
|
+
...(profileSettings?.timeZone
|
|
69
|
+
? { timeZone: profileSettings.timeZone }
|
|
70
|
+
: {}),
|
|
71
|
+
},
|
|
62
72
|
attachments: [
|
|
63
73
|
{
|
|
64
74
|
filename: 'event.ics',
|
|
@@ -38,7 +38,7 @@ export const loadThreadPreviewReplies = async (rootId, currentProfile) => {
|
|
|
38
38
|
if (!parentId || parentId === rootId)
|
|
39
39
|
return post;
|
|
40
40
|
const parent = byId.get(parentId);
|
|
41
|
-
return parent ?
|
|
41
|
+
return parent ? { ...post, replyTo: parent } : post;
|
|
42
42
|
});
|
|
43
43
|
return { replies, hasMore };
|
|
44
44
|
};
|
|
@@ -3,12 +3,12 @@ import { allpeepDb } from '../db/index.js';
|
|
|
3
3
|
import { sorts } from '../db/pg/queries/index.js';
|
|
4
4
|
const HISTORY_SAMPLE_SIZE = 50;
|
|
5
5
|
const FILETYPE_DEFAULTS_MS = {
|
|
6
|
-
image:
|
|
7
|
-
audio:
|
|
8
|
-
video:
|
|
9
|
-
document:
|
|
6
|
+
image: 2_000,
|
|
7
|
+
audio: 8_000,
|
|
8
|
+
video: 30_000,
|
|
9
|
+
document: 1_500,
|
|
10
10
|
};
|
|
11
|
-
const GENERIC_DEFAULT_MS =
|
|
11
|
+
const GENERIC_DEFAULT_MS = 5_000;
|
|
12
12
|
const median = (values) => {
|
|
13
13
|
if (!values.length)
|
|
14
14
|
return 0;
|
|
@@ -27,7 +27,6 @@ const findRecent = async (filter) => {
|
|
|
27
27
|
.all(db);
|
|
28
28
|
};
|
|
29
29
|
export const estimateProcessingDuration = async ({ filetype, filesize, }) => {
|
|
30
|
-
var _a;
|
|
31
30
|
const lower = filesize * 0.5;
|
|
32
31
|
const upper = filesize * 2;
|
|
33
32
|
const sized = await findRecent({ filetype })
|
|
@@ -42,5 +41,5 @@ export const estimateProcessingDuration = async ({ filetype, filesize, }) => {
|
|
|
42
41
|
if (scaledMedian > 0)
|
|
43
42
|
return scaledMedian;
|
|
44
43
|
}
|
|
45
|
-
return
|
|
44
|
+
return FILETYPE_DEFAULTS_MS[filetype] ?? GENERIC_DEFAULT_MS;
|
|
46
45
|
};
|
|
@@ -12,9 +12,8 @@ hub.on('profileSettingsUpdated', (profileId) => {
|
|
|
12
12
|
void profileSettingsCache.del(profileId);
|
|
13
13
|
});
|
|
14
14
|
const uniqueViolation = (error) => {
|
|
15
|
-
var _a;
|
|
16
15
|
const current = error;
|
|
17
|
-
return current.code === '23505' ||
|
|
16
|
+
return current.code === '23505' || current.cause?.code === '23505';
|
|
18
17
|
};
|
|
19
18
|
const readProfileSettings = async (db, id) =>
|
|
20
19
|
// Include soft-deleted rows: the profile_id unique index still covers them,
|
|
@@ -14,6 +14,7 @@ export declare const profileSettingsMapping: import("../db/pg/map").Mapping<{
|
|
|
14
14
|
push: boolean;
|
|
15
15
|
email: boolean;
|
|
16
16
|
}> | undefined;
|
|
17
|
+
groupNotificationLevels?: Record<string, "off" | "all" | "mostRelevant"> | undefined;
|
|
17
18
|
jamSettings?: {
|
|
18
19
|
backgroundObfuscation?: {
|
|
19
20
|
type: "blur";
|