@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
@@ -11,14 +11,30 @@ export const profileSettingsCache = createCache({
11
11
  hub.on('profileSettingsUpdated', (profileId) => {
12
12
  void profileSettingsCache.del(profileId);
13
13
  });
14
+ const uniqueViolation = (error) => {
15
+ const current = error;
16
+ return current.code === '23505' || current.cause?.code === '23505';
17
+ };
18
+ const readProfileSettings = async (db, id) =>
19
+ // Include soft-deleted rows: the profile_id unique index still covers them,
20
+ // so a miss here would insert and fail with 23505.
21
+ profileSettingsMapping.find(db, id, { ignoreSoftDelete: true });
14
22
  export const getProfileSettings = async (id) => profileSettingsCache.wrap(id, async () => {
15
23
  const { db } = await allpeepDb();
16
- const foundSettings = await profileSettingsMapping.find(db, id);
24
+ const foundSettings = await readProfileSettings(db, id);
17
25
  if (foundSettings) {
18
26
  return foundSettings;
19
27
  }
20
- const newSettings = await profileSettingsMapping.create(db, {
21
- id,
22
- });
23
- return newSettings;
28
+ try {
29
+ return await profileSettingsMapping.create(db, { id });
30
+ }
31
+ catch (error) {
32
+ // Another request created the row between the read and this insert.
33
+ if (!uniqueViolation(error))
34
+ throw error;
35
+ const raced = await readProfileSettings(db, id);
36
+ if (raced)
37
+ return raced;
38
+ throw error;
39
+ }
24
40
  });
@@ -2,6 +2,7 @@ import { ProfileSettings } from '@openpeepshq/common/types';
2
2
  export declare const profileSettingsMapping: import("../db/pg/map").Mapping<{
3
3
  id: string;
4
4
  language?: string | undefined;
5
+ timeZone?: string | undefined;
5
6
  theme?: "light" | "dark" | "community" | "system" | undefined;
6
7
  defaults?: {
7
8
  privacy?: "public" | "unlisted" | "private" | undefined;
@@ -31,6 +32,7 @@ export declare const profileSettingsMapping: import("../db/pg/map").Mapping<{
31
32
  customerId?: string | undefined;
32
33
  } | undefined;
33
34
  feedSettings?: {
35
+ format?: "threaded" | "linear" | undefined;
34
36
  communityFeed?: {
35
37
  showGroupPosts?: boolean | undefined;
36
38
  } | undefined;
@@ -0,0 +1,5 @@
1
+ export declare const TOP_POSTS_LIMIT = 5;
2
+ export declare const TOP_POST_CANDIDATE_LIMIT = 25;
3
+ export declare const profileActivityCountsSql: (profileId: string) => import("drizzle-orm").SQL<unknown>;
4
+ export declare const profileTopPostScoresSql: (profileId: string) => import("drizzle-orm").SQL<unknown>;
5
+ export declare const takeTopReadablePosts: <T>(ordered: T[], isReadable: (item: T) => boolean) => T[];
@@ -0,0 +1,85 @@
1
+ import { sql } from 'drizzle-orm';
2
+ import { postActivityScoreExpr } from '../db/pg/queries/index.js';
3
+ import { posts } from '../db/pg/schema/documents.js';
4
+ import { bookmarks, entries, replyTo, repost, userGroups, } from '../db/pg/schema/edges.js';
5
+ export const TOP_POSTS_LIMIT = 5;
6
+ export const TOP_POST_CANDIDATE_LIMIT = 25;
7
+ const isReplySql = sql `EXISTS (
8
+ SELECT 1 FROM ${replyTo} WHERE ${replyTo.fromId} = ${posts.id}::text
9
+ )`;
10
+ export const profileActivityCountsSql = (profileId) => sql `
11
+ SELECT
12
+ COUNT(*) FILTER (WHERE NOT ${isReplySql})::int AS posts_count,
13
+ COUNT(*) FILTER (WHERE ${isReplySql})::int AS replies_count,
14
+ COUNT(*) FILTER (
15
+ WHERE ${posts.type} = 'event' AND NOT ${isReplySql}
16
+ )::int AS events_count,
17
+ (
18
+ SELECT COUNT(*)::int FROM ${entries}
19
+ WHERE ${entries.fromId} = ${profileId}
20
+ AND ${entries.body}->>'type' = 'reaction'
21
+ ) AS reactions_given,
22
+ (
23
+ SELECT COUNT(*)::int
24
+ FROM ${entries}
25
+ INNER JOIN ${posts} received_posts
26
+ ON received_posts.id::text = ${entries.toId}
27
+ WHERE received_posts.creator_id = ${profileId}
28
+ AND received_posts.deleted_at IS NULL
29
+ AND received_posts.visibility <> 'direct'
30
+ AND ${entries.body}->>'type' = 'reaction'
31
+ ) AS reactions_received,
32
+ (
33
+ SELECT COUNT(*)::int FROM ${repost}
34
+ WHERE ${repost.fromId} = ${profileId}
35
+ ) AS reposts_count,
36
+ (
37
+ SELECT COUNT(*)::int
38
+ FROM ${repost}
39
+ INNER JOIN ${posts} reposted_posts
40
+ ON reposted_posts.id::text = ${repost.toId}
41
+ WHERE reposted_posts.creator_id = ${profileId}
42
+ AND reposted_posts.deleted_at IS NULL
43
+ AND reposted_posts.visibility <> 'direct'
44
+ ) AS reposts_received,
45
+ (
46
+ SELECT COUNT(*)::int
47
+ FROM ${replyTo}
48
+ INNER JOIN ${posts} reply_child_posts
49
+ ON reply_child_posts.id::text = ${replyTo.fromId}
50
+ INNER JOIN ${posts} parent_posts
51
+ ON parent_posts.id::text = ${replyTo.toId}
52
+ WHERE parent_posts.creator_id = ${profileId}
53
+ AND parent_posts.deleted_at IS NULL
54
+ AND parent_posts.visibility <> 'direct'
55
+ AND reply_child_posts.deleted_at IS NULL
56
+ ) AS replies_received,
57
+ (
58
+ SELECT COUNT(*)::int FROM ${entries}
59
+ WHERE ${entries.fromId} = ${profileId}
60
+ AND ${entries.body}->>'type' = 'rsvp'
61
+ ) AS rsvps_count,
62
+ (
63
+ SELECT COUNT(*)::int FROM ${bookmarks}
64
+ WHERE ${bookmarks.fromId} = ${profileId}
65
+ ) AS bookmarks_count,
66
+ (
67
+ SELECT COUNT(*)::int FROM ${userGroups}
68
+ WHERE ${userGroups.fromId} = ${profileId}
69
+ ) AS groups_count
70
+ FROM ${posts}
71
+ WHERE ${posts.creatorId} = ${profileId}
72
+ AND ${posts.deletedAt} IS NULL
73
+ AND ${posts.visibility} <> 'direct'
74
+ `;
75
+ export const profileTopPostScoresSql = (profileId) => sql `
76
+ SELECT ${posts.id}::text AS id, (${postActivityScoreExpr(posts)})::int AS activity_score
77
+ FROM ${posts}
78
+ WHERE ${posts.creatorId} = ${profileId}
79
+ AND ${posts.deletedAt} IS NULL
80
+ AND ${posts.visibility} <> 'direct'
81
+ AND NOT ${isReplySql}
82
+ ORDER BY activity_score DESC, ${posts.id} DESC
83
+ LIMIT ${TOP_POST_CANDIDATE_LIMIT}
84
+ `;
85
+ export const takeTopReadablePosts = (ordered, isReadable) => ordered.filter(isReadable).slice(0, TOP_POSTS_LIMIT);
@@ -0,0 +1,3 @@
1
+ import { AuthorizationData, ProfileActivitySummary, type AdminProfileSummary } from '@openpeepshq/common/types';
2
+ export declare const getProfileActivitySummary: (authData: AuthorizationData, profileId: string) => Promise<ProfileActivitySummary>;
3
+ export declare const getAdminProfileSummary: (authData: AuthorizationData, profileId: string) => Promise<AdminProfileSummary>;
@@ -0,0 +1,82 @@
1
+ import { adminProfileSummarySchema, profileActivitySummarySchema, publicPostWithActivityScoreSchema, publicProfileSchema, } from '@openpeepshq/common/types';
2
+ import { allpeepDb } from '../db/index.js';
3
+ import { fetchRowsByIds, hydrateMapData } from '../db/pg/map/relations.js';
4
+ import { capabilitiesConfig } from '../config/index.js';
5
+ import { canReadPost, transformPost } from '../posts/helpers/index.js';
6
+ import { postsMappingForProfile } from '../posts/mapping.js';
7
+ import { listBlockedByIds } from './blocks.js';
8
+ import { findProfile } from './finders.js';
9
+ import { listReportsByReportedProfile } from '../reports/finders.js';
10
+ import { profileActivityCountsSql, profileTopPostScoresSql, takeTopReadablePosts, } from './activityQueries.js';
11
+ const sqlRows = (result) => result.rows ?? [];
12
+ const loadPostsByIds = async (db, ids, authData) => {
13
+ if (ids.length === 0)
14
+ return [];
15
+ const mapData = postsMappingForProfile(authData.profile).data();
16
+ const rows = await fetchRowsByIds(db, mapData.collection, ids, mapData.softDelete);
17
+ const hydrated = (await hydrateMapData(db, mapData, rows));
18
+ const byId = new Map(await Promise.all(hydrated.map(async (post) => {
19
+ const transformed = await transformPost(post, authData.profile);
20
+ return [transformed.id, transformed];
21
+ })));
22
+ return ids
23
+ .map((id) => byId.get(id))
24
+ .filter((post) => !!post);
25
+ };
26
+ export const getProfileActivitySummary = async (authData, profileId) => {
27
+ const { db } = await allpeepDb();
28
+ const [countRow] = sqlRows(await db.execute(profileActivityCountsSql(profileId)));
29
+ const scored = sqlRows(await db.execute(profileTopPostScoresSql(profileId)))
30
+ .map((row) => ({
31
+ id: String(row.id ?? ''),
32
+ activityScore: Number(row.activity_score ?? 0),
33
+ }))
34
+ .filter((row) => row.id);
35
+ const scoreById = new Map(scored.map((row) => [row.id, row.activityScore]));
36
+ const loaded = await loadPostsByIds(db, scored.map((row) => row.id), authData);
37
+ const config = await capabilitiesConfig();
38
+ const readable = canReadPost(config, authData);
39
+ const topPosts = takeTopReadablePosts(loaded, readable)
40
+ .map((post) => publicPostWithActivityScoreSchema.safeParse({
41
+ ...post,
42
+ activityScore: scoreById.get(post.id) ?? 0,
43
+ }))
44
+ .filter((result) => result.success)
45
+ .map((result) => result.data);
46
+ return profileActivitySummarySchema.parse({
47
+ postsCount: Number(countRow?.posts_count ?? 0),
48
+ repliesCount: Number(countRow?.replies_count ?? 0),
49
+ eventsCount: Number(countRow?.events_count ?? 0),
50
+ reactionsGiven: Number(countRow?.reactions_given ?? 0),
51
+ reactionsReceived: Number(countRow?.reactions_received ?? 0),
52
+ repostsCount: Number(countRow?.reposts_count ?? 0),
53
+ repostsReceived: Number(countRow?.reposts_received ?? 0),
54
+ repliesReceived: Number(countRow?.replies_received ?? 0),
55
+ rsvpsCount: Number(countRow?.rsvps_count ?? 0),
56
+ bookmarksCount: Number(countRow?.bookmarks_count ?? 0),
57
+ groupsCount: Number(countRow?.groups_count ?? 0),
58
+ topPosts,
59
+ });
60
+ };
61
+ export const getAdminProfileSummary = async (authData, profileId) => {
62
+ const profile = await findProfile(profileId);
63
+ if (!profile) {
64
+ throw new Error(`Profile with id ${profileId} not found`);
65
+ }
66
+ const activity = await getProfileActivitySummary(authData, profileId);
67
+ const { db } = await allpeepDb();
68
+ const [blockedByIds, reports] = await Promise.all([
69
+ listBlockedByIds(db, profileId),
70
+ listReportsByReportedProfile(profile),
71
+ ]);
72
+ return adminProfileSummarySchema.parse({
73
+ profile: publicProfileSchema.parse(profile),
74
+ activity,
75
+ createdAt: profile.createdAt,
76
+ email: profile.controllers?.[0]?.email,
77
+ followersCount: profile.profileStats?.followersCount ?? 0,
78
+ followingCount: profile.profileStats?.followingCount ?? 0,
79
+ reportsCount: reports.length,
80
+ blockedByCount: blockedByIds.length,
81
+ });
82
+ };
@@ -0,0 +1,12 @@
1
+ import type { PgDb } from '../db/pg/client';
2
+ export declare const listBlockingIds: (db: PgDb, profileId: string) => Promise<string[]>;
3
+ export declare const listBlockedByIds: (db: PgDb, profileId: string) => Promise<string[]>;
4
+ export declare const loadBlockIds: (db: PgDb, profileId: string) => Promise<{
5
+ blockingIds: string[];
6
+ blockedByIds: string[];
7
+ }>;
8
+ export declare const insertBlock: (db: PgDb, fromId: string, toId: string) => Promise<void>;
9
+ export declare const deleteBlock: (db: PgDb, fromId: string, toId: string) => Promise<void>;
10
+ export declare const dropFollowsBetween: (db: PgDb, a: string, b: string) => Promise<void>;
11
+ export declare const areBlocked: (db: PgDb, a: string, b: string) => Promise<boolean>;
12
+ export declare const hasBlockAmong: (db: PgDb, ids: string[]) => Promise<boolean>;
@@ -0,0 +1,73 @@
1
+ import { and, eq, inArray, or } from 'drizzle-orm';
2
+ import { uuidv7 } from 'uuidv7';
3
+ import { nowIso } from '../db/pg/mappers.js';
4
+ import { blocks, follows, requestsFollow } from '../db/pg/schema/edges.js';
5
+ export const listBlockingIds = async (db, profileId) => {
6
+ const rows = await db
7
+ .select({ toId: blocks.toId })
8
+ .from(blocks)
9
+ .where(eq(blocks.fromId, profileId));
10
+ return rows.map((row) => row.toId);
11
+ };
12
+ export const listBlockedByIds = async (db, profileId) => {
13
+ const rows = await db
14
+ .select({ fromId: blocks.fromId })
15
+ .from(blocks)
16
+ .where(eq(blocks.toId, profileId));
17
+ return rows.map((row) => row.fromId);
18
+ };
19
+ export const loadBlockIds = async (db, profileId) => {
20
+ const [blockingIds, blockedByIds] = await Promise.all([
21
+ listBlockingIds(db, profileId),
22
+ listBlockedByIds(db, profileId),
23
+ ]);
24
+ return { blockingIds, blockedByIds };
25
+ };
26
+ export const insertBlock = async (db, fromId, toId) => {
27
+ const ts = nowIso();
28
+ await db
29
+ .insert(blocks)
30
+ .values({
31
+ id: uuidv7(),
32
+ fromId,
33
+ toId,
34
+ body: {},
35
+ createdAt: ts,
36
+ updatedAt: ts,
37
+ })
38
+ .onConflictDoNothing();
39
+ };
40
+ export const deleteBlock = async (db, fromId, toId) => {
41
+ await db
42
+ .delete(blocks)
43
+ .where(and(eq(blocks.fromId, fromId), eq(blocks.toId, toId)));
44
+ };
45
+ const eitherDirection = (a, b) => or(and(eq(follows.fromId, a), eq(follows.toId, b)), and(eq(follows.fromId, b), eq(follows.toId, a)));
46
+ const eitherFollowRequest = (a, b) => or(and(eq(requestsFollow.fromId, a), eq(requestsFollow.toId, b)), and(eq(requestsFollow.fromId, b), eq(requestsFollow.toId, a)));
47
+ export const dropFollowsBetween = async (db, a, b) => {
48
+ await Promise.all([
49
+ db.delete(follows).where(eitherDirection(a, b)),
50
+ db.delete(requestsFollow).where(eitherFollowRequest(a, b)),
51
+ ]);
52
+ };
53
+ export const areBlocked = async (db, a, b) => {
54
+ if (!a || !b || a === b)
55
+ return false;
56
+ const rows = await db
57
+ .select({ id: blocks.id })
58
+ .from(blocks)
59
+ .where(or(and(eq(blocks.fromId, a), eq(blocks.toId, b)), and(eq(blocks.fromId, b), eq(blocks.toId, a))))
60
+ .limit(1);
61
+ return rows.length > 0;
62
+ };
63
+ export const hasBlockAmong = async (db, ids) => {
64
+ const unique = [...new Set(ids.filter(Boolean))];
65
+ if (unique.length < 2)
66
+ return false;
67
+ const rows = await db
68
+ .select({ id: blocks.id })
69
+ .from(blocks)
70
+ .where(and(inArray(blocks.fromId, unique), inArray(blocks.toId, unique)))
71
+ .limit(1);
72
+ return rows.length > 0;
73
+ };
@@ -5,5 +5,6 @@ export declare const clearProfileCache: (profile: Pick<Profile, "id" | "handle">
5
5
  export declare const getProfile: (id: string, ignoreSoftDelete?: boolean) => Promise<ProfileWithMeta | undefined>;
6
6
  /** Lean profile for post/feed hydrate — no followers/following trees. */
7
7
  export declare const getPublicProfile: (id: string, ignoreSoftDelete?: boolean) => Promise<ProfileWithMeta | undefined>;
8
+ /** Local handle lookup only — federated paths must use uri or (handle, domain). */
8
9
  export declare const getProfileByHandle: (handle: string, ignoreSoftDelete?: boolean) => Promise<ProfileWithMeta | undefined>;
9
10
  export declare const getProfiles: (ids: string[]) => Promise<ProfileWithMeta[]>;
@@ -1,6 +1,7 @@
1
1
  import { createCache } from 'cache-manager';
2
2
  import { allpeepDb } from '../db/index.js';
3
3
  import { profilesMapping, publicProfilesMapping } from './mapping.js';
4
+ import { loadBlockIds } from './blocks.js';
4
5
  export const profilesCache = createCache({
5
6
  ttl: 60 * 60 * 1000,
6
7
  refreshThreshold: 60 * 1000,
@@ -17,16 +18,32 @@ export const clearProfileCache = async (profile) => {
17
18
  publicProfilesCache.del(`all:${profile.id}`),
18
19
  ]);
19
20
  };
20
- const withEmptyFollowGraphs = (profile) => {
21
- var _a, _b, _c, _d;
22
- return (Object.assign(Object.assign({}, profile), { roles: (_a = profile.roles) !== null && _a !== void 0 ? _a : [], followers: [], following: [], controllers: (_b = profile.controllers) !== null && _b !== void 0 ? _b : [], memberships: (_c = profile.memberships) !== null && _c !== void 0 ? _c : [], profileStats: (_d = profile.profileStats) !== null && _d !== void 0 ? _d : {
23
- followersCount: 0,
24
- followingCount: 0,
25
- } }));
21
+ const withEmptyFollowGraphs = (profile) => ({
22
+ ...profile,
23
+ roles: profile.roles ?? [],
24
+ followers: [],
25
+ following: [],
26
+ controllers: profile.controllers ?? [],
27
+ memberships: profile.memberships ?? [],
28
+ profileStats: profile.profileStats ?? {
29
+ followersCount: 0,
30
+ followingCount: 0,
31
+ },
32
+ blockingIds: profile.blockingIds ?? [],
33
+ blockedByIds: profile.blockedByIds ?? [],
34
+ });
35
+ const withBlockIds = async (profile) => {
36
+ if (!profile)
37
+ return undefined;
38
+ const { db } = await allpeepDb();
39
+ const { blockingIds, blockedByIds } = await loadBlockIds(db, profile.id);
40
+ return { ...profile, blockingIds, blockedByIds };
26
41
  };
27
- export const getProfile = async (id, ignoreSoftDelete = false) => profilesCache.wrap(id, () => allpeepDb().then(({ db }) => ignoreSoftDelete
42
+ export const getProfile = async (id, ignoreSoftDelete = false) => profilesCache.wrap(id, () => allpeepDb()
43
+ .then(({ db }) => ignoreSoftDelete
28
44
  ? profilesMapping.ignoreSoftDelete().find(db, id)
29
- : profilesMapping.find(db, id)));
45
+ : profilesMapping.find(db, id))
46
+ .then(withBlockIds));
30
47
  /** Lean profile for post/feed hydrate — no followers/following trees. */
31
48
  export const getPublicProfile = async (id, ignoreSoftDelete = false) => {
32
49
  const profile = await publicProfilesCache.wrap(`${ignoreSoftDelete ? 'all:' : ''}${id}`, () => allpeepDb().then(({ db }) => ignoreSoftDelete
@@ -34,11 +51,14 @@ export const getPublicProfile = async (id, ignoreSoftDelete = false) => {
34
51
  : publicProfilesMapping.find(db, id)));
35
52
  return profile ? withEmptyFollowGraphs(profile) : undefined;
36
53
  };
37
- export const getProfileByHandle = async (handle, ignoreSoftDelete = false) => profilesCache.wrap(handle, () => allpeepDb().then(({ db }) => ignoreSoftDelete
54
+ /** Local handle lookup only — federated paths must use uri or (handle, domain). */
55
+ export const getProfileByHandle = async (handle, ignoreSoftDelete = false) => profilesCache.wrap(handle, () => allpeepDb()
56
+ .then(({ db }) => ignoreSoftDelete
38
57
  ? profilesMapping
39
58
  .ignoreSoftDelete()
40
59
  .findOneBy(db, { matches: { handle } })
41
- : profilesMapping.findOneBy(db, { matches: { handle } })));
60
+ : profilesMapping.findOneBy(db, { matches: { handle } }))
61
+ .then(withBlockIds));
42
62
  export const getProfiles = async (ids) => profilesCache
43
63
  .mget(ids)
44
64
  .then((profiles) => Promise.all(profiles.map(async (p, index) => p || (await getProfile(ids[index])))))
@@ -9,14 +9,11 @@ const emptyStats = () => ({
9
9
  reactionsCount: 0,
10
10
  lastSeen: null,
11
11
  });
12
- const toMemberExportStats = (row) => {
13
- var _a, _b, _c;
14
- return ({
15
- postsCount: (_a = row === null || row === void 0 ? void 0 : row.postsCount) !== null && _a !== void 0 ? _a : 0,
16
- reactionsCount: (_b = row === null || row === void 0 ? void 0 : row.reactionsCount) !== null && _b !== void 0 ? _b : 0,
17
- lastSeen: (_c = row === null || row === void 0 ? void 0 : row.lastSeen) !== null && _c !== void 0 ? _c : null,
18
- });
19
- };
12
+ const toMemberExportStats = (row) => ({
13
+ postsCount: row?.postsCount ?? 0,
14
+ reactionsCount: row?.reactionsCount ?? 0,
15
+ lastSeen: row?.lastSeen ?? null,
16
+ });
20
17
  export const listMembersForExport = async () => {
21
18
  const { db } = await allpeepDb();
22
19
  const [profiles, statsRows] = await Promise.all([
@@ -24,22 +21,19 @@ export const listMembersForExport = async () => {
24
21
  membersExportMapping.filter(guestFilter).all(db),
25
22
  ]);
26
23
  const statsById = new Map(statsRows.map((row) => [row.id, toMemberExportStats(row)]));
27
- return profiles.map((profile) => {
28
- var _a;
29
- return (Object.assign(Object.assign({}, profile), ((_a = statsById.get(profile.id)) !== null && _a !== void 0 ? _a : emptyStats())));
30
- });
24
+ return profiles.map((profile) => ({
25
+ ...profile,
26
+ ...(statsById.get(profile.id) ?? emptyStats()),
27
+ }));
31
28
  };
32
29
  const formatCustomFields = (fields) => formatMemberExportCustomFields(fields);
33
30
  const formatEmailVerified = (controllers) => {
34
- var _a;
35
- const validated = (_a = controllers[0]) === null || _a === void 0 ? void 0 : _a.emailValidated;
31
+ const validated = controllers[0]?.emailValidated;
36
32
  return validated == null ? '' : validated ? 'yes' : 'no';
37
33
  };
38
- const formatGroups = (memberships) => {
39
- var _a;
40
- return (_a = memberships === null || memberships === void 0 ? void 0 : memberships.map((membership) => membership.group.displayName).join('; ')) !== null && _a !== void 0 ? _a : '';
41
- };
42
- const formatRoles = (roles) => { var _a; return (_a = roles === null || roles === void 0 ? void 0 : roles.map((role) => role.displayName || role.key).join('; ')) !== null && _a !== void 0 ? _a : ''; };
34
+ const formatGroups = (memberships) => memberships?.map((membership) => membership.group.displayName).join('; ') ??
35
+ '';
36
+ const formatRoles = (roles) => roles?.map((role) => role.displayName || role.key).join('; ') ?? '';
43
37
  const memberExportHeaders = [
44
38
  'Email',
45
39
  'Email Verified',
@@ -61,25 +55,22 @@ export const exportMembersCsv = async () => {
61
55
  const members = await listMembersForExport();
62
56
  return [
63
57
  toCsvRow([...memberExportHeaders]),
64
- ...members.map((member) => {
65
- var _a, _b, _c, _d, _e, _f, _g;
66
- return toCsvRow([
67
- (_b = (_a = member.controllers[0]) === null || _a === void 0 ? void 0 : _a.email) !== null && _b !== void 0 ? _b : '',
68
- formatEmailVerified(member.controllers),
69
- member.createdAt,
70
- member.handle,
71
- (_c = member.displayName) !== null && _c !== void 0 ? _c : '',
72
- formatRoles(member.roles),
73
- (_d = member.bio) !== null && _d !== void 0 ? _d : '',
74
- (_f = (_e = member.location) === null || _e === void 0 ? void 0 : _e.text) !== null && _f !== void 0 ? _f : '',
75
- formatCustomFields(member.fields),
76
- formatGroups(member.memberships),
77
- (_g = member.lastSeen) !== null && _g !== void 0 ? _g : '',
78
- member.postsCount,
79
- member.reactionsCount,
80
- member.profileStats.followersCount,
81
- member.profileStats.followingCount,
82
- ]);
83
- }),
58
+ ...members.map((member) => toCsvRow([
59
+ member.controllers[0]?.email ?? '',
60
+ formatEmailVerified(member.controllers),
61
+ member.createdAt,
62
+ member.handle,
63
+ member.displayName ?? '',
64
+ formatRoles(member.roles),
65
+ member.bio ?? '',
66
+ member.location?.text ?? '',
67
+ formatCustomFields(member.fields),
68
+ formatGroups(member.memberships),
69
+ member.lastSeen ?? '',
70
+ member.postsCount,
71
+ member.reactionsCount,
72
+ member.profileStats.followersCount,
73
+ member.profileStats.followingCount,
74
+ ])),
84
75
  ].join('\n');
85
76
  };
@@ -1,8 +1,9 @@
1
1
  import { Account, GroupMember, GroupWithMeta, Profile, ProfileWithMeta, Role } from '@openpeepshq/common/types';
2
2
  export declare const findProfile: (profileId: string) => Promise<ProfileWithMeta | undefined>;
3
3
  export declare const findProfileByHandle: (handle: string) => Promise<ProfileWithMeta | undefined>;
4
+ export { findProfileByHandleAndDomain, findProfileByUri, } from '../federation/profiles';
4
5
  export declare const existsProfileByHandle: (handle: string) => Promise<boolean>;
5
- export declare const listProfiles: () => Promise<ProfileWithMeta[]>;
6
+ export declare const listProfiles: (viewer?: ProfileWithMeta) => Promise<ProfileWithMeta[]>;
6
7
  export declare const listProfilesByRole: (role: Role) => Promise<ProfileWithMeta[]>;
7
8
  export declare const listProfilesByAccount: (account: Account) => Promise<ProfileWithMeta[]>;
8
9
  export declare const listProfilesWithCapabilities: (capabilities: string[]) => Promise<ProfileWithMeta[]>;
@@ -1,6 +1,7 @@
1
1
  import { accountProfileRelation, baseProfilesMapping, membersRelation, profileRoleRelation, } from './mapping.js';
2
2
  import { allpeepDb } from '../db/index.js';
3
3
  import { profileFilters } from '../db/pg/filters/index.js';
4
+ import { blockedPairIds, getUniqueBy } from '@openpeepshq/common/lib';
4
5
  import { rolesMapping } from '../roles/mapping.js';
5
6
  import { findRolesByCapabilities } from '../roles/finders.js';
6
7
  import { expandProfiles, followFinder } from './helpers.js';
@@ -10,9 +11,13 @@ import { listGroups } from '../groups/index.js';
10
11
  import { getProfile, getProfileByHandle } from './cache.js';
11
12
  export const findProfile = (profileId) => getProfile(profileId);
12
13
  export const findProfileByHandle = (handle) => getProfileByHandle(handle);
14
+ export { findProfileByHandleAndDomain, findProfileByUri, } from '../federation/profiles.js';
13
15
  export const existsProfileByHandle = (handle) => getProfileByHandle(handle, true).then(Boolean);
14
- export const listProfiles = () => allpeepDb()
15
- .then(({ db }) => baseProfilesMapping.filter(profileFilters.notGuest()).all(db))
16
+ export const listProfiles = (viewer) => allpeepDb()
17
+ .then(({ db }) => baseProfilesMapping
18
+ .filter(profileFilters.notGuest())
19
+ .filter(profileFilters.notIdIn(blockedPairIds(viewer)))
20
+ .all(db))
16
21
  .then(expandProfiles);
17
22
  export const listProfilesByRole = (role) => allpeepDb()
18
23
  .then(({ db }) => rolesMapping.relationsFrom(role, profileRoleRelation).all(db))
@@ -22,18 +27,20 @@ export const listProfilesByAccount = (account) => allpeepDb()
22
27
  .then(expandProfiles);
23
28
  export const listProfilesWithCapabilities = async (capabilities) => findRolesByCapabilities(capabilities)
24
29
  .then((roles) => Promise.all(roles.map((role) => listProfilesByRole(role))))
25
- .then((pp) => pp.flat());
30
+ .then((pp) => getUniqueBy(pp.flat(), (p) => p.id));
26
31
  export const follows = (follower, followed) => allpeepDb().then(({ db }) => followFinder(db, follower, followed).then(Boolean));
27
32
  export const listGroupMembers = (group) => allpeepDb()
28
33
  .then(({ db }) => groupsMapping.relationsFrom(group, membersRelation).all(db))
29
34
  .then((members) => Promise.all(members
30
- .filter((m) => { var _a; return (_a = m.profile) === null || _a === void 0 ? void 0 : _a.id; })
31
- .map(async (m) => (Object.assign(Object.assign({}, m), { profile: (await getProfile(m.profile.id)) })))))
35
+ .filter((m) => m.profile?.id)
36
+ .map(async (m) => ({
37
+ ...m,
38
+ profile: (await getProfile(m.profile.id)),
39
+ }))))
32
40
  .then((members) => members.filter((m) => !!m.profile));
33
41
  export const listCommonGroups = async (profile1, profile2) => {
34
- var _a, _b;
35
42
  const groups = await listGroups({ profile: profile1, scopes: [] });
36
- const profile1GroupIds = new Set(((_a = profile1.memberships) === null || _a === void 0 ? void 0 : _a.map((m) => m.group.id)) || []);
37
- const profile2GroupIds = new Set(((_b = profile2.memberships) === null || _b === void 0 ? void 0 : _b.map((m) => m.group.id)) || []);
43
+ const profile1GroupIds = new Set(profile1.memberships?.map((m) => m.group.id) || []);
44
+ const profile2GroupIds = new Set(profile2.memberships?.map((m) => m.group.id) || []);
38
45
  return groups.filter((group) => profile1GroupIds.has(group.id) && profile2GroupIds.has(group.id));
39
46
  };
@@ -1,11 +1,13 @@
1
1
  import { Profile, ProfileWithMeta, Role } from '@openpeepshq/common/types';
2
2
  export declare const followConnector: (db: import("../db").PgDb, from: Profile, to: Profile, data?: {
3
+ uri?: string | undefined;
3
4
  reblogs?: boolean | undefined;
4
5
  notify?: boolean | undefined;
5
6
  languages?: string[] | undefined;
6
7
  } & {
7
8
  id?: string;
8
9
  }) => Promise<import("../db/pg/map").WithId<{
10
+ uri?: string | undefined;
9
11
  reblogs?: boolean | undefined;
10
12
  notify?: boolean | undefined;
11
13
  languages?: string[] | undefined;
@@ -2,5 +2,7 @@ export * from './mapping';
2
2
  export * from './mutations';
3
3
  export * from './finders';
4
4
  export * from './export';
5
+ export { getProfileActivitySummary, getAdminProfileSummary, } from './activitySummary';
5
6
  export { getProfile, getPublicProfile, getProfiles, clearProfileCache, } from './cache';
7
+ export { areBlocked, hasBlockAmong, loadBlockIds, listBlockingIds, } from './blocks';
6
8
  export declare const findNewFreeHandle: (seed: string) => Promise<string>;
@@ -3,7 +3,9 @@ export * from './mapping.js';
3
3
  export * from './mutations.js';
4
4
  export * from './finders.js';
5
5
  export * from './export.js';
6
+ export { getProfileActivitySummary, getAdminProfileSummary, } from './activitySummary.js';
6
7
  export { getProfile, getPublicProfile, getProfiles, clearProfileCache, } from './cache.js';
8
+ export { areBlocked, hasBlockAmong, loadBlockIds, listBlockingIds, } from './blocks.js';
7
9
  const sanitizeHandle = (name) => name.replace(/[^a-zA-Z0-9]/g, '-');
8
10
  export const findNewFreeHandle = async (seed) => {
9
11
  let counter = 2;