@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/finders.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const baseFeed: ({ start, sort, profile, }: {
|
|
|
18
18
|
profile?: ProfileWithMeta;
|
|
19
19
|
}) => Mapping<DbPost>;
|
|
20
20
|
export declare const baseEventsFeed: (profile?: ProfileWithMeta) => Mapping<{
|
|
21
|
-
type: "note" | "question" | "event" | "article";
|
|
21
|
+
type: "resource" | "note" | "question" | "event" | "article";
|
|
22
22
|
visibility: "local" | "group" | "report" | "public" | "unlisted" | "private" | "direct";
|
|
23
23
|
creatorId: string;
|
|
24
24
|
capabilitiesNeeded?: string[] | undefined;
|
|
@@ -214,6 +214,44 @@ export declare const baseEventsFeed: (profile?: ProfileWithMeta) => Mapping<{
|
|
|
214
214
|
language?: string | undefined;
|
|
215
215
|
image?: string | undefined;
|
|
216
216
|
title?: string | undefined;
|
|
217
|
+
} | {
|
|
218
|
+
type: "resource";
|
|
219
|
+
title: string;
|
|
220
|
+
resourceKind: "link" | "file" | "video" | "gallery" | "audio";
|
|
221
|
+
content?: string | undefined;
|
|
222
|
+
sensitive?: boolean | undefined;
|
|
223
|
+
spoilerText?: string | undefined;
|
|
224
|
+
attachments?: {
|
|
225
|
+
type: string;
|
|
226
|
+
url: string;
|
|
227
|
+
previewUrl: string | null;
|
|
228
|
+
textUrl: null;
|
|
229
|
+
filename: string;
|
|
230
|
+
meta: {
|
|
231
|
+
usage?: string | undefined;
|
|
232
|
+
focus?: {
|
|
233
|
+
x: number;
|
|
234
|
+
y: number;
|
|
235
|
+
} | undefined;
|
|
236
|
+
mimetype?: string | undefined;
|
|
237
|
+
size?: number | undefined;
|
|
238
|
+
};
|
|
239
|
+
description?: string | undefined;
|
|
240
|
+
blurhash?: string | undefined;
|
|
241
|
+
status?: "failed" | "processing" | "ready" | undefined;
|
|
242
|
+
error?: string | undefined;
|
|
243
|
+
}[] | undefined;
|
|
244
|
+
customEmojis?: {
|
|
245
|
+
shortcode: string;
|
|
246
|
+
url: string;
|
|
247
|
+
staticUrl: string;
|
|
248
|
+
visibleInPicker: boolean;
|
|
249
|
+
category: string;
|
|
250
|
+
}[] | undefined;
|
|
251
|
+
language?: string | undefined;
|
|
252
|
+
tags?: string[] | undefined;
|
|
253
|
+
categoryPath?: string[] | undefined;
|
|
254
|
+
url?: string | undefined;
|
|
217
255
|
} | undefined;
|
|
218
256
|
}, DbPost, DbPost>;
|
|
219
257
|
export declare const listPosts: (authData: AuthorizationData, { start, limit, filter, }?: {
|
|
@@ -236,11 +274,13 @@ export declare const listBookmarkedPosts: (authData: AuthorizationData, requeste
|
|
|
236
274
|
}) => Promise<PostWithMeta[]>;
|
|
237
275
|
export declare const listBookmarkedPostIds: (requestedProfile: ProfileWithMeta) => Promise<string[]>;
|
|
238
276
|
export declare const getUnseenPostCounts: (authData: AuthorizationData) => Promise<UnseenPostCounts>;
|
|
239
|
-
export declare const listPostsByType: (authData: AuthorizationData, type: PostType, { start, limit, filter, format, }?: {
|
|
277
|
+
export declare const listPostsByType: (authData: AuthorizationData, type: PostType, { start, limit, filter, format, groupId, ungrouped, }?: {
|
|
240
278
|
start?: string;
|
|
241
279
|
limit?: number;
|
|
242
280
|
filter?: PgFilter<DbBasePost>;
|
|
243
281
|
format?: string | null;
|
|
282
|
+
groupId?: string;
|
|
283
|
+
ungrouped?: boolean;
|
|
244
284
|
}) => Promise<PostWithMeta[]>;
|
|
245
285
|
export declare const listPostsByTag: (authData: AuthorizationData, tag: string, { start, limit, filter, format, }?: {
|
|
246
286
|
start?: string;
|
package/dist/posts/finders.js
CHANGED
|
@@ -30,14 +30,13 @@ const requireProfile = (authData) => {
|
|
|
30
30
|
return authData.profile;
|
|
31
31
|
};
|
|
32
32
|
const hideBlockedAuthorPost = (post, profile) => {
|
|
33
|
-
var _a, _b;
|
|
34
33
|
if (!post)
|
|
35
34
|
return undefined;
|
|
36
|
-
const creatorId =
|
|
35
|
+
const creatorId = post.creatorId ?? post.profile?.id;
|
|
37
36
|
return isBlockedPair(profile, creatorId) ? undefined : post;
|
|
38
37
|
};
|
|
39
38
|
export const findPost = async (id, authData) => {
|
|
40
|
-
const profile = authData
|
|
39
|
+
const profile = authData?.profile;
|
|
41
40
|
return allpeepDb()
|
|
42
41
|
.then(({ db }) => postsMappingForProfile(profile).find(db, id))
|
|
43
42
|
.then((post) => (post ? transformPost(post, profile) : undefined))
|
|
@@ -47,7 +46,7 @@ export const findPost = async (id, authData) => {
|
|
|
47
46
|
export const findPostsForAuth = async (ids, authData) => {
|
|
48
47
|
if (ids.length === 0)
|
|
49
48
|
return [];
|
|
50
|
-
const profile = authData
|
|
49
|
+
const profile = authData?.profile;
|
|
51
50
|
const { db } = await allpeepDb();
|
|
52
51
|
const mapData = postsAuthMapping.data();
|
|
53
52
|
const rows = await fetchRowsByIds(db, mapData.collection, ids, mapData.softDelete);
|
|
@@ -63,7 +62,7 @@ export const findPostsForAuth = async (ids, authData) => {
|
|
|
63
62
|
export const postContext = async (authData, id, depth, direction, contextMapping) => {
|
|
64
63
|
const profile = authData.profile;
|
|
65
64
|
const mapping = postsMappingForProfile(profile);
|
|
66
|
-
return toFilteredPostsList(mapping.relationsFrom({ id }, contextRelation(depth, direction, contextMapping
|
|
65
|
+
return toFilteredPostsList(mapping.relationsFrom({ id }, contextRelation(depth, direction, contextMapping ?? mapping)), { authData });
|
|
67
66
|
};
|
|
68
67
|
export const descendents = async (authData, post, depth, contextMapping) => postContext(authData, post.id, depth, 'descendents', contextMapping);
|
|
69
68
|
export const ancestors = async (authData, post, depth, contextMapping) => postContext(authData, post.id, depth, 'ancestors', contextMapping);
|
|
@@ -158,11 +157,24 @@ export const getUnseenPostCounts = async (authData) => withSpan('unseen.counts',
|
|
|
158
157
|
const { db } = await allpeepDb();
|
|
159
158
|
return queryUnseenPostCounts(db, profile.id, groupIds);
|
|
160
159
|
});
|
|
161
|
-
export const listPostsByType = async (authData, type, { start, limit = 100, filter, format, } = {
|
|
160
|
+
export const listPostsByType = async (authData, type, { start, limit = 100, filter, format, groupId, ungrouped, } = {
|
|
162
161
|
limit: 100,
|
|
163
|
-
}) =>
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
}) => {
|
|
163
|
+
let mapping = conversationFeed({
|
|
164
|
+
start,
|
|
165
|
+
profile: authData.profile,
|
|
166
|
+
format,
|
|
167
|
+
})
|
|
168
|
+
.filter(filter)
|
|
169
|
+
.filter({ matches: { type } });
|
|
170
|
+
if (groupId) {
|
|
171
|
+
mapping = mapping.filter(postFilters.inGroup(groupId));
|
|
172
|
+
}
|
|
173
|
+
else if (ungrouped) {
|
|
174
|
+
mapping = mapping.filter(postFilters.notInAnyGroup());
|
|
175
|
+
}
|
|
176
|
+
return toFilteredPostsList(mapping, { authData, limit });
|
|
177
|
+
};
|
|
166
178
|
export const listPostsByTag = async (authData, tag, { start, limit = 100, filter, format, } = {
|
|
167
179
|
limit: 100,
|
|
168
180
|
}) => {
|
|
@@ -16,8 +16,7 @@ export const followFilter = (profile) => ({
|
|
|
16
16
|
})),
|
|
17
17
|
});
|
|
18
18
|
export const myFeedFilter = (profile) => {
|
|
19
|
-
|
|
20
|
-
const hashtagFilterResult = postFilters.hasAnyHashtag((_b = (_a = profile.followedHashtags) === null || _a === void 0 ? void 0 : _a.map((h) => h.id)) !== null && _b !== void 0 ? _b : []);
|
|
19
|
+
const hashtagFilterResult = postFilters.hasAnyHashtag(profile.followedHashtags?.map((h) => h.id) ?? []);
|
|
21
20
|
return {
|
|
22
21
|
operator: '||',
|
|
23
22
|
predicates: [
|
|
@@ -30,7 +29,7 @@ export const myFeedFilter = (profile) => {
|
|
|
30
29
|
};
|
|
31
30
|
export const myFeedGroupMembershipFilter = (profile) => (post) => post.visibility !== 'group' ||
|
|
32
31
|
(!!post.group &&
|
|
33
|
-
profile.memberships.some((m) =>
|
|
32
|
+
profile.memberships.some((m) => m.group.id === post.group?.id));
|
|
34
33
|
export const localFeedFilter = (_profile) => ({
|
|
35
34
|
matches: [{ visibility: 'local' }, { visibility: 'public' }],
|
|
36
35
|
});
|
|
@@ -205,6 +205,44 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
205
205
|
language?: string | undefined;
|
|
206
206
|
image?: string | undefined;
|
|
207
207
|
title?: string | undefined;
|
|
208
|
+
} | {
|
|
209
|
+
type: "resource";
|
|
210
|
+
title: string;
|
|
211
|
+
resourceKind: "link" | "file" | "video" | "gallery" | "audio";
|
|
212
|
+
content?: string | undefined;
|
|
213
|
+
sensitive?: boolean | undefined;
|
|
214
|
+
spoilerText?: string | undefined;
|
|
215
|
+
attachments?: {
|
|
216
|
+
type: string;
|
|
217
|
+
url: string;
|
|
218
|
+
previewUrl: string | null;
|
|
219
|
+
textUrl: null;
|
|
220
|
+
filename: string;
|
|
221
|
+
meta: {
|
|
222
|
+
usage?: string | undefined;
|
|
223
|
+
focus?: {
|
|
224
|
+
x: number;
|
|
225
|
+
y: number;
|
|
226
|
+
} | undefined;
|
|
227
|
+
mimetype?: string | undefined;
|
|
228
|
+
size?: number | undefined;
|
|
229
|
+
};
|
|
230
|
+
description?: string | undefined;
|
|
231
|
+
blurhash?: string | undefined;
|
|
232
|
+
status?: "failed" | "processing" | "ready" | undefined;
|
|
233
|
+
error?: string | undefined;
|
|
234
|
+
}[] | undefined;
|
|
235
|
+
customEmojis?: {
|
|
236
|
+
shortcode: string;
|
|
237
|
+
url: string;
|
|
238
|
+
staticUrl: string;
|
|
239
|
+
visibleInPicker: boolean;
|
|
240
|
+
category: string;
|
|
241
|
+
}[] | undefined;
|
|
242
|
+
language?: string | undefined;
|
|
243
|
+
tags?: string[] | undefined;
|
|
244
|
+
categoryPath?: string[] | undefined;
|
|
245
|
+
url?: string | undefined;
|
|
208
246
|
};
|
|
209
247
|
} | {
|
|
210
248
|
type: "edit";
|
|
@@ -400,6 +438,44 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
400
438
|
language?: string | undefined;
|
|
401
439
|
image?: string | undefined;
|
|
402
440
|
title?: string | undefined;
|
|
441
|
+
} | {
|
|
442
|
+
type: "resource";
|
|
443
|
+
title: string;
|
|
444
|
+
resourceKind: "link" | "file" | "video" | "gallery" | "audio";
|
|
445
|
+
content?: string | undefined;
|
|
446
|
+
sensitive?: boolean | undefined;
|
|
447
|
+
spoilerText?: string | undefined;
|
|
448
|
+
attachments?: {
|
|
449
|
+
type: string;
|
|
450
|
+
url: string;
|
|
451
|
+
previewUrl: string | null;
|
|
452
|
+
textUrl: null;
|
|
453
|
+
filename: string;
|
|
454
|
+
meta: {
|
|
455
|
+
usage?: string | undefined;
|
|
456
|
+
focus?: {
|
|
457
|
+
x: number;
|
|
458
|
+
y: number;
|
|
459
|
+
} | undefined;
|
|
460
|
+
mimetype?: string | undefined;
|
|
461
|
+
size?: number | undefined;
|
|
462
|
+
};
|
|
463
|
+
description?: string | undefined;
|
|
464
|
+
blurhash?: string | undefined;
|
|
465
|
+
status?: "failed" | "processing" | "ready" | undefined;
|
|
466
|
+
error?: string | undefined;
|
|
467
|
+
}[] | undefined;
|
|
468
|
+
customEmojis?: {
|
|
469
|
+
shortcode: string;
|
|
470
|
+
url: string;
|
|
471
|
+
staticUrl: string;
|
|
472
|
+
visibleInPicker: boolean;
|
|
473
|
+
category: string;
|
|
474
|
+
}[] | undefined;
|
|
475
|
+
language?: string | undefined;
|
|
476
|
+
tags?: string[] | undefined;
|
|
477
|
+
categoryPath?: string[] | undefined;
|
|
478
|
+
url?: string | undefined;
|
|
403
479
|
};
|
|
404
480
|
} | {
|
|
405
481
|
type: "delete";
|
|
@@ -623,6 +699,44 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
623
699
|
language?: string | undefined;
|
|
624
700
|
image?: string | undefined;
|
|
625
701
|
title?: string | undefined;
|
|
702
|
+
} | {
|
|
703
|
+
type: "resource";
|
|
704
|
+
title: string;
|
|
705
|
+
resourceKind: "link" | "file" | "video" | "gallery" | "audio";
|
|
706
|
+
content?: string | undefined;
|
|
707
|
+
sensitive?: boolean | undefined;
|
|
708
|
+
spoilerText?: string | undefined;
|
|
709
|
+
attachments?: {
|
|
710
|
+
type: string;
|
|
711
|
+
url: string;
|
|
712
|
+
previewUrl: string | null;
|
|
713
|
+
textUrl: null;
|
|
714
|
+
filename: string;
|
|
715
|
+
meta: {
|
|
716
|
+
usage?: string | undefined;
|
|
717
|
+
focus?: {
|
|
718
|
+
x: number;
|
|
719
|
+
y: number;
|
|
720
|
+
} | undefined;
|
|
721
|
+
mimetype?: string | undefined;
|
|
722
|
+
size?: number | undefined;
|
|
723
|
+
};
|
|
724
|
+
description?: string | undefined;
|
|
725
|
+
blurhash?: string | undefined;
|
|
726
|
+
status?: "failed" | "processing" | "ready" | undefined;
|
|
727
|
+
error?: string | undefined;
|
|
728
|
+
}[] | undefined;
|
|
729
|
+
customEmojis?: {
|
|
730
|
+
shortcode: string;
|
|
731
|
+
url: string;
|
|
732
|
+
staticUrl: string;
|
|
733
|
+
visibleInPicker: boolean;
|
|
734
|
+
category: string;
|
|
735
|
+
}[] | undefined;
|
|
736
|
+
language?: string | undefined;
|
|
737
|
+
tags?: string[] | undefined;
|
|
738
|
+
categoryPath?: string[] | undefined;
|
|
739
|
+
url?: string | undefined;
|
|
626
740
|
};
|
|
627
741
|
} | {
|
|
628
742
|
type: "edit";
|
|
@@ -818,6 +932,44 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
818
932
|
language?: string | undefined;
|
|
819
933
|
image?: string | undefined;
|
|
820
934
|
title?: string | undefined;
|
|
935
|
+
} | {
|
|
936
|
+
type: "resource";
|
|
937
|
+
title: string;
|
|
938
|
+
resourceKind: "link" | "file" | "video" | "gallery" | "audio";
|
|
939
|
+
content?: string | undefined;
|
|
940
|
+
sensitive?: boolean | undefined;
|
|
941
|
+
spoilerText?: string | undefined;
|
|
942
|
+
attachments?: {
|
|
943
|
+
type: string;
|
|
944
|
+
url: string;
|
|
945
|
+
previewUrl: string | null;
|
|
946
|
+
textUrl: null;
|
|
947
|
+
filename: string;
|
|
948
|
+
meta: {
|
|
949
|
+
usage?: string | undefined;
|
|
950
|
+
focus?: {
|
|
951
|
+
x: number;
|
|
952
|
+
y: number;
|
|
953
|
+
} | undefined;
|
|
954
|
+
mimetype?: string | undefined;
|
|
955
|
+
size?: number | undefined;
|
|
956
|
+
};
|
|
957
|
+
description?: string | undefined;
|
|
958
|
+
blurhash?: string | undefined;
|
|
959
|
+
status?: "failed" | "processing" | "ready" | undefined;
|
|
960
|
+
error?: string | undefined;
|
|
961
|
+
}[] | undefined;
|
|
962
|
+
customEmojis?: {
|
|
963
|
+
shortcode: string;
|
|
964
|
+
url: string;
|
|
965
|
+
staticUrl: string;
|
|
966
|
+
visibleInPicker: boolean;
|
|
967
|
+
category: string;
|
|
968
|
+
}[] | undefined;
|
|
969
|
+
language?: string | undefined;
|
|
970
|
+
tags?: string[] | undefined;
|
|
971
|
+
categoryPath?: string[] | undefined;
|
|
972
|
+
url?: string | undefined;
|
|
821
973
|
};
|
|
822
974
|
} | {
|
|
823
975
|
type: "delete";
|
|
@@ -21,10 +21,11 @@ const getTags = (text) => {
|
|
|
21
21
|
return (text.match(hashtagRegex) || []).map((tag) => normalizeHashtagTag(tag.substring(1)));
|
|
22
22
|
};
|
|
23
23
|
export const extractHashtags = (data) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const fromContent = getTags(data?.content);
|
|
25
|
+
if (data.type !== 'resource')
|
|
26
|
+
return fromContent;
|
|
27
|
+
const fromTags = (data.tags ?? []).map((tag) => normalizeHashtagTag(tag.replace(/^#/, '')));
|
|
28
|
+
return [...new Set([...fromContent, ...fromTags])];
|
|
28
29
|
};
|
|
29
30
|
export const extractMentionHandles = (text) => matchMentionHandles(text);
|
|
30
31
|
export const resolveMentionsForPost = async (data) => {
|
|
@@ -52,20 +53,24 @@ export const bookmarkConnector = connector(collectionInfos.profilesCollection, c
|
|
|
52
53
|
export const bookmarkDisconnector = disconnector(collectionInfos.profilesCollection, collectionInfos.postsCollection, collectionInfos.bookmarksCollection);
|
|
53
54
|
export const postSeenConnector = connector(collectionInfos.profilesCollection, collectionInfos.postsCollection, collectionInfos.postSeenCollection);
|
|
54
55
|
const loadPublicProfile = async (profileId, ignoreSoftDelete = false) => tombstoneProfileWithMetaIfDeleted(await getPublicProfile(profileId, ignoreSoftDelete));
|
|
55
|
-
const addProfileForEntry = async (rawEntry) => (
|
|
56
|
+
const addProfileForEntry = async (rawEntry) => ({
|
|
57
|
+
...rawEntry,
|
|
56
58
|
// ignoreSoftDelete: authorship must survive account removal
|
|
57
|
-
profile: (await loadPublicProfile(rawEntry.profile.id, true))
|
|
58
|
-
|
|
59
|
+
profile: (await loadPublicProfile(rawEntry.profile.id, true)),
|
|
60
|
+
});
|
|
61
|
+
const addProfileForMention = async (rawMention) => ({
|
|
62
|
+
...rawMention,
|
|
63
|
+
profile: (await loadPublicProfile(rawMention.profile.id, true)),
|
|
64
|
+
});
|
|
59
65
|
const leanRepostsFromWrappers = async (wrappers) => {
|
|
60
|
-
if (!
|
|
66
|
+
if (!wrappers?.length)
|
|
61
67
|
return [];
|
|
62
68
|
const withProfiles = await Promise.all(wrappers.map(async (wrapper) => {
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const profileId = (_c = (_b = createEntry === null || createEntry === void 0 ? void 0 : createEntry.profile) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : wrapper.creatorId;
|
|
69
|
+
const createEntry = wrapper.entries?.find((entry) => entry.type === 'create');
|
|
70
|
+
const profileId = createEntry?.profile?.id ?? wrapper.creatorId;
|
|
66
71
|
if (!profileId)
|
|
67
72
|
return null;
|
|
68
|
-
const profile =
|
|
73
|
+
const profile = createEntry?.profile
|
|
69
74
|
? await loadPublicProfile(createEntry.profile.id, true)
|
|
70
75
|
: await loadPublicProfile(profileId, true);
|
|
71
76
|
if (!profile)
|
|
@@ -81,8 +86,7 @@ const leanRepostsFromWrappers = async (wrappers) => {
|
|
|
81
86
|
.slice(0, EMBEDDED_REPOSTS_LIMIT);
|
|
82
87
|
};
|
|
83
88
|
export const transformPost = async (post, currentProfile, options = {}) => {
|
|
84
|
-
|
|
85
|
-
const embedThreadPreview = (_a = options.embedThreadPreview) !== null && _a !== void 0 ? _a : true;
|
|
89
|
+
const embedThreadPreview = options.embedThreadPreview ?? true;
|
|
86
90
|
const nested = { embedThreadPreview: false };
|
|
87
91
|
const allEntries = post.entries
|
|
88
92
|
? await Promise.all(post.entries.map(addProfileForEntry))
|
|
@@ -101,38 +105,50 @@ export const transformPost = async (post, currentProfile, options = {}) => {
|
|
|
101
105
|
const mentions = post.mentions
|
|
102
106
|
? await Promise.all(post.mentions.map(addProfileForMention))
|
|
103
107
|
: [];
|
|
104
|
-
const createProfile =
|
|
105
|
-
const profile = createProfile
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
const createProfile = entries.find((entry) => entry.type === 'create')?.profile;
|
|
109
|
+
const profile = createProfile ??
|
|
110
|
+
(post.creatorId
|
|
111
|
+
? await loadPublicProfile(post.creatorId, true)
|
|
112
|
+
: undefined);
|
|
108
113
|
const preview = embedThreadPreview
|
|
109
114
|
? await loadThreadPreviewReplies(post.id, currentProfile)
|
|
110
115
|
: {
|
|
111
|
-
replies: (
|
|
116
|
+
replies: (post.latestReplies ?? []),
|
|
112
117
|
hasMore: !!post.latestRepliesHasMore,
|
|
113
118
|
};
|
|
114
119
|
const latestReplies = (await Promise.all(preview.replies.map((reply) => transformPost(reply, currentProfile, nested)))).filter((reply) => !!reply.profile);
|
|
115
|
-
return
|
|
120
|
+
return {
|
|
121
|
+
...post,
|
|
122
|
+
data: post.data ? normalizePostDataFromDb(post.data) : post.data,
|
|
123
|
+
seen: currentProfile ? post.seen : undefined,
|
|
124
|
+
replyTo: post.replyTo
|
|
116
125
|
? withBlockTombstone(await transformPost(post.replyTo, currentProfile, nested), currentProfile)
|
|
117
|
-
: undefined,
|
|
126
|
+
: undefined,
|
|
127
|
+
latestReplies: latestReplies.map((reply) => withBlockTombstone(reply, currentProfile)),
|
|
128
|
+
latestRepliesHasMore: preview.hasMore,
|
|
129
|
+
repost: post.repost
|
|
118
130
|
? await transformPost(post.repost, currentProfile, {
|
|
119
131
|
embedThreadPreview,
|
|
120
132
|
})
|
|
121
|
-
: undefined,
|
|
133
|
+
: undefined,
|
|
134
|
+
rsvps: entries
|
|
122
135
|
.filter((entry) => entry.type === 'rsvp')
|
|
123
136
|
.map((entry) => ({
|
|
124
137
|
profile: entry.profile,
|
|
125
138
|
response: entry.data.response,
|
|
126
139
|
recurrenceId: entry.data.recurrenceId,
|
|
127
140
|
createdAt: entry.createdAt,
|
|
128
|
-
})),
|
|
129
|
-
|
|
141
|
+
})),
|
|
142
|
+
audience,
|
|
143
|
+
mentions,
|
|
144
|
+
profile: profile,
|
|
145
|
+
entries,
|
|
130
146
|
reactions,
|
|
131
|
-
reposts
|
|
147
|
+
reposts,
|
|
148
|
+
};
|
|
132
149
|
};
|
|
133
150
|
const withBlockTombstone = (post, currentProfile) => {
|
|
134
|
-
|
|
135
|
-
const creatorId = (_a = post.creatorId) !== null && _a !== void 0 ? _a : (_b = post.profile) === null || _b === void 0 ? void 0 : _b.id;
|
|
151
|
+
const creatorId = post.creatorId ?? post.profile?.id;
|
|
136
152
|
return creatorId && isBlockedPair(currentProfile, creatorId)
|
|
137
153
|
? toHiddenPost(post)
|
|
138
154
|
: post;
|