@openpeepshq/core 0.1.34 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accessTokens/finders.js +5 -6
- package/dist/accessTokens/mutations.js +1 -1
- package/dist/accessTokens/tokens.js +8 -11
- package/dist/accounts/helpers.js +6 -2
- package/dist/accounts/mutations.js +13 -8
- package/dist/analytics/cache.js +3 -3
- package/dist/analytics/clicks.js +14 -22
- package/dist/analytics/compile.js +1 -2
- package/dist/analytics/dateRange.js +3 -5
- package/dist/analytics/jobs.js +3 -4
- package/dist/analytics/pdfReport.js +45 -61
- package/dist/analytics/privacy.js +1 -1
- package/dist/analytics/read.js +116 -135
- package/dist/analytics/report.d.ts +2 -1
- package/dist/analytics/report.js +2 -3
- package/dist/analytics/settings.js +3 -4
- package/dist/backups/index.js +13 -16
- package/dist/backups/metadata.js +1 -1
- package/dist/config/db.js +2 -4
- package/dist/config/defaults/community.js +1 -0
- package/dist/config/defaults/core.js +13 -8
- package/dist/config/defaults/logs.d.ts +4 -0
- package/dist/config/defaults/logs.js +5 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.js +9 -11
- package/dist/db/explorer/query.js +9 -8
- package/dist/db/explorer/sql.js +8 -8
- package/dist/db/helpers.js +15 -5
- package/dist/db/migration/importCollections.js +15 -18
- package/dist/db/migration/shared.js +15 -35
- package/dist/db/pg/client.js +4 -7
- package/dist/db/pg/filters/index.js +1 -1
- package/dist/db/pg/filters/posts.d.ts +2 -0
- package/dist/db/pg/filters/posts.js +3 -1
- package/dist/db/pg/helpers.js +2 -14
- package/dist/db/pg/map/filters.js +8 -8
- package/dist/db/pg/map/helpers.js +5 -1
- package/dist/db/pg/map/index.js +46 -51
- package/dist/db/pg/map/mutations.js +56 -21
- package/dist/db/pg/map/registry.js +87 -50
- package/dist/db/pg/map/relations.js +67 -63
- package/dist/db/pg/map/search.js +15 -37
- package/dist/db/pg/mappers.js +13 -7
- package/dist/db/pg/migrate.js +2 -3
- package/dist/db/pg/queries/activity.js +2 -2
- package/dist/db/pg/queries/derived.js +8 -12
- package/dist/db/pg/schema/documents.js +119 -18
- package/dist/db/pg/schema/edges.js +7 -1
- package/dist/db/pg/schema/index.js +5 -1
- package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
- package/dist/db/pg/sql/meta/_journal.json +8 -1
- package/dist/db/replaceOrigin.js +1 -1
- package/dist/email/queueStats.js +8 -11
- package/dist/email/render.js +7 -4
- package/dist/email/send.js +19 -17
- package/dist/email/smtpTest.js +10 -6
- package/dist/errors/index.js +1 -1
- package/dist/events/once.js +2 -4
- package/dist/federation/activities.js +1 -2
- package/dist/groups/finders.d.ts +2 -2
- package/dist/groups/helpers.d.ts +6 -6
- package/dist/groups/helpers.js +1 -2
- package/dist/groups/mapping.d.ts +4 -4
- package/dist/groups/mutations.js +1 -1
- package/dist/hashtags/finders.js +2 -2
- package/dist/inviteLinks/mutations.js +2 -3
- package/dist/jams/export.js +5 -7
- package/dist/jams/finders.js +4 -1
- package/dist/jams/health.d.ts +6 -4
- package/dist/jams/health.js +15 -11
- package/dist/jams/helpers.d.ts +2 -2
- package/dist/jams/helpers.js +6 -2
- package/dist/jams/index.js +2 -2
- package/dist/jams/jobs.js +1 -2
- package/dist/jams/livekit.d.ts +2 -2
- package/dist/jams/livekit.js +8 -8
- package/dist/jams/mapping.d.ts +10 -10
- package/dist/jams/mutations.d.ts +2 -2
- package/dist/jams/recording.js +1 -1
- package/dist/jams/token.js +13 -17
- package/dist/jobs/index.js +7 -6
- package/dist/jobs/jobDetail.js +5 -6
- package/dist/jobs/jobLog.js +2 -3
- package/dist/lib/streams.js +4 -39
- package/dist/lib/zodDeepPartial.d.ts +1 -1
- package/dist/lib/zodDeepPartial.js +1 -1
- package/dist/log/index.d.ts +1 -0
- package/dist/log/index.js +14 -29
- package/dist/log/retention.d.ts +9 -0
- package/dist/log/retention.js +83 -0
- package/dist/log/retentionJobs.d.ts +17 -0
- package/dist/log/retentionJobs.js +50 -0
- package/dist/media/index.js +127 -4
- package/dist/media/jobs.js +1 -2
- package/dist/media/openpeeps/index.js +11 -46
- package/dist/media/processing.js +7 -4
- package/dist/media/streaming.js +5 -5
- package/dist/media/streamingCleanupJobs.js +1 -2
- package/dist/media/streamingJobs.js +3 -4
- package/dist/media/streamingPrewarm.js +7 -11
- package/dist/mediaAttachments/index.js +6 -2
- package/dist/mediaAttachments/mapping.d.ts +1 -1
- package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
- package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
- package/dist/notifications/defaultNotifications/follow/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
- package/dist/notifications/defaultNotifications/jamModerator/index.js +27 -20
- package/dist/notifications/defaultNotifications/jamModerator/recipients.d.ts +2 -0
- package/dist/notifications/defaultNotifications/jamModerator/recipients.js +5 -0
- 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 +9 -10
- package/dist/notifications/defaultNotifications/newGroupPost/recipients.d.ts +5 -0
- package/dist/notifications/defaultNotifications/newGroupPost/recipients.js +23 -0
- package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
- package/dist/notifications/defaultNotifications/pollEnded/index.js +21 -21
- package/dist/notifications/defaultNotifications/pollEnded/recipients.js +2 -3
- package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
- package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
- package/dist/notifications/defaultNotifications/reply/index.js +21 -22
- package/dist/notifications/defaultNotifications/repost/index.js +16 -20
- package/dist/notifications/defaultNotifications/rsvp/index.js +24 -18
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +20 -13
- package/dist/notifications/eventIcsAttachment.d.ts +6 -0
- package/dist/notifications/eventIcsAttachment.js +32 -0
- package/dist/notifications/fcmCredential.js +1 -1
- package/dist/notifications/finders.js +1 -1
- package/dist/notifications/helpers.d.ts +11 -1
- package/dist/notifications/helpers.js +38 -9
- package/dist/notifications/jobs.js +16 -7
- package/dist/notifications/mutations.js +13 -2
- package/dist/notifications/push.js +11 -16
- package/dist/performance/index.js +3 -3
- package/dist/plugins/helpers.js +3 -6
- package/dist/plugins/index.js +2 -3
- package/dist/plugins/install.js +31 -17
- package/dist/plugins/pluginAuth.js +3 -4
- package/dist/plugins/state.js +2 -3
- package/dist/posts/activity.d.ts +1 -1
- package/dist/posts/activity.js +2 -3
- package/dist/posts/contextClosure.js +1 -2
- package/dist/posts/conversationQueries.js +2 -4
- package/dist/posts/eventAgenda.js +12 -7
- package/dist/posts/eventOccurrences.js +2 -2
- package/dist/posts/finders.d.ts +46 -6
- package/dist/posts/finders.js +21 -9
- package/dist/posts/helpers/filters.js +2 -3
- package/dist/posts/helpers/index.d.ts +170 -18
- package/dist/posts/helpers/index.js +43 -27
- package/dist/posts/mapping.d.ts +616 -84
- package/dist/posts/mapping.js +60 -18
- package/dist/posts/mutations.d.ts +85 -9
- package/dist/posts/mutations.js +47 -34
- package/dist/posts/pollEnd.js +3 -6
- package/dist/posts/rsvpConfirmationEmail.js +18 -8
- package/dist/posts/threadPreview.js +1 -1
- package/dist/processingStats/queries.js +6 -7
- package/dist/profileSettings/cache.js +1 -2
- package/dist/profileSettings/mapping.d.ts +1 -0
- package/dist/profiles/activitySummary.js +23 -28
- package/dist/profiles/cache.js +15 -8
- package/dist/profiles/export.js +30 -39
- package/dist/profiles/finders.js +7 -5
- package/dist/profiles/mapping.d.ts +10 -10
- package/dist/profiles/mutations.js +3 -5
- package/dist/redis/connection.js +1 -1
- package/dist/reports/helpers.js +7 -3
- package/dist/reports/mapping.d.ts +1 -1
- package/dist/roles/mutations.js +20 -21
- package/dist/search/finders.js +15 -3
- package/dist/search/helpers.js +1 -1
- package/dist/sentry/index.js +9 -11
- package/dist/seo/index.d.ts +50 -0
- package/dist/seo/index.js +145 -0
- package/dist/seo/route.d.ts +18 -0
- package/dist/seo/route.js +19 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +16 -11
- package/dist/server/status.js +6 -7
- package/dist/session/index.js +2 -2
- package/dist/stats/finders.js +13 -4
- package/dist/stats/helpers.js +4 -1
- package/dist/stats/mapping.d.ts +43 -5
- package/dist/stats/mapping.js +9 -2
- package/dist/stripe/cache.js +5 -6
- package/dist/stripe/connection.js +3 -4
- package/dist/stripe/helpers.js +15 -20
- package/package.json +5 -6
- package/LICENSE +0 -674
|
@@ -8,7 +8,7 @@ import { listBlockedByIds } from './blocks.js';
|
|
|
8
8
|
import { findProfile } from './finders.js';
|
|
9
9
|
import { listReportsByReportedProfile } from '../reports/finders.js';
|
|
10
10
|
import { profileActivityCountsSql, profileTopPostScoresSql, takeTopReadablePosts, } from './activityQueries.js';
|
|
11
|
-
const sqlRows = (result) =>
|
|
11
|
+
const sqlRows = (result) => result.rows ?? [];
|
|
12
12
|
const loadPostsByIds = async (db, ids, authData) => {
|
|
13
13
|
if (ids.length === 0)
|
|
14
14
|
return [];
|
|
@@ -24,46 +24,41 @@ const loadPostsByIds = async (db, ids, authData) => {
|
|
|
24
24
|
.filter((post) => !!post);
|
|
25
25
|
};
|
|
26
26
|
export const getProfileActivitySummary = async (authData, profileId) => {
|
|
27
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
28
27
|
const { db } = await allpeepDb();
|
|
29
28
|
const [countRow] = sqlRows(await db.execute(profileActivityCountsSql(profileId)));
|
|
30
29
|
const scored = sqlRows(await db.execute(profileTopPostScoresSql(profileId)))
|
|
31
|
-
.map((row) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
activityScore: Number((_b = row.activity_score) !== null && _b !== void 0 ? _b : 0),
|
|
36
|
-
});
|
|
37
|
-
})
|
|
30
|
+
.map((row) => ({
|
|
31
|
+
id: String(row.id ?? ''),
|
|
32
|
+
activityScore: Number(row.activity_score ?? 0),
|
|
33
|
+
}))
|
|
38
34
|
.filter((row) => row.id);
|
|
39
35
|
const scoreById = new Map(scored.map((row) => [row.id, row.activityScore]));
|
|
40
36
|
const loaded = await loadPostsByIds(db, scored.map((row) => row.id), authData);
|
|
41
37
|
const config = await capabilitiesConfig();
|
|
42
38
|
const readable = canReadPost(config, authData);
|
|
43
39
|
const topPosts = takeTopReadablePosts(loaded, readable)
|
|
44
|
-
.map((post) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
40
|
+
.map((post) => publicPostWithActivityScoreSchema.safeParse({
|
|
41
|
+
...post,
|
|
42
|
+
activityScore: scoreById.get(post.id) ?? 0,
|
|
43
|
+
}))
|
|
48
44
|
.filter((result) => result.success)
|
|
49
45
|
.map((result) => result.data);
|
|
50
46
|
return profileActivitySummarySchema.parse({
|
|
51
|
-
postsCount: Number(
|
|
52
|
-
repliesCount: Number(
|
|
53
|
-
eventsCount: Number(
|
|
54
|
-
reactionsGiven: Number(
|
|
55
|
-
reactionsReceived: Number(
|
|
56
|
-
repostsCount: Number(
|
|
57
|
-
repostsReceived: Number(
|
|
58
|
-
repliesReceived: Number(
|
|
59
|
-
rsvpsCount: Number(
|
|
60
|
-
bookmarksCount: Number(
|
|
61
|
-
groupsCount: Number(
|
|
47
|
+
postsCount: Number(countRow?.posts_count ?? 0),
|
|
48
|
+
repliesCount: Number(countRow?.replies_count ?? 0),
|
|
49
|
+
eventsCount: Number(countRow?.events_count ?? 0),
|
|
50
|
+
reactionsGiven: Number(countRow?.reactions_given ?? 0),
|
|
51
|
+
reactionsReceived: Number(countRow?.reactions_received ?? 0),
|
|
52
|
+
repostsCount: Number(countRow?.reposts_count ?? 0),
|
|
53
|
+
repostsReceived: Number(countRow?.reposts_received ?? 0),
|
|
54
|
+
repliesReceived: Number(countRow?.replies_received ?? 0),
|
|
55
|
+
rsvpsCount: Number(countRow?.rsvps_count ?? 0),
|
|
56
|
+
bookmarksCount: Number(countRow?.bookmarks_count ?? 0),
|
|
57
|
+
groupsCount: Number(countRow?.groups_count ?? 0),
|
|
62
58
|
topPosts,
|
|
63
59
|
});
|
|
64
60
|
};
|
|
65
61
|
export const getAdminProfileSummary = async (authData, profileId) => {
|
|
66
|
-
var _a, _b, _c, _d, _e, _f;
|
|
67
62
|
const profile = await findProfile(profileId);
|
|
68
63
|
if (!profile) {
|
|
69
64
|
throw new Error(`Profile with id ${profileId} not found`);
|
|
@@ -78,9 +73,9 @@ export const getAdminProfileSummary = async (authData, profileId) => {
|
|
|
78
73
|
profile: publicProfileSchema.parse(profile),
|
|
79
74
|
activity,
|
|
80
75
|
createdAt: profile.createdAt,
|
|
81
|
-
email:
|
|
82
|
-
followersCount:
|
|
83
|
-
followingCount:
|
|
76
|
+
email: profile.controllers?.[0]?.email,
|
|
77
|
+
followersCount: profile.profileStats?.followersCount ?? 0,
|
|
78
|
+
followingCount: profile.profileStats?.followingCount ?? 0,
|
|
84
79
|
reportsCount: reports.length,
|
|
85
80
|
blockedByCount: blockedByIds.length,
|
|
86
81
|
});
|
package/dist/profiles/cache.js
CHANGED
|
@@ -18,19 +18,26 @@ export const clearProfileCache = async (profile) => {
|
|
|
18
18
|
publicProfilesCache.del(`all:${profile.id}`),
|
|
19
19
|
]);
|
|
20
20
|
};
|
|
21
|
-
const withEmptyFollowGraphs = (profile) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
});
|
|
28
35
|
const withBlockIds = async (profile) => {
|
|
29
36
|
if (!profile)
|
|
30
37
|
return undefined;
|
|
31
38
|
const { db } = await allpeepDb();
|
|
32
39
|
const { blockingIds, blockedByIds } = await loadBlockIds(db, profile.id);
|
|
33
|
-
return
|
|
40
|
+
return { ...profile, blockingIds, blockedByIds };
|
|
34
41
|
};
|
|
35
42
|
export const getProfile = async (id, ignoreSoftDelete = false) => profilesCache.wrap(id, () => allpeepDb()
|
|
36
43
|
.then(({ db }) => ignoreSoftDelete
|
package/dist/profiles/export.js
CHANGED
|
@@ -9,14 +9,11 @@ const emptyStats = () => ({
|
|
|
9
9
|
reactionsCount: 0,
|
|
10
10
|
lastSeen: null,
|
|
11
11
|
});
|
|
12
|
-
const toMemberExportStats = (row) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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
|
-
|
|
40
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
};
|
package/dist/profiles/finders.js
CHANGED
|
@@ -32,13 +32,15 @@ export const follows = (follower, followed) => allpeepDb().then(({ db }) => foll
|
|
|
32
32
|
export const listGroupMembers = (group) => allpeepDb()
|
|
33
33
|
.then(({ db }) => groupsMapping.relationsFrom(group, membersRelation).all(db))
|
|
34
34
|
.then((members) => Promise.all(members
|
|
35
|
-
.filter((m) =>
|
|
36
|
-
.map(async (m) => (
|
|
35
|
+
.filter((m) => m.profile?.id)
|
|
36
|
+
.map(async (m) => ({
|
|
37
|
+
...m,
|
|
38
|
+
profile: (await getProfile(m.profile.id)),
|
|
39
|
+
}))))
|
|
37
40
|
.then((members) => members.filter((m) => !!m.profile));
|
|
38
41
|
export const listCommonGroups = async (profile1, profile2) => {
|
|
39
|
-
var _a, _b;
|
|
40
42
|
const groups = await listGroups({ profile: profile1, scopes: [] });
|
|
41
|
-
const profile1GroupIds = new Set(
|
|
42
|
-
const profile2GroupIds = new Set(
|
|
43
|
+
const profile1GroupIds = new Set(profile1.memberships?.map((m) => m.group.id) || []);
|
|
44
|
+
const profile2GroupIds = new Set(profile2.memberships?.map((m) => m.group.id) || []);
|
|
43
45
|
return groups.filter((group) => profile1GroupIds.has(group.id) && profile2GroupIds.has(group.id));
|
|
44
46
|
};
|
|
@@ -5,7 +5,7 @@ export declare const baseProfileRelations: Relation[];
|
|
|
5
5
|
export declare const profileRelations: Relation[];
|
|
6
6
|
export declare const baseProfilesMapping: import("../db/pg/map").Mapping<{
|
|
7
7
|
handle: string;
|
|
8
|
-
type: "
|
|
8
|
+
type: "local" | "guest" | "federated";
|
|
9
9
|
deletedHandle?: string | undefined;
|
|
10
10
|
avatar?: string | null | undefined;
|
|
11
11
|
header?: string | null | undefined;
|
|
@@ -35,7 +35,7 @@ export declare const baseProfilesMapping: import("../db/pg/map").Mapping<{
|
|
|
35
35
|
guestData?: {
|
|
36
36
|
email?: string | undefined;
|
|
37
37
|
resource?: {
|
|
38
|
-
type: "
|
|
38
|
+
type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
|
|
39
39
|
id?: string | undefined;
|
|
40
40
|
} | undefined;
|
|
41
41
|
} | undefined;
|
|
@@ -44,7 +44,7 @@ export declare const baseProfilesMapping: import("../db/pg/map").Mapping<{
|
|
|
44
44
|
/** Lean mapping for public search results (memberships only). */
|
|
45
45
|
export declare const publicProfilesSearchMapping: import("../db/pg/map").Mapping<{
|
|
46
46
|
handle: string;
|
|
47
|
-
type: "
|
|
47
|
+
type: "local" | "guest" | "federated";
|
|
48
48
|
deletedHandle?: string | undefined;
|
|
49
49
|
avatar?: string | null | undefined;
|
|
50
50
|
header?: string | null | undefined;
|
|
@@ -74,7 +74,7 @@ export declare const publicProfilesSearchMapping: import("../db/pg/map").Mapping
|
|
|
74
74
|
guestData?: {
|
|
75
75
|
email?: string | undefined;
|
|
76
76
|
resource?: {
|
|
77
|
-
type: "
|
|
77
|
+
type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
|
|
78
78
|
id?: string | undefined;
|
|
79
79
|
} | undefined;
|
|
80
80
|
} | undefined;
|
|
@@ -86,7 +86,7 @@ export declare const publicProfilesSearchMapping: import("../db/pg/map").Mapping
|
|
|
86
86
|
*/
|
|
87
87
|
export declare const publicProfilesMapping: import("../db/pg/map").Mapping<{
|
|
88
88
|
handle: string;
|
|
89
|
-
type: "
|
|
89
|
+
type: "local" | "guest" | "federated";
|
|
90
90
|
deletedHandle?: string | undefined;
|
|
91
91
|
avatar?: string | null | undefined;
|
|
92
92
|
header?: string | null | undefined;
|
|
@@ -116,7 +116,7 @@ export declare const publicProfilesMapping: import("../db/pg/map").Mapping<{
|
|
|
116
116
|
guestData?: {
|
|
117
117
|
email?: string | undefined;
|
|
118
118
|
resource?: {
|
|
119
|
-
type: "
|
|
119
|
+
type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
|
|
120
120
|
id?: string | undefined;
|
|
121
121
|
} | undefined;
|
|
122
122
|
} | undefined;
|
|
@@ -124,7 +124,7 @@ export declare const publicProfilesMapping: import("../db/pg/map").Mapping<{
|
|
|
124
124
|
}, ProfileWithMeta, ProfileWithMeta>;
|
|
125
125
|
export declare const profilesMapping: import("../db/pg/map").Mapping<{
|
|
126
126
|
handle: string;
|
|
127
|
-
type: "
|
|
127
|
+
type: "local" | "guest" | "federated";
|
|
128
128
|
deletedHandle?: string | undefined;
|
|
129
129
|
avatar?: string | null | undefined;
|
|
130
130
|
header?: string | null | undefined;
|
|
@@ -154,7 +154,7 @@ export declare const profilesMapping: import("../db/pg/map").Mapping<{
|
|
|
154
154
|
guestData?: {
|
|
155
155
|
email?: string | undefined;
|
|
156
156
|
resource?: {
|
|
157
|
-
type: "
|
|
157
|
+
type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
|
|
158
158
|
id?: string | undefined;
|
|
159
159
|
} | undefined;
|
|
160
160
|
} | undefined;
|
|
@@ -162,7 +162,7 @@ export declare const profilesMapping: import("../db/pg/map").Mapping<{
|
|
|
162
162
|
}, ProfileWithMeta, ProfileWithMeta>;
|
|
163
163
|
export declare const membersExportMapping: import("../db/pg/map").Mapping<{
|
|
164
164
|
handle: string;
|
|
165
|
-
type: "
|
|
165
|
+
type: "local" | "guest" | "federated";
|
|
166
166
|
deletedHandle?: string | undefined;
|
|
167
167
|
avatar?: string | null | undefined;
|
|
168
168
|
header?: string | null | undefined;
|
|
@@ -192,7 +192,7 @@ export declare const membersExportMapping: import("../db/pg/map").Mapping<{
|
|
|
192
192
|
guestData?: {
|
|
193
193
|
email?: string | undefined;
|
|
194
194
|
resource?: {
|
|
195
|
-
type: "
|
|
195
|
+
type: "db" | "jams" | "profiles" | "self" | "*" | "notifications" | "posts" | "groups" | "reports" | "webhooks" | "analytics" | "render";
|
|
196
196
|
id?: string | undefined;
|
|
197
197
|
} | undefined;
|
|
198
198
|
} | undefined;
|
|
@@ -11,13 +11,12 @@ import { deleteBlock, dropFollowsBetween, insertBlock, listBlockingIds, } from '
|
|
|
11
11
|
import { localActorScalars } from '../federation/identity.js';
|
|
12
12
|
import { uuidv7 } from 'uuidv7';
|
|
13
13
|
export const createProfile = async (data, controllingAccount) => {
|
|
14
|
-
var _a;
|
|
15
14
|
await assertProfileCapacity();
|
|
16
15
|
const db = await allpeepDb().then((db) => db.db);
|
|
17
16
|
const id = uuidv7();
|
|
18
|
-
const domain =
|
|
17
|
+
const domain = data.activityPub?.domain;
|
|
19
18
|
const actor = data.type === 'local' && domain ? localActorScalars(id, domain) : {};
|
|
20
|
-
const profile = await profilesMapping.create(db,
|
|
19
|
+
const profile = await profilesMapping.create(db, { ...data, id, ...actor });
|
|
21
20
|
if (controllingAccount) {
|
|
22
21
|
await giveControl(db, controllingAccount, profile);
|
|
23
22
|
await accountsCache.del(controllingAccount.id);
|
|
@@ -50,11 +49,10 @@ export const pinPostOnProfile = async (profile, pinnedPostId) => {
|
|
|
50
49
|
return updated;
|
|
51
50
|
};
|
|
52
51
|
export const deleteProfile = async (profileId) => {
|
|
53
|
-
var _a, _b;
|
|
54
52
|
const db = await allpeepDb().then((db) => db.db);
|
|
55
53
|
const profileToDelete = await getProfile(profileId);
|
|
56
54
|
if (profileToDelete) {
|
|
57
|
-
await Promise.all(
|
|
55
|
+
await Promise.all(profileToDelete.controllers?.map((account) => accountsCache.del(account.id)) ?? []);
|
|
58
56
|
if (profileToDelete.following && profileToDelete.following.length > 0) {
|
|
59
57
|
await Promise.all(profileToDelete.following.map((followed) => profilesCache.del(followed.id)));
|
|
60
58
|
}
|
package/dist/redis/connection.js
CHANGED
package/dist/reports/helpers.js
CHANGED
|
@@ -3,9 +3,13 @@ import { collectionInfos } from '../db/index.js';
|
|
|
3
3
|
import { tombstoneProfileWithMetaIfDeleted } from '@openpeepshq/common/lib';
|
|
4
4
|
import { transformPost } from '../posts/index.js';
|
|
5
5
|
export const transformReport = async (report) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const rawPosts = (report.reportedPosts ?? []);
|
|
7
|
+
return {
|
|
8
|
+
...report,
|
|
9
|
+
reporterProfile: tombstoneProfileWithMetaIfDeleted(report.reporterProfile),
|
|
10
|
+
reportedProfile: tombstoneProfileWithMetaIfDeleted(report.reportedProfile),
|
|
11
|
+
reportedPosts: await Promise.all(rawPosts.map((post) => transformPost(post))),
|
|
12
|
+
};
|
|
9
13
|
};
|
|
10
14
|
export const transformReports = async (reports) => Promise.all(reports.map(transformReport));
|
|
11
15
|
export const createdReportConnector = connector(collectionInfos.profilesCollection, collectionInfos.reportsCollection, collectionInfos.createdReportCollection);
|
|
@@ -5,5 +5,5 @@ export declare const reportsMapping: import("../db/pg/map").Mapping<{
|
|
|
5
5
|
uri?: string | undefined;
|
|
6
6
|
forward?: boolean | undefined;
|
|
7
7
|
ruleIds?: number[] | undefined;
|
|
8
|
-
resolution?: "
|
|
8
|
+
resolution?: "remove" | "warn" | "ignore" | "other" | "ban" | undefined;
|
|
9
9
|
}, ReportWithMeta, ReportWithMeta>;
|
package/dist/roles/mutations.js
CHANGED
|
@@ -15,11 +15,8 @@ export const createRole = (roleData) => allpeepDb().then(async ({ db }) => {
|
|
|
15
15
|
}
|
|
16
16
|
return rolesMapping.create(db, roleData);
|
|
17
17
|
});
|
|
18
|
-
const capabilitiesMatchFactory = (capabilities, factoryRole) =>
|
|
19
|
-
|
|
20
|
-
return capabilitySetsEqual(capabilities === null || capabilities === void 0 ? void 0 : capabilities.add, (_a = factoryRole.capabilities) === null || _a === void 0 ? void 0 : _a.add) &&
|
|
21
|
-
capabilitySetsEqual(capabilities === null || capabilities === void 0 ? void 0 : capabilities.remove, (_b = factoryRole.capabilities) === null || _b === void 0 ? void 0 : _b.remove);
|
|
22
|
-
};
|
|
18
|
+
const capabilitiesMatchFactory = (capabilities, factoryRole) => capabilitySetsEqual(capabilities?.add, factoryRole.capabilities?.add) &&
|
|
19
|
+
capabilitySetsEqual(capabilities?.remove, factoryRole.capabilities?.remove);
|
|
23
20
|
/**
|
|
24
21
|
* Effective default flag for a write: an explicit `true` wins, and
|
|
25
22
|
* capabilities that exactly match the system defaults re-adopt the role as a
|
|
@@ -28,15 +25,18 @@ const capabilitiesMatchFactory = (capabilities, factoryRole) => {
|
|
|
28
25
|
* the current defaults version when the write does not set one explicitly.
|
|
29
26
|
*/
|
|
30
27
|
const withDefaultAdoption = (existingRole, roleData) => {
|
|
31
|
-
|
|
32
|
-
const factoryRole = defaultRoles.find((role) => { var _a; return role.key === ((_a = roleData.key) !== null && _a !== void 0 ? _a : existingRole === null || existingRole === void 0 ? void 0 : existingRole.key); });
|
|
28
|
+
const factoryRole = defaultRoles.find((role) => role.key === (roleData.key ?? existingRole?.key));
|
|
33
29
|
if (!factoryRole)
|
|
34
30
|
return roleData;
|
|
35
|
-
const matchesFactory = capabilitiesMatchFactory(
|
|
31
|
+
const matchesFactory = capabilitiesMatchFactory(roleData.capabilities ?? existingRole?.capabilities, factoryRole);
|
|
36
32
|
const isDefault = roleData.default === true || matchesFactory;
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
:
|
|
33
|
+
return {
|
|
34
|
+
...roleData,
|
|
35
|
+
default: isDefault,
|
|
36
|
+
...(matchesFactory && roleData.baseVersion === undefined
|
|
37
|
+
? { baseVersion: currentRoleDefaults.version }
|
|
38
|
+
: {}),
|
|
39
|
+
};
|
|
40
40
|
};
|
|
41
41
|
/**
|
|
42
42
|
* Applies the base→current delta of the system defaults to a capability
|
|
@@ -45,16 +45,16 @@ const withDefaultAdoption = (existingRole, roleData) => {
|
|
|
45
45
|
*/
|
|
46
46
|
const applyCapabilityDelta = (capabilities, base, current) => {
|
|
47
47
|
const delta = (list, from, to) => {
|
|
48
|
-
const removed = (from
|
|
49
|
-
const added = (to
|
|
48
|
+
const removed = (from ?? []).filter((c) => !(to ?? []).includes(c));
|
|
49
|
+
const added = (to ?? []).filter((c) => !(from ?? []).includes(c));
|
|
50
50
|
return [
|
|
51
|
-
...(list
|
|
52
|
-
...added.filter((c) => !(list
|
|
51
|
+
...(list ?? []).filter((c) => !removed.includes(c)),
|
|
52
|
+
...added.filter((c) => !(list ?? []).includes(c)),
|
|
53
53
|
];
|
|
54
54
|
};
|
|
55
55
|
return {
|
|
56
|
-
add: delta(capabilities
|
|
57
|
-
remove: delta(capabilities
|
|
56
|
+
add: delta(capabilities?.add, base?.add, current?.add),
|
|
57
|
+
remove: delta(capabilities?.remove, base?.remove, current?.remove),
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
@@ -64,17 +64,16 @@ const applyCapabilityDelta = (capabilities, base, current) => {
|
|
|
64
64
|
* role untouched — the anchor only moves when capabilities actually change.
|
|
65
65
|
*/
|
|
66
66
|
const rebaseRoleToCurrentDefaults = (existingRole, factoryRole) => {
|
|
67
|
-
var _a, _b, _c;
|
|
68
67
|
const baseVersion = existingRole.baseVersion;
|
|
69
68
|
if (!baseVersion || baseVersion === currentRoleDefaults.version) {
|
|
70
69
|
return null;
|
|
71
70
|
}
|
|
72
|
-
const baseRole =
|
|
71
|
+
const baseRole = findRoleDefaultsVersion(baseVersion)?.roles.find((role) => role.key === factoryRole.key);
|
|
73
72
|
if (!baseRole)
|
|
74
73
|
return null;
|
|
75
74
|
const capabilities = applyCapabilityDelta(existingRole.capabilities, baseRole.capabilities, factoryRole.capabilities);
|
|
76
|
-
const unchanged = capabilitySetsEqual(
|
|
77
|
-
capabilitySetsEqual(
|
|
75
|
+
const unchanged = capabilitySetsEqual(existingRole.capabilities?.add, capabilities.add) &&
|
|
76
|
+
capabilitySetsEqual(existingRole.capabilities?.remove, capabilities.remove);
|
|
78
77
|
if (unchanged)
|
|
79
78
|
return null;
|
|
80
79
|
return { capabilities, baseVersion: currentRoleDefaults.version };
|
package/dist/search/finders.js
CHANGED
|
@@ -36,15 +36,27 @@ export const searchPosts = async (query, authData, limitOffset = { offset: 0, li
|
|
|
36
36
|
const profile = requireProfile(authData);
|
|
37
37
|
const { db } = await allpeepDb();
|
|
38
38
|
const mapping = postSearchMapping(profile, query);
|
|
39
|
-
return filterAndTransform(mapping, db,
|
|
39
|
+
return filterAndTransform(mapping, db, {
|
|
40
|
+
transform: transformPostWithScore(profile),
|
|
41
|
+
filter: await canReadPostFilter(authData),
|
|
42
|
+
...limitOffset,
|
|
43
|
+
});
|
|
40
44
|
});
|
|
41
45
|
export const searchEvents = async (query, authData, limitOffset = { offset: 0, limit: 15 }) => {
|
|
42
46
|
const profile = requireProfile(authData);
|
|
43
|
-
return filterAndTransform(eventSearchMapping(profile, query), (await allpeepDb()).db,
|
|
47
|
+
return filterAndTransform(eventSearchMapping(profile, query), (await allpeepDb()).db, {
|
|
48
|
+
transform: transformPostWithScore(profile),
|
|
49
|
+
filter: await canReadPostFilter(authData),
|
|
50
|
+
...limitOffset,
|
|
51
|
+
});
|
|
44
52
|
};
|
|
45
53
|
export const searchJams = async (query, authData, limitOffset = { offset: 0, limit: 15 }) => {
|
|
46
54
|
const profile = requireProfile(authData);
|
|
47
|
-
return filterAndTransform(jamSearchMapping(profile, query), (await allpeepDb()).db,
|
|
55
|
+
return filterAndTransform(jamSearchMapping(profile, query), (await allpeepDb()).db, {
|
|
56
|
+
transform: transformPostWithScore(profile),
|
|
57
|
+
filter: await canReadPostFilter(authData),
|
|
58
|
+
...limitOffset,
|
|
59
|
+
});
|
|
48
60
|
};
|
|
49
61
|
export const searchResultCounts = async (query, authData) => {
|
|
50
62
|
const profile = requireProfile(authData);
|
package/dist/search/helpers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const queryParamsToLimit = (query) =>
|
|
1
|
+
export const queryParamsToLimit = (query) => query?.offset ? [query.offset, query?.limit ?? 15] : (query?.limit ?? 15);
|
package/dist/sentry/index.js
CHANGED
|
@@ -10,7 +10,6 @@ export const SERVICE_TAG = 'service';
|
|
|
10
10
|
* Strip scheme/port from `server.host` / `SERVER_HOST` for Sentry tags.
|
|
11
11
|
*/
|
|
12
12
|
export const normalizeServerHostname = (host) => {
|
|
13
|
-
var _a;
|
|
14
13
|
const trimmed = host.trim();
|
|
15
14
|
if (!trimmed)
|
|
16
15
|
return 'unknown';
|
|
@@ -18,8 +17,8 @@ export const normalizeServerHostname = (host) => {
|
|
|
18
17
|
const serverUrl = trimmed.includes('://') ? trimmed : `http://${trimmed}`;
|
|
19
18
|
return new URL(serverUrl).hostname || 'unknown';
|
|
20
19
|
}
|
|
21
|
-
catch
|
|
22
|
-
return
|
|
20
|
+
catch {
|
|
21
|
+
return trimmed.split('/')[0]?.split(':')[0] || 'unknown';
|
|
23
22
|
}
|
|
24
23
|
};
|
|
25
24
|
export const getCommunityHostname = () => communityHostname;
|
|
@@ -30,14 +29,13 @@ export const getSentryService = () => serviceName;
|
|
|
30
29
|
* — never fall back to `NODE_ENV` (Docker images always set that to production).
|
|
31
30
|
*/
|
|
32
31
|
export const resolveSentryEnvironment = (explicit) => {
|
|
33
|
-
|
|
34
|
-
const fromExplicit = explicit === null || explicit === void 0 ? void 0 : explicit.trim();
|
|
32
|
+
const fromExplicit = explicit?.trim();
|
|
35
33
|
if (fromExplicit)
|
|
36
34
|
return fromExplicit;
|
|
37
|
-
const fromSentryEnv =
|
|
35
|
+
const fromSentryEnv = process.env.SENTRY_ENVIRONMENT?.trim();
|
|
38
36
|
if (fromSentryEnv)
|
|
39
37
|
return fromSentryEnv;
|
|
40
|
-
const fromEnvironment =
|
|
38
|
+
const fromEnvironment = process.env.ENVIRONMENT?.trim();
|
|
41
39
|
if (fromEnvironment)
|
|
42
40
|
return fromEnvironment;
|
|
43
41
|
return 'local';
|
|
@@ -56,7 +54,6 @@ export const applyCommunitySentryTags = () => {
|
|
|
56
54
|
* Always records hostname/service for local diagnostics even when Sentry is off.
|
|
57
55
|
*/
|
|
58
56
|
export const initSentry = (options = {}) => {
|
|
59
|
-
var _a, _b, _c, _d;
|
|
60
57
|
if (options.hostname !== undefined) {
|
|
61
58
|
communityHostname = normalizeServerHostname(options.hostname);
|
|
62
59
|
}
|
|
@@ -76,8 +73,8 @@ export const initSentry = (options = {}) => {
|
|
|
76
73
|
}
|
|
77
74
|
return;
|
|
78
75
|
}
|
|
79
|
-
const dsn =
|
|
80
|
-
const enabled =
|
|
76
|
+
const dsn = options.dsn ?? process.env.SENTRY_DSN;
|
|
77
|
+
const enabled = options.enabled ?? (Boolean(dsn) && process.env.SENTRY_ENABLED !== '0');
|
|
81
78
|
if (!enabled || !dsn) {
|
|
82
79
|
log.info({
|
|
83
80
|
communityHostname,
|
|
@@ -86,7 +83,8 @@ export const initSentry = (options = {}) => {
|
|
|
86
83
|
initialized = true;
|
|
87
84
|
return;
|
|
88
85
|
}
|
|
89
|
-
const tracesSampleRate =
|
|
86
|
+
const tracesSampleRate = options.tracesSampleRate ??
|
|
87
|
+
Number(process.env.SENTRY_TRACES_SAMPLE_RATE ?? '0.1');
|
|
90
88
|
const environment = resolveSentryEnvironment(options.environment);
|
|
91
89
|
Sentry.init({
|
|
92
90
|
dsn,
|