@openpeepshq/core 0.1.34 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accessTokens/finders.js +5 -6
- package/dist/accessTokens/mutations.js +1 -1
- package/dist/accessTokens/tokens.js +8 -11
- package/dist/accounts/helpers.js +6 -2
- package/dist/accounts/mutations.js +13 -8
- package/dist/analytics/cache.js +3 -3
- package/dist/analytics/clicks.js +14 -22
- package/dist/analytics/compile.js +1 -2
- package/dist/analytics/dateRange.js +3 -5
- package/dist/analytics/jobs.js +3 -4
- package/dist/analytics/pdfReport.js +45 -61
- package/dist/analytics/privacy.js +1 -1
- package/dist/analytics/read.js +116 -135
- package/dist/analytics/report.d.ts +2 -1
- package/dist/analytics/report.js +2 -3
- package/dist/analytics/settings.js +3 -4
- package/dist/backups/index.js +13 -16
- package/dist/backups/metadata.js +1 -1
- package/dist/config/db.js +2 -4
- package/dist/config/defaults/community.js +1 -0
- package/dist/config/defaults/core.js +13 -8
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +9 -11
- package/dist/db/explorer/query.js +9 -8
- package/dist/db/explorer/sql.js +8 -8
- package/dist/db/helpers.js +15 -5
- package/dist/db/migration/importCollections.js +15 -18
- package/dist/db/migration/shared.js +15 -35
- package/dist/db/pg/client.js +4 -7
- package/dist/db/pg/filters/index.js +1 -1
- package/dist/db/pg/filters/posts.d.ts +2 -0
- package/dist/db/pg/filters/posts.js +2 -0
- package/dist/db/pg/helpers.js +2 -14
- package/dist/db/pg/map/filters.js +8 -8
- package/dist/db/pg/map/helpers.js +5 -1
- package/dist/db/pg/map/index.js +46 -51
- package/dist/db/pg/map/mutations.js +56 -21
- package/dist/db/pg/map/registry.js +87 -50
- package/dist/db/pg/map/relations.js +67 -63
- package/dist/db/pg/map/search.js +15 -37
- package/dist/db/pg/mappers.js +13 -7
- package/dist/db/pg/migrate.js +2 -3
- package/dist/db/pg/queries/activity.js +2 -2
- package/dist/db/pg/queries/derived.js +8 -12
- package/dist/db/pg/schema/documents.js +119 -18
- package/dist/db/pg/schema/edges.js +7 -1
- package/dist/db/pg/schema/index.js +5 -1
- package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
- package/dist/db/pg/sql/meta/_journal.json +8 -1
- package/dist/db/replaceOrigin.js +1 -1
- package/dist/email/queueStats.js +8 -11
- package/dist/email/render.js +7 -4
- package/dist/email/send.js +19 -17
- package/dist/email/smtpTest.js +10 -6
- package/dist/errors/index.js +1 -1
- package/dist/events/once.js +2 -4
- package/dist/federation/activities.js +1 -2
- package/dist/groups/helpers.js +1 -2
- package/dist/groups/mutations.js +1 -1
- package/dist/hashtags/finders.js +2 -2
- package/dist/inviteLinks/mutations.js +2 -3
- package/dist/jams/export.js +5 -7
- package/dist/jams/finders.js +4 -1
- package/dist/jams/health.d.ts +6 -4
- package/dist/jams/health.js +15 -11
- package/dist/jams/helpers.js +6 -2
- package/dist/jams/index.js +2 -2
- package/dist/jams/jobs.js +1 -2
- package/dist/jams/livekit.js +8 -8
- package/dist/jams/recording.js +1 -1
- package/dist/jams/token.js +13 -17
- package/dist/jobs/index.js +7 -6
- package/dist/jobs/jobDetail.js +5 -6
- package/dist/jobs/jobLog.js +2 -3
- package/dist/lib/streams.js +4 -39
- package/dist/lib/zodDeepPartial.d.ts +1 -1
- package/dist/lib/zodDeepPartial.js +1 -1
- package/dist/log/index.js +13 -29
- package/dist/media/index.js +50 -4
- package/dist/media/jobs.js +1 -2
- package/dist/media/openpeeps/index.js +11 -46
- package/dist/media/processing.js +7 -4
- package/dist/media/streaming.js +5 -5
- package/dist/media/streamingCleanupJobs.js +1 -2
- package/dist/media/streamingJobs.js +3 -4
- package/dist/media/streamingPrewarm.js +7 -11
- package/dist/mediaAttachments/index.js +6 -2
- package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
- package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
- package/dist/notifications/defaultNotifications/follow/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
- package/dist/notifications/defaultNotifications/jamModerator/index.js +3 -5
- package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
- package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
- package/dist/notifications/defaultNotifications/mention/index.js +20 -24
- package/dist/notifications/defaultNotifications/newGroupPost/index.js +6 -7
- package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
- package/dist/notifications/defaultNotifications/pollEnded/index.js +21 -21
- package/dist/notifications/defaultNotifications/pollEnded/recipients.js +2 -3
- package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
- package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
- package/dist/notifications/defaultNotifications/reply/index.js +21 -22
- package/dist/notifications/defaultNotifications/repost/index.js +16 -20
- package/dist/notifications/defaultNotifications/rsvp/index.js +24 -18
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +20 -13
- package/dist/notifications/fcmCredential.js +1 -1
- package/dist/notifications/finders.js +1 -1
- package/dist/notifications/helpers.js +13 -10
- package/dist/notifications/jobs.js +10 -7
- package/dist/notifications/mutations.js +4 -1
- package/dist/notifications/push.js +11 -16
- package/dist/performance/index.js +3 -3
- package/dist/plugins/helpers.js +3 -6
- package/dist/plugins/index.js +2 -3
- package/dist/plugins/install.js +31 -17
- package/dist/plugins/pluginAuth.js +3 -4
- package/dist/plugins/state.js +2 -3
- package/dist/posts/activity.js +1 -2
- package/dist/posts/contextClosure.js +1 -2
- package/dist/posts/conversationQueries.js +2 -4
- package/dist/posts/eventAgenda.js +8 -5
- package/dist/posts/eventOccurrences.js +2 -2
- package/dist/posts/finders.d.ts +42 -2
- package/dist/posts/finders.js +21 -9
- package/dist/posts/helpers/filters.js +2 -3
- package/dist/posts/helpers/index.d.ts +152 -0
- package/dist/posts/helpers/index.js +43 -27
- package/dist/posts/mapping.d.ts +546 -14
- package/dist/posts/mapping.js +60 -18
- package/dist/posts/mutations.d.ts +76 -0
- package/dist/posts/mutations.js +46 -31
- package/dist/posts/pollEnd.js +3 -6
- package/dist/posts/rsvpConfirmationEmail.js +18 -8
- package/dist/posts/threadPreview.js +1 -1
- package/dist/processingStats/queries.js +6 -7
- package/dist/profileSettings/cache.js +1 -2
- package/dist/profiles/activitySummary.js +23 -28
- package/dist/profiles/cache.js +15 -8
- package/dist/profiles/export.js +30 -39
- package/dist/profiles/finders.js +7 -5
- package/dist/profiles/mutations.js +3 -5
- package/dist/redis/connection.js +1 -1
- package/dist/reports/helpers.js +7 -3
- package/dist/roles/mutations.js +20 -21
- package/dist/search/finders.js +15 -3
- package/dist/search/helpers.js +1 -1
- package/dist/sentry/index.js +9 -11
- package/dist/seo/index.d.ts +50 -0
- package/dist/seo/index.js +145 -0
- package/dist/seo/route.d.ts +18 -0
- package/dist/seo/route.js +19 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +16 -11
- package/dist/server/status.js +6 -7
- package/dist/session/index.js +2 -2
- package/dist/stats/finders.js +13 -4
- package/dist/stats/helpers.js +4 -1
- package/dist/stats/mapping.d.ts +39 -1
- package/dist/stats/mapping.js +9 -2
- package/dist/stripe/cache.js +5 -6
- package/dist/stripe/connection.js +3 -4
- package/dist/stripe/helpers.js +15 -20
- package/package.json +5 -6
|
@@ -1,26 +1,85 @@
|
|
|
1
1
|
import { boolean, index, jsonb, pgTable, text, timestamp, uniqueIndex, uuid, } from 'drizzle-orm/pg-core';
|
|
2
2
|
import { sql } from 'drizzle-orm';
|
|
3
3
|
import { idColumn, modelTimestamps, tsvector } from './base.js';
|
|
4
|
-
export const configs = pgTable('configs',
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export const configs = pgTable('configs', {
|
|
5
|
+
key: text('key').primaryKey(),
|
|
6
|
+
body: jsonb('body').notNull(),
|
|
7
|
+
...modelTimestamps,
|
|
8
|
+
});
|
|
9
|
+
export const i18nEntries = pgTable('i18n', {
|
|
10
|
+
id: idColumn(),
|
|
11
|
+
locale: text('locale').notNull(),
|
|
12
|
+
namespace: text('namespace').notNull(),
|
|
13
|
+
body: jsonb('body').notNull(),
|
|
14
|
+
...modelTimestamps,
|
|
15
|
+
}, (t) => [uniqueIndex('i18n_locale_namespace').on(t.locale, t.namespace)]);
|
|
16
|
+
export const accounts = pgTable('accounts', {
|
|
17
|
+
id: idColumn(),
|
|
18
|
+
email: text('email').notNull(),
|
|
19
|
+
passwordHash: text('password_hash').notNull(),
|
|
20
|
+
emailValidated: boolean('email_validated').notNull().default(false),
|
|
21
|
+
guest: boolean('guest'),
|
|
22
|
+
...modelTimestamps,
|
|
23
|
+
}, (t) => [uniqueIndex('accounts_email_unique').on(t.email)]);
|
|
24
|
+
export const profiles = pgTable('profiles', {
|
|
25
|
+
id: idColumn(),
|
|
26
|
+
handle: text('handle').notNull(),
|
|
27
|
+
activityPubDomain: text('activity_pub_domain'),
|
|
28
|
+
type: text('type').notNull(),
|
|
29
|
+
uri: text('uri'),
|
|
30
|
+
inboxUrl: text('inbox_url'),
|
|
31
|
+
sharedInboxUrl: text('shared_inbox_url'),
|
|
32
|
+
publicKeyPem: text('public_key_pem'),
|
|
33
|
+
privateKeyPem: text('private_key_pem'),
|
|
34
|
+
keyId: text('key_id'),
|
|
35
|
+
fetchedAt: timestamp('fetched_at', { withTimezone: true, mode: 'string' }),
|
|
36
|
+
body: jsonb('body').notNull().default({}),
|
|
37
|
+
searchVector: tsvector('search_vector'),
|
|
38
|
+
...modelTimestamps,
|
|
39
|
+
}, (t) => [
|
|
8
40
|
uniqueIndex('profiles_handle_domain_unique').on(t.handle, t.activityPubDomain),
|
|
9
41
|
uniqueIndex('profiles_uri_unique').on(t.uri),
|
|
10
42
|
index('profiles_search_vector_idx').using('gin', t.searchVector),
|
|
11
43
|
]);
|
|
12
|
-
export const roles = pgTable('roles',
|
|
13
|
-
|
|
14
|
-
|
|
44
|
+
export const roles = pgTable('roles', {
|
|
45
|
+
id: idColumn(),
|
|
46
|
+
key: text('key').notNull(),
|
|
47
|
+
isDefault: boolean('is_default').notNull().default(false),
|
|
48
|
+
body: jsonb('body').notNull().default({}),
|
|
49
|
+
...modelTimestamps,
|
|
50
|
+
}, (t) => [uniqueIndex('roles_key_unique').on(t.key)]);
|
|
51
|
+
export const hashtags = pgTable('hashtags', {
|
|
52
|
+
id: idColumn(),
|
|
53
|
+
name: text('name').notNull(),
|
|
54
|
+
...modelTimestamps,
|
|
55
|
+
}, (t) => [uniqueIndex('hashtags_name_unique').on(t.name)]);
|
|
56
|
+
export const groups = pgTable('groups', {
|
|
57
|
+
id: idColumn(),
|
|
58
|
+
handle: text('handle').notNull(),
|
|
59
|
+
body: jsonb('body').notNull().default({}),
|
|
60
|
+
searchVector: tsvector('search_vector'),
|
|
61
|
+
...modelTimestamps,
|
|
62
|
+
}, (t) => [
|
|
15
63
|
uniqueIndex('groups_handle_unique').on(t.handle),
|
|
16
64
|
index('groups_search_vector_idx').using('gin', t.searchVector),
|
|
17
65
|
]);
|
|
18
|
-
export const posts = pgTable('posts',
|
|
66
|
+
export const posts = pgTable('posts', {
|
|
67
|
+
id: idColumn(),
|
|
68
|
+
type: text('type').notNull(),
|
|
69
|
+
visibility: text('visibility').notNull(),
|
|
70
|
+
creatorId: text('creator_id').notNull(),
|
|
71
|
+
uri: text('uri'),
|
|
72
|
+
inReplyToUri: text('in_reply_to_uri'),
|
|
73
|
+
body: jsonb('body').notNull().default({}),
|
|
74
|
+
searchVector: tsvector('search_vector'),
|
|
75
|
+
lastActivityAt: timestamp('last_activity_at', {
|
|
19
76
|
withTimezone: true,
|
|
20
77
|
mode: 'string',
|
|
21
78
|
})
|
|
22
79
|
.notNull()
|
|
23
|
-
.default(sql `now()`)
|
|
80
|
+
.default(sql `now()`),
|
|
81
|
+
...modelTimestamps,
|
|
82
|
+
}, (t) => [
|
|
24
83
|
index('posts_type_idx').on(t.type),
|
|
25
84
|
index('posts_visibility_idx').on(t.visibility),
|
|
26
85
|
index('posts_creator_idx').on(t.creatorId),
|
|
@@ -29,18 +88,60 @@ export const posts = pgTable('posts', Object.assign({ id: idColumn(), type: text
|
|
|
29
88
|
index('posts_search_vector_idx').using('gin', t.searchVector),
|
|
30
89
|
index('posts_last_activity_id_idx').on(t.lastActivityAt, t.id),
|
|
31
90
|
]);
|
|
32
|
-
export const notifications = pgTable('notifications',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export const
|
|
39
|
-
|
|
91
|
+
export const notifications = pgTable('notifications', {
|
|
92
|
+
id: idColumn(),
|
|
93
|
+
profileId: text('profile_id').notNull(),
|
|
94
|
+
body: jsonb('body').notNull().default({}),
|
|
95
|
+
...modelTimestamps,
|
|
96
|
+
}, (t) => [index('notifications_profile_idx').on(t.profileId)]);
|
|
97
|
+
export const reports = pgTable('reports', {
|
|
98
|
+
id: idColumn(),
|
|
99
|
+
body: jsonb('body').notNull().default({}),
|
|
100
|
+
...modelTimestamps,
|
|
101
|
+
});
|
|
102
|
+
export const accessTokens = pgTable('access_tokens', {
|
|
103
|
+
id: idColumn(),
|
|
104
|
+
body: jsonb('body').notNull().default({}),
|
|
105
|
+
...modelTimestamps,
|
|
106
|
+
});
|
|
107
|
+
export const pushSubscriptions = pgTable('push_subscriptions', {
|
|
108
|
+
id: idColumn(),
|
|
109
|
+
body: jsonb('body').notNull().default({}),
|
|
110
|
+
...modelTimestamps,
|
|
111
|
+
});
|
|
112
|
+
export const inviteLinks = pgTable('invite_links', {
|
|
113
|
+
id: idColumn(),
|
|
114
|
+
slug: text('slug').notNull(),
|
|
115
|
+
body: jsonb('body').notNull().default({}),
|
|
116
|
+
...modelTimestamps,
|
|
117
|
+
}, (t) => [uniqueIndex('invite_links_slug_unique').on(t.slug)]);
|
|
118
|
+
export const jamEvents = pgTable('jam_events', {
|
|
119
|
+
id: idColumn(),
|
|
120
|
+
postId: text('post_id').notNull(),
|
|
121
|
+
body: jsonb('body').notNull().default({}),
|
|
122
|
+
...modelTimestamps,
|
|
123
|
+
}, (t) => [index('jam_events_post_idx').on(t.postId)]);
|
|
124
|
+
export const mediaAttachments = pgTable('media_attachments', {
|
|
125
|
+
id: idColumn(),
|
|
126
|
+
body: jsonb('body').notNull().default({}),
|
|
127
|
+
...modelTimestamps,
|
|
128
|
+
});
|
|
129
|
+
export const processingStats = pgTable('processing_stats', {
|
|
130
|
+
id: idColumn(),
|
|
131
|
+
filetype: text('filetype').notNull(),
|
|
132
|
+
filesize: text('filesize').notNull(),
|
|
133
|
+
body: jsonb('body').notNull().default({}),
|
|
134
|
+
...modelTimestamps,
|
|
135
|
+
}, (t) => [
|
|
40
136
|
index('processing_stats_filetype_idx').on(t.filetype),
|
|
41
137
|
index('processing_stats_filetype_size_idx').on(t.filetype, t.filesize),
|
|
42
138
|
]);
|
|
43
|
-
export const profileSettings = pgTable('profile_settings',
|
|
139
|
+
export const profileSettings = pgTable('profile_settings', {
|
|
140
|
+
id: idColumn(),
|
|
141
|
+
profileId: text('profile_id').notNull(),
|
|
142
|
+
body: jsonb('body').notNull().default({}),
|
|
143
|
+
...modelTimestamps,
|
|
144
|
+
}, (t) => [uniqueIndex('profile_settings_profile_unique').on(t.profileId)]);
|
|
44
145
|
export const eventOccurrences = pgTable('event_occurrences', {
|
|
45
146
|
id: idColumn(),
|
|
46
147
|
postId: uuid('post_id').notNull(),
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { index, jsonb, pgTable, text, uniqueIndex } from 'drizzle-orm/pg-core';
|
|
2
2
|
import { edgeTimestamps, idColumn } from './base.js';
|
|
3
|
-
const edgeTable = (name, uniqueFromTo = false) => pgTable(name,
|
|
3
|
+
const edgeTable = (name, uniqueFromTo = false) => pgTable(name, {
|
|
4
|
+
id: idColumn(),
|
|
5
|
+
fromId: text('from_id').notNull(),
|
|
6
|
+
toId: text('to_id').notNull(),
|
|
7
|
+
body: jsonb('body').default({}),
|
|
8
|
+
...edgeTimestamps,
|
|
9
|
+
}, (t) => [
|
|
4
10
|
index(`${name}_from_idx`).on(t.fromId),
|
|
5
11
|
index(`${name}_to_idx`).on(t.toId),
|
|
6
12
|
...(uniqueFromTo
|
|
@@ -4,4 +4,8 @@ export * from './analytics.js';
|
|
|
4
4
|
import * as documents from './documents.js';
|
|
5
5
|
import * as edges from './edges.js';
|
|
6
6
|
import * as analytics from './analytics.js';
|
|
7
|
-
export const schema =
|
|
7
|
+
export const schema = {
|
|
8
|
+
...documents,
|
|
9
|
+
...edges,
|
|
10
|
+
...analytics,
|
|
11
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
CREATE OR REPLACE FUNCTION openpeeps_posts_search_vector(p_body jsonb) RETURNS tsvector
|
|
2
|
+
LANGUAGE sql
|
|
3
|
+
STABLE
|
|
4
|
+
AS $$
|
|
5
|
+
SELECT to_tsvector('english', trim(
|
|
6
|
+
coalesce(p_body->>'content', '') || ' ' ||
|
|
7
|
+
coalesce(p_body->>'title', '') || ' ' ||
|
|
8
|
+
coalesce(p_body->>'name', '') || ' ' ||
|
|
9
|
+
coalesce(p_body->'physicalLocation'->>'text', '') || ' ' ||
|
|
10
|
+
coalesce(p_body->>'url', '') || ' ' ||
|
|
11
|
+
coalesce((
|
|
12
|
+
SELECT string_agg(tag, ' ')
|
|
13
|
+
FROM jsonb_array_elements_text(
|
|
14
|
+
CASE
|
|
15
|
+
WHEN jsonb_typeof(p_body->'tags') = 'array' THEN p_body->'tags'
|
|
16
|
+
ELSE '[]'::jsonb
|
|
17
|
+
END
|
|
18
|
+
) AS tag
|
|
19
|
+
), '') || ' ' ||
|
|
20
|
+
coalesce((
|
|
21
|
+
SELECT string_agg(segment, ' ')
|
|
22
|
+
FROM jsonb_array_elements_text(
|
|
23
|
+
CASE
|
|
24
|
+
WHEN jsonb_typeof(p_body->'categoryPath') = 'array'
|
|
25
|
+
THEN p_body->'categoryPath'
|
|
26
|
+
ELSE '[]'::jsonb
|
|
27
|
+
END
|
|
28
|
+
) AS segment
|
|
29
|
+
), '') || ' ' ||
|
|
30
|
+
coalesce((
|
|
31
|
+
SELECT string_agg(o->>'content', ' ')
|
|
32
|
+
FROM jsonb_array_elements(
|
|
33
|
+
CASE
|
|
34
|
+
WHEN jsonb_typeof(p_body->'options') = 'array' THEN p_body->'options'
|
|
35
|
+
ELSE '[]'::jsonb
|
|
36
|
+
END
|
|
37
|
+
) AS o
|
|
38
|
+
), '') || ' ' ||
|
|
39
|
+
coalesce((
|
|
40
|
+
SELECT string_agg(
|
|
41
|
+
coalesce(a->>'description', '') || ' ' || coalesce(a->>'filename', ''),
|
|
42
|
+
' '
|
|
43
|
+
)
|
|
44
|
+
FROM jsonb_array_elements(
|
|
45
|
+
CASE
|
|
46
|
+
WHEN jsonb_typeof(p_body->'attachments') = 'array' THEN p_body->'attachments'
|
|
47
|
+
ELSE '[]'::jsonb
|
|
48
|
+
END
|
|
49
|
+
) AS a
|
|
50
|
+
), '')
|
|
51
|
+
));
|
|
52
|
+
$$;
|
|
53
|
+
--> statement-breakpoint
|
|
54
|
+
UPDATE "posts" SET "search_vector" = openpeeps_posts_search_vector("body");
|
|
@@ -113,6 +113,13 @@
|
|
|
113
113
|
"when": 1790593758508,
|
|
114
114
|
"tag": "0015_profile_hashtags",
|
|
115
115
|
"breakpoints": true
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"idx": 16,
|
|
119
|
+
"version": "7",
|
|
120
|
+
"when": 1791620000000,
|
|
121
|
+
"tag": "0016_posts_search_vector_title_tags_path",
|
|
122
|
+
"breakpoints": true
|
|
116
123
|
}
|
|
117
124
|
]
|
|
118
|
-
}
|
|
125
|
+
}
|
package/dist/db/replaceOrigin.js
CHANGED
package/dist/email/queueStats.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SEND_EMAIL_QUEUE_NAME, sendEmailQueue } from './jobs.js';
|
|
2
|
-
const n = (record, key) =>
|
|
2
|
+
const n = (record, key) => record[key] ?? 0;
|
|
3
3
|
export const getSendEmailQueueStats = async () => {
|
|
4
4
|
const queue = sendEmailQueue();
|
|
5
5
|
const raw = await queue.getJobCounts();
|
|
@@ -13,15 +13,12 @@ export const getSendEmailQueueStats = async () => {
|
|
|
13
13
|
delayed: n(raw, 'delayed'),
|
|
14
14
|
prioritized: n(raw, 'prioritized'),
|
|
15
15
|
},
|
|
16
|
-
recentFailures: failedJobs.map((j) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
finishedOn: (_c = j.finishedOn) !== null && _c !== void 0 ? _c : null,
|
|
24
|
-
});
|
|
25
|
-
}),
|
|
16
|
+
recentFailures: failedJobs.map((j) => ({
|
|
17
|
+
queue: SEND_EMAIL_QUEUE_NAME,
|
|
18
|
+
id: j.id ?? null,
|
|
19
|
+
name: j.name,
|
|
20
|
+
failedReason: j.failedReason ?? '',
|
|
21
|
+
finishedOn: j.finishedOn ?? null,
|
|
22
|
+
})),
|
|
26
23
|
};
|
|
27
24
|
};
|
package/dist/email/render.js
CHANGED
|
@@ -5,11 +5,10 @@ import { registeredTemplates } from './registry.js';
|
|
|
5
5
|
import { serverRootUrl } from '../server/index.js';
|
|
6
6
|
import { initI18nEmailContext } from '../i18n/index.js';
|
|
7
7
|
const localTimeZone = (locals) => {
|
|
8
|
-
const value = locals
|
|
8
|
+
const value = locals?.timeZone;
|
|
9
9
|
return typeof value === 'string' ? value : undefined;
|
|
10
10
|
};
|
|
11
11
|
const globals = async (locals) => {
|
|
12
|
-
var _a;
|
|
13
12
|
const serverConfig = await config();
|
|
14
13
|
const rootUrl = await serverRootUrl();
|
|
15
14
|
const community = await communityConfig();
|
|
@@ -21,7 +20,7 @@ const globals = async (locals) => {
|
|
|
21
20
|
androidUrl: serverConfig.apps.android.url,
|
|
22
21
|
},
|
|
23
22
|
i18nContext: await initI18nEmailContext(),
|
|
24
|
-
timeZone: resolveTimeZone(localTimeZone(locals),
|
|
23
|
+
timeZone: resolveTimeZone(localTimeZone(locals), community.settings?.defaultTimeZone, FALLBACK_TIME_ZONE),
|
|
25
24
|
};
|
|
26
25
|
};
|
|
27
26
|
export const render = async (emailData) => {
|
|
@@ -30,7 +29,11 @@ export const render = async (emailData) => {
|
|
|
30
29
|
if (!render) {
|
|
31
30
|
throw Error(`No renderer registered for ${emailData.template}`);
|
|
32
31
|
}
|
|
33
|
-
const { html, subject } = await render(
|
|
32
|
+
const { html, subject } = await render({
|
|
33
|
+
...emailData,
|
|
34
|
+
globals: await globals(locals),
|
|
35
|
+
locals: locals || {},
|
|
36
|
+
});
|
|
34
37
|
const text = convert(html);
|
|
35
38
|
return {
|
|
36
39
|
to: emailData.to,
|
package/dist/email/send.js
CHANGED
|
@@ -10,16 +10,15 @@ const logStep = async (log, message) => {
|
|
|
10
10
|
serverLog.info(message);
|
|
11
11
|
};
|
|
12
12
|
const formatTransportSummary = (transportConfig) => {
|
|
13
|
-
var _a;
|
|
14
13
|
if (!transportConfig)
|
|
15
14
|
return '(no transport config)';
|
|
16
15
|
const { host, port, secure, auth } = transportConfig;
|
|
17
16
|
return JSON.stringify({
|
|
18
|
-
host: host
|
|
19
|
-
port: port
|
|
20
|
-
secure: secure
|
|
21
|
-
authUser:
|
|
22
|
-
authPass:
|
|
17
|
+
host: host ?? null,
|
|
18
|
+
port: port ?? null,
|
|
19
|
+
secure: secure ?? null,
|
|
20
|
+
authUser: auth?.user ?? null,
|
|
21
|
+
authPass: auth?.pass ? '[set]' : auth ? '[empty]' : null,
|
|
23
22
|
});
|
|
24
23
|
};
|
|
25
24
|
const formatErrorDetail = (err) => {
|
|
@@ -48,11 +47,10 @@ const logFailure = async (log, err) => {
|
|
|
48
47
|
}
|
|
49
48
|
};
|
|
50
49
|
export const sendEmail = async (emailData, coreConfig, options) => {
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
const localKeys = Object.keys((_a = emailData.locals) !== null && _a !== void 0 ? _a : {});
|
|
50
|
+
const log = options?.log;
|
|
51
|
+
const localKeys = Object.keys(emailData.locals ?? {});
|
|
54
52
|
await logStep(log, `Template "${emailData.template}" → ${emailData.to}${localKeys.length ? ` (locals: ${localKeys.join(', ')})` : ''}`);
|
|
55
|
-
await logStep(log, `defaultFrom=${
|
|
53
|
+
await logStep(log, `defaultFrom=${coreConfig.email.defaultFrom ?? '(unset)'}`);
|
|
56
54
|
await logStep(log, `SMTP transport: ${formatTransportSummary(coreConfig.email.transportConfig)}`);
|
|
57
55
|
let renderedEmail;
|
|
58
56
|
await logStep(log, 'Render in-process (worker templates)');
|
|
@@ -72,11 +70,16 @@ export const sendEmail = async (emailData, coreConfig, options) => {
|
|
|
72
70
|
}
|
|
73
71
|
const emailTransport = nodemailer.createTransport(coreConfig.email.transportConfig);
|
|
74
72
|
try {
|
|
75
|
-
const result = await emailTransport.sendMail(
|
|
76
|
-
|
|
77
|
-
:
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
const result = await emailTransport.sendMail({
|
|
74
|
+
from,
|
|
75
|
+
replyTo: communityConf.info.contactEmail,
|
|
76
|
+
...renderedEmail,
|
|
77
|
+
...(emailData.attachments?.length
|
|
78
|
+
? { attachments: emailData.attachments }
|
|
79
|
+
: {}),
|
|
80
|
+
});
|
|
81
|
+
await logStep(log, `SMTP accepted message (messageId: ${result.messageId ?? 'n/a'}, response: ${result.response ?? 'n/a'})`);
|
|
82
|
+
if (result.rejected?.length) {
|
|
80
83
|
await logStep(log, `SMTP rejected recipients: ${result.rejected.join(', ')}`);
|
|
81
84
|
}
|
|
82
85
|
return result;
|
|
@@ -87,10 +90,9 @@ export const sendEmail = async (emailData, coreConfig, options) => {
|
|
|
87
90
|
}
|
|
88
91
|
};
|
|
89
92
|
export const send = async (job) => {
|
|
90
|
-
var _a;
|
|
91
93
|
const log = (message) => job.log(message).then(() => undefined);
|
|
92
94
|
const attempt = job.attemptsMade + 1;
|
|
93
|
-
await logStep(log, `Job ${job.id} started (attempt ${attempt}/${
|
|
95
|
+
await logStep(log, `Job ${job.id} started (attempt ${attempt}/${job.opts.attempts ?? 1}, name="${job.name}")`);
|
|
94
96
|
const coreConfig = await config();
|
|
95
97
|
await logStep(log, 'Loaded core config');
|
|
96
98
|
return sendEmail(job.data, coreConfig, { log });
|
package/dist/email/smtpTest.js
CHANGED
|
@@ -3,24 +3,28 @@ import { passwordPlaceHolder } from '@openpeepshq/common/types';
|
|
|
3
3
|
import { config } from '../config/index.js';
|
|
4
4
|
import { sendEmail } from './send.js';
|
|
5
5
|
const mergeEmailForTest = (base, override) => {
|
|
6
|
-
var _a, _b, _c;
|
|
7
6
|
if (!override) {
|
|
8
7
|
return base;
|
|
9
8
|
}
|
|
10
9
|
const merged = deepmerge(base, override);
|
|
11
|
-
const pass =
|
|
10
|
+
const pass = override.transportConfig?.auth?.pass;
|
|
12
11
|
if (pass === undefined || pass === '' || pass === passwordPlaceHolder) {
|
|
13
|
-
merged.transportConfig =
|
|
12
|
+
merged.transportConfig = {
|
|
13
|
+
...merged.transportConfig,
|
|
14
|
+
auth: {
|
|
15
|
+
...merged.transportConfig.auth,
|
|
16
|
+
pass: base.transportConfig.auth?.pass,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
14
19
|
}
|
|
15
20
|
return merged;
|
|
16
21
|
};
|
|
17
22
|
export const sendSmtpTestEmail = async (input) => {
|
|
18
|
-
var _a;
|
|
19
23
|
const saved = await config();
|
|
20
24
|
const emailSettings = mergeEmailForTest(saved.email, input.email);
|
|
21
|
-
if (!
|
|
25
|
+
if (!emailSettings.defaultFrom?.trim()) {
|
|
22
26
|
throw new Error('defaultFrom is required to send mail');
|
|
23
27
|
}
|
|
24
|
-
const draftConfig =
|
|
28
|
+
const draftConfig = { ...saved, email: emailSettings };
|
|
25
29
|
await sendEmail({ to: input.to, template: 'test' }, draftConfig);
|
|
26
30
|
};
|
package/dist/errors/index.js
CHANGED
|
@@ -10,4 +10,4 @@ export const notFound = ({ errorKey = 'notFound', parameters, }) => allPeepError
|
|
|
10
10
|
export const conflict = ({ errorKey = 'conflict', parameters, }) => allPeepError({ code: 409, errorKey, parameters });
|
|
11
11
|
export const unprocessableRequest = ({ errorKey = 'unprocessableRequest', parameters, }) => allPeepError({ code: 422, errorKey, parameters });
|
|
12
12
|
export const internalError = ({ errorKey = 'internalError', parameters, }) => allPeepError({ code: 500, errorKey, parameters });
|
|
13
|
-
export const isOpenpeepsError = (o) => o
|
|
13
|
+
export const isOpenpeepsError = (o) => o?.__allPeepError__;
|
package/dist/events/once.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { queueAndWorker } from '../jobs/index.js';
|
|
2
2
|
export const registeredHandlers = new Map();
|
|
3
3
|
export const registerOnceHandler = (qualifiedEventType, handler) => {
|
|
4
|
-
var _a;
|
|
5
4
|
if (registeredHandlers.has(qualifiedEventType)) {
|
|
6
|
-
|
|
5
|
+
registeredHandlers.get(qualifiedEventType)?.push(handler);
|
|
7
6
|
}
|
|
8
7
|
else {
|
|
9
8
|
registeredHandlers.set(qualifiedEventType, [handler]);
|
|
10
9
|
}
|
|
11
10
|
};
|
|
12
11
|
const [onceQueue, onceWorker] = queueAndWorker('once', async (job) => {
|
|
13
|
-
var _a;
|
|
14
12
|
const event = job.name;
|
|
15
13
|
const args = job.data;
|
|
16
|
-
return Promise.all((
|
|
14
|
+
return Promise.all((registeredHandlers.get(event) ?? []).map((handler) => handler(...args)));
|
|
17
15
|
}, {
|
|
18
16
|
defaultJobOptions: {
|
|
19
17
|
removeOnComplete: { age: 3600 }, // Remove successful tasks after 1 hour
|
|
@@ -2,7 +2,6 @@ import { eq } from 'drizzle-orm';
|
|
|
2
2
|
import { pgDb } from '../db/pg/client.js';
|
|
3
3
|
import { apActivities } from '../db/pg/schema/documents.js';
|
|
4
4
|
export const recordApActivity = async (activity) => {
|
|
5
|
-
var _a;
|
|
6
5
|
const db = pgDb();
|
|
7
6
|
await db
|
|
8
7
|
.insert(apActivities)
|
|
@@ -10,7 +9,7 @@ export const recordApActivity = async (activity) => {
|
|
|
10
9
|
uri: activity.uri,
|
|
11
10
|
type: activity.type,
|
|
12
11
|
actorUri: activity.actorUri,
|
|
13
|
-
objectUri:
|
|
12
|
+
objectUri: activity.objectUri ?? null,
|
|
14
13
|
direction: activity.direction,
|
|
15
14
|
})
|
|
16
15
|
.onConflictDoNothing();
|
package/dist/groups/helpers.js
CHANGED
|
@@ -6,8 +6,7 @@ export const addMember = connector(collectionInfos.profilesCollection, collectio
|
|
|
6
6
|
export const removeMember = disconnector(collectionInfos.profilesCollection, collectionInfos.groupsCollection, collectionInfos.userGroupsCollection);
|
|
7
7
|
export const updateMember = connectionUpdater(collectionInfos.profilesCollection, collectionInfos.groupsCollection, collectionInfos.userGroupsCollection);
|
|
8
8
|
export const canSeeGroupFilter = (profile) => {
|
|
9
|
-
|
|
10
|
-
if (checkRoleCapabilities((_a = profile === null || profile === void 0 ? void 0 : profile.roles) !== null && _a !== void 0 ? _a : [], ['core-groups-read']).success) {
|
|
9
|
+
if (checkRoleCapabilities(profile?.roles ?? [], ['core-groups-read']).success) {
|
|
11
10
|
return undefined;
|
|
12
11
|
}
|
|
13
12
|
if (!profile || !isLocal(profile)) {
|
package/dist/groups/mutations.js
CHANGED
|
@@ -13,7 +13,7 @@ export const createGroup = async (groupData, profile, members = []) => {
|
|
|
13
13
|
roles: ['owner'],
|
|
14
14
|
});
|
|
15
15
|
profilesCache.del(profile.id);
|
|
16
|
-
const filteredMembers = members
|
|
16
|
+
const filteredMembers = members?.filter((member) => member.id !== profile.id);
|
|
17
17
|
const uniqueMembers = filteredMembers
|
|
18
18
|
? Array.from(new Set(filteredMembers.map((m) => m.id))).map((id) => filteredMembers.find((m) => m.id === id))
|
|
19
19
|
: [];
|
package/dist/hashtags/finders.js
CHANGED
|
@@ -20,5 +20,5 @@ export const findOrCreateHashtag = async (tag) => {
|
|
|
20
20
|
}
|
|
21
21
|
return hashtagsMapping.create(db, { tag: normalizedTag });
|
|
22
22
|
};
|
|
23
|
-
export const listFollowedHashtags = (profile) =>
|
|
24
|
-
export const isFollowingHashtag = (profile, hashtag) =>
|
|
23
|
+
export const listFollowedHashtags = (profile) => profile.followedHashtags ?? [];
|
|
24
|
+
export const isFollowingHashtag = (profile, hashtag) => profile.followedHashtags?.some((h) => h.id === hashtag.id) ?? false;
|
|
@@ -18,12 +18,11 @@ export const updateInviteLink = async (id, inviteLinkData) => {
|
|
|
18
18
|
return inviteLinksMapping.update(db, id, inviteLinkData);
|
|
19
19
|
};
|
|
20
20
|
export const redeemInviteLink = async (inviteLink, profile) => {
|
|
21
|
-
|
|
22
|
-
if (((_a = inviteLink.profile) === null || _a === void 0 ? void 0 : _a.id) === profile.id) {
|
|
21
|
+
if (inviteLink.profile?.id === profile.id) {
|
|
23
22
|
throw new Error('Invite link creator and redeemer cannot be the same');
|
|
24
23
|
}
|
|
25
24
|
await allpeepDb().then(({ db }) => redeemInviteLinkConnector(db, profile, inviteLink));
|
|
26
|
-
const groupIds = [...new Set(
|
|
25
|
+
const groupIds = [...new Set(inviteLink.groupIds ?? [])];
|
|
27
26
|
const adder = inviteLink.profile;
|
|
28
27
|
for (const groupId of groupIds) {
|
|
29
28
|
const group = await findGroup(groupId);
|
package/dist/jams/export.js
CHANGED
|
@@ -12,14 +12,13 @@ export const jamAttendanceExportHeaders = [
|
|
|
12
12
|
'Joined At',
|
|
13
13
|
];
|
|
14
14
|
export const jamAttendanceRowFromJoin = (join, profile) => {
|
|
15
|
-
|
|
16
|
-
const isPublic = (profile === null || profile === void 0 ? void 0 : profile.type) === 'guest';
|
|
15
|
+
const isPublic = profile?.type === 'guest';
|
|
17
16
|
return {
|
|
18
17
|
kind: profile ? (isPublic ? 'public' : 'community') : '',
|
|
19
|
-
name:
|
|
18
|
+
name: profile?.displayName || (isPublic ? '' : (profile?.handle ?? '')),
|
|
20
19
|
// Community emails aren't here: several accounts can control one profile.
|
|
21
|
-
email: isPublic ? (
|
|
22
|
-
handle: isPublic ? '' : (
|
|
20
|
+
email: isPublic ? (profile?.guestData?.email ?? '') : '',
|
|
21
|
+
handle: isPublic ? '' : (profile?.handle ?? ''),
|
|
23
22
|
joinedAt: join.createdAt,
|
|
24
23
|
};
|
|
25
24
|
};
|
|
@@ -38,8 +37,7 @@ const listJamJoinEvents = async (jamId) => {
|
|
|
38
37
|
.where(and(eq(jamEvents.postId, jamId), isNull(jamEvents.deletedAt), sql `${jamEvents.body}->>'type' = 'join'`))
|
|
39
38
|
.orderBy(asc(jamEvents.createdAt), asc(jamEvents.id));
|
|
40
39
|
return rows.flatMap((row) => {
|
|
41
|
-
|
|
42
|
-
const profileId = (_a = row.body) === null || _a === void 0 ? void 0 : _a.profileId;
|
|
40
|
+
const profileId = row.body?.profileId;
|
|
43
41
|
if (typeof profileId !== 'string' || !profileId) {
|
|
44
42
|
return [];
|
|
45
43
|
}
|
package/dist/jams/finders.js
CHANGED
|
@@ -10,7 +10,10 @@ export const listJamEvents = (jamId, { start, limit } = {}) => allpeepDb().then(
|
|
|
10
10
|
export const listAttendance = (jamId, { start, limit } = {}) => allpeepDb().then(({ db }) => baseListJam({ jamId, type: 'join' }, { start, limit }).all(db));
|
|
11
11
|
export const findJamState = async (jam, hideParticipants, recurrenceId) => {
|
|
12
12
|
const state = await getJamState(jam, recurrenceId);
|
|
13
|
-
return
|
|
13
|
+
return {
|
|
14
|
+
...state,
|
|
15
|
+
participants: hideParticipants ? [] : state.participants,
|
|
16
|
+
};
|
|
14
17
|
};
|
|
15
18
|
export const findJamRecording = async (recordingId) => allpeepDb()
|
|
16
19
|
.then(({ db }) => jamRecordingsMapping.find(db, recordingId))
|
package/dist/jams/health.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export declare const LIVEKIT_HEALTH_TIMEOUT_MS =
|
|
1
|
+
export declare const LIVEKIT_HEALTH_TIMEOUT_MS = 5000;
|
|
2
|
+
export declare const LIVEKIT_HEALTH_MAX_ATTEMPTS = 3;
|
|
2
3
|
/**
|
|
3
|
-
* True when a LiveKit RoomService call succeeds
|
|
4
|
-
*
|
|
4
|
+
* True when a LiveKit RoomService call succeeds within maxAttempts. Retries so a
|
|
5
|
+
* single transient failure does not disable jams for a full /server/info bucket.
|
|
6
|
+
* Credentials in config are not enough — invalid keys fail on first RPC.
|
|
5
7
|
*/
|
|
6
|
-
export declare const probeLivekitConnection: (listRooms: () => Promise<unknown>, timeoutMs?: number) => Promise<boolean>;
|
|
8
|
+
export declare const probeLivekitConnection: (listRooms: () => Promise<unknown>, timeoutMs?: number, maxAttempts?: number) => Promise<boolean>;
|
|
7
9
|
/** Cached LiveKit reachability. False when unset, unauthorized, or unreachable. */
|
|
8
10
|
export declare const isLivekitConnected: () => Promise<boolean>;
|