@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.
Files changed (297) hide show
  1. package/dist/accessTokens/finders.js +5 -6
  2. package/dist/accessTokens/mutations.js +1 -1
  3. package/dist/accessTokens/tokens.js +8 -11
  4. package/dist/accounts/helpers.js +6 -2
  5. package/dist/accounts/mutations.js +36 -33
  6. package/dist/analytics/cache.js +3 -3
  7. package/dist/analytics/clicks.js +14 -22
  8. package/dist/analytics/compile.js +17 -12
  9. package/dist/analytics/dateRange.js +3 -5
  10. package/dist/analytics/jobs.js +3 -4
  11. package/dist/analytics/pdfReport.js +45 -61
  12. package/dist/analytics/privacy.js +1 -1
  13. package/dist/analytics/read.js +164 -140
  14. package/dist/analytics/report.d.ts +22 -1
  15. package/dist/analytics/report.js +2 -3
  16. package/dist/analytics/settings.js +3 -4
  17. package/dist/backups/index.js +82 -25
  18. package/dist/backups/metadata.d.ts +2 -3
  19. package/dist/backups/metadata.js +6 -2
  20. package/dist/config/db.js +2 -4
  21. package/dist/config/defaults/capabilities.js +13 -2
  22. package/dist/config/defaults/community.js +8 -3
  23. package/dist/config/defaults/core.d.ts +1 -1
  24. package/dist/config/defaults/core.js +16 -8
  25. package/dist/config/index.d.ts +22 -0
  26. package/dist/config/index.js +15 -11
  27. package/dist/db/explorer/query.js +9 -8
  28. package/dist/db/explorer/sql.js +8 -8
  29. package/dist/db/helpers.d.ts +1 -0
  30. package/dist/db/helpers.js +25 -7
  31. package/dist/db/index.d.ts +1 -1
  32. package/dist/db/index.js +1 -0
  33. package/dist/db/init.js +2 -3
  34. package/dist/db/migration/importCollections.d.ts +14 -9
  35. package/dist/db/migration/importCollections.js +121 -174
  36. package/dist/db/migration/shared.d.ts +2 -33
  37. package/dist/db/migration/shared.js +17 -87
  38. package/dist/db/pg/client.js +4 -7
  39. package/dist/db/pg/collections.d.ts +2 -2
  40. package/dist/db/pg/collections.js +2 -2
  41. package/dist/db/pg/filters/index.js +1 -1
  42. package/dist/db/pg/filters/posts.d.ts +12 -0
  43. package/dist/db/pg/filters/posts.js +30 -4
  44. package/dist/db/pg/filters/profiles.d.ts +1 -0
  45. package/dist/db/pg/filters/profiles.js +2 -1
  46. package/dist/db/pg/helpers.js +2 -14
  47. package/dist/db/pg/map/filters.js +40 -10
  48. package/dist/db/pg/map/helpers.js +5 -1
  49. package/dist/db/pg/map/index.js +46 -51
  50. package/dist/db/pg/map/mutations.js +65 -25
  51. package/dist/db/pg/map/registry.d.ts +5 -0
  52. package/dist/db/pg/map/registry.js +133 -56
  53. package/dist/db/pg/map/relations.js +76 -68
  54. package/dist/db/pg/map/search.js +15 -37
  55. package/dist/db/pg/mappers.js +13 -7
  56. package/dist/db/pg/migrate.d.ts +1 -2
  57. package/dist/db/pg/migrate.js +8 -9
  58. package/dist/db/pg/queries/activity.js +5 -5
  59. package/dist/db/pg/queries/derived.js +8 -12
  60. package/dist/db/pg/queries/sorts.d.ts +1 -0
  61. package/dist/db/pg/queries/sorts.js +4 -0
  62. package/dist/db/pg/schema/documents.d.ts +279 -41
  63. package/dist/db/pg/schema/documents.js +136 -22
  64. package/dist/db/pg/schema/edges.d.ts +116 -7
  65. package/dist/db/pg/schema/edges.js +9 -2
  66. package/dist/db/pg/schema/index.d.ts +362 -15
  67. package/dist/db/pg/schema/index.js +5 -1
  68. package/dist/db/pg/sql/0010_user_group_membership_roles.sql +16 -0
  69. package/dist/db/pg/sql/0011_drop_data_migrations.sql +1 -0
  70. package/dist/db/pg/sql/0012_posts_last_activity_at.sql +5 -0
  71. package/dist/db/pg/sql/0013_add_blocks_edge.sql +12 -0
  72. package/dist/db/pg/sql/0014_federation_datamodel.sql +59 -0
  73. package/dist/db/pg/sql/0015_profile_hashtags.sql +12 -0
  74. package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
  75. package/dist/db/pg/sql/meta/{0009_snapshot.json → 0015_snapshot.json} +291 -36
  76. package/dist/db/pg/sql/meta/_journal.json +49 -0
  77. package/dist/db/replaceOrigin.js +1 -1
  78. package/dist/email/queueStats.js +8 -11
  79. package/dist/email/render.js +14 -3
  80. package/dist/email/send.js +19 -17
  81. package/dist/email/smtpTest.js +10 -6
  82. package/dist/errors/index.js +1 -1
  83. package/dist/events/index.d.ts +4 -0
  84. package/dist/events/index.js +1 -0
  85. package/dist/events/once.js +2 -4
  86. package/dist/federation/activities.d.ts +17 -0
  87. package/dist/federation/activities.js +25 -0
  88. package/dist/federation/identity.d.ts +16 -0
  89. package/dist/federation/identity.js +52 -0
  90. package/dist/federation/index.d.ts +4 -0
  91. package/dist/federation/index.js +3 -0
  92. package/dist/federation/profiles.d.ts +3 -0
  93. package/dist/federation/profiles.js +14 -0
  94. package/dist/groups/finders.d.ts +2 -1
  95. package/dist/groups/helpers.d.ts +18 -0
  96. package/dist/groups/helpers.js +1 -2
  97. package/dist/groups/mapping.d.ts +4 -2
  98. package/dist/groups/mutations.js +1 -1
  99. package/dist/hashtags/finders.d.ts +6 -3
  100. package/dist/hashtags/finders.js +2 -0
  101. package/dist/hashtags/helpers.d.ts +8 -0
  102. package/dist/hashtags/helpers.js +4 -0
  103. package/dist/hashtags/index.d.ts +2 -0
  104. package/dist/hashtags/index.js +2 -0
  105. package/dist/hashtags/mutations.d.ts +3 -0
  106. package/dist/hashtags/mutations.js +13 -1
  107. package/dist/i18n/index.d.ts +1 -1
  108. package/dist/i18n/index.js +3 -1
  109. package/dist/i18n/pluginLocales.d.ts +6 -0
  110. package/dist/i18n/pluginLocales.js +15 -0
  111. package/dist/inviteLinks/mutations.js +2 -3
  112. package/dist/jams/export.d.ts +19 -0
  113. package/dist/jams/export.js +58 -0
  114. package/dist/jams/finders.js +4 -1
  115. package/dist/jams/health.d.ts +10 -0
  116. package/dist/jams/health.js +50 -0
  117. package/dist/jams/helpers.d.ts +2 -2
  118. package/dist/jams/helpers.js +6 -2
  119. package/dist/jams/index.d.ts +2 -0
  120. package/dist/jams/index.js +25 -18
  121. package/dist/jams/jobs.js +2 -3
  122. package/dist/jams/livekit.d.ts +49 -4
  123. package/dist/jams/livekit.js +62 -45
  124. package/dist/jams/mapping.d.ts +3 -3
  125. package/dist/jams/mutations.d.ts +1 -1
  126. package/dist/jams/recording.d.ts +10 -0
  127. package/dist/jams/recording.js +33 -1
  128. package/dist/jams/token.d.ts +13 -1
  129. package/dist/jams/token.js +25 -18
  130. package/dist/jams/waitingRoom.js +1 -1
  131. package/dist/jobs/index.d.ts +1 -0
  132. package/dist/jobs/index.js +9 -3
  133. package/dist/jobs/jobDetail.js +6 -12
  134. package/dist/jobs/jobLog.js +2 -3
  135. package/dist/lib/streams.js +4 -39
  136. package/dist/lib/zodDeepPartial.d.ts +1 -1
  137. package/dist/lib/zodDeepPartial.js +1 -1
  138. package/dist/log/index.js +13 -29
  139. package/dist/media/index.d.ts +1 -1
  140. package/dist/media/index.js +73 -12
  141. package/dist/media/jobs.js +1 -2
  142. package/dist/media/openpeeps/index.js +11 -46
  143. package/dist/media/processing.js +25 -11
  144. package/dist/media/streaming.js +5 -5
  145. package/dist/media/streamingCleanupJobs.js +1 -2
  146. package/dist/media/streamingJobs.js +3 -4
  147. package/dist/media/streamingPrewarm.js +7 -11
  148. package/dist/mediaAttachments/index.js +6 -2
  149. package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
  150. package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
  151. package/dist/notifications/defaultNotifications/follow/index.js +15 -18
  152. package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
  153. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
  154. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
  155. package/dist/notifications/defaultNotifications/index.js +4 -0
  156. package/dist/notifications/defaultNotifications/jamModerator/index.js +3 -5
  157. package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
  158. package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
  159. package/dist/notifications/defaultNotifications/mention/index.js +20 -24
  160. package/dist/notifications/defaultNotifications/newGroupPost/index.js +11 -6
  161. package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
  162. package/dist/notifications/defaultNotifications/pollEnded/index.d.ts +19 -0
  163. package/dist/notifications/defaultNotifications/pollEnded/index.js +39 -0
  164. package/dist/notifications/defaultNotifications/pollEnded/recipients.d.ts +3 -0
  165. package/dist/notifications/defaultNotifications/pollEnded/recipients.js +17 -0
  166. package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
  167. package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
  168. package/dist/notifications/defaultNotifications/reply/index.js +21 -22
  169. package/dist/notifications/defaultNotifications/repost/index.js +16 -20
  170. package/dist/notifications/defaultNotifications/rsvp/index.d.ts +6 -1
  171. package/dist/notifications/defaultNotifications/rsvp/index.js +31 -18
  172. package/dist/notifications/defaultNotifications/rsvpCanceled/index.d.ts +24 -0
  173. package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +82 -0
  174. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.d.ts +4 -0
  175. package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.js +11 -0
  176. package/dist/notifications/fcmCredential.js +1 -1
  177. package/dist/notifications/finders.js +1 -1
  178. package/dist/notifications/helpers.js +13 -10
  179. package/dist/notifications/jobs.js +10 -5
  180. package/dist/notifications/mutations.js +8 -1
  181. package/dist/notifications/push.js +11 -16
  182. package/dist/performance/index.js +3 -3
  183. package/dist/plugins/helpers.js +3 -6
  184. package/dist/plugins/index.js +39 -4
  185. package/dist/plugins/install.d.ts +28 -9
  186. package/dist/plugins/install.js +302 -56
  187. package/dist/plugins/pluginAuth.d.ts +1 -1
  188. package/dist/plugins/pluginAuth.js +13 -10
  189. package/dist/plugins/state.js +2 -3
  190. package/dist/posts/activity.d.ts +9 -0
  191. package/dist/posts/activity.js +34 -0
  192. package/dist/posts/contextClosure.d.ts +1 -9
  193. package/dist/posts/contextClosure.js +14 -44
  194. package/dist/posts/conversationQueries.d.ts +7 -0
  195. package/dist/posts/conversationQueries.js +76 -4
  196. package/dist/posts/eventAgenda.d.ts +1 -0
  197. package/dist/posts/eventAgenda.js +17 -8
  198. package/dist/posts/eventOccurrenceJobs.js +7 -2
  199. package/dist/posts/eventOccurrences.d.ts +6 -0
  200. package/dist/posts/eventOccurrences.js +22 -1
  201. package/dist/posts/finders.d.ts +56 -9
  202. package/dist/posts/finders.js +84 -23
  203. package/dist/posts/helpers/filters.js +13 -9
  204. package/dist/posts/helpers/index.d.ts +179 -14
  205. package/dist/posts/helpers/index.js +70 -34
  206. package/dist/posts/index.d.ts +5 -2
  207. package/dist/posts/index.js +5 -2
  208. package/dist/posts/mapping.d.ts +765 -30
  209. package/dist/posts/mapping.js +74 -31
  210. package/dist/posts/mutations.d.ts +516 -3
  211. package/dist/posts/mutations.js +179 -41
  212. package/dist/posts/pollEnd.d.ts +3 -0
  213. package/dist/posts/pollEnd.js +4 -0
  214. package/dist/posts/pollEndJobs.d.ts +8 -0
  215. package/dist/posts/pollEndJobs.js +49 -0
  216. package/dist/posts/replyClosure.d.ts +10 -0
  217. package/dist/posts/replyClosure.js +43 -0
  218. package/dist/posts/rsvpConfirmationEmail.js +23 -15
  219. package/dist/posts/threadPreview.d.ts +8 -0
  220. package/dist/posts/threadPreview.js +44 -0
  221. package/dist/posts/unseenCounts.js +4 -1
  222. package/dist/processingStats/queries.js +6 -7
  223. package/dist/profileSettings/cache.js +21 -5
  224. package/dist/profileSettings/mapping.d.ts +2 -0
  225. package/dist/profiles/activityQueries.d.ts +5 -0
  226. package/dist/profiles/activityQueries.js +85 -0
  227. package/dist/profiles/activitySummary.d.ts +3 -0
  228. package/dist/profiles/activitySummary.js +82 -0
  229. package/dist/profiles/blocks.d.ts +12 -0
  230. package/dist/profiles/blocks.js +73 -0
  231. package/dist/profiles/cache.d.ts +1 -0
  232. package/dist/profiles/cache.js +30 -10
  233. package/dist/profiles/export.js +30 -39
  234. package/dist/profiles/finders.d.ts +2 -1
  235. package/dist/profiles/finders.js +15 -8
  236. package/dist/profiles/helpers.d.ts +2 -0
  237. package/dist/profiles/index.d.ts +2 -0
  238. package/dist/profiles/index.js +2 -0
  239. package/dist/profiles/mapping.d.ts +10 -5
  240. package/dist/profiles/mapping.js +13 -1
  241. package/dist/profiles/mutations.d.ts +8 -4
  242. package/dist/profiles/mutations.js +31 -4
  243. package/dist/redis/connection.d.ts +2 -0
  244. package/dist/redis/connection.js +25 -6
  245. package/dist/reports/helpers.js +7 -3
  246. package/dist/roles/index.d.ts +1 -1
  247. package/dist/roles/index.js +1 -1
  248. package/dist/roles/mapping.d.ts +1 -0
  249. package/dist/roles/mutations.js +85 -3
  250. package/dist/search/finders.js +15 -3
  251. package/dist/search/helpers.js +1 -1
  252. package/dist/search/mapping.d.ts +1 -1
  253. package/dist/search/mapping.js +6 -2
  254. package/dist/sentry/index.js +9 -11
  255. package/dist/seo/index.d.ts +50 -0
  256. package/dist/seo/index.js +145 -0
  257. package/dist/seo/route.d.ts +18 -0
  258. package/dist/seo/route.js +19 -0
  259. package/dist/server/index.d.ts +19 -0
  260. package/dist/server/index.js +31 -14
  261. package/dist/server/stablePublicServerInfo.d.ts +17 -0
  262. package/dist/server/stablePublicServerInfo.js +37 -0
  263. package/dist/server/status.d.ts +25 -0
  264. package/dist/server/status.js +97 -0
  265. package/dist/session/index.js +2 -2
  266. package/dist/stats/finders.d.ts +1 -17681
  267. package/dist/stats/finders.js +22 -9
  268. package/dist/stats/helpers.js +4 -1
  269. package/dist/stats/mapping.d.ts +39 -2
  270. package/dist/stats/mapping.js +8 -4
  271. package/dist/stripe/cache.js +5 -6
  272. package/dist/stripe/connection.js +3 -4
  273. package/dist/stripe/helpers.js +15 -20
  274. package/package.json +5 -7
  275. package/dist/db/migration/detect.d.ts +0 -3
  276. package/dist/db/migration/detect.js +0 -33
  277. package/dist/db/migration/importPostgres.d.ts +0 -3
  278. package/dist/db/migration/importPostgres.js +0 -18
  279. package/dist/db/migration/transform.d.ts +0 -20
  280. package/dist/db/migration/transform.js +0 -232
  281. package/dist/db/migration/validate.d.ts +0 -18
  282. package/dist/db/migration/validate.js +0 -69
  283. package/dist/db/pg/sql/meta/0000_snapshot.json +0 -3380
  284. package/dist/db/pg/sql/meta/0004_snapshot.json +0 -4114
  285. package/dist/db/pg/sql/meta/0005_snapshot.json +0 -4179
  286. package/dist/db/pg/sql/meta/0006_snapshot.json +0 -4200
  287. package/dist/db/pg/sql/meta/0007_snapshot.json +0 -4179
  288. package/dist/mastodon/index.d.ts +0 -4
  289. package/dist/mastodon/index.js +0 -51
  290. package/dist/mastodon/types.d.ts +0 -7579
  291. package/dist/mastodon/types.js +0 -523
  292. package/dist/mastodon/typescript.d.ts +0 -1578
  293. package/dist/mastodon/typescript.js +0 -1
  294. package/dist/migration/index.d.ts +0 -4
  295. package/dist/migration/index.js +0 -4
  296. package/dist/roles/defaults.d.ts +0 -2
  297. package/dist/roles/defaults.js +0 -95
@@ -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 === null || authData === void 0 ? void 0 : authData.profile;
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 === null || authData === void 0 ? void 0 : authData.profile;
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 !== null && contextMapping !== void 0 ? contextMapping : mapping)), { authData });
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: baseFeed({ start, profile: authData.profile })
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: baseFeed({ start, profile: authData.profile })
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
- }) => toFilteredPostsList(baseFeed({ start, profile: authData.profile })
132
- .filter(filter)
133
- .filter({ matches: { type } }), { authData, limit });
134
- export const listPostsByTag = async (authData, tag, { start, limit = 100, filter, } = {
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: baseFeed({ start, profile: authData.profile })
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: _sort, } = { limit: 100 }) => withSpan('feed.group', async () => {
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: baseFeed({ start, profile: authData.profile })
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 } = { limit: 100 }) => withSpan('feed.local', () => toFilteredPostsList(baseFeed({ start, profile: authData.profile }).filter(localFeedFilter()), { authData, limit }));
169
- export const listMyFeed = async (authData, { start, limit = 100 } = { limit: 100 }) => {
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(baseFeed({ start, profile }).filter(myFeedFilter(profile)), { authData, limit, filters: [myFeedGroupMembershipFilter(profile)] }));
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
- operator: '||',
20
- predicates: [
21
- ownPostsFilter(profile),
22
- groupPostVisibilityQueryFilter,
23
- followFilter(profile),
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) => { var _a; return m.group.id === ((_a = post.group) === null || _a === void 0 ? void 0 : _a.id); }));
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
- id: string;
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
- switch (data.type) {
24
- default:
25
- return getTags(data === null || data === void 0 ? void 0 : data.content);
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) => (Object.assign(Object.assign({}, 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
- const addProfileForReaction = async (rawReaction) => (Object.assign(Object.assign({}, rawReaction), { profile: (await loadPublicProfile(rawReaction.profile.id, true)) }));
60
- const addProfileForMention = async (rawMention) => (Object.assign(Object.assign({}, rawMention), { profile: (await loadPublicProfile(rawMention.profile.id, true)) }));
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 (!(wrappers === null || wrappers === void 0 ? void 0 : wrappers.length))
66
+ if (!wrappers?.length)
63
67
  return [];
64
68
  const withProfiles = await Promise.all(wrappers.map(async (wrapper) => {
65
- var _a, _b, _c;
66
- const createEntry = (_a = wrapper.entries) === null || _a === void 0 ? void 0 : _a.find((entry) => entry.type === 'create');
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 = (createEntry === null || createEntry === void 0 ? void 0 : createEntry.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
- var _a;
87
- const entries = post.entries
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 reactions = post.reactions
91
- ? await Promise.all(post.reactions.map(addProfileForReaction))
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 = (_a = entries.find((entry) => entry.type === 'create')) === null || _a === void 0 ? void 0 : _a.profile;
101
- const profile = createProfile !== null && createProfile !== void 0 ? createProfile : (post.creatorId
102
- ? await loadPublicProfile(post.creatorId, true)
103
- : undefined);
104
- return Object.assign(Object.assign({}, post), { data: post.data ? normalizePostDataFromDb(post.data) : post.data, seen: currentProfile ? post.seen : undefined, replyTo: post.replyTo
105
- ? await transformPost(post.replyTo, currentProfile)
106
- : undefined, repost: post.repost
107
- ? await transformPost(post.repost, currentProfile)
108
- : undefined, rsvps: entries
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
- })), audience,
116
- mentions, profile: profile, entries,
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;
@@ -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 { listConversationPreviews, getConversationThread, findLatestThreadPostId, } from './conversationQueries';
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';