@openpeepshq/core 0.1.33 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accessTokens/finders.js +5 -6
- package/dist/accessTokens/mutations.js +1 -1
- package/dist/accessTokens/tokens.js +8 -11
- package/dist/accounts/helpers.js +6 -2
- package/dist/accounts/mutations.js +36 -33
- package/dist/analytics/cache.js +3 -3
- package/dist/analytics/clicks.js +14 -22
- package/dist/analytics/compile.js +17 -12
- package/dist/analytics/dateRange.js +3 -5
- package/dist/analytics/jobs.js +3 -4
- package/dist/analytics/pdfReport.js +45 -61
- package/dist/analytics/privacy.js +1 -1
- package/dist/analytics/read.js +164 -140
- package/dist/analytics/report.d.ts +22 -1
- package/dist/analytics/report.js +2 -3
- package/dist/analytics/settings.js +3 -4
- package/dist/backups/index.js +82 -25
- package/dist/backups/metadata.d.ts +2 -3
- package/dist/backups/metadata.js +6 -2
- package/dist/config/db.js +2 -4
- package/dist/config/defaults/capabilities.js +13 -2
- package/dist/config/defaults/community.js +8 -3
- package/dist/config/defaults/core.d.ts +1 -1
- package/dist/config/defaults/core.js +16 -8
- package/dist/config/index.d.ts +22 -0
- package/dist/config/index.js +15 -11
- package/dist/db/explorer/query.js +9 -8
- package/dist/db/explorer/sql.js +8 -8
- package/dist/db/helpers.d.ts +1 -0
- package/dist/db/helpers.js +25 -7
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +1 -0
- package/dist/db/init.js +2 -3
- package/dist/db/migration/importCollections.d.ts +14 -9
- package/dist/db/migration/importCollections.js +121 -174
- package/dist/db/migration/shared.d.ts +2 -33
- package/dist/db/migration/shared.js +17 -87
- package/dist/db/pg/client.js +4 -7
- package/dist/db/pg/collections.d.ts +2 -2
- package/dist/db/pg/collections.js +2 -2
- package/dist/db/pg/filters/index.js +1 -1
- package/dist/db/pg/filters/posts.d.ts +12 -0
- package/dist/db/pg/filters/posts.js +30 -4
- package/dist/db/pg/filters/profiles.d.ts +1 -0
- package/dist/db/pg/filters/profiles.js +2 -1
- package/dist/db/pg/helpers.js +2 -14
- package/dist/db/pg/map/filters.js +40 -10
- package/dist/db/pg/map/helpers.js +5 -1
- package/dist/db/pg/map/index.js +46 -51
- package/dist/db/pg/map/mutations.js +65 -25
- package/dist/db/pg/map/registry.d.ts +5 -0
- package/dist/db/pg/map/registry.js +133 -56
- package/dist/db/pg/map/relations.js +76 -68
- package/dist/db/pg/map/search.js +15 -37
- package/dist/db/pg/mappers.js +13 -7
- package/dist/db/pg/migrate.d.ts +1 -2
- package/dist/db/pg/migrate.js +8 -9
- package/dist/db/pg/queries/activity.js +5 -5
- package/dist/db/pg/queries/derived.js +8 -12
- package/dist/db/pg/queries/sorts.d.ts +1 -0
- package/dist/db/pg/queries/sorts.js +4 -0
- package/dist/db/pg/schema/documents.d.ts +279 -41
- package/dist/db/pg/schema/documents.js +136 -22
- package/dist/db/pg/schema/edges.d.ts +116 -7
- package/dist/db/pg/schema/edges.js +9 -2
- package/dist/db/pg/schema/index.d.ts +362 -15
- package/dist/db/pg/schema/index.js +5 -1
- package/dist/db/pg/sql/0010_user_group_membership_roles.sql +16 -0
- package/dist/db/pg/sql/0011_drop_data_migrations.sql +1 -0
- package/dist/db/pg/sql/0012_posts_last_activity_at.sql +5 -0
- package/dist/db/pg/sql/0013_add_blocks_edge.sql +12 -0
- package/dist/db/pg/sql/0014_federation_datamodel.sql +59 -0
- package/dist/db/pg/sql/0015_profile_hashtags.sql +12 -0
- package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
- package/dist/db/pg/sql/meta/{0009_snapshot.json → 0015_snapshot.json} +291 -36
- package/dist/db/pg/sql/meta/_journal.json +49 -0
- package/dist/db/replaceOrigin.js +1 -1
- package/dist/email/queueStats.js +8 -11
- package/dist/email/render.js +14 -3
- package/dist/email/send.js +19 -17
- package/dist/email/smtpTest.js +10 -6
- package/dist/errors/index.js +1 -1
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.js +1 -0
- package/dist/events/once.js +2 -4
- package/dist/federation/activities.d.ts +17 -0
- package/dist/federation/activities.js +25 -0
- package/dist/federation/identity.d.ts +16 -0
- package/dist/federation/identity.js +52 -0
- package/dist/federation/index.d.ts +4 -0
- package/dist/federation/index.js +3 -0
- package/dist/federation/profiles.d.ts +3 -0
- package/dist/federation/profiles.js +14 -0
- package/dist/groups/finders.d.ts +2 -1
- package/dist/groups/helpers.d.ts +18 -0
- package/dist/groups/helpers.js +1 -2
- package/dist/groups/mapping.d.ts +4 -2
- package/dist/groups/mutations.js +1 -1
- package/dist/hashtags/finders.d.ts +6 -3
- package/dist/hashtags/finders.js +2 -0
- package/dist/hashtags/helpers.d.ts +8 -0
- package/dist/hashtags/helpers.js +4 -0
- package/dist/hashtags/index.d.ts +2 -0
- package/dist/hashtags/index.js +2 -0
- package/dist/hashtags/mutations.d.ts +3 -0
- package/dist/hashtags/mutations.js +13 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +3 -1
- package/dist/i18n/pluginLocales.d.ts +6 -0
- package/dist/i18n/pluginLocales.js +15 -0
- package/dist/inviteLinks/mutations.js +2 -3
- package/dist/jams/export.d.ts +19 -0
- package/dist/jams/export.js +58 -0
- package/dist/jams/finders.js +4 -1
- package/dist/jams/health.d.ts +10 -0
- package/dist/jams/health.js +50 -0
- package/dist/jams/helpers.d.ts +2 -2
- package/dist/jams/helpers.js +6 -2
- package/dist/jams/index.d.ts +2 -0
- package/dist/jams/index.js +25 -18
- package/dist/jams/jobs.js +2 -3
- package/dist/jams/livekit.d.ts +49 -4
- package/dist/jams/livekit.js +62 -45
- package/dist/jams/mapping.d.ts +3 -3
- package/dist/jams/mutations.d.ts +1 -1
- package/dist/jams/recording.d.ts +10 -0
- package/dist/jams/recording.js +33 -1
- package/dist/jams/token.d.ts +13 -1
- package/dist/jams/token.js +25 -18
- package/dist/jams/waitingRoom.js +1 -1
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.js +9 -3
- package/dist/jobs/jobDetail.js +6 -12
- package/dist/jobs/jobLog.js +2 -3
- package/dist/lib/streams.js +4 -39
- package/dist/lib/zodDeepPartial.d.ts +1 -1
- package/dist/lib/zodDeepPartial.js +1 -1
- package/dist/log/index.js +13 -29
- package/dist/media/index.d.ts +1 -1
- package/dist/media/index.js +73 -12
- package/dist/media/jobs.js +1 -2
- package/dist/media/openpeeps/index.js +11 -46
- package/dist/media/processing.js +25 -11
- package/dist/media/streaming.js +5 -5
- package/dist/media/streamingCleanupJobs.js +1 -2
- package/dist/media/streamingJobs.js +3 -4
- package/dist/media/streamingPrewarm.js +7 -11
- package/dist/mediaAttachments/index.js +6 -2
- package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
- package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
- package/dist/notifications/defaultNotifications/follow/index.js +15 -18
- package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
- package/dist/notifications/defaultNotifications/index.js +4 -0
- package/dist/notifications/defaultNotifications/jamModerator/index.js +3 -5
- package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
- package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
- package/dist/notifications/defaultNotifications/mention/index.js +20 -24
- package/dist/notifications/defaultNotifications/newGroupPost/index.js +11 -6
- package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
- package/dist/notifications/defaultNotifications/pollEnded/index.d.ts +19 -0
- package/dist/notifications/defaultNotifications/pollEnded/index.js +39 -0
- package/dist/notifications/defaultNotifications/pollEnded/recipients.d.ts +3 -0
- package/dist/notifications/defaultNotifications/pollEnded/recipients.js +17 -0
- package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
- package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
- package/dist/notifications/defaultNotifications/reply/index.js +21 -22
- package/dist/notifications/defaultNotifications/repost/index.js +16 -20
- package/dist/notifications/defaultNotifications/rsvp/index.d.ts +6 -1
- package/dist/notifications/defaultNotifications/rsvp/index.js +31 -18
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.d.ts +24 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +82 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.d.ts +4 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.js +11 -0
- package/dist/notifications/fcmCredential.js +1 -1
- package/dist/notifications/finders.js +1 -1
- package/dist/notifications/helpers.js +13 -10
- package/dist/notifications/jobs.js +10 -5
- package/dist/notifications/mutations.js +8 -1
- package/dist/notifications/push.js +11 -16
- package/dist/performance/index.js +3 -3
- package/dist/plugins/helpers.js +3 -6
- package/dist/plugins/index.js +39 -4
- package/dist/plugins/install.d.ts +28 -9
- package/dist/plugins/install.js +302 -56
- package/dist/plugins/pluginAuth.d.ts +1 -1
- package/dist/plugins/pluginAuth.js +13 -10
- package/dist/plugins/state.js +2 -3
- package/dist/posts/activity.d.ts +9 -0
- package/dist/posts/activity.js +34 -0
- package/dist/posts/contextClosure.d.ts +1 -9
- package/dist/posts/contextClosure.js +14 -44
- package/dist/posts/conversationQueries.d.ts +7 -0
- package/dist/posts/conversationQueries.js +76 -4
- package/dist/posts/eventAgenda.d.ts +1 -0
- package/dist/posts/eventAgenda.js +17 -8
- package/dist/posts/eventOccurrenceJobs.js +7 -2
- package/dist/posts/eventOccurrences.d.ts +6 -0
- package/dist/posts/eventOccurrences.js +22 -1
- package/dist/posts/finders.d.ts +56 -9
- package/dist/posts/finders.js +84 -23
- package/dist/posts/helpers/filters.js +13 -9
- package/dist/posts/helpers/index.d.ts +179 -14
- package/dist/posts/helpers/index.js +70 -34
- package/dist/posts/index.d.ts +5 -2
- package/dist/posts/index.js +5 -2
- package/dist/posts/mapping.d.ts +765 -30
- package/dist/posts/mapping.js +74 -31
- package/dist/posts/mutations.d.ts +516 -3
- package/dist/posts/mutations.js +179 -41
- package/dist/posts/pollEnd.d.ts +3 -0
- package/dist/posts/pollEnd.js +4 -0
- package/dist/posts/pollEndJobs.d.ts +8 -0
- package/dist/posts/pollEndJobs.js +49 -0
- package/dist/posts/replyClosure.d.ts +10 -0
- package/dist/posts/replyClosure.js +43 -0
- package/dist/posts/rsvpConfirmationEmail.js +23 -15
- package/dist/posts/threadPreview.d.ts +8 -0
- package/dist/posts/threadPreview.js +44 -0
- package/dist/posts/unseenCounts.js +4 -1
- package/dist/processingStats/queries.js +6 -7
- package/dist/profileSettings/cache.js +21 -5
- package/dist/profileSettings/mapping.d.ts +2 -0
- package/dist/profiles/activityQueries.d.ts +5 -0
- package/dist/profiles/activityQueries.js +85 -0
- package/dist/profiles/activitySummary.d.ts +3 -0
- package/dist/profiles/activitySummary.js +82 -0
- package/dist/profiles/blocks.d.ts +12 -0
- package/dist/profiles/blocks.js +73 -0
- package/dist/profiles/cache.d.ts +1 -0
- package/dist/profiles/cache.js +30 -10
- package/dist/profiles/export.js +30 -39
- package/dist/profiles/finders.d.ts +2 -1
- package/dist/profiles/finders.js +15 -8
- package/dist/profiles/helpers.d.ts +2 -0
- package/dist/profiles/index.d.ts +2 -0
- package/dist/profiles/index.js +2 -0
- package/dist/profiles/mapping.d.ts +10 -5
- package/dist/profiles/mapping.js +13 -1
- package/dist/profiles/mutations.d.ts +8 -4
- package/dist/profiles/mutations.js +31 -4
- package/dist/redis/connection.d.ts +2 -0
- package/dist/redis/connection.js +25 -6
- package/dist/reports/helpers.js +7 -3
- package/dist/roles/index.d.ts +1 -1
- package/dist/roles/index.js +1 -1
- package/dist/roles/mapping.d.ts +1 -0
- package/dist/roles/mutations.js +85 -3
- package/dist/search/finders.js +15 -3
- package/dist/search/helpers.js +1 -1
- package/dist/search/mapping.d.ts +1 -1
- package/dist/search/mapping.js +6 -2
- package/dist/sentry/index.js +9 -11
- package/dist/seo/index.d.ts +50 -0
- package/dist/seo/index.js +145 -0
- package/dist/seo/route.d.ts +18 -0
- package/dist/seo/route.js +19 -0
- package/dist/server/index.d.ts +19 -0
- package/dist/server/index.js +31 -14
- package/dist/server/stablePublicServerInfo.d.ts +17 -0
- package/dist/server/stablePublicServerInfo.js +37 -0
- package/dist/server/status.d.ts +25 -0
- package/dist/server/status.js +97 -0
- package/dist/session/index.js +2 -2
- package/dist/stats/finders.d.ts +1 -17681
- package/dist/stats/finders.js +22 -9
- package/dist/stats/helpers.js +4 -1
- package/dist/stats/mapping.d.ts +39 -2
- package/dist/stats/mapping.js +8 -4
- package/dist/stripe/cache.js +5 -6
- package/dist/stripe/connection.js +3 -4
- package/dist/stripe/helpers.js +15 -20
- package/package.json +5 -7
- package/dist/db/migration/detect.d.ts +0 -3
- package/dist/db/migration/detect.js +0 -33
- package/dist/db/migration/importPostgres.d.ts +0 -3
- package/dist/db/migration/importPostgres.js +0 -18
- package/dist/db/migration/transform.d.ts +0 -20
- package/dist/db/migration/transform.js +0 -232
- package/dist/db/migration/validate.d.ts +0 -18
- package/dist/db/migration/validate.js +0 -69
- package/dist/db/pg/sql/meta/0000_snapshot.json +0 -3380
- package/dist/db/pg/sql/meta/0004_snapshot.json +0 -4114
- package/dist/db/pg/sql/meta/0005_snapshot.json +0 -4179
- package/dist/db/pg/sql/meta/0006_snapshot.json +0 -4200
- package/dist/db/pg/sql/meta/0007_snapshot.json +0 -4179
- package/dist/mastodon/index.d.ts +0 -4
- package/dist/mastodon/index.js +0 -51
- package/dist/mastodon/types.d.ts +0 -7579
- package/dist/mastodon/types.js +0 -523
- package/dist/mastodon/typescript.d.ts +0 -1578
- package/dist/mastodon/typescript.js +0 -1
- package/dist/migration/index.d.ts +0 -4
- package/dist/migration/index.js +0 -4
- package/dist/roles/defaults.d.ts +0 -2
- package/dist/roles/defaults.js +0 -95
package/dist/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
|
@@ -1,19 +1,26 @@
|
|
|
1
|
+
import { FALLBACK_TIME_ZONE, resolveTimeZone } from '@openpeepshq/common/lib';
|
|
1
2
|
import { communityConfig, config } from '../config/index.js';
|
|
2
3
|
import { convert } from 'html-to-text';
|
|
3
4
|
import { registeredTemplates } from './registry.js';
|
|
4
5
|
import { serverRootUrl } from '../server/index.js';
|
|
5
6
|
import { initI18nEmailContext } from '../i18n/index.js';
|
|
6
|
-
const
|
|
7
|
+
const localTimeZone = (locals) => {
|
|
8
|
+
const value = locals?.timeZone;
|
|
9
|
+
return typeof value === 'string' ? value : undefined;
|
|
10
|
+
};
|
|
11
|
+
const globals = async (locals) => {
|
|
7
12
|
const serverConfig = await config();
|
|
8
13
|
const rootUrl = await serverRootUrl();
|
|
14
|
+
const community = await communityConfig();
|
|
9
15
|
return {
|
|
10
|
-
communityConfig:
|
|
16
|
+
communityConfig: community,
|
|
11
17
|
serverData: {
|
|
12
18
|
rootUrl,
|
|
13
19
|
iosUrl: serverConfig.apps.ios.url,
|
|
14
20
|
androidUrl: serverConfig.apps.android.url,
|
|
15
21
|
},
|
|
16
22
|
i18nContext: await initI18nEmailContext(),
|
|
23
|
+
timeZone: resolveTimeZone(localTimeZone(locals), community.settings?.defaultTimeZone, FALLBACK_TIME_ZONE),
|
|
17
24
|
};
|
|
18
25
|
};
|
|
19
26
|
export const render = async (emailData) => {
|
|
@@ -22,7 +29,11 @@ export const render = async (emailData) => {
|
|
|
22
29
|
if (!render) {
|
|
23
30
|
throw Error(`No renderer registered for ${emailData.template}`);
|
|
24
31
|
}
|
|
25
|
-
const { html, subject } = await render(
|
|
32
|
+
const { html, subject } = await render({
|
|
33
|
+
...emailData,
|
|
34
|
+
globals: await globals(locals),
|
|
35
|
+
locals: locals || {},
|
|
36
|
+
});
|
|
26
37
|
const text = convert(html);
|
|
27
38
|
return {
|
|
28
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/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RsvpCancelNotice } from '@openpeepshq/common/lib';
|
|
1
2
|
import type { Profile, EntryData, PostWithMeta, Notification, ReactionData, JamRecordingWithMeta, RSVP, RsvpResponse } from '@openpeepshq/common/types';
|
|
2
3
|
export type CoreEvents = {
|
|
3
4
|
profileCreated: (profile: Profile) => void;
|
|
@@ -10,12 +11,15 @@ export type CoreEvents = {
|
|
|
10
11
|
rsvpCreated: (profile: Profile, post: PostWithMeta, data: {
|
|
11
12
|
type: 'rsvp';
|
|
12
13
|
data: RSVP;
|
|
14
|
+
occurrenceIds?: string[];
|
|
13
15
|
previousResponse?: RsvpResponse;
|
|
16
|
+
cancel?: RsvpCancelNotice;
|
|
14
17
|
}) => void;
|
|
15
18
|
postAnnounced: (post: PostWithMeta) => void;
|
|
16
19
|
configUpdated: (namespace: string, name: string) => void;
|
|
17
20
|
/** Profile settings changed — clear in-process caches in all services. */
|
|
18
21
|
profileSettingsUpdated: (profileId: string) => void;
|
|
22
|
+
pollEnded: (post: PostWithMeta) => void;
|
|
19
23
|
};
|
|
20
24
|
export type CoreEventKey = keyof CoreEvents;
|
|
21
25
|
export declare const VALID_EVENT_KEYS: CoreEventKey[];
|
package/dist/events/index.js
CHANGED
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
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type ApActivityDirection = 'in' | 'out';
|
|
2
|
+
export type ApActivity = {
|
|
3
|
+
uri: string;
|
|
4
|
+
type: string;
|
|
5
|
+
actorUri: string;
|
|
6
|
+
objectUri?: string | null;
|
|
7
|
+
direction: ApActivityDirection;
|
|
8
|
+
};
|
|
9
|
+
export declare const recordApActivity: (activity: ApActivity) => Promise<void>;
|
|
10
|
+
export declare const findApActivityByUri: (uri: string) => Promise<{
|
|
11
|
+
uri: string;
|
|
12
|
+
type: string;
|
|
13
|
+
actorUri: string;
|
|
14
|
+
objectUri: string | null;
|
|
15
|
+
direction: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { eq } from 'drizzle-orm';
|
|
2
|
+
import { pgDb } from '../db/pg/client.js';
|
|
3
|
+
import { apActivities } from '../db/pg/schema/documents.js';
|
|
4
|
+
export const recordApActivity = async (activity) => {
|
|
5
|
+
const db = pgDb();
|
|
6
|
+
await db
|
|
7
|
+
.insert(apActivities)
|
|
8
|
+
.values({
|
|
9
|
+
uri: activity.uri,
|
|
10
|
+
type: activity.type,
|
|
11
|
+
actorUri: activity.actorUri,
|
|
12
|
+
objectUri: activity.objectUri ?? null,
|
|
13
|
+
direction: activity.direction,
|
|
14
|
+
})
|
|
15
|
+
.onConflictDoNothing();
|
|
16
|
+
};
|
|
17
|
+
export const findApActivityByUri = async (uri) => {
|
|
18
|
+
const db = pgDb();
|
|
19
|
+
const [row] = await db
|
|
20
|
+
.select()
|
|
21
|
+
.from(apActivities)
|
|
22
|
+
.where(eq(apActivities.uri, uri))
|
|
23
|
+
.limit(1);
|
|
24
|
+
return row;
|
|
25
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const actorUri: (domain: string, profileId: string) => string;
|
|
2
|
+
export declare const objectUri: (domain: string, postId: string) => string;
|
|
3
|
+
export declare const generateActorKeyPair: () => import("crypto").KeyPairSyncResult<string, string>;
|
|
4
|
+
export declare const localActorScalars: (profileId: string, domain: string) => {
|
|
5
|
+
uri: string;
|
|
6
|
+
inboxUrl: string;
|
|
7
|
+
publicKeyPem: string;
|
|
8
|
+
privateKeyPem: string;
|
|
9
|
+
keyId: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const localObjectScalars: (postId: string, domain: string, inReplyToId?: string | null) => {
|
|
12
|
+
uri: string;
|
|
13
|
+
inReplyToUri: string | null;
|
|
14
|
+
};
|
|
15
|
+
/** Fill actor/object URIs and local RSA keys after schema migrate. */
|
|
16
|
+
export declare const backfillLocalFederationIdentities: () => Promise<void>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { generateKeyPairSync } from 'node:crypto';
|
|
2
|
+
import { and, eq, isNull, sql } from 'drizzle-orm';
|
|
3
|
+
import { pgDb } from '../db/pg/client.js';
|
|
4
|
+
import { profiles } from '../db/pg/schema/documents.js';
|
|
5
|
+
export const actorUri = (domain, profileId) => `https://${domain}/ap/users/${profileId}`;
|
|
6
|
+
export const objectUri = (domain, postId) => `https://${domain}/ap/objects/${postId}`;
|
|
7
|
+
export const generateActorKeyPair = () => generateKeyPairSync('rsa', {
|
|
8
|
+
modulusLength: 2048,
|
|
9
|
+
publicKeyEncoding: { type: 'spki', format: 'pem' },
|
|
10
|
+
privateKeyEncoding: { type: 'pkcs8', format: 'pem' },
|
|
11
|
+
});
|
|
12
|
+
export const localActorScalars = (profileId, domain) => {
|
|
13
|
+
const uri = actorUri(domain, profileId);
|
|
14
|
+
const keys = generateActorKeyPair();
|
|
15
|
+
return {
|
|
16
|
+
uri,
|
|
17
|
+
inboxUrl: `${uri}/inbox`,
|
|
18
|
+
publicKeyPem: keys.publicKey,
|
|
19
|
+
privateKeyPem: keys.privateKey,
|
|
20
|
+
keyId: `${uri}#main-key`,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export const localObjectScalars = (postId, domain, inReplyToId) => ({
|
|
24
|
+
uri: objectUri(domain, postId),
|
|
25
|
+
inReplyToUri: inReplyToId ? objectUri(domain, inReplyToId) : null,
|
|
26
|
+
});
|
|
27
|
+
const federationDomain = () => process.env.ACTIVITY_PUB_DEFAULT_DOMAIN || 'localhost';
|
|
28
|
+
/** Fill actor/object URIs and local RSA keys after schema migrate. */
|
|
29
|
+
export const backfillLocalFederationIdentities = async () => {
|
|
30
|
+
const db = pgDb();
|
|
31
|
+
const domain = federationDomain();
|
|
32
|
+
const locals = await db
|
|
33
|
+
.select({ id: profiles.id })
|
|
34
|
+
.from(profiles)
|
|
35
|
+
.where(and(eq(profiles.type, 'local'), isNull(profiles.uri), isNull(profiles.deletedAt)));
|
|
36
|
+
for (const row of locals) {
|
|
37
|
+
await db
|
|
38
|
+
.update(profiles)
|
|
39
|
+
.set(localActorScalars(row.id, domain))
|
|
40
|
+
.where(eq(profiles.id, row.id));
|
|
41
|
+
}
|
|
42
|
+
await db.execute(sql `UPDATE posts SET uri = ${`https://${domain}/ap/objects/`} || id::text WHERE uri IS NULL`);
|
|
43
|
+
await db.execute(sql `
|
|
44
|
+
UPDATE posts p
|
|
45
|
+
SET in_reply_to_uri = parent.uri
|
|
46
|
+
FROM reply_to rt
|
|
47
|
+
JOIN posts parent ON parent.id::text = rt.to_id
|
|
48
|
+
WHERE rt.from_id = p.id::text
|
|
49
|
+
AND p.in_reply_to_uri IS NULL
|
|
50
|
+
AND parent.uri IS NOT NULL
|
|
51
|
+
`);
|
|
52
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { findApActivityByUri, recordApActivity } from './activities';
|
|
2
|
+
export type { ApActivity, ApActivityDirection } from './activities';
|
|
3
|
+
export { actorUri, backfillLocalFederationIdentities, generateActorKeyPair, localActorScalars, localObjectScalars, objectUri, } from './identity';
|
|
4
|
+
export { findProfileByHandleAndDomain, findProfileByUri } from './profiles';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { findApActivityByUri, recordApActivity } from './activities.js';
|
|
2
|
+
export { actorUri, backfillLocalFederationIdentities, generateActorKeyPair, localActorScalars, localObjectScalars, objectUri, } from './identity.js';
|
|
3
|
+
export { findProfileByHandleAndDomain, findProfileByUri } from './profiles.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ProfileWithMeta } from '@openpeepshq/common/types';
|
|
2
|
+
export declare const findProfileByUri: (uri: string) => Promise<ProfileWithMeta | undefined>;
|
|
3
|
+
export declare const findProfileByHandleAndDomain: (handle: string, domain: string) => Promise<ProfileWithMeta | undefined>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { allpeepDb } from '../db/index.js';
|
|
2
|
+
import { profilesMapping } from '../profiles/mapping.js';
|
|
3
|
+
export const findProfileByUri = async (uri) => {
|
|
4
|
+
const { db } = await allpeepDb();
|
|
5
|
+
return profilesMapping.findOneBy(db, {
|
|
6
|
+
matches: { uri },
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export const findProfileByHandleAndDomain = async (handle, domain) => {
|
|
10
|
+
const { db } = await allpeepDb();
|
|
11
|
+
return profilesMapping.findOneBy(db, {
|
|
12
|
+
matches: { handle, activityPub: { domain } },
|
|
13
|
+
});
|
|
14
|
+
};
|
package/dist/groups/finders.d.ts
CHANGED
|
@@ -107,10 +107,11 @@ export declare const listAdminGroups: () => Promise<{
|
|
|
107
107
|
guestData?: {
|
|
108
108
|
email?: string | undefined;
|
|
109
109
|
resource?: {
|
|
110
|
-
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "
|
|
110
|
+
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
|
|
111
111
|
id?: string | undefined;
|
|
112
112
|
} | undefined;
|
|
113
113
|
} | undefined;
|
|
114
|
+
pinnedPostId?: string | undefined;
|
|
114
115
|
deletedAt?: string | null | undefined;
|
|
115
116
|
}[];
|
|
116
117
|
avatar?: string | null | undefined;
|
package/dist/groups/helpers.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ export declare const addMember: (db: import("../db").PgDb, from: {
|
|
|
43
43
|
locked?: boolean | undefined;
|
|
44
44
|
bot?: boolean | undefined;
|
|
45
45
|
discoverable?: boolean | undefined;
|
|
46
|
+
roles?: {
|
|
47
|
+
key: string;
|
|
48
|
+
displayName: string;
|
|
49
|
+
}[] | undefined;
|
|
46
50
|
fields?: {
|
|
47
51
|
name: string;
|
|
48
52
|
value: string;
|
|
@@ -51,6 +55,8 @@ export declare const addMember: (db: import("../db").PgDb, from: {
|
|
|
51
55
|
followersCount: number;
|
|
52
56
|
followingCount: number;
|
|
53
57
|
} | undefined;
|
|
58
|
+
pinnedPostId?: string | undefined;
|
|
59
|
+
blockedByMe?: boolean | undefined;
|
|
54
60
|
}, to: {
|
|
55
61
|
handle: string;
|
|
56
62
|
capabilities: Record<string, {
|
|
@@ -123,6 +129,10 @@ export declare const removeMember: (db: import("../db").PgDb, from: {
|
|
|
123
129
|
locked?: boolean | undefined;
|
|
124
130
|
bot?: boolean | undefined;
|
|
125
131
|
discoverable?: boolean | undefined;
|
|
132
|
+
roles?: {
|
|
133
|
+
key: string;
|
|
134
|
+
displayName: string;
|
|
135
|
+
}[] | undefined;
|
|
126
136
|
fields?: {
|
|
127
137
|
name: string;
|
|
128
138
|
value: string;
|
|
@@ -131,6 +141,8 @@ export declare const removeMember: (db: import("../db").PgDb, from: {
|
|
|
131
141
|
followersCount: number;
|
|
132
142
|
followingCount: number;
|
|
133
143
|
} | undefined;
|
|
144
|
+
pinnedPostId?: string | undefined;
|
|
145
|
+
blockedByMe?: boolean | undefined;
|
|
134
146
|
}, to: {
|
|
135
147
|
handle: string;
|
|
136
148
|
capabilities: Record<string, {
|
|
@@ -194,6 +206,10 @@ export declare const updateMember: (db: import("../db").PgDb, from: {
|
|
|
194
206
|
locked?: boolean | undefined;
|
|
195
207
|
bot?: boolean | undefined;
|
|
196
208
|
discoverable?: boolean | undefined;
|
|
209
|
+
roles?: {
|
|
210
|
+
key: string;
|
|
211
|
+
displayName: string;
|
|
212
|
+
}[] | undefined;
|
|
197
213
|
fields?: {
|
|
198
214
|
name: string;
|
|
199
215
|
value: string;
|
|
@@ -202,6 +218,8 @@ export declare const updateMember: (db: import("../db").PgDb, from: {
|
|
|
202
218
|
followersCount: number;
|
|
203
219
|
followingCount: number;
|
|
204
220
|
} | undefined;
|
|
221
|
+
pinnedPostId?: string | undefined;
|
|
222
|
+
blockedByMe?: boolean | undefined;
|
|
205
223
|
}, to: {
|
|
206
224
|
handle: string;
|
|
207
225
|
capabilities: Record<string, {
|
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/mapping.d.ts
CHANGED
|
@@ -109,10 +109,11 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
|
|
|
109
109
|
guestData?: {
|
|
110
110
|
email?: string | undefined;
|
|
111
111
|
resource?: {
|
|
112
|
-
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "
|
|
112
|
+
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
|
|
113
113
|
id?: string | undefined;
|
|
114
114
|
} | undefined;
|
|
115
115
|
} | undefined;
|
|
116
|
+
pinnedPostId?: string | undefined;
|
|
116
117
|
deletedAt?: string | null | undefined;
|
|
117
118
|
}[];
|
|
118
119
|
avatar?: string | null | undefined;
|
|
@@ -170,10 +171,11 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
|
|
|
170
171
|
guestData?: {
|
|
171
172
|
email?: string | undefined;
|
|
172
173
|
resource?: {
|
|
173
|
-
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "
|
|
174
|
+
type: "profiles" | "groups" | "posts" | "notifications" | "reports" | "db" | "self" | "*" | "jams" | "webhooks" | "analytics" | "render";
|
|
174
175
|
id?: string | undefined;
|
|
175
176
|
} | undefined;
|
|
176
177
|
} | undefined;
|
|
178
|
+
pinnedPostId?: string | undefined;
|
|
177
179
|
deletedAt?: string | null | undefined;
|
|
178
180
|
}[];
|
|
179
181
|
avatar?: string | null | undefined;
|
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
|
: [];
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
1
|
+
import type { Hashtag, ProfileWithMeta } from '@openpeepshq/common/types';
|
|
2
|
+
export declare const findHashtag: (id: string) => Promise<Hashtag | undefined>;
|
|
3
|
+
export declare const findHashtagByTag: (tag: string) => Promise<Hashtag | undefined>;
|
|
4
|
+
export declare const findOrCreateHashtag: (tag: string) => Promise<Hashtag>;
|
|
5
|
+
export declare const listFollowedHashtags: (profile: ProfileWithMeta) => Hashtag[];
|
|
6
|
+
export declare const isFollowingHashtag: (profile: ProfileWithMeta, hashtag: Pick<Hashtag, "id">) => boolean;
|
package/dist/hashtags/finders.js
CHANGED
|
@@ -20,3 +20,5 @@ export const findOrCreateHashtag = async (tag) => {
|
|
|
20
20
|
}
|
|
21
21
|
return hashtagsMapping.create(db, { tag: normalizedTag });
|
|
22
22
|
};
|
|
23
|
+
export const listFollowedHashtags = (profile) => profile.followedHashtags ?? [];
|
|
24
|
+
export const isFollowingHashtag = (profile, hashtag) => profile.followedHashtags?.some((h) => h.id === hashtag.id) ?? false;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Hashtag, Profile } from '@openpeepshq/common/types';
|
|
2
|
+
export declare const profileHashtagConnector: (db: import("../db").PgDb, from: Profile, to: Hashtag, data?: object & {
|
|
3
|
+
id?: string;
|
|
4
|
+
}) => Promise<import("../db/pg/map").WithId<object & {
|
|
5
|
+
_from: string;
|
|
6
|
+
_to: string;
|
|
7
|
+
}>>;
|
|
8
|
+
export declare const profileHashtagDisconnector: (db: import("../db").PgDb, from: Profile, to: Hashtag) => Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { connector, disconnector } from '../db/helpers.js';
|
|
2
|
+
import { collectionInfos } from '../db/index.js';
|
|
3
|
+
export const profileHashtagConnector = connector(collectionInfos.profilesCollection, collectionInfos.hashtagsCollection, collectionInfos.profileHashtagsCollection);
|
|
4
|
+
export const profileHashtagDisconnector = disconnector(collectionInfos.profilesCollection, collectionInfos.hashtagsCollection, collectionInfos.profileHashtagsCollection);
|
package/dist/hashtags/index.d.ts
CHANGED
package/dist/hashtags/index.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { allpeepDb } from '../db/index.js';
|
|
2
|
+
import { clearProfileCache } from '../profiles/cache.js';
|
|
3
|
+
import { profileHashtagConnector, profileHashtagDisconnector } from './helpers.js';
|
|
4
|
+
export const followHashtag = async (profile, hashtag) => {
|
|
5
|
+
const { db } = await allpeepDb();
|
|
6
|
+
await profileHashtagConnector(db, profile, hashtag);
|
|
7
|
+
await clearProfileCache(profile);
|
|
8
|
+
};
|
|
9
|
+
export const unfollowHashtag = async (profile, hashtag) => {
|
|
10
|
+
const { db } = await allpeepDb();
|
|
11
|
+
await profileHashtagDisconnector(db, profile, hashtag);
|
|
12
|
+
await clearProfileCache(profile);
|
|
13
|
+
};
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Resource, ResourceLanguage } from 'i18next';
|
|
2
2
|
import type { i18n } from 'i18next';
|
|
3
|
+
export { clearPluginLocales, mergeHostAndPluginLocales, registerPluginLocales, } from './pluginLocales';
|
|
3
4
|
interface I18nContext {
|
|
4
5
|
i18n: i18n;
|
|
5
6
|
t: i18n['t'];
|
|
@@ -11,4 +12,3 @@ export declare const i18nWithPlugins: () => Promise<Resource>;
|
|
|
11
12
|
export declare const i18nComplete: () => Promise<Resource>;
|
|
12
13
|
export declare const updateI18nOverrides: (resources: Resource) => Promise<void>;
|
|
13
14
|
export declare const initI18nEmailContext: (lng?: string) => Promise<I18nContext>;
|
|
14
|
-
export {};
|
package/dist/i18n/index.js
CHANGED
|
@@ -6,12 +6,14 @@ import { nowIso } from '../db/pg/mappers.js';
|
|
|
6
6
|
import { uuidv7 } from 'uuidv7';
|
|
7
7
|
import i18next from 'i18next';
|
|
8
8
|
import Backend from 'i18next-fs-backend';
|
|
9
|
+
import { mergeHostAndPluginLocales, registeredPluginLocales, } from './pluginLocales.js';
|
|
10
|
+
export { clearPluginLocales, mergeHostAndPluginLocales, registerPluginLocales, } from './pluginLocales.js';
|
|
9
11
|
const I18N_NAMESPACE = 'translation';
|
|
10
12
|
export const i18nOverrides = () => allpeepDb().then(async ({ db }) => {
|
|
11
13
|
const rows = await db.select().from(i18nEntries);
|
|
12
14
|
return Object.fromEntries(rows.map((row) => [row.locale, row.body]));
|
|
13
15
|
});
|
|
14
|
-
export const i18nWithPlugins = async () => i18nextResources;
|
|
16
|
+
export const i18nWithPlugins = async () => mergeHostAndPluginLocales(i18nextResources, registeredPluginLocales());
|
|
15
17
|
export const i18nComplete = async () => deepmerge(await i18nWithPlugins(), await i18nOverrides());
|
|
16
18
|
export const updateI18nOverrides = async (resources) => allpeepDb().then(async ({ db }) => {
|
|
17
19
|
const ts = nowIso();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Resource } from 'i18next';
|
|
2
|
+
export declare const registerPluginLocales: (pluginKey: string, locales: Resource) => void;
|
|
3
|
+
export declare const clearPluginLocales: () => void;
|
|
4
|
+
export declare const registeredPluginLocales: () => Resource[];
|
|
5
|
+
/** Plugin packs first, host last so plugins cannot overwrite host strings. */
|
|
6
|
+
export declare const mergeHostAndPluginLocales: (host: Resource, pluginLocales: readonly Resource[]) => Resource;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { deepmerge } from 'deepmerge-ts';
|
|
2
|
+
const pluginLocaleRegistry = new Map();
|
|
3
|
+
export const registerPluginLocales = (pluginKey, locales) => {
|
|
4
|
+
pluginLocaleRegistry.set(pluginKey, locales);
|
|
5
|
+
};
|
|
6
|
+
export const clearPluginLocales = () => {
|
|
7
|
+
pluginLocaleRegistry.clear();
|
|
8
|
+
};
|
|
9
|
+
export const registeredPluginLocales = () => [
|
|
10
|
+
...pluginLocaleRegistry.values(),
|
|
11
|
+
];
|
|
12
|
+
/** Plugin packs first, host last so plugins cannot overwrite host strings. */
|
|
13
|
+
export const mergeHostAndPluginLocales = (host, pluginLocales) => pluginLocales.length === 0
|
|
14
|
+
? host
|
|
15
|
+
: deepmerge(...pluginLocales, host);
|