@openpeepshq/core 0.1.33 → 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 +36 -33
- package/dist/analytics/cache.js +3 -3
- package/dist/analytics/clicks.js +14 -22
- package/dist/analytics/compile.js +17 -12
- 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 +164 -140
- package/dist/analytics/report.d.ts +22 -1
- package/dist/analytics/report.js +2 -3
- package/dist/analytics/settings.js +3 -4
- package/dist/backups/index.js +82 -25
- package/dist/backups/metadata.d.ts +2 -3
- package/dist/backups/metadata.js +6 -2
- package/dist/config/db.js +2 -4
- package/dist/config/defaults/capabilities.js +13 -2
- package/dist/config/defaults/community.js +8 -3
- package/dist/config/defaults/core.d.ts +1 -1
- package/dist/config/defaults/core.js +16 -8
- package/dist/config/index.d.ts +22 -0
- package/dist/config/index.js +15 -11
- package/dist/db/explorer/query.js +9 -8
- package/dist/db/explorer/sql.js +8 -8
- package/dist/db/helpers.d.ts +1 -0
- package/dist/db/helpers.js +25 -7
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +1 -0
- package/dist/db/init.js +2 -3
- package/dist/db/migration/importCollections.d.ts +14 -9
- package/dist/db/migration/importCollections.js +121 -174
- package/dist/db/migration/shared.d.ts +2 -33
- package/dist/db/migration/shared.js +17 -87
- package/dist/db/pg/client.js +4 -7
- package/dist/db/pg/collections.d.ts +2 -2
- package/dist/db/pg/collections.js +2 -2
- package/dist/db/pg/filters/index.js +1 -1
- package/dist/db/pg/filters/posts.d.ts +12 -0
- package/dist/db/pg/filters/posts.js +30 -4
- package/dist/db/pg/filters/profiles.d.ts +1 -0
- package/dist/db/pg/filters/profiles.js +2 -1
- package/dist/db/pg/helpers.js +2 -14
- package/dist/db/pg/map/filters.js +40 -10
- 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 +65 -25
- package/dist/db/pg/map/registry.d.ts +5 -0
- package/dist/db/pg/map/registry.js +133 -56
- package/dist/db/pg/map/relations.js +76 -68
- package/dist/db/pg/map/search.js +15 -37
- package/dist/db/pg/mappers.js +13 -7
- package/dist/db/pg/migrate.d.ts +1 -2
- package/dist/db/pg/migrate.js +8 -9
- package/dist/db/pg/queries/activity.js +5 -5
- package/dist/db/pg/queries/derived.js +8 -12
- package/dist/db/pg/queries/sorts.d.ts +1 -0
- package/dist/db/pg/queries/sorts.js +4 -0
- package/dist/db/pg/schema/documents.d.ts +279 -41
- package/dist/db/pg/schema/documents.js +136 -22
- package/dist/db/pg/schema/edges.d.ts +116 -7
- package/dist/db/pg/schema/edges.js +9 -2
- package/dist/db/pg/schema/index.d.ts +362 -15
- package/dist/db/pg/schema/index.js +5 -1
- package/dist/db/pg/sql/0010_user_group_membership_roles.sql +16 -0
- package/dist/db/pg/sql/0011_drop_data_migrations.sql +1 -0
- package/dist/db/pg/sql/0012_posts_last_activity_at.sql +5 -0
- package/dist/db/pg/sql/0013_add_blocks_edge.sql +12 -0
- package/dist/db/pg/sql/0014_federation_datamodel.sql +59 -0
- package/dist/db/pg/sql/0015_profile_hashtags.sql +12 -0
- package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
- package/dist/db/pg/sql/meta/{0009_snapshot.json → 0015_snapshot.json} +291 -36
- package/dist/db/pg/sql/meta/_journal.json +49 -0
- package/dist/db/replaceOrigin.js +1 -1
- package/dist/email/queueStats.js +8 -11
- package/dist/email/render.js +14 -3
- package/dist/email/send.js +19 -17
- package/dist/email/smtpTest.js +10 -6
- package/dist/errors/index.js +1 -1
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.js +1 -0
- package/dist/events/once.js +2 -4
- package/dist/federation/activities.d.ts +17 -0
- package/dist/federation/activities.js +25 -0
- package/dist/federation/identity.d.ts +16 -0
- package/dist/federation/identity.js +52 -0
- package/dist/federation/index.d.ts +4 -0
- package/dist/federation/index.js +3 -0
- package/dist/federation/profiles.d.ts +3 -0
- package/dist/federation/profiles.js +14 -0
- package/dist/groups/finders.d.ts +2 -1
- package/dist/groups/helpers.d.ts +18 -0
- package/dist/groups/helpers.js +1 -2
- package/dist/groups/mapping.d.ts +4 -2
- package/dist/groups/mutations.js +1 -1
- package/dist/hashtags/finders.d.ts +6 -3
- package/dist/hashtags/finders.js +2 -0
- package/dist/hashtags/helpers.d.ts +8 -0
- package/dist/hashtags/helpers.js +4 -0
- package/dist/hashtags/index.d.ts +2 -0
- package/dist/hashtags/index.js +2 -0
- package/dist/hashtags/mutations.d.ts +3 -0
- package/dist/hashtags/mutations.js +13 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +3 -1
- package/dist/i18n/pluginLocales.d.ts +6 -0
- package/dist/i18n/pluginLocales.js +15 -0
- package/dist/inviteLinks/mutations.js +2 -3
- package/dist/jams/export.d.ts +19 -0
- package/dist/jams/export.js +58 -0
- package/dist/jams/finders.js +4 -1
- package/dist/jams/health.d.ts +10 -0
- package/dist/jams/health.js +50 -0
- package/dist/jams/helpers.d.ts +2 -2
- package/dist/jams/helpers.js +6 -2
- package/dist/jams/index.d.ts +2 -0
- package/dist/jams/index.js +25 -18
- package/dist/jams/jobs.js +2 -3
- package/dist/jams/livekit.d.ts +49 -4
- package/dist/jams/livekit.js +62 -45
- package/dist/jams/mapping.d.ts +3 -3
- package/dist/jams/mutations.d.ts +1 -1
- package/dist/jams/recording.d.ts +10 -0
- package/dist/jams/recording.js +33 -1
- package/dist/jams/token.d.ts +13 -1
- package/dist/jams/token.js +25 -18
- package/dist/jams/waitingRoom.js +1 -1
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.js +9 -3
- package/dist/jobs/jobDetail.js +6 -12
- 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.d.ts +1 -1
- package/dist/media/index.js +73 -12
- package/dist/media/jobs.js +1 -2
- package/dist/media/openpeeps/index.js +11 -46
- package/dist/media/processing.js +25 -11
- 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 +15 -18
- 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/index.js +4 -0
- 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 +11 -6
- package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
- package/dist/notifications/defaultNotifications/pollEnded/index.d.ts +19 -0
- package/dist/notifications/defaultNotifications/pollEnded/index.js +39 -0
- package/dist/notifications/defaultNotifications/pollEnded/recipients.d.ts +3 -0
- package/dist/notifications/defaultNotifications/pollEnded/recipients.js +17 -0
- 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.d.ts +6 -1
- package/dist/notifications/defaultNotifications/rsvp/index.js +31 -18
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.d.ts +24 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +82 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.d.ts +4 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.js +11 -0
- 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 -5
- package/dist/notifications/mutations.js +8 -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 +39 -4
- package/dist/plugins/install.d.ts +28 -9
- package/dist/plugins/install.js +302 -56
- package/dist/plugins/pluginAuth.d.ts +1 -1
- package/dist/plugins/pluginAuth.js +13 -10
- package/dist/plugins/state.js +2 -3
- package/dist/posts/activity.d.ts +9 -0
- package/dist/posts/activity.js +34 -0
- package/dist/posts/contextClosure.d.ts +1 -9
- package/dist/posts/contextClosure.js +14 -44
- package/dist/posts/conversationQueries.d.ts +7 -0
- package/dist/posts/conversationQueries.js +76 -4
- package/dist/posts/eventAgenda.d.ts +1 -0
- package/dist/posts/eventAgenda.js +17 -8
- package/dist/posts/eventOccurrenceJobs.js +7 -2
- package/dist/posts/eventOccurrences.d.ts +6 -0
- package/dist/posts/eventOccurrences.js +22 -1
- package/dist/posts/finders.d.ts +56 -9
- package/dist/posts/finders.js +84 -23
- package/dist/posts/helpers/filters.js +13 -9
- package/dist/posts/helpers/index.d.ts +179 -14
- package/dist/posts/helpers/index.js +70 -34
- package/dist/posts/index.d.ts +5 -2
- package/dist/posts/index.js +5 -2
- package/dist/posts/mapping.d.ts +765 -30
- package/dist/posts/mapping.js +74 -31
- package/dist/posts/mutations.d.ts +516 -3
- package/dist/posts/mutations.js +179 -41
- package/dist/posts/pollEnd.d.ts +3 -0
- package/dist/posts/pollEnd.js +4 -0
- package/dist/posts/pollEndJobs.d.ts +8 -0
- package/dist/posts/pollEndJobs.js +49 -0
- package/dist/posts/replyClosure.d.ts +10 -0
- package/dist/posts/replyClosure.js +43 -0
- package/dist/posts/rsvpConfirmationEmail.js +23 -15
- package/dist/posts/threadPreview.d.ts +8 -0
- package/dist/posts/threadPreview.js +44 -0
- package/dist/posts/unseenCounts.js +4 -1
- package/dist/processingStats/queries.js +6 -7
- package/dist/profileSettings/cache.js +21 -5
- package/dist/profileSettings/mapping.d.ts +2 -0
- package/dist/profiles/activityQueries.d.ts +5 -0
- package/dist/profiles/activityQueries.js +85 -0
- package/dist/profiles/activitySummary.d.ts +3 -0
- package/dist/profiles/activitySummary.js +82 -0
- package/dist/profiles/blocks.d.ts +12 -0
- package/dist/profiles/blocks.js +73 -0
- package/dist/profiles/cache.d.ts +1 -0
- package/dist/profiles/cache.js +30 -10
- package/dist/profiles/export.js +30 -39
- package/dist/profiles/finders.d.ts +2 -1
- package/dist/profiles/finders.js +15 -8
- package/dist/profiles/helpers.d.ts +2 -0
- package/dist/profiles/index.d.ts +2 -0
- package/dist/profiles/index.js +2 -0
- package/dist/profiles/mapping.d.ts +10 -5
- package/dist/profiles/mapping.js +13 -1
- package/dist/profiles/mutations.d.ts +8 -4
- package/dist/profiles/mutations.js +31 -4
- package/dist/redis/connection.d.ts +2 -0
- package/dist/redis/connection.js +25 -6
- package/dist/reports/helpers.js +7 -3
- package/dist/roles/index.d.ts +1 -1
- package/dist/roles/index.js +1 -1
- package/dist/roles/mapping.d.ts +1 -0
- package/dist/roles/mutations.js +85 -3
- package/dist/search/finders.js +15 -3
- package/dist/search/helpers.js +1 -1
- package/dist/search/mapping.d.ts +1 -1
- package/dist/search/mapping.js +6 -2
- 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 +19 -0
- package/dist/server/index.js +31 -14
- package/dist/server/stablePublicServerInfo.d.ts +17 -0
- package/dist/server/stablePublicServerInfo.js +37 -0
- package/dist/server/status.d.ts +25 -0
- package/dist/server/status.js +97 -0
- package/dist/session/index.js +2 -2
- package/dist/stats/finders.d.ts +1 -17681
- package/dist/stats/finders.js +22 -9
- package/dist/stats/helpers.js +4 -1
- package/dist/stats/mapping.d.ts +39 -2
- package/dist/stats/mapping.js +8 -4
- 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 -7
- package/dist/db/migration/detect.d.ts +0 -3
- package/dist/db/migration/detect.js +0 -33
- package/dist/db/migration/importPostgres.d.ts +0 -3
- package/dist/db/migration/importPostgres.js +0 -18
- package/dist/db/migration/transform.d.ts +0 -20
- package/dist/db/migration/transform.js +0 -232
- package/dist/db/migration/validate.d.ts +0 -18
- package/dist/db/migration/validate.js +0 -69
- package/dist/db/pg/sql/meta/0000_snapshot.json +0 -3380
- package/dist/db/pg/sql/meta/0004_snapshot.json +0 -4114
- package/dist/db/pg/sql/meta/0005_snapshot.json +0 -4179
- package/dist/db/pg/sql/meta/0006_snapshot.json +0 -4200
- package/dist/db/pg/sql/meta/0007_snapshot.json +0 -4179
- package/dist/mastodon/index.d.ts +0 -4
- package/dist/mastodon/index.js +0 -51
- package/dist/mastodon/types.d.ts +0 -7579
- package/dist/mastodon/types.js +0 -523
- package/dist/mastodon/typescript.d.ts +0 -1578
- package/dist/mastodon/typescript.js +0 -1
- package/dist/migration/index.d.ts +0 -4
- package/dist/migration/index.js +0 -4
- package/dist/roles/defaults.d.ts +0 -2
- package/dist/roles/defaults.js +0 -95
package/dist/posts/finders.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { parseFeedFormat } from '@openpeepshq/common';
|
|
2
|
+
import { blockedPairIds, isBlockedPair } from '@openpeepshq/common/lib';
|
|
1
3
|
import { allpeepDb, collectionInfos } from '../db/index.js';
|
|
2
4
|
import { edgeFilters, postFilters } from '../db/pg/filters/index.js';
|
|
3
5
|
import { contextRelation, conversationLeavesMappingForProfile, postContextMappingForProfile, postsAuthMapping, postsMappingForProfile, repostsOfPostRelationForProfile, postIdsMapping, } from './mapping.js';
|
|
4
6
|
import { audienceConnectionFinder, localFeedFilter, mentionsConnectionFinder, myFeedFilter, myFeedGroupMembershipFilter, toFilteredPostsList, transformPost, } from './helpers/index.js';
|
|
5
|
-
import { addQuerySort, addStart, sortOldestFirst } from '../db/helpers.js';
|
|
7
|
+
import { addActivityStart, addQuerySort, addStart, sortOldestFirst, } from '../db/helpers.js';
|
|
6
8
|
import { sorts } from '../db/pg/queries/index.js';
|
|
7
9
|
import { findHashtagByTag, hashtagsMapping } from '../hashtags/index.js';
|
|
8
10
|
import { findGroup } from '../groups/finders.js';
|
|
@@ -27,17 +29,24 @@ const requireProfile = (authData) => {
|
|
|
27
29
|
}
|
|
28
30
|
return authData.profile;
|
|
29
31
|
};
|
|
32
|
+
const hideBlockedAuthorPost = (post, profile) => {
|
|
33
|
+
if (!post)
|
|
34
|
+
return undefined;
|
|
35
|
+
const creatorId = post.creatorId ?? post.profile?.id;
|
|
36
|
+
return isBlockedPair(profile, creatorId) ? undefined : post;
|
|
37
|
+
};
|
|
30
38
|
export const findPost = async (id, authData) => {
|
|
31
|
-
const profile = authData
|
|
39
|
+
const profile = authData?.profile;
|
|
32
40
|
return allpeepDb()
|
|
33
41
|
.then(({ db }) => postsMappingForProfile(profile).find(db, id))
|
|
34
|
-
.then((post) => (post ? transformPost(post, profile) : undefined))
|
|
42
|
+
.then((post) => (post ? transformPost(post, profile) : undefined))
|
|
43
|
+
.then((post) => hideBlockedAuthorPost(post, profile));
|
|
35
44
|
};
|
|
36
45
|
/** Lean post load for capability checks (no nested reply/repost). */
|
|
37
46
|
export const findPostsForAuth = async (ids, authData) => {
|
|
38
47
|
if (ids.length === 0)
|
|
39
48
|
return [];
|
|
40
|
-
const profile = authData
|
|
49
|
+
const profile = authData?.profile;
|
|
41
50
|
const { db } = await allpeepDb();
|
|
42
51
|
const mapData = postsAuthMapping.data();
|
|
43
52
|
const rows = await fetchRowsByIds(db, mapData.collection, ids, mapData.softDelete);
|
|
@@ -47,23 +56,37 @@ export const findPostsForAuth = async (ids, authData) => {
|
|
|
47
56
|
return [transformed.id, transformed];
|
|
48
57
|
})));
|
|
49
58
|
return ids
|
|
50
|
-
.map((id) => byId.get(id))
|
|
59
|
+
.map((id) => hideBlockedAuthorPost(byId.get(id), profile))
|
|
51
60
|
.filter((post) => !!post);
|
|
52
61
|
};
|
|
53
62
|
export const postContext = async (authData, id, depth, direction, contextMapping) => {
|
|
54
63
|
const profile = authData.profile;
|
|
55
64
|
const mapping = postsMappingForProfile(profile);
|
|
56
|
-
return toFilteredPostsList(mapping.relationsFrom({ id }, contextRelation(depth, direction, contextMapping
|
|
65
|
+
return toFilteredPostsList(mapping.relationsFrom({ id }, contextRelation(depth, direction, contextMapping ?? mapping)), { authData });
|
|
57
66
|
};
|
|
58
67
|
export const descendents = async (authData, post, depth, contextMapping) => postContext(authData, post.id, depth, 'descendents', contextMapping);
|
|
59
68
|
export const ancestors = async (authData, post, depth, contextMapping) => postContext(authData, post.id, depth, 'ancestors', contextMapping);
|
|
60
69
|
export const replies = async (authData, post) => descendents(authData, post, 1);
|
|
61
|
-
export const baseListPosts = ({ start, profile, }) => addStart(postsMappingForProfile(profile), start);
|
|
70
|
+
export const baseListPosts = ({ start, profile, }) => addStart(postsMappingForProfile(profile), start).filter(postFilters.notCreatorIn(blockedPairIds(profile)));
|
|
62
71
|
export const baseFeed = ({ start, sort, profile, }) => addQuerySort(baseListPosts({ start, profile }).filter(postFilters.notDirect()), sort);
|
|
72
|
+
/**
|
|
73
|
+
* Community / my / group timelines: original posts (and reposts) only,
|
|
74
|
+
* ordered by last conversation activity. Replies stay nested on the post
|
|
75
|
+
* detail thread so the same conversation is not repeated as standalone
|
|
76
|
+
* feed items.
|
|
77
|
+
*/
|
|
78
|
+
const timelineFeed = ({ start, sort, profile, }) => addQuerySort(addActivityStart(postsMappingForProfile(profile)
|
|
79
|
+
.filter(postFilters.notDirect())
|
|
80
|
+
.filter(postFilters.notReply())
|
|
81
|
+
.filter(postFilters.notCreatorIn(blockedPairIds(profile))), start), sort);
|
|
82
|
+
const conversationFeed = ({ start, sort, profile, format, }) => parseFeedFormat(format) === 'linear'
|
|
83
|
+
? baseFeed({ start, sort, profile })
|
|
84
|
+
: timelineFeed({ start, sort, profile });
|
|
63
85
|
export const baseEventsFeed = (profile) => {
|
|
64
86
|
const mapping = postsMappingForProfile(profile)
|
|
65
87
|
.sort(sorts.eventStartAsc)
|
|
66
|
-
.filter({ matches: { type: 'event' } })
|
|
88
|
+
.filter({ matches: { type: 'event' } })
|
|
89
|
+
.filter(postFilters.notCreatorIn(blockedPairIds(profile)));
|
|
67
90
|
return mapping;
|
|
68
91
|
};
|
|
69
92
|
export const listPosts = async (authData, { start, limit = 100, filter, } = {
|
|
@@ -79,7 +102,7 @@ export const listConversationLeaves = async (authData) => withSpan('conversation
|
|
|
79
102
|
.sort(sorts.createdAtDesc)
|
|
80
103
|
.data(),
|
|
81
104
|
}), { authData, limit: 9999 }));
|
|
82
|
-
export const listPostsByProfile = async (authData, requestedProfile, { start, limit = 100, filter, } = {
|
|
105
|
+
export const listPostsByProfile = async (authData, requestedProfile, { start, limit = 100, filter, format, } = {
|
|
83
106
|
limit: 100,
|
|
84
107
|
}) => toFilteredPostsList(profilesMapping.relationsFrom(requestedProfile, {
|
|
85
108
|
alias: 'posts',
|
|
@@ -88,11 +111,15 @@ export const listPostsByProfile = async (authData, requestedProfile, { start, li
|
|
|
88
111
|
edgeFilter: edgeFilters.entryType('create'),
|
|
89
112
|
skipEdge: true,
|
|
90
113
|
cardinality: 'many',
|
|
91
|
-
mapping:
|
|
114
|
+
mapping: conversationFeed({
|
|
115
|
+
start,
|
|
116
|
+
profile: authData.profile,
|
|
117
|
+
format,
|
|
118
|
+
})
|
|
92
119
|
.filter(filter)
|
|
93
120
|
.data(),
|
|
94
121
|
}), { authData, limit });
|
|
95
|
-
export const listBookmarkedPosts = async (authData, requestedProfile, { start, limit = 100, filter, } = {
|
|
122
|
+
export const listBookmarkedPosts = async (authData, requestedProfile, { start, limit = 100, filter, format, } = {
|
|
96
123
|
limit: 100,
|
|
97
124
|
}) => toFilteredPostsList(profilesMapping.relationsFrom(requestedProfile, {
|
|
98
125
|
alias: 'posts',
|
|
@@ -100,7 +127,11 @@ export const listBookmarkedPosts = async (authData, requestedProfile, { start, l
|
|
|
100
127
|
direction: 'OUTBOUND',
|
|
101
128
|
skipEdge: true,
|
|
102
129
|
cardinality: 'many',
|
|
103
|
-
mapping:
|
|
130
|
+
mapping: conversationFeed({
|
|
131
|
+
start,
|
|
132
|
+
profile: authData.profile,
|
|
133
|
+
format,
|
|
134
|
+
})
|
|
104
135
|
.filter(filter)
|
|
105
136
|
.data(),
|
|
106
137
|
}), { authData, limit });
|
|
@@ -126,12 +157,25 @@ export const getUnseenPostCounts = async (authData) => withSpan('unseen.counts',
|
|
|
126
157
|
const { db } = await allpeepDb();
|
|
127
158
|
return queryUnseenPostCounts(db, profile.id, groupIds);
|
|
128
159
|
});
|
|
129
|
-
export const listPostsByType = async (authData, type, { start, limit = 100, filter, } = {
|
|
160
|
+
export const listPostsByType = async (authData, type, { start, limit = 100, filter, format, groupId, ungrouped, } = {
|
|
130
161
|
limit: 100,
|
|
131
|
-
}) =>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
+
};
|
|
178
|
+
export const listPostsByTag = async (authData, tag, { start, limit = 100, filter, format, } = {
|
|
135
179
|
limit: 100,
|
|
136
180
|
}) => {
|
|
137
181
|
const hashtag = await findHashtagByTag(tag);
|
|
@@ -144,12 +188,16 @@ export const listPostsByTag = async (authData, tag, { start, limit = 100, filter
|
|
|
144
188
|
direction: 'INBOUND',
|
|
145
189
|
cardinality: 'many',
|
|
146
190
|
skipEdge: true,
|
|
147
|
-
mapping:
|
|
191
|
+
mapping: conversationFeed({
|
|
192
|
+
start,
|
|
193
|
+
profile: authData.profile,
|
|
194
|
+
format,
|
|
195
|
+
})
|
|
148
196
|
.filter(filter)
|
|
149
197
|
.data(),
|
|
150
198
|
}), { authData, limit });
|
|
151
199
|
};
|
|
152
|
-
export const listPostsByGroup = async (authData, groupId, { start, limit = 100, filter, sort
|
|
200
|
+
export const listPostsByGroup = async (authData, groupId, { start, limit = 100, filter, sort, format, } = { limit: 100 }) => withSpan('feed.group', async () => {
|
|
153
201
|
const group = await findGroup(groupId);
|
|
154
202
|
if (!group) {
|
|
155
203
|
return [];
|
|
@@ -160,15 +208,28 @@ export const listPostsByGroup = async (authData, groupId, { start, limit = 100,
|
|
|
160
208
|
direction: 'INBOUND',
|
|
161
209
|
skipEdge: true,
|
|
162
210
|
cardinality: 'many',
|
|
163
|
-
mapping:
|
|
211
|
+
mapping: conversationFeed({
|
|
212
|
+
start,
|
|
213
|
+
profile: authData.profile,
|
|
214
|
+
format,
|
|
215
|
+
sort,
|
|
216
|
+
})
|
|
164
217
|
.filter(filter)
|
|
165
218
|
.data(),
|
|
166
219
|
}), { authData, limit });
|
|
167
220
|
});
|
|
168
|
-
export const listLocalFeed = async (authData, { start, limit = 100
|
|
169
|
-
|
|
221
|
+
export const listLocalFeed = async (authData, { start, limit = 100, format, } = {
|
|
222
|
+
limit: 100,
|
|
223
|
+
}) => withSpan('feed.local', () => toFilteredPostsList(conversationFeed({
|
|
224
|
+
start,
|
|
225
|
+
profile: authData.profile,
|
|
226
|
+
format,
|
|
227
|
+
}).filter(localFeedFilter()), { authData, limit }));
|
|
228
|
+
export const listMyFeed = async (authData, { start, limit = 100, format, } = {
|
|
229
|
+
limit: 100,
|
|
230
|
+
}) => {
|
|
170
231
|
const profile = requireProfile(authData);
|
|
171
|
-
return withSpan('feed.my', () => toFilteredPostsList(
|
|
232
|
+
return withSpan('feed.my', () => toFilteredPostsList(conversationFeed({ start, profile, format }).filter(myFeedFilter(profile)), { authData, limit, filters: [myFeedGroupMembershipFilter(profile)] }));
|
|
172
233
|
};
|
|
173
234
|
export const listUpcomingEventsFeed = async (authData, { offset, limit = 100, jamOnly, mine, } = {
|
|
174
235
|
limit: 100,
|
|
@@ -15,17 +15,21 @@ export const followFilter = (profile) => ({
|
|
|
15
15
|
creatorId: f.id,
|
|
16
16
|
})),
|
|
17
17
|
});
|
|
18
|
-
export const myFeedFilter = (profile) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
export const myFeedFilter = (profile) => {
|
|
19
|
+
const hashtagFilterResult = postFilters.hasAnyHashtag(profile.followedHashtags?.map((h) => h.id) ?? []);
|
|
20
|
+
return {
|
|
21
|
+
operator: '||',
|
|
22
|
+
predicates: [
|
|
23
|
+
ownPostsFilter(profile),
|
|
24
|
+
groupPostVisibilityQueryFilter,
|
|
25
|
+
followFilter(profile),
|
|
26
|
+
...(hashtagFilterResult ? [hashtagFilterResult] : []),
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
};
|
|
26
30
|
export const myFeedGroupMembershipFilter = (profile) => (post) => post.visibility !== 'group' ||
|
|
27
31
|
(!!post.group &&
|
|
28
|
-
profile.memberships.some((m) =>
|
|
32
|
+
profile.memberships.some((m) => m.group.id === post.group?.id));
|
|
29
33
|
export const localFeedFilter = (_profile) => ({
|
|
30
34
|
matches: [{ visibility: 'local' }, { visibility: 'public' }],
|
|
31
35
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthorizationData, PostWithMeta, PostDataUnion, Profile, Post, Hashtag, MentionWithPublicProfile, DbPost } from '@openpeepshq/common/types';
|
|
1
|
+
import { AuthorizationData, PostWithMeta, PostDataUnion, Profile, Post, Hashtag, ProfileWithMeta, MentionWithPublicProfile, DbPost } from '@openpeepshq/common/types';
|
|
2
2
|
import type { PgQueryResult } from '../../db/pg/map/types';
|
|
3
3
|
import { ObjectFilter } from '../../db/types';
|
|
4
4
|
export declare const isDirect: (post: PostWithMeta) => boolean;
|
|
@@ -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";
|
|
@@ -415,6 +491,18 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
415
491
|
response: "removed" | "no" | "yes" | "tentative";
|
|
416
492
|
recurrenceId?: string | undefined;
|
|
417
493
|
};
|
|
494
|
+
} | {
|
|
495
|
+
type: "reaction";
|
|
496
|
+
data: {
|
|
497
|
+
reaction: string;
|
|
498
|
+
};
|
|
499
|
+
uri?: string | undefined;
|
|
500
|
+
} | {
|
|
501
|
+
type: "unreaction";
|
|
502
|
+
data: {
|
|
503
|
+
reaction: string;
|
|
504
|
+
};
|
|
505
|
+
uri?: string | undefined;
|
|
418
506
|
}) & {
|
|
419
507
|
id?: string;
|
|
420
508
|
}) => Promise<import("../../db/pg/map").WithId<({
|
|
@@ -611,6 +699,44 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
611
699
|
language?: string | undefined;
|
|
612
700
|
image?: string | undefined;
|
|
613
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;
|
|
614
740
|
};
|
|
615
741
|
} | {
|
|
616
742
|
type: "edit";
|
|
@@ -806,6 +932,44 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
806
932
|
language?: string | undefined;
|
|
807
933
|
image?: string | undefined;
|
|
808
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;
|
|
809
973
|
};
|
|
810
974
|
} | {
|
|
811
975
|
type: "delete";
|
|
@@ -821,6 +985,18 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
821
985
|
response: "removed" | "no" | "yes" | "tentative";
|
|
822
986
|
recurrenceId?: string | undefined;
|
|
823
987
|
};
|
|
988
|
+
} | {
|
|
989
|
+
type: "reaction";
|
|
990
|
+
data: {
|
|
991
|
+
reaction: string;
|
|
992
|
+
};
|
|
993
|
+
uri?: string | undefined;
|
|
994
|
+
} | {
|
|
995
|
+
type: "unreaction";
|
|
996
|
+
data: {
|
|
997
|
+
reaction: string;
|
|
998
|
+
};
|
|
999
|
+
uri?: string | undefined;
|
|
824
1000
|
}) & {
|
|
825
1001
|
_from: string;
|
|
826
1002
|
_to: string;
|
|
@@ -888,17 +1064,6 @@ export declare const repostConnector: (db: import("../../db").PgDb, from: Post,
|
|
|
888
1064
|
_from: string;
|
|
889
1065
|
_to: string;
|
|
890
1066
|
}>>;
|
|
891
|
-
export declare const reactionConnector: (db: import("../../db").PgDb, from: Profile, to: Post, data?: {
|
|
892
|
-
reaction: "👍";
|
|
893
|
-
} & {
|
|
894
|
-
id?: string;
|
|
895
|
-
}) => Promise<import("../../db/pg/map").WithId<{
|
|
896
|
-
reaction: "👍";
|
|
897
|
-
} & {
|
|
898
|
-
_from: string;
|
|
899
|
-
_to: string;
|
|
900
|
-
}>>;
|
|
901
|
-
export declare const reactionDisconnector: (db: import("../../db").PgDb, from: Profile, to: Post) => Promise<void>;
|
|
902
1067
|
export declare const bookmarkConnector: (db: import("../../db").PgDb, from: Profile, to: Post, data?: object & {
|
|
903
1068
|
id?: string;
|
|
904
1069
|
}) => Promise<import("../../db/pg/map").WithId<object & {
|
|
@@ -912,8 +1077,8 @@ export declare const postSeenConnector: (db: import("../../db").PgDb, from: Prof
|
|
|
912
1077
|
_from: string;
|
|
913
1078
|
_to: string;
|
|
914
1079
|
}>>;
|
|
915
|
-
export declare const transformPost: (post: DbPost, currentProfile?: {
|
|
916
|
-
|
|
1080
|
+
export declare const transformPost: (post: DbPost, currentProfile?: ProfileWithMeta, options?: {
|
|
1081
|
+
embedThreadPreview?: boolean;
|
|
917
1082
|
}) => Promise<PostWithMeta>;
|
|
918
1083
|
export declare const toFilteredPostsList: (queryResult: PgQueryResult<DbPost>, options: {
|
|
919
1084
|
authData: AuthorizationData;
|
|
@@ -5,8 +5,9 @@ import { composeFilters, connectionFinder, connector, disconnector, filterAndTra
|
|
|
5
5
|
import { allpeepDb, collectionInfos } from '../../db/index.js';
|
|
6
6
|
import { capabilitiesConfig } from '../../config/index.js';
|
|
7
7
|
import { canReadPost } from './filters.js';
|
|
8
|
-
import { matchMentionHandles, normalizePostDataFromDb, tombstoneProfileWithMetaIfDeleted, } from '@openpeepshq/common/lib';
|
|
8
|
+
import { AP_LIKE_REACTION, currentReactionsFromEntries, isBlockedPair, isReactionHistoryEntry, matchMentionHandles, normalizePostDataFromDb, toHiddenPost, tombstoneProfileWithMetaIfDeleted, } from '@openpeepshq/common/lib';
|
|
9
9
|
import { EMBEDDED_REPOSTS_LIMIT } from '../mapping.js';
|
|
10
|
+
import { loadThreadPreviewReplies } from '../threadPreview.js';
|
|
10
11
|
export const isDirect = (post) => post.visibility === 'direct';
|
|
11
12
|
export const isPrivate = (post) => post.visibility === 'private';
|
|
12
13
|
export const isUnlisted = (post) => post.visibility === 'unlisted';
|
|
@@ -20,10 +21,11 @@ const getTags = (text) => {
|
|
|
20
21
|
return (text.match(hashtagRegex) || []).map((tag) => normalizeHashtagTag(tag.substring(1)));
|
|
21
22
|
};
|
|
22
23
|
export const extractHashtags = (data) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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])];
|
|
27
29
|
};
|
|
28
30
|
export const extractMentionHandles = (text) => matchMentionHandles(text);
|
|
29
31
|
export const resolveMentionsForPost = async (data) => {
|
|
@@ -47,27 +49,28 @@ export const hashtagDisconnector = disconnector(collectionInfos.postsCollection,
|
|
|
47
49
|
export const mentionConnector = connector(collectionInfos.postsCollection, collectionInfos.profilesCollection, collectionInfos.mentionsCollection);
|
|
48
50
|
export const mentionsConnectionFinder = connectionFinder(collectionInfos.postsCollection, collectionInfos.profilesCollection, collectionInfos.mentionsCollection);
|
|
49
51
|
export const repostConnector = connector(collectionInfos.postsCollection, collectionInfos.postsCollection, collectionInfos.repostCollection);
|
|
50
|
-
export const reactionConnector = connector(collectionInfos.profilesCollection, collectionInfos.postsCollection, collectionInfos.reactionsCollection);
|
|
51
|
-
export const reactionDisconnector = disconnector(collectionInfos.profilesCollection, collectionInfos.postsCollection, collectionInfos.reactionsCollection);
|
|
52
52
|
export const bookmarkConnector = connector(collectionInfos.profilesCollection, collectionInfos.postsCollection, collectionInfos.bookmarksCollection);
|
|
53
53
|
export const bookmarkDisconnector = disconnector(collectionInfos.profilesCollection, collectionInfos.postsCollection, collectionInfos.bookmarksCollection);
|
|
54
54
|
export const postSeenConnector = connector(collectionInfos.profilesCollection, collectionInfos.postsCollection, collectionInfos.postSeenCollection);
|
|
55
55
|
const loadPublicProfile = async (profileId, ignoreSoftDelete = false) => tombstoneProfileWithMetaIfDeleted(await getPublicProfile(profileId, ignoreSoftDelete));
|
|
56
|
-
const addProfileForEntry = async (rawEntry) => (
|
|
56
|
+
const addProfileForEntry = async (rawEntry) => ({
|
|
57
|
+
...rawEntry,
|
|
57
58
|
// ignoreSoftDelete: authorship must survive account removal
|
|
58
|
-
profile: (await loadPublicProfile(rawEntry.profile.id, true))
|
|
59
|
-
|
|
60
|
-
const addProfileForMention = async (rawMention) => (
|
|
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
|
+
});
|
|
61
65
|
const leanRepostsFromWrappers = async (wrappers) => {
|
|
62
|
-
if (!
|
|
66
|
+
if (!wrappers?.length)
|
|
63
67
|
return [];
|
|
64
68
|
const withProfiles = await Promise.all(wrappers.map(async (wrapper) => {
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
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;
|
|
68
71
|
if (!profileId)
|
|
69
72
|
return null;
|
|
70
|
-
const profile =
|
|
73
|
+
const profile = createEntry?.profile
|
|
71
74
|
? await loadPublicProfile(createEntry.profile.id, true)
|
|
72
75
|
: await loadPublicProfile(profileId, true);
|
|
73
76
|
if (!profile)
|
|
@@ -82,14 +85,19 @@ const leanRepostsFromWrappers = async (wrappers) => {
|
|
|
82
85
|
.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))
|
|
83
86
|
.slice(0, EMBEDDED_REPOSTS_LIMIT);
|
|
84
87
|
};
|
|
85
|
-
export const transformPost = async (post, currentProfile) => {
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
+
export const transformPost = async (post, currentProfile, options = {}) => {
|
|
89
|
+
const embedThreadPreview = options.embedThreadPreview ?? true;
|
|
90
|
+
const nested = { embedThreadPreview: false };
|
|
91
|
+
const allEntries = post.entries
|
|
88
92
|
? await Promise.all(post.entries.map(addProfileForEntry))
|
|
89
93
|
: [];
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
const entries = allEntries.filter((entry) => !isReactionHistoryEntry(entry.type));
|
|
95
|
+
const reactions = currentReactionsFromEntries(allEntries)
|
|
96
|
+
.filter((item) => item.reaction === AP_LIKE_REACTION)
|
|
97
|
+
.map((item) => ({
|
|
98
|
+
reaction: AP_LIKE_REACTION,
|
|
99
|
+
profile: item.profile,
|
|
100
|
+
}));
|
|
93
101
|
const reposts = await leanRepostsFromWrappers(post.reposts);
|
|
94
102
|
const audience = post.audience
|
|
95
103
|
? (await Promise.all(post.audience.map((p) => loadPublicProfile(p.id)))).filter((profile) => !!profile)
|
|
@@ -97,25 +105,53 @@ export const transformPost = async (post, currentProfile) => {
|
|
|
97
105
|
const mentions = post.mentions
|
|
98
106
|
? await Promise.all(post.mentions.map(addProfileForMention))
|
|
99
107
|
: [];
|
|
100
|
-
const createProfile =
|
|
101
|
-
const profile = createProfile
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
:
|
|
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);
|
|
113
|
+
const preview = embedThreadPreview
|
|
114
|
+
? await loadThreadPreviewReplies(post.id, currentProfile)
|
|
115
|
+
: {
|
|
116
|
+
replies: (post.latestReplies ?? []),
|
|
117
|
+
hasMore: !!post.latestRepliesHasMore,
|
|
118
|
+
};
|
|
119
|
+
const latestReplies = (await Promise.all(preview.replies.map((reply) => transformPost(reply, currentProfile, nested)))).filter((reply) => !!reply.profile);
|
|
120
|
+
return {
|
|
121
|
+
...post,
|
|
122
|
+
data: post.data ? normalizePostDataFromDb(post.data) : post.data,
|
|
123
|
+
seen: currentProfile ? post.seen : undefined,
|
|
124
|
+
replyTo: post.replyTo
|
|
125
|
+
? withBlockTombstone(await transformPost(post.replyTo, currentProfile, nested), currentProfile)
|
|
126
|
+
: undefined,
|
|
127
|
+
latestReplies: latestReplies.map((reply) => withBlockTombstone(reply, currentProfile)),
|
|
128
|
+
latestRepliesHasMore: preview.hasMore,
|
|
129
|
+
repost: post.repost
|
|
130
|
+
? await transformPost(post.repost, currentProfile, {
|
|
131
|
+
embedThreadPreview,
|
|
132
|
+
})
|
|
133
|
+
: undefined,
|
|
134
|
+
rsvps: entries
|
|
109
135
|
.filter((entry) => entry.type === 'rsvp')
|
|
110
136
|
.map((entry) => ({
|
|
111
137
|
profile: entry.profile,
|
|
112
138
|
response: entry.data.response,
|
|
113
139
|
recurrenceId: entry.data.recurrenceId,
|
|
114
140
|
createdAt: entry.createdAt,
|
|
115
|
-
})),
|
|
116
|
-
|
|
141
|
+
})),
|
|
142
|
+
audience,
|
|
143
|
+
mentions,
|
|
144
|
+
profile: profile,
|
|
145
|
+
entries,
|
|
117
146
|
reactions,
|
|
118
|
-
reposts
|
|
147
|
+
reposts,
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
const withBlockTombstone = (post, currentProfile) => {
|
|
151
|
+
const creatorId = post.creatorId ?? post.profile?.id;
|
|
152
|
+
return creatorId && isBlockedPair(currentProfile, creatorId)
|
|
153
|
+
? toHiddenPost(post)
|
|
154
|
+
: post;
|
|
119
155
|
};
|
|
120
156
|
export const toFilteredPostsList = async (queryResult, options) => {
|
|
121
157
|
const { authData, limit = 100, offset = 0, filters = [] } = options;
|
package/dist/posts/index.d.ts
CHANGED
|
@@ -2,9 +2,12 @@ export * from './finders';
|
|
|
2
2
|
export * from './mutations';
|
|
3
3
|
export * from './mapping';
|
|
4
4
|
export { CONTEXT_NODE_CAP, collectReplyClosureIds, loadReplyContextPosts, } from './contextClosure';
|
|
5
|
-
export {
|
|
5
|
+
export { loadThreadPreviewReplies, THREAD_PREVIEW_LIMIT, } from './threadPreview';
|
|
6
|
+
export { listConversationPreviews, getConversationThread, findLatestThreadPostId, listLeftConversations, } from './conversationQueries';
|
|
6
7
|
export * from './helpers';
|
|
8
|
+
export { bumpConversationActivity, findReplyRootId } from './activity';
|
|
7
9
|
export { registerRsvpConfirmationEmail } from './rsvpConfirmationEmail';
|
|
8
|
-
export { rebuildEventOccurrences, clearEventOccurrences, rebuildRecurringEventOccurrences, } from './eventOccurrences';
|
|
10
|
+
export { rebuildEventOccurrences, clearEventOccurrences, backfillMissingEventOccurrences, rebuildRecurringEventOccurrences, } from './eventOccurrences';
|
|
9
11
|
export { listEventAgenda } from './eventAgenda';
|
|
10
12
|
export { eventOccurrenceQueue, eventOccurrenceWorker, ensureEventOccurrenceSchedule, } from './eventOccurrenceJobs';
|
|
13
|
+
export { pollEndQueue, pollEndWorker, schedulePollEnd, cancelPollEnd, } from './pollEndJobs';
|