@openpeepshq/core 0.1.32 → 0.1.34
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/helpers.d.ts +2 -2
- package/dist/accessTokens/tokens.js +14 -7
- package/dist/accounts/mutations.d.ts +2 -2
- package/dist/accounts/mutations.js +33 -35
- package/dist/analytics/cache.js +12 -7
- package/dist/analytics/compile.js +16 -10
- package/dist/analytics/pdfReport.d.ts +1 -0
- package/dist/analytics/pdfReport.js +5 -4
- package/dist/analytics/privacy.d.ts +18 -0
- package/dist/analytics/privacy.js +10 -0
- package/dist/analytics/read.js +75 -19
- package/dist/analytics/report.d.ts +21 -1
- package/dist/analytics/report.js +9 -2
- package/dist/backups/index.js +78 -15
- package/dist/backups/metadata.d.ts +8 -2
- package/dist/backups/metadata.js +6 -2
- package/dist/config/defaults/capabilities.js +13 -2
- package/dist/config/defaults/community.js +7 -9
- package/dist/config/defaults/core.d.ts +1 -1
- package/dist/config/defaults/core.js +3 -0
- package/dist/config/defaults/db.d.ts +0 -2
- package/dist/config/defaults/db.js +0 -2
- package/dist/config/index.d.ts +25 -3
- package/dist/config/index.js +7 -1
- package/dist/db/helpers.d.ts +7 -28
- package/dist/db/helpers.js +30 -152
- package/dist/db/index.d.ts +3 -1
- package/dist/db/index.js +5 -0
- package/dist/db/init.js +2 -2
- package/dist/db/migration/importCollections.d.ts +15 -10
- package/dist/db/migration/importCollections.js +121 -155
- package/dist/db/migration/shared.d.ts +2 -37
- package/dist/db/migration/shared.js +2 -59
- package/dist/db/pg/client.js +4 -0
- package/dist/db/pg/collections.d.ts +2 -2
- package/dist/db/pg/collections.js +2 -2
- package/dist/db/pg/filters/edges.d.ts +1 -1
- package/dist/db/pg/filters/edges.js +1 -1
- package/dist/db/pg/filters/posts.d.ts +11 -0
- package/dist/db/pg/filters/posts.js +37 -3
- package/dist/db/pg/filters/profiles.d.ts +1 -0
- package/dist/db/pg/filters/profiles.js +2 -1
- package/dist/db/pg/map/filters.js +37 -2
- package/dist/db/pg/map/mutations.js +13 -8
- package/dist/db/pg/map/registry.d.ts +5 -0
- package/dist/db/pg/map/registry.js +64 -24
- package/dist/db/pg/map/relations.d.ts +1 -1
- package/dist/db/pg/map/relations.js +98 -46
- package/dist/db/pg/migrate.d.ts +22 -0
- package/dist/db/pg/migrate.js +88 -2
- package/dist/db/pg/queries/activity.js +3 -3
- 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 +422 -41
- package/dist/db/pg/schema/documents.js +43 -9
- package/dist/db/pg/schema/edges.d.ts +117 -7
- package/dist/db/pg/schema/edges.js +4 -2
- package/dist/db/pg/schema/index.d.ts +505 -15
- package/dist/db/pg/sql/0007_shallow_oracle.sql +3 -0
- package/dist/db/pg/sql/0008_group_owner_roles.sql +31 -0
- package/dist/db/pg/sql/0009_event_occurrences.sql +26 -0
- 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/meta/{0006_snapshot.json → 0015_snapshot.json} +393 -39
- package/dist/db/pg/sql/meta/_journal.json +64 -1
- package/dist/db/replaceOrigin.js +6 -0
- package/dist/db/types.d.ts +0 -4
- package/dist/email/render.js +11 -3
- package/dist/events/index.d.ts +6 -1
- package/dist/events/index.js +55 -33
- package/dist/federation/activities.d.ts +17 -0
- package/dist/federation/activities.js +26 -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 +3 -2
- package/dist/groups/helpers.d.ts +24 -6
- package/dist/groups/mapping.d.ts +6 -4
- package/dist/groups/mapping.js +2 -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/helpers.d.ts +4 -4
- package/dist/jams/cache.d.ts +1 -1
- package/dist/jams/cache.js +2 -1
- package/dist/jams/export.d.ts +19 -0
- package/dist/jams/export.js +60 -0
- package/dist/jams/finders.d.ts +2 -1
- package/dist/jams/finders.js +18 -7
- package/dist/jams/health.d.ts +8 -0
- package/dist/jams/health.js +46 -0
- package/dist/jams/helpers.d.ts +6 -2
- package/dist/jams/index.d.ts +6 -3
- package/dist/jams/index.js +41 -27
- package/dist/jams/jobs.js +1 -1
- package/dist/jams/livekit.d.ts +93 -10
- package/dist/jams/livekit.js +151 -52
- package/dist/jams/mapping.d.ts +17 -7
- package/dist/jams/mutations.d.ts +3 -1
- package/dist/jams/recording.d.ts +10 -0
- package/dist/jams/recording.js +32 -0
- package/dist/jams/rtmp.d.ts +5 -0
- package/dist/jams/rtmp.js +8 -0
- package/dist/jams/token.d.ts +15 -3
- package/dist/jams/token.js +30 -16
- package/dist/jams/waitingRoom.d.ts +6 -6
- package/dist/jams/waitingRoom.js +24 -23
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.js +6 -1
- package/dist/jobs/jobDetail.js +1 -6
- package/dist/media/index.d.ts +1 -1
- package/dist/media/index.js +23 -8
- package/dist/media/processing.js +18 -7
- package/dist/notifications/defaultNotifications/follow/index.js +2 -2
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +3 -1
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +3 -1
- package/dist/notifications/defaultNotifications/index.js +4 -0
- package/dist/notifications/defaultNotifications/newGroupPost/index.js +12 -6
- 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 +18 -0
- package/dist/notifications/defaultNotifications/rsvp/index.d.ts +6 -1
- package/dist/notifications/defaultNotifications/rsvp/index.js +7 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.d.ts +24 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +75 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.d.ts +4 -0
- package/dist/notifications/defaultNotifications/rsvpCanceled/recipients.js +11 -0
- package/dist/notifications/helpers.js +6 -2
- package/dist/notifications/jobs.js +3 -1
- package/dist/notifications/mutations.js +4 -0
- package/dist/notifications/push.js +11 -4
- package/dist/plugins/helpers.d.ts +1 -0
- package/dist/plugins/helpers.js +1 -8
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +78 -5
- package/dist/plugins/install.d.ts +39 -0
- package/dist/plugins/install.js +455 -0
- package/dist/plugins/pluginAuth.d.ts +1 -1
- package/dist/plugins/pluginAuth.js +10 -6
- package/dist/plugins/state.d.ts +4 -0
- package/dist/plugins/state.js +29 -0
- package/dist/posts/activity.d.ts +9 -0
- package/dist/posts/activity.js +35 -0
- package/dist/posts/contextClosure.d.ts +1 -9
- package/dist/posts/contextClosure.js +15 -44
- package/dist/posts/conversationQueries.d.ts +7 -0
- package/dist/posts/conversationQueries.js +76 -2
- package/dist/posts/eventAgenda.d.ts +166 -0
- package/dist/posts/eventAgenda.js +126 -0
- package/dist/posts/eventOccurrenceJobs.d.ts +4 -0
- package/dist/posts/eventOccurrenceJobs.js +28 -0
- package/dist/posts/eventOccurrences.d.ts +10 -0
- package/dist/posts/eventOccurrences.js +61 -0
- package/dist/posts/finders.d.ts +47 -16
- package/dist/posts/finders.js +93 -62
- package/dist/posts/helpers/filters.js +14 -9
- package/dist/posts/helpers/index.d.ts +129 -30
- package/dist/posts/helpers/index.js +66 -33
- package/dist/posts/index.d.ts +7 -1
- package/dist/posts/index.js +7 -1
- package/dist/posts/mapping.d.ts +491 -13
- package/dist/posts/mapping.js +45 -10
- package/dist/posts/mutations.d.ts +441 -4
- package/dist/posts/mutations.js +177 -43
- package/dist/posts/pollEnd.d.ts +3 -0
- package/dist/posts/pollEnd.js +7 -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 +14 -15
- package/dist/posts/threadPreview.d.ts +8 -0
- package/dist/posts/threadPreview.js +44 -0
- package/dist/posts/unseenCounts.d.ts +2 -0
- package/dist/posts/unseenCounts.js +28 -8
- package/dist/profileSettings/cache.js +22 -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 +87 -0
- package/dist/profiles/blocks.d.ts +12 -0
- package/dist/profiles/blocks.js +73 -0
- package/dist/profiles/cache.d.ts +4 -1
- package/dist/profiles/cache.js +28 -7
- package/dist/profiles/finders.d.ts +2 -1
- package/dist/profiles/finders.js +8 -3
- package/dist/profiles/helpers.d.ts +7 -5
- package/dist/profiles/index.d.ts +3 -1
- package/dist/profiles/index.js +3 -1
- 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 +42 -15
- package/dist/pushSubscriptions/helpers.d.ts +2 -2
- package/dist/pushSubscriptions/mutations.js +13 -1
- package/dist/redis/connection.d.ts +2 -0
- package/dist/redis/connection.js +25 -6
- package/dist/reports/helpers.d.ts +6 -6
- 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 +86 -3
- package/dist/search/mapping.d.ts +1 -1
- package/dist/search/mapping.js +6 -2
- package/dist/server/index.d.ts +19 -1
- package/dist/server/index.js +37 -18
- 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 +98 -0
- package/dist/stats/finders.d.ts +1 -16131
- package/dist/stats/finders.js +9 -5
- package/dist/stats/mapping.d.ts +21 -1
- package/dist/stats/mapping.js +0 -3
- package/package.json +6 -12
- package/dist/db/arango.d.ts +0 -2
- package/dist/db/arango.js +0 -110
- package/dist/db/migration/autoMigrate.d.ts +0 -2
- package/dist/db/migration/autoMigrate.js +0 -111
- package/dist/db/migration/cli.d.ts +0 -1
- package/dist/db/migration/cli.js +0 -56
- package/dist/db/migration/detect.d.ts +0 -6
- package/dist/db/migration/detect.js +0 -87
- package/dist/db/migration/exportArango.d.ts +0 -4
- package/dist/db/migration/exportArango.js +0 -80
- 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 -18
- package/dist/db/migration/transform.js +0 -209
- 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/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/roles/defaults.d.ts +0 -2
- package/dist/roles/defaults.js +0 -94
|
@@ -50,6 +50,69 @@
|
|
|
50
50
|
"when": 1787042540973,
|
|
51
51
|
"tag": "0006_fine_trish_tilby",
|
|
52
52
|
"breakpoints": true
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"idx": 7,
|
|
56
|
+
"version": "7",
|
|
57
|
+
"when": 1787554098682,
|
|
58
|
+
"tag": "0007_shallow_oracle",
|
|
59
|
+
"breakpoints": true
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"idx": 8,
|
|
63
|
+
"version": "7",
|
|
64
|
+
"when": 1787632300000,
|
|
65
|
+
"tag": "0008_group_owner_roles",
|
|
66
|
+
"breakpoints": true
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"idx": 9,
|
|
70
|
+
"version": "7",
|
|
71
|
+
"when": 1787640000000,
|
|
72
|
+
"tag": "0009_event_occurrences",
|
|
73
|
+
"breakpoints": true
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"idx": 10,
|
|
77
|
+
"version": "7",
|
|
78
|
+
"when": 1789536200000,
|
|
79
|
+
"tag": "0010_user_group_membership_roles",
|
|
80
|
+
"breakpoints": true
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"idx": 11,
|
|
84
|
+
"version": "7",
|
|
85
|
+
"when": 1789538000000,
|
|
86
|
+
"tag": "0011_drop_data_migrations",
|
|
87
|
+
"breakpoints": true
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"idx": 12,
|
|
91
|
+
"version": "7",
|
|
92
|
+
"when": 1789540000000,
|
|
93
|
+
"tag": "0012_posts_last_activity_at",
|
|
94
|
+
"breakpoints": true
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"idx": 13,
|
|
98
|
+
"version": "7",
|
|
99
|
+
"when": 1789541000000,
|
|
100
|
+
"tag": "0013_add_blocks_edge",
|
|
101
|
+
"breakpoints": true
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"idx": 14,
|
|
105
|
+
"version": "7",
|
|
106
|
+
"when": 1789542000000,
|
|
107
|
+
"tag": "0014_federation_datamodel",
|
|
108
|
+
"breakpoints": true
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"idx": 15,
|
|
112
|
+
"version": "7",
|
|
113
|
+
"when": 1790593758508,
|
|
114
|
+
"tag": "0015_profile_hashtags",
|
|
115
|
+
"breakpoints": true
|
|
53
116
|
}
|
|
54
117
|
]
|
|
55
|
-
}
|
|
118
|
+
}
|
package/dist/db/replaceOrigin.js
CHANGED
|
@@ -3,11 +3,17 @@ import { logger } from '../log/index.js';
|
|
|
3
3
|
import { pgDb } from './pg/client.js';
|
|
4
4
|
import { asTable, getTableForCollection } from './pg/map/registry.js';
|
|
5
5
|
const log = logger('db:replaceOrigin');
|
|
6
|
+
// Walk collections that embed absolute media URLs (avatar/header/image,
|
|
7
|
+
// denormalized attachments, jam backgrounds). posts covers articles + events;
|
|
8
|
+
// groups covers group avatar/header — omitting them leaves those on the backup host.
|
|
6
9
|
const hostnameCollections = [
|
|
7
10
|
'configs',
|
|
8
11
|
'entries',
|
|
12
|
+
'groups',
|
|
9
13
|
'jamEvents',
|
|
10
14
|
'mediaAttachments',
|
|
15
|
+
'posts',
|
|
16
|
+
'profileSettings',
|
|
11
17
|
'profiles',
|
|
12
18
|
];
|
|
13
19
|
const absoluteHttpUrlPattern = /https?:\/\/[^\s"'<>`]+/g;
|
package/dist/db/types.d.ts
CHANGED
|
@@ -2,10 +2,6 @@ import type { PgDb } from './pg/client';
|
|
|
2
2
|
export interface OpenpeepsDatabase {
|
|
3
3
|
db: PgDb;
|
|
4
4
|
}
|
|
5
|
-
export interface UserFunctionDefinition {
|
|
6
|
-
name: string;
|
|
7
|
-
dbFunction: Function;
|
|
8
|
-
}
|
|
9
5
|
export interface ObjectFilter<O extends object> {
|
|
10
6
|
(item: O): boolean;
|
|
11
7
|
}
|
package/dist/email/render.js
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
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 === null || locals === void 0 ? void 0 : locals.timeZone;
|
|
9
|
+
return typeof value === 'string' ? value : undefined;
|
|
10
|
+
};
|
|
11
|
+
const globals = async (locals) => {
|
|
12
|
+
var _a;
|
|
7
13
|
const serverConfig = await config();
|
|
8
14
|
const rootUrl = await serverRootUrl();
|
|
15
|
+
const community = await communityConfig();
|
|
9
16
|
return {
|
|
10
|
-
communityConfig:
|
|
17
|
+
communityConfig: community,
|
|
11
18
|
serverData: {
|
|
12
19
|
rootUrl,
|
|
13
20
|
iosUrl: serverConfig.apps.ios.url,
|
|
14
21
|
androidUrl: serverConfig.apps.android.url,
|
|
15
22
|
},
|
|
16
23
|
i18nContext: await initI18nEmailContext(),
|
|
24
|
+
timeZone: resolveTimeZone(localTimeZone(locals), (_a = community.settings) === null || _a === void 0 ? void 0 : _a.defaultTimeZone, FALLBACK_TIME_ZONE),
|
|
17
25
|
};
|
|
18
26
|
};
|
|
19
27
|
export const render = async (emailData) => {
|
|
@@ -22,7 +30,7 @@ export const render = async (emailData) => {
|
|
|
22
30
|
if (!render) {
|
|
23
31
|
throw Error(`No renderer registered for ${emailData.template}`);
|
|
24
32
|
}
|
|
25
|
-
const { html, subject } = await render(Object.assign(Object.assign({}, emailData), { globals: await globals(), locals: locals || {} }));
|
|
33
|
+
const { html, subject } = await render(Object.assign(Object.assign({}, emailData), { globals: await globals(locals), locals: locals || {} }));
|
|
26
34
|
const text = convert(html);
|
|
27
35
|
return {
|
|
28
36
|
to: emailData.to,
|
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,22 +11,26 @@ 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[];
|
|
26
|
+
type Unsubscribe = () => void;
|
|
22
27
|
export declare const hub: {
|
|
23
28
|
/**
|
|
24
29
|
* Fan-out must not fail the caller (register/react/etc.). Redis publish and
|
|
25
30
|
* the BullMQ once-queue are best-effort side channels.
|
|
26
31
|
*/
|
|
27
32
|
emit: (eventType: string, ...eventArgs: unknown[]) => Promise<void>;
|
|
28
|
-
on: <T extends unknown[]>(eventType: string, handler: (...args: T) => unknown) =>
|
|
33
|
+
on: <T extends unknown[]>(eventType: string, handler: (...args: T) => unknown) => Unsubscribe;
|
|
29
34
|
once: (eventType: string, handler: (...args: unknown[]) => unknown) => void;
|
|
30
35
|
};
|
|
31
36
|
export { onceWorker, onceQueue } from './once';
|
package/dist/events/index.js
CHANGED
|
@@ -16,6 +16,7 @@ const validEventKeyMap = {
|
|
|
16
16
|
postAnnounced: true,
|
|
17
17
|
configUpdated: true,
|
|
18
18
|
profileSettingsUpdated: true,
|
|
19
|
+
pollEnded: true,
|
|
19
20
|
};
|
|
20
21
|
export const VALID_EVENT_KEYS = Object.keys(validEventKeyMap);
|
|
21
22
|
let connectionPromise = undefined;
|
|
@@ -29,38 +30,59 @@ const publishConnection = async () => {
|
|
|
29
30
|
connectionPromise = getConnection();
|
|
30
31
|
return connectionPromise;
|
|
31
32
|
};
|
|
32
|
-
const baseHub = (prefix) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
33
|
+
const baseHub = (prefix) => {
|
|
34
|
+
const subscriptions = new Map();
|
|
35
|
+
return {
|
|
36
|
+
/**
|
|
37
|
+
* Fan-out must not fail the caller (register/react/etc.). Redis publish and
|
|
38
|
+
* the BullMQ once-queue are best-effort side channels.
|
|
39
|
+
*/
|
|
40
|
+
emit: async (eventType, ...eventArgs) => {
|
|
41
|
+
const qualifiedEventType = `${prefix}:${eventType}`;
|
|
42
|
+
try {
|
|
43
|
+
const conn = await publishConnection();
|
|
44
|
+
await conn.publish(qualifiedEventType, JSON.stringify(eventArgs));
|
|
45
|
+
log.info({ qualifiedEventType }, 'hub event published');
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
log.error({ qualifiedEventType, err }, 'hub publish failed');
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
await onceQueue().add(qualifiedEventType, eventArgs);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
log.error({ qualifiedEventType, err }, 'hub once-queue enqueue failed');
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
on: (eventType, handler) => {
|
|
58
|
+
const channel = `${prefix}:${eventType}`;
|
|
59
|
+
getConnection().then((conn) => {
|
|
60
|
+
conn.subscribe(channel, (message) => {
|
|
61
|
+
const args = JSON.parse(message);
|
|
62
|
+
handler(...args);
|
|
63
|
+
});
|
|
64
|
+
let entry = subscriptions.get(channel);
|
|
65
|
+
if (!entry) {
|
|
66
|
+
entry = { conn, channels: [] };
|
|
67
|
+
subscriptions.set(channel, entry);
|
|
68
|
+
}
|
|
69
|
+
entry.channels.push(channel);
|
|
70
|
+
});
|
|
71
|
+
return () => {
|
|
72
|
+
getConnection().then((conn) => conn.unsubscribe(channel));
|
|
73
|
+
const entry = subscriptions.get(channel);
|
|
74
|
+
if (entry) {
|
|
75
|
+
entry.channels = entry.channels.filter((c) => c !== channel);
|
|
76
|
+
if (entry.channels.length === 0) {
|
|
77
|
+
subscriptions.delete(channel);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
once: (eventType, handler) => {
|
|
83
|
+
registerOnceHandler(`${prefix}:${eventType}`, handler);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
};
|
|
65
87
|
export const hub = baseHub('allpeep:core');
|
|
66
88
|
export { onceWorker, onceQueue } from './once.js';
|
|
@@ -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,26 @@
|
|
|
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
|
+
var _a;
|
|
6
|
+
const db = pgDb();
|
|
7
|
+
await db
|
|
8
|
+
.insert(apActivities)
|
|
9
|
+
.values({
|
|
10
|
+
uri: activity.uri,
|
|
11
|
+
type: activity.type,
|
|
12
|
+
actorUri: activity.actorUri,
|
|
13
|
+
objectUri: (_a = activity.objectUri) !== null && _a !== void 0 ? _a : null,
|
|
14
|
+
direction: activity.direction,
|
|
15
|
+
})
|
|
16
|
+
.onConflictDoNothing();
|
|
17
|
+
};
|
|
18
|
+
export const findApActivityByUri = async (uri) => {
|
|
19
|
+
const db = pgDb();
|
|
20
|
+
const [row] = await db
|
|
21
|
+
.select()
|
|
22
|
+
.from(apActivities)
|
|
23
|
+
.where(eq(apActivities.uri, uri))
|
|
24
|
+
.limit(1);
|
|
25
|
+
return row;
|
|
26
|
+
};
|
|
@@ -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
|
@@ -72,7 +72,7 @@ export declare const listAdminGroups: () => Promise<{
|
|
|
72
72
|
createdAt: string;
|
|
73
73
|
updatedAt: string;
|
|
74
74
|
postsCount: number;
|
|
75
|
-
|
|
75
|
+
owners: {
|
|
76
76
|
handle: string;
|
|
77
77
|
type: "guest" | "local" | "federated";
|
|
78
78
|
id: string;
|
|
@@ -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
|
@@ -25,7 +25,7 @@ export declare const addMember: (db: import("../db").PgDb, from: {
|
|
|
25
25
|
discoverable?: boolean | undefined;
|
|
26
26
|
deletedAt?: string | null | undefined;
|
|
27
27
|
};
|
|
28
|
-
roles?: ("none" | "local" | "member" | "admin" | "
|
|
28
|
+
roles?: ("none" | "local" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
29
29
|
}[] | undefined;
|
|
30
30
|
deletedAt?: string | null | undefined;
|
|
31
31
|
avatar?: string | null | undefined;
|
|
@@ -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, {
|
|
@@ -71,11 +77,11 @@ export declare const addMember: (db: import("../db").PgDb, from: {
|
|
|
71
77
|
lastPostAt?: string | null | undefined;
|
|
72
78
|
deletedAt?: string | null | undefined;
|
|
73
79
|
}, data?: {
|
|
74
|
-
roles?: ("
|
|
80
|
+
roles?: ("local" | "none" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
75
81
|
} & {
|
|
76
82
|
id?: string;
|
|
77
83
|
}) => Promise<import("../db/pg/map").WithId<{
|
|
78
|
-
roles?: ("
|
|
84
|
+
roles?: ("local" | "none" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
79
85
|
} & {
|
|
80
86
|
_from: string;
|
|
81
87
|
_to: string;
|
|
@@ -105,7 +111,7 @@ export declare const removeMember: (db: import("../db").PgDb, from: {
|
|
|
105
111
|
discoverable?: boolean | undefined;
|
|
106
112
|
deletedAt?: string | null | undefined;
|
|
107
113
|
};
|
|
108
|
-
roles?: ("none" | "local" | "member" | "admin" | "
|
|
114
|
+
roles?: ("none" | "local" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
109
115
|
}[] | undefined;
|
|
110
116
|
deletedAt?: string | null | undefined;
|
|
111
117
|
avatar?: string | null | undefined;
|
|
@@ -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, {
|
|
@@ -176,7 +188,7 @@ export declare const updateMember: (db: import("../db").PgDb, from: {
|
|
|
176
188
|
discoverable?: boolean | undefined;
|
|
177
189
|
deletedAt?: string | null | undefined;
|
|
178
190
|
};
|
|
179
|
-
roles?: ("none" | "local" | "member" | "admin" | "
|
|
191
|
+
roles?: ("none" | "local" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
180
192
|
}[] | undefined;
|
|
181
193
|
deletedAt?: string | null | undefined;
|
|
182
194
|
avatar?: string | null | undefined;
|
|
@@ -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, {
|
|
@@ -222,6 +240,6 @@ export declare const updateMember: (db: import("../db").PgDb, from: {
|
|
|
222
240
|
lastPostAt?: string | null | undefined;
|
|
223
241
|
deletedAt?: string | null | undefined;
|
|
224
242
|
}, data?: {
|
|
225
|
-
roles?: ("
|
|
243
|
+
roles?: ("local" | "none" | "member" | "moderator" | "admin" | "owner" | "invited")[] | null | undefined;
|
|
226
244
|
} | undefined) => Promise<void>;
|
|
227
245
|
export declare const canSeeGroupFilter: (profile?: ProfileWithMeta) => PgFilter<GroupWithMeta> | undefined;
|
package/dist/groups/mapping.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
|
|
|
74
74
|
createdAt: string;
|
|
75
75
|
updatedAt: string;
|
|
76
76
|
postsCount: number;
|
|
77
|
-
|
|
77
|
+
owners: {
|
|
78
78
|
handle: string;
|
|
79
79
|
type: "guest" | "local" | "federated";
|
|
80
80
|
id: string;
|
|
@@ -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;
|
|
@@ -135,7 +136,7 @@ export declare const adminGroupsMapping: import("../db/pg/map").Mapping<{
|
|
|
135
136
|
createdAt: string;
|
|
136
137
|
updatedAt: string;
|
|
137
138
|
postsCount: number;
|
|
138
|
-
|
|
139
|
+
owners: {
|
|
139
140
|
handle: string;
|
|
140
141
|
type: "guest" | "local" | "federated";
|
|
141
142
|
id: string;
|
|
@@ -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/mapping.js
CHANGED
|
@@ -30,12 +30,12 @@ export const adminGroupsMapping = map({
|
|
|
30
30
|
relations: [
|
|
31
31
|
...groupRelations,
|
|
32
32
|
{
|
|
33
|
-
alias: '
|
|
33
|
+
alias: 'owners',
|
|
34
34
|
edgeCollection: 'userGroups',
|
|
35
35
|
direction: 'INBOUND',
|
|
36
36
|
skipEdge: true,
|
|
37
37
|
cardinality: 'many',
|
|
38
|
-
edgeFilter: edgeFilters.
|
|
38
|
+
edgeFilter: edgeFilters.groupOwnerRole(),
|
|
39
39
|
mapping: {
|
|
40
40
|
collection: 'profiles',
|
|
41
41
|
softDelete: true,
|
package/dist/groups/mutations.js
CHANGED
|
@@ -10,7 +10,7 @@ export const createGroup = async (groupData, profile, members = []) => {
|
|
|
10
10
|
const { db } = await allpeepDb();
|
|
11
11
|
const emptyGroup = await groupsMapping.create(db, groupData);
|
|
12
12
|
await addMember(db, profile, emptyGroup, {
|
|
13
|
-
roles: ['
|
|
13
|
+
roles: ['owner'],
|
|
14
14
|
});
|
|
15
15
|
profilesCache.del(profile.id);
|
|
16
16
|
const filteredMembers = members === null || members === void 0 ? void 0 : members.filter((member) => member.id !== profile.id);
|
|
@@ -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) => { var _a; return (_a = profile.followedHashtags) !== null && _a !== void 0 ? _a : []; };
|
|
24
|
+
export const isFollowingHashtag = (profile, hashtag) => { var _a, _b; return (_b = (_a = profile.followedHashtags) === null || _a === void 0 ? void 0 : _a.some((h) => h.id === hashtag.id)) !== null && _b !== void 0 ? _b : 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>;
|