@openpeepshq/core 0.1.34 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/index.d.ts +1 -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 +2 -0
- 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/helpers.js +1 -2
- 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.js +6 -2
- package/dist/jams/index.js +2 -2
- package/dist/jams/jobs.js +1 -2
- package/dist/jams/livekit.js +8 -8
- 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.js +13 -29
- package/dist/media/index.js +50 -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/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 +3 -5
- 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 +6 -7
- 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/fcmCredential.js +1 -1
- package/dist/notifications/finders.js +1 -1
- package/dist/notifications/helpers.js +13 -10
- package/dist/notifications/jobs.js +10 -7
- package/dist/notifications/mutations.js +4 -1
- 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.js +1 -2
- package/dist/posts/contextClosure.js +1 -2
- package/dist/posts/conversationQueries.js +2 -4
- package/dist/posts/eventAgenda.js +8 -5
- package/dist/posts/eventOccurrences.js +2 -2
- package/dist/posts/finders.d.ts +42 -2
- package/dist/posts/finders.js +21 -9
- package/dist/posts/helpers/filters.js +2 -3
- package/dist/posts/helpers/index.d.ts +152 -0
- package/dist/posts/helpers/index.js +43 -27
- package/dist/posts/mapping.d.ts +546 -14
- package/dist/posts/mapping.js +60 -18
- package/dist/posts/mutations.d.ts +76 -0
- package/dist/posts/mutations.js +46 -31
- 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/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/mutations.js +3 -5
- package/dist/redis/connection.js +1 -1
- package/dist/reports/helpers.js +7 -3
- 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 +39 -1
- 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/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);
|
|
@@ -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: "link" | "file" | "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" | "processing" | "ready" | 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";
|
|
@@ -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: "link" | "file" | "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" | "processing" | "ready" | 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";
|
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)
|
|
@@ -140,7 +145,10 @@ export const reactToPost = async (post, profile, data) => allpeepDb().then(({ db
|
|
|
140
145
|
data: { reaction: data.reaction },
|
|
141
146
|
})
|
|
142
147
|
.then(() => bumpConversationActivity(db, post.id))
|
|
143
|
-
.then(() => hub.emit('reactionCreated', profile, post,
|
|
148
|
+
.then(() => hub.emit('reactionCreated', profile, post, {
|
|
149
|
+
type: 'reaction',
|
|
150
|
+
...data,
|
|
151
|
+
})));
|
|
144
152
|
export const retractReaction = async (post, profile) => allpeepDb().then(({ db }) => entryConnector(db, profile, post, {
|
|
145
153
|
type: 'unreaction',
|
|
146
154
|
data: { reaction: AP_LIKE_REACTION },
|
|
@@ -178,7 +186,10 @@ export const deletePost = async (post, profile) => {
|
|
|
178
186
|
type: 'tombstone',
|
|
179
187
|
},
|
|
180
188
|
});
|
|
181
|
-
await postsMapping.deleteRelations(db, post.id,
|
|
189
|
+
await postsMapping.deleteRelations(db, post.id, {
|
|
190
|
+
...repostRelation,
|
|
191
|
+
direction: 'INBOUND',
|
|
192
|
+
});
|
|
182
193
|
await postsMapping.delete(db, post.id);
|
|
183
194
|
if (post.type === 'event') {
|
|
184
195
|
await clearEventOccurrences(post.id);
|
|
@@ -194,19 +205,17 @@ export const vote = (profile, post, data) => allpeepDb().then(({ db }) => entryC
|
|
|
194
205
|
}).then(() => hub.emit('entryCreated', profile, post, { type: 'answer', data })));
|
|
195
206
|
const attendingRsvp = (response) => response === 'yes' || response === 'tentative';
|
|
196
207
|
const rsvpOccurrenceIds = (data) => {
|
|
197
|
-
|
|
198
|
-
if ((_a = data.recurrenceIds) === null || _a === void 0 ? void 0 : _a.length)
|
|
208
|
+
if (data.recurrenceIds?.length)
|
|
199
209
|
return data.recurrenceIds;
|
|
200
210
|
if (data.recurrenceId)
|
|
201
211
|
return [data.recurrenceId];
|
|
202
212
|
return undefined;
|
|
203
213
|
};
|
|
204
214
|
export const rsvpRespond = async (profile, post, data) => {
|
|
205
|
-
var _a, _b, _c, _d;
|
|
206
215
|
if (profile.id === post.profile.id) {
|
|
207
216
|
return;
|
|
208
217
|
}
|
|
209
|
-
if (post.type !== 'event' ||
|
|
218
|
+
if (post.type !== 'event' || post.data?.type !== 'event') {
|
|
210
219
|
throw unprocessableRequest({ errorKey: 'error.unprocessableRequest' });
|
|
211
220
|
}
|
|
212
221
|
// `removed` is an organizer-only status; users cannot set it on themselves,
|
|
@@ -215,7 +224,7 @@ export const rsvpRespond = async (profile, post, data) => {
|
|
|
215
224
|
if (data.response === 'removed') {
|
|
216
225
|
throw forbidden({ errorKey: 'error.rsvpRemovedForbidden' });
|
|
217
226
|
}
|
|
218
|
-
if (
|
|
227
|
+
if (getEffectiveRsvp(post, profile.id)?.response === 'removed') {
|
|
219
228
|
throw forbidden({ errorKey: 'error.rsvpRemoved' });
|
|
220
229
|
}
|
|
221
230
|
const occurrenceIds = rsvpOccurrenceIds(data);
|
|
@@ -233,10 +242,10 @@ export const rsvpRespond = async (profile, post, data) => {
|
|
|
233
242
|
}
|
|
234
243
|
}
|
|
235
244
|
else {
|
|
236
|
-
const ids = occurrenceIds
|
|
245
|
+
const ids = occurrenceIds ?? [undefined];
|
|
237
246
|
for (const recurrenceId of ids) {
|
|
238
247
|
const currentRsvp = getEffectiveRsvp(post, profile.id, recurrenceId);
|
|
239
|
-
if (
|
|
248
|
+
if (currentRsvp?.response !== 'yes' &&
|
|
240
249
|
countYesRsvps(post, recurrenceId) >= maxAttendees) {
|
|
241
250
|
throw unprocessableRequest({ errorKey: 'error.eventAtCapacity' });
|
|
242
251
|
}
|
|
@@ -246,16 +255,16 @@ export const rsvpRespond = async (profile, post, data) => {
|
|
|
246
255
|
}
|
|
247
256
|
const { db } = await allpeepDb();
|
|
248
257
|
const previousResponses = occurrenceIds
|
|
249
|
-
? occurrenceIds.map((id) =>
|
|
258
|
+
? occurrenceIds.map((id) => getEffectiveRsvp(post, profile.id, id)?.response)
|
|
250
259
|
: undefined;
|
|
251
260
|
const previousResponse = previousResponses
|
|
252
261
|
? previousResponses.every(attendingRsvp)
|
|
253
262
|
? previousResponses[0]
|
|
254
263
|
: previousResponses.find((response) => !attendingRsvp(response))
|
|
255
|
-
:
|
|
264
|
+
: [...(post.rsvps ?? [])]
|
|
256
265
|
.filter((rsvp) => rsvp.profile.id === profile.id)
|
|
257
266
|
.filter((rsvp) => !rsvp.recurrenceId)
|
|
258
|
-
.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))[0]
|
|
267
|
+
.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))[0]?.response;
|
|
259
268
|
const writes = occurrenceIds
|
|
260
269
|
? occurrenceIds.map((recurrenceId) => ({
|
|
261
270
|
response: data.response,
|
|
@@ -269,13 +278,20 @@ export const rsvpRespond = async (profile, post, data) => {
|
|
|
269
278
|
});
|
|
270
279
|
}
|
|
271
280
|
const cancel = rsvpCancelNotice(post, profile.id, data.response, occurrenceIds);
|
|
272
|
-
hub.emit('rsvpCreated', profile, post,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
281
|
+
hub.emit('rsvpCreated', profile, post, {
|
|
282
|
+
type: 'rsvp',
|
|
283
|
+
data: {
|
|
284
|
+
response: data.response,
|
|
285
|
+
...(occurrenceIds?.length === 1
|
|
286
|
+
? { recurrenceId: occurrenceIds[0] }
|
|
287
|
+
: {}),
|
|
288
|
+
},
|
|
289
|
+
occurrenceIds,
|
|
290
|
+
previousResponse,
|
|
291
|
+
...(cancel ? { cancel } : {}),
|
|
292
|
+
});
|
|
276
293
|
};
|
|
277
294
|
export const rsvpManageByOrganizer = async (actingProfile, targetProfile, post, response, recurrenceId) => {
|
|
278
|
-
var _a, _b;
|
|
279
295
|
if (!canManageEventRsvps(actingProfile, post)) {
|
|
280
296
|
throw forbidden({ errorKey: 'forbidden' });
|
|
281
297
|
}
|
|
@@ -287,13 +303,13 @@ export const rsvpManageByOrganizer = async (actingProfile, targetProfile, post,
|
|
|
287
303
|
}
|
|
288
304
|
const data = { response, recurrenceId };
|
|
289
305
|
const { db } = await allpeepDb();
|
|
290
|
-
const previousResponse =
|
|
306
|
+
const previousResponse = [...(post.rsvps ?? [])]
|
|
291
307
|
.filter((rsvp) => rsvp.profile.id === targetProfile.id)
|
|
292
308
|
.filter((rsvp) => recurrenceId
|
|
293
309
|
? sameRecurrenceId(rsvp.recurrenceId, recurrenceId) ||
|
|
294
310
|
!rsvp.recurrenceId
|
|
295
311
|
: !rsvp.recurrenceId)
|
|
296
|
-
.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))[0]
|
|
312
|
+
.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))[0]?.response;
|
|
297
313
|
await entryConnector(db, targetProfile, post, {
|
|
298
314
|
type: 'rsvp',
|
|
299
315
|
data,
|
|
@@ -322,7 +338,6 @@ export const rsvpManageByOrganizer = async (actingProfile, targetProfile, post,
|
|
|
322
338
|
* tab, detected by posts they authored but are not in.
|
|
323
339
|
*/
|
|
324
340
|
export const leaveConversation = async (rootPost, profile) => {
|
|
325
|
-
var _a, _b;
|
|
326
341
|
const { db } = await allpeepDb();
|
|
327
342
|
const lastPostId = await findLatestThreadPostId(rootPost.id);
|
|
328
343
|
const [lastPost] = lastPostId === rootPost.id
|
|
@@ -330,7 +345,7 @@ export const leaveConversation = async (rootPost, profile) => {
|
|
|
330
345
|
: await findPostsForAuth([lastPostId]);
|
|
331
346
|
if (!lastPost)
|
|
332
347
|
return;
|
|
333
|
-
const remainingAudience =
|
|
348
|
+
const remainingAudience = lastPost.audience?.filter((p) => p.id !== profile.id) ?? [];
|
|
334
349
|
if (remainingAudience.length > 0) {
|
|
335
350
|
await createPost({ type: 'note', content: '' }, profile, { type: 'note', visibility: 'direct', creatorId: profile.id }, {
|
|
336
351
|
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,
|
|
@@ -8,7 +8,7 @@ import { listBlockedByIds } from './blocks.js';
|
|
|
8
8
|
import { findProfile } from './finders.js';
|
|
9
9
|
import { listReportsByReportedProfile } from '../reports/finders.js';
|
|
10
10
|
import { profileActivityCountsSql, profileTopPostScoresSql, takeTopReadablePosts, } from './activityQueries.js';
|
|
11
|
-
const sqlRows = (result) =>
|
|
11
|
+
const sqlRows = (result) => result.rows ?? [];
|
|
12
12
|
const loadPostsByIds = async (db, ids, authData) => {
|
|
13
13
|
if (ids.length === 0)
|
|
14
14
|
return [];
|
|
@@ -24,46 +24,41 @@ const loadPostsByIds = async (db, ids, authData) => {
|
|
|
24
24
|
.filter((post) => !!post);
|
|
25
25
|
};
|
|
26
26
|
export const getProfileActivitySummary = async (authData, profileId) => {
|
|
27
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
28
27
|
const { db } = await allpeepDb();
|
|
29
28
|
const [countRow] = sqlRows(await db.execute(profileActivityCountsSql(profileId)));
|
|
30
29
|
const scored = sqlRows(await db.execute(profileTopPostScoresSql(profileId)))
|
|
31
|
-
.map((row) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
activityScore: Number((_b = row.activity_score) !== null && _b !== void 0 ? _b : 0),
|
|
36
|
-
});
|
|
37
|
-
})
|
|
30
|
+
.map((row) => ({
|
|
31
|
+
id: String(row.id ?? ''),
|
|
32
|
+
activityScore: Number(row.activity_score ?? 0),
|
|
33
|
+
}))
|
|
38
34
|
.filter((row) => row.id);
|
|
39
35
|
const scoreById = new Map(scored.map((row) => [row.id, row.activityScore]));
|
|
40
36
|
const loaded = await loadPostsByIds(db, scored.map((row) => row.id), authData);
|
|
41
37
|
const config = await capabilitiesConfig();
|
|
42
38
|
const readable = canReadPost(config, authData);
|
|
43
39
|
const topPosts = takeTopReadablePosts(loaded, readable)
|
|
44
|
-
.map((post) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
40
|
+
.map((post) => publicPostWithActivityScoreSchema.safeParse({
|
|
41
|
+
...post,
|
|
42
|
+
activityScore: scoreById.get(post.id) ?? 0,
|
|
43
|
+
}))
|
|
48
44
|
.filter((result) => result.success)
|
|
49
45
|
.map((result) => result.data);
|
|
50
46
|
return profileActivitySummarySchema.parse({
|
|
51
|
-
postsCount: Number(
|
|
52
|
-
repliesCount: Number(
|
|
53
|
-
eventsCount: Number(
|
|
54
|
-
reactionsGiven: Number(
|
|
55
|
-
reactionsReceived: Number(
|
|
56
|
-
repostsCount: Number(
|
|
57
|
-
repostsReceived: Number(
|
|
58
|
-
repliesReceived: Number(
|
|
59
|
-
rsvpsCount: Number(
|
|
60
|
-
bookmarksCount: Number(
|
|
61
|
-
groupsCount: Number(
|
|
47
|
+
postsCount: Number(countRow?.posts_count ?? 0),
|
|
48
|
+
repliesCount: Number(countRow?.replies_count ?? 0),
|
|
49
|
+
eventsCount: Number(countRow?.events_count ?? 0),
|
|
50
|
+
reactionsGiven: Number(countRow?.reactions_given ?? 0),
|
|
51
|
+
reactionsReceived: Number(countRow?.reactions_received ?? 0),
|
|
52
|
+
repostsCount: Number(countRow?.reposts_count ?? 0),
|
|
53
|
+
repostsReceived: Number(countRow?.reposts_received ?? 0),
|
|
54
|
+
repliesReceived: Number(countRow?.replies_received ?? 0),
|
|
55
|
+
rsvpsCount: Number(countRow?.rsvps_count ?? 0),
|
|
56
|
+
bookmarksCount: Number(countRow?.bookmarks_count ?? 0),
|
|
57
|
+
groupsCount: Number(countRow?.groups_count ?? 0),
|
|
62
58
|
topPosts,
|
|
63
59
|
});
|
|
64
60
|
};
|
|
65
61
|
export const getAdminProfileSummary = async (authData, profileId) => {
|
|
66
|
-
var _a, _b, _c, _d, _e, _f;
|
|
67
62
|
const profile = await findProfile(profileId);
|
|
68
63
|
if (!profile) {
|
|
69
64
|
throw new Error(`Profile with id ${profileId} not found`);
|
|
@@ -78,9 +73,9 @@ export const getAdminProfileSummary = async (authData, profileId) => {
|
|
|
78
73
|
profile: publicProfileSchema.parse(profile),
|
|
79
74
|
activity,
|
|
80
75
|
createdAt: profile.createdAt,
|
|
81
|
-
email:
|
|
82
|
-
followersCount:
|
|
83
|
-
followingCount:
|
|
76
|
+
email: profile.controllers?.[0]?.email,
|
|
77
|
+
followersCount: profile.profileStats?.followersCount ?? 0,
|
|
78
|
+
followingCount: profile.profileStats?.followingCount ?? 0,
|
|
84
79
|
reportsCount: reports.length,
|
|
85
80
|
blockedByCount: blockedByIds.length,
|
|
86
81
|
});
|