@openpeepshq/core 0.1.33 → 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/accounts/mutations.js +33 -35
- package/dist/analytics/compile.js +16 -10
- package/dist/analytics/read.js +52 -9
- package/dist/analytics/report.d.ts +20 -0
- package/dist/backups/index.js +75 -15
- package/dist/backups/metadata.d.ts +2 -3
- package/dist/backups/metadata.js +6 -2
- package/dist/config/defaults/capabilities.js +13 -2
- package/dist/config/defaults/community.js +7 -3
- package/dist/config/defaults/core.d.ts +1 -1
- package/dist/config/defaults/core.js +3 -0
- package/dist/config/index.d.ts +21 -0
- package/dist/config/index.js +7 -1
- package/dist/db/helpers.d.ts +1 -0
- package/dist/db/helpers.js +11 -3
- 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 +114 -164
- package/dist/db/migration/shared.d.ts +2 -33
- package/dist/db/migration/shared.js +2 -52
- package/dist/db/pg/collections.d.ts +2 -2
- package/dist/db/pg/collections.js +2 -2
- package/dist/db/pg/filters/posts.d.ts +10 -0
- package/dist/db/pg/filters/posts.js +28 -4
- 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 +32 -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.js +9 -5
- package/dist/db/pg/migrate.d.ts +1 -2
- package/dist/db/pg/migrate.js +6 -6
- 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 +279 -41
- package/dist/db/pg/schema/documents.js +21 -8
- package/dist/db/pg/schema/edges.d.ts +116 -7
- package/dist/db/pg/schema/edges.js +2 -1
- package/dist/db/pg/schema/index.d.ts +362 -15
- 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/{0009_snapshot.json → 0015_snapshot.json} +291 -36
- package/dist/db/pg/sql/meta/_journal.json +43 -1
- package/dist/email/render.js +11 -3
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.js +1 -0
- 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 +2 -1
- package/dist/groups/helpers.d.ts +18 -0
- package/dist/groups/mapping.d.ts +4 -2
- 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/jams/export.d.ts +19 -0
- package/dist/jams/export.js +60 -0
- package/dist/jams/health.d.ts +8 -0
- package/dist/jams/health.js +46 -0
- package/dist/jams/helpers.d.ts +2 -2
- package/dist/jams/index.d.ts +2 -0
- package/dist/jams/index.js +23 -16
- package/dist/jams/jobs.js +1 -1
- package/dist/jams/livekit.d.ts +49 -4
- package/dist/jams/livekit.js +56 -39
- 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 +32 -0
- package/dist/jams/token.d.ts +13 -1
- package/dist/jams/token.js +18 -7
- package/dist/jams/waitingRoom.js +1 -1
- 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/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/jobs.js +3 -1
- package/dist/notifications/mutations.js +4 -0
- package/dist/plugins/index.js +37 -1
- package/dist/plugins/install.d.ts +28 -9
- package/dist/plugins/install.js +281 -49
- package/dist/plugins/pluginAuth.d.ts +1 -1
- package/dist/plugins/pluginAuth.js +10 -6
- 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 +1 -0
- package/dist/posts/eventAgenda.js +10 -4
- package/dist/posts/eventOccurrenceJobs.js +7 -2
- package/dist/posts/eventOccurrences.d.ts +6 -0
- package/dist/posts/eventOccurrences.js +21 -0
- package/dist/posts/finders.d.ts +15 -8
- package/dist/posts/finders.js +67 -18
- package/dist/posts/helpers/filters.js +13 -8
- package/dist/posts/helpers/index.d.ts +27 -14
- package/dist/posts/helpers/index.js +34 -14
- package/dist/posts/index.d.ts +5 -2
- package/dist/posts/index.js +5 -2
- package/dist/posts/mapping.d.ts +216 -13
- package/dist/posts/mapping.js +14 -13
- package/dist/posts/mutations.d.ts +440 -3
- package/dist/posts/mutations.js +155 -32
- 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 -16
- package/dist/posts/threadPreview.d.ts +8 -0
- package/dist/posts/threadPreview.js +44 -0
- package/dist/posts/unseenCounts.js +4 -1
- 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 +1 -0
- package/dist/profiles/cache.js +19 -6
- package/dist/profiles/finders.d.ts +2 -1
- package/dist/profiles/finders.js +8 -3
- 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 -2
- package/dist/redis/connection.d.ts +2 -0
- package/dist/redis/connection.js +25 -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 +18 -0
- package/dist/server/index.js +24 -12
- 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 -17681
- package/dist/stats/finders.js +9 -5
- package/dist/stats/mapping.d.ts +0 -1
- package/dist/stats/mapping.js +0 -3
- package/package.json +4 -5
- 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/plugins/install.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
13
3
|
import fs from 'node:fs/promises';
|
|
14
4
|
import path from 'node:path';
|
|
15
5
|
import { defaultConfig } from '../config/index.js';
|
|
@@ -20,8 +10,10 @@ import { nowIso } from '../db/pg/mappers.js';
|
|
|
20
10
|
import { eq } from 'drizzle-orm';
|
|
21
11
|
import { setPluginEnabledOverride } from './state.js';
|
|
22
12
|
const log = logger('core:plugins:install');
|
|
13
|
+
const requireFromHost = createRequire(new URL('../../package.json', import.meta.url));
|
|
14
|
+
const MAX_COMMAND_OUTPUT = 16000;
|
|
23
15
|
const INSTALLED_PLUGINS_KEY = 'openpeeps-installed-plugins';
|
|
24
|
-
const getInstalledPlugins = async () => {
|
|
16
|
+
export const getInstalledPlugins = async () => {
|
|
25
17
|
var _a, _b;
|
|
26
18
|
const { db } = await allpeepDb();
|
|
27
19
|
const rows = await db
|
|
@@ -31,9 +23,9 @@ const getInstalledPlugins = async () => {
|
|
|
31
23
|
.limit(1);
|
|
32
24
|
return (_b = (_a = rows[0]) === null || _a === void 0 ? void 0 : _a.body) !== null && _b !== void 0 ? _b : {};
|
|
33
25
|
};
|
|
34
|
-
const setInstalledPlugin = async (pluginKey, source, installedBy) => {
|
|
26
|
+
const setInstalledPlugin = async (pluginKey, source, requiresAuth, installedBy) => {
|
|
35
27
|
const installed = await getInstalledPlugins();
|
|
36
|
-
const body = Object.assign(Object.assign({}, installed), { [pluginKey]: { source, installedAt: nowIso(), installedBy } });
|
|
28
|
+
const body = Object.assign(Object.assign({}, installed), { [pluginKey]: { source, requiresAuth, installedAt: nowIso(), installedBy } });
|
|
37
29
|
const ts = nowIso();
|
|
38
30
|
const { db } = await allpeepDb();
|
|
39
31
|
await db
|
|
@@ -46,7 +38,7 @@ const setInstalledPlugin = async (pluginKey, source, installedBy) => {
|
|
|
46
38
|
};
|
|
47
39
|
const removeInstalledPlugin = async (pluginKey) => {
|
|
48
40
|
const installed = await getInstalledPlugins();
|
|
49
|
-
const
|
|
41
|
+
const rest = Object.fromEntries(Object.entries(installed).filter(([key]) => key !== pluginKey));
|
|
50
42
|
const ts = nowIso();
|
|
51
43
|
const { db } = await allpeepDb();
|
|
52
44
|
await db
|
|
@@ -62,8 +54,12 @@ const removeInstalledPlugin = async (pluginKey) => {
|
|
|
62
54
|
set: { body: rest, updatedAt: ts },
|
|
63
55
|
});
|
|
64
56
|
};
|
|
65
|
-
const runCommand = (command, args, cwd) => new Promise((resolve) => {
|
|
66
|
-
const child = spawn(command, args, {
|
|
57
|
+
const runCommand = (command, args, cwd, environment = {}) => new Promise((resolve) => {
|
|
58
|
+
const child = spawn(command, args, {
|
|
59
|
+
cwd,
|
|
60
|
+
env: Object.assign({ HOME: process.env.HOME, LANG: process.env.LANG, LC_ALL: process.env.LC_ALL, NODE_EXTRA_CA_CERTS: process.env.NODE_EXTRA_CA_CERTS, PATH: process.env.PATH, SSL_CERT_DIR: process.env.SSL_CERT_DIR, SSL_CERT_FILE: process.env.SSL_CERT_FILE, TMPDIR: process.env.TMPDIR }, environment),
|
|
61
|
+
shell: false,
|
|
62
|
+
});
|
|
67
63
|
let stdout = '';
|
|
68
64
|
let stderr = '';
|
|
69
65
|
child.stdout.on('data', (chunk) => {
|
|
@@ -83,13 +79,176 @@ const getPluginDir = async () => {
|
|
|
83
79
|
const { plugins } = await defaultConfig;
|
|
84
80
|
return plugins.path;
|
|
85
81
|
};
|
|
82
|
+
const redactUrl = (url) => {
|
|
83
|
+
const parsed = new URL(url);
|
|
84
|
+
if (parsed.protocol !== 'ssh:') {
|
|
85
|
+
parsed.username = '';
|
|
86
|
+
}
|
|
87
|
+
parsed.password = '';
|
|
88
|
+
return parsed.toString();
|
|
89
|
+
};
|
|
86
90
|
const sourceLabel = (source) => source.type === 'npm'
|
|
87
91
|
? `npm:${source.package}${source.version ? `@${source.version}` : ''}`
|
|
88
|
-
: `git:${source.url}${source.ref ? `#${source.ref}` : ''}`;
|
|
89
|
-
|
|
92
|
+
: `git:${redactUrl(source.url)}${source.ref ? `#${source.ref}` : ''}`;
|
|
93
|
+
/**
|
|
94
|
+
* Inverse of sourceLabel for credentials-free sources; undefined when the
|
|
95
|
+
* stored label is not a label this version produced.
|
|
96
|
+
*/
|
|
97
|
+
const parseInstallSource = (label) => {
|
|
98
|
+
if (label.startsWith('npm:')) {
|
|
99
|
+
const spec = label.slice('npm:'.length);
|
|
100
|
+
const at = spec.lastIndexOf('@');
|
|
101
|
+
// A leading '@' is the scope prefix, not a version separator.
|
|
102
|
+
if (at <= 0) {
|
|
103
|
+
return { type: 'npm', package: spec };
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
type: 'npm',
|
|
107
|
+
package: spec.slice(0, at),
|
|
108
|
+
version: spec.slice(at + 1),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (label.startsWith('git:')) {
|
|
112
|
+
const spec = label.slice('git:'.length);
|
|
113
|
+
const hash = spec.indexOf('#');
|
|
114
|
+
if (hash === -1) {
|
|
115
|
+
return { type: 'git', url: spec };
|
|
116
|
+
}
|
|
117
|
+
return { type: 'git', url: spec.slice(0, hash), ref: spec.slice(hash + 1) };
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
};
|
|
121
|
+
const sourceSecrets = (source) => {
|
|
122
|
+
if (source.type === 'npm') {
|
|
123
|
+
return source.auth ? [source.auth.token] : [];
|
|
124
|
+
}
|
|
125
|
+
if (!source.auth) {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
if (source.auth.type === 'token') {
|
|
129
|
+
return [source.auth.token];
|
|
130
|
+
}
|
|
131
|
+
return [source.auth.privateKey];
|
|
132
|
+
};
|
|
133
|
+
const redactSecrets = (value, secrets) => secrets.reduce((redacted, secret) => redacted.split(secret).join('[REDACTED]'), value);
|
|
134
|
+
const trimCommandOutput = (value) => value.length <= MAX_COMMAND_OUTPUT
|
|
135
|
+
? value
|
|
136
|
+
: `${value.slice(0, MAX_COMMAND_OUTPUT)}\n… truncated`;
|
|
137
|
+
const commandFailure = (operation, result, secrets) => {
|
|
138
|
+
const output = [result.stderr, result.stdout]
|
|
139
|
+
.map((part) => part.trim())
|
|
140
|
+
.filter(Boolean)
|
|
141
|
+
.join('\n');
|
|
142
|
+
return redactSecrets(`${operation} failed: ${trimCommandOutput(output)}`, secrets).trim();
|
|
143
|
+
};
|
|
144
|
+
const peerDependencyNames = (pkgJson) => {
|
|
145
|
+
const peers = pkgJson.peerDependencies;
|
|
146
|
+
if (!peers || typeof peers !== 'object' || Array.isArray(peers)) {
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
return Object.keys(peers);
|
|
150
|
+
};
|
|
151
|
+
const resolveHostPackage = async (name) => {
|
|
152
|
+
let current = path.dirname(requireFromHost.resolve(name));
|
|
153
|
+
while (true) {
|
|
154
|
+
try {
|
|
155
|
+
const pkg = JSON.parse(await fs.readFile(path.join(current, 'package.json'), 'utf8'));
|
|
156
|
+
if (pkg.name === name) {
|
|
157
|
+
return current;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (_a) {
|
|
161
|
+
// Keep walking toward the filesystem root.
|
|
162
|
+
}
|
|
163
|
+
const parent = path.dirname(current);
|
|
164
|
+
if (parent === current) {
|
|
165
|
+
throw new Error(`Could not locate package root for "${name}".`);
|
|
166
|
+
}
|
|
167
|
+
current = parent;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
export const linkHostPeerDependencies = async (installDir, names) => {
|
|
171
|
+
for (const name of names) {
|
|
172
|
+
let resolved;
|
|
173
|
+
try {
|
|
174
|
+
resolved = await resolveHostPackage(name);
|
|
175
|
+
}
|
|
176
|
+
catch (_a) {
|
|
177
|
+
return {
|
|
178
|
+
success: false,
|
|
179
|
+
error: `Host does not provide peer dependency "${name}".`,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const destination = path.join(installDir, 'node_modules', name);
|
|
183
|
+
await fs.mkdir(path.dirname(destination), { recursive: true });
|
|
184
|
+
await fs.rm(destination, { recursive: true, force: true });
|
|
185
|
+
await fs.symlink(resolved, destination);
|
|
186
|
+
}
|
|
187
|
+
return { success: true };
|
|
188
|
+
};
|
|
189
|
+
const writeNpmConfig = async (tempDir, auth) => {
|
|
190
|
+
var _a;
|
|
191
|
+
if (!auth) {
|
|
192
|
+
return {};
|
|
193
|
+
}
|
|
194
|
+
const registry = new URL((_a = auth.registry) !== null && _a !== void 0 ? _a : 'https://registry.npmjs.org/');
|
|
195
|
+
const registryUrl = registry.toString().replace(/\/?$/, '/');
|
|
196
|
+
const authPath = registry.pathname.replace(/\/?$/, '/');
|
|
197
|
+
const configPath = path.join(tempDir, '.npmrc');
|
|
198
|
+
await fs.writeFile(configPath, [
|
|
199
|
+
`registry=${registryUrl}`,
|
|
200
|
+
`//${registry.host}${authPath}:_authToken=${auth.token}`,
|
|
201
|
+
'always-auth=true',
|
|
202
|
+
'',
|
|
203
|
+
].join('\n'), { mode: 0o600 });
|
|
204
|
+
return { NPM_CONFIG_USERCONFIG: configPath };
|
|
205
|
+
};
|
|
206
|
+
const removeNpmConfig = (tempDir) => fs.rm(path.join(tempDir, '.npmrc'), { force: true });
|
|
207
|
+
const writeGitAuth = async (tempDir, auth) => {
|
|
208
|
+
if (!auth) {
|
|
209
|
+
return { GIT_TERMINAL_PROMPT: '0' };
|
|
210
|
+
}
|
|
211
|
+
if (auth.type === 'token') {
|
|
212
|
+
const askpassPath = path.join(tempDir, 'git-askpass');
|
|
213
|
+
await fs.writeFile(askpassPath, [
|
|
214
|
+
'#!/bin/sh',
|
|
215
|
+
'case "$1" in',
|
|
216
|
+
' *Username*) printf "%s\\n" "$OPENPEEPS_GIT_USERNAME" ;;',
|
|
217
|
+
' *) printf "%s\\n" "$OPENPEEPS_GIT_TOKEN" ;;',
|
|
218
|
+
'esac',
|
|
219
|
+
'',
|
|
220
|
+
].join('\n'), { mode: 0o700 });
|
|
221
|
+
return {
|
|
222
|
+
GIT_ASKPASS: askpassPath,
|
|
223
|
+
GIT_ASKPASS_REQUIRE: 'force',
|
|
224
|
+
GIT_TERMINAL_PROMPT: '0',
|
|
225
|
+
OPENPEEPS_GIT_TOKEN: auth.token,
|
|
226
|
+
OPENPEEPS_GIT_USERNAME: auth.username,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const keyPath = path.join(tempDir, 'git-deploy-key');
|
|
230
|
+
const knownHostsPath = path.join(tempDir, 'known_hosts');
|
|
231
|
+
await fs.writeFile(keyPath, `${auth.privateKey.trim()}\n`, { mode: 0o600 });
|
|
232
|
+
await fs.writeFile(knownHostsPath, '', { mode: 0o600 });
|
|
233
|
+
return {
|
|
234
|
+
GIT_SSH_COMMAND: [
|
|
235
|
+
'ssh',
|
|
236
|
+
'-F /dev/null',
|
|
237
|
+
`-i "${keyPath}"`,
|
|
238
|
+
'-o BatchMode=yes',
|
|
239
|
+
'-o IdentitiesOnly=yes',
|
|
240
|
+
'-o StrictHostKeyChecking=accept-new',
|
|
241
|
+
`-o UserKnownHostsFile="${knownHostsPath}"`,
|
|
242
|
+
].join(' '),
|
|
243
|
+
GIT_SSH_VARIANT: 'ssh',
|
|
244
|
+
GIT_TERMINAL_PROMPT: '0',
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
export const installPlugin = async (source, installedBy, options) => {
|
|
90
248
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
91
249
|
const pluginsDir = await getPluginDir();
|
|
92
250
|
const label = sourceLabel(source);
|
|
251
|
+
const secrets = sourceSecrets(source);
|
|
93
252
|
let tempDir;
|
|
94
253
|
try {
|
|
95
254
|
tempDir = await fs.mkdtemp(path.join(pluginsDir, '.install-'));
|
|
@@ -100,6 +259,7 @@ export const installPlugin = async (source, installedBy) => {
|
|
|
100
259
|
}
|
|
101
260
|
try {
|
|
102
261
|
let installDir;
|
|
262
|
+
let npmEnvironment;
|
|
103
263
|
if (source.type === 'npm') {
|
|
104
264
|
const pkg = source.version
|
|
105
265
|
? `${source.package}@${source.version}`
|
|
@@ -107,27 +267,33 @@ export const installPlugin = async (source, installedBy) => {
|
|
|
107
267
|
log.info(`Installing npm package ${pkg} to temp dir ${tempDir}`);
|
|
108
268
|
const init = await runCommand('npm', ['init', '-y'], tempDir);
|
|
109
269
|
if (init.exitCode !== 0) {
|
|
110
|
-
|
|
270
|
+
const error = commandFailure('npm init', init, secrets);
|
|
271
|
+
log.error(new Error(error), `npm init failed for ${label}.`);
|
|
272
|
+
return { success: false, error };
|
|
111
273
|
}
|
|
112
|
-
|
|
274
|
+
npmEnvironment = await writeNpmConfig(tempDir, source.auth);
|
|
275
|
+
const install = await runCommand('npm', ['install', '--omit=peer', pkg], tempDir, npmEnvironment);
|
|
113
276
|
if (install.exitCode !== 0) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
};
|
|
277
|
+
const error = commandFailure('npm install', install, secrets);
|
|
278
|
+
log.error(new Error(error), `npm install failed for ${label}.`);
|
|
279
|
+
return { success: false, error };
|
|
118
280
|
}
|
|
119
281
|
installDir = path.join(tempDir, 'node_modules', source.package);
|
|
120
282
|
}
|
|
121
283
|
else {
|
|
122
|
-
|
|
284
|
+
const repositoryUrl = redactUrl(source.url);
|
|
285
|
+
log.info(`Cloning git repo ${repositoryUrl} to temp dir ${tempDir}`);
|
|
123
286
|
const cloneArgs = ['clone', '--depth', '1'];
|
|
124
287
|
if (source.ref) {
|
|
125
288
|
cloneArgs.push('--branch', source.ref);
|
|
126
289
|
}
|
|
127
|
-
cloneArgs.push(
|
|
128
|
-
const
|
|
290
|
+
cloneArgs.push(repositoryUrl, path.join(tempDir, 'repo'));
|
|
291
|
+
const gitEnvironment = await writeGitAuth(tempDir, source.auth);
|
|
292
|
+
const clone = await runCommand('git', cloneArgs, tempDir, gitEnvironment);
|
|
129
293
|
if (clone.exitCode !== 0) {
|
|
130
|
-
|
|
294
|
+
const error = commandFailure('git clone', clone, secrets);
|
|
295
|
+
log.error(new Error(error), `git clone failed for ${label}.`);
|
|
296
|
+
return { success: false, error };
|
|
131
297
|
}
|
|
132
298
|
installDir = path.join(tempDir, 'repo');
|
|
133
299
|
}
|
|
@@ -160,40 +326,57 @@ export const installPlugin = async (source, installedBy) => {
|
|
|
160
326
|
// Build the plugin if it has a build script
|
|
161
327
|
if ((_m = pkgJson.scripts) === null || _m === void 0 ? void 0 : _m.build) {
|
|
162
328
|
log.info(`Building plugin ${pluginKey}...`);
|
|
163
|
-
const buildDeps = await runCommand('npm', ['install'], installDir);
|
|
329
|
+
const buildDeps = await runCommand('npm', ['install', '--omit=peer'], installDir, npmEnvironment);
|
|
164
330
|
if (buildDeps.exitCode !== 0) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
331
|
+
const error = commandFailure('Dependency install', buildDeps, secrets);
|
|
332
|
+
log.error(new Error(error), `Plugin ${pluginKey} dependency install failed.`);
|
|
333
|
+
return { success: false, error };
|
|
334
|
+
}
|
|
335
|
+
const linked = await linkHostPeerDependencies(installDir, peerDependencyNames(pkgJson));
|
|
336
|
+
if (!linked.success) {
|
|
337
|
+
log.error(new Error(linked.error), `Plugin ${pluginKey} peer link failed.`);
|
|
338
|
+
return linked;
|
|
169
339
|
}
|
|
170
|
-
|
|
340
|
+
// The plugin temp dir sits under the host tree. A plugin script that
|
|
341
|
+
// invokes pnpm would otherwise adopt the host workspace.
|
|
342
|
+
await fs.writeFile(path.join(installDir, 'pnpm-workspace.yaml'), "packages:\n - '.'\n");
|
|
343
|
+
await removeNpmConfig(tempDir);
|
|
344
|
+
const build = await runCommand('npm', ['run', 'build'], installDir, {
|
|
345
|
+
CI: 'true',
|
|
346
|
+
});
|
|
171
347
|
if (build.exitCode !== 0) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
};
|
|
348
|
+
const error = commandFailure('Build', build, secrets);
|
|
349
|
+
log.error(new Error(error), `Plugin ${pluginKey} build failed.`);
|
|
350
|
+
return { success: false, error };
|
|
176
351
|
}
|
|
177
352
|
}
|
|
178
353
|
// Move to final location
|
|
354
|
+
await removeNpmConfig(tempDir);
|
|
179
355
|
await fs.mkdir(path.join(pluginsDir, namespace), { recursive: true });
|
|
180
356
|
await fs.rm(destDir, { recursive: true, force: true });
|
|
181
357
|
await fs.cp(installDir, destDir, { recursive: true });
|
|
182
|
-
await
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
358
|
+
await setInstalledPlugin(pluginKey, label, secrets.length > 0, installedBy);
|
|
359
|
+
if (options === null || options === void 0 ? void 0 : options.selfHeal) {
|
|
360
|
+
// Re-downloading an already-reviewed plugin keeps its enabled state.
|
|
361
|
+
log.info(`Self-healed plugin ${pluginKey} (re-downloaded from ${label}).`);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
// Installed plugins never auto-enable — an admin must explicitly
|
|
365
|
+
// activate them via the enable toggle (Phase B) after reviewing them.
|
|
366
|
+
await setPluginEnabledOverride(pluginKey, false);
|
|
367
|
+
log.info(`Plugin ${pluginKey} installed successfully from ${label}${installedBy ? ` by ${installedBy}` : ''}. Disabled by default — activate it explicitly to load it.`);
|
|
368
|
+
}
|
|
188
369
|
return { success: true, pluginKey };
|
|
189
370
|
}
|
|
190
371
|
catch (e) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
log.error(e, `Failed to install plugin from ${label}.`);
|
|
372
|
+
const rawMessage = e instanceof Error ? e.message : String(e);
|
|
373
|
+
const message = redactSecrets(rawMessage, secrets);
|
|
374
|
+
log.error(new Error(message), `Failed to install plugin from ${label}.`);
|
|
195
375
|
return { success: false, error: message };
|
|
196
376
|
}
|
|
377
|
+
finally {
|
|
378
|
+
await fs.rm(tempDir, { recursive: true, force: true }).catch(() => { });
|
|
379
|
+
}
|
|
197
380
|
};
|
|
198
381
|
export const uninstallPlugin = async (pluginKey, uninstalledBy) => {
|
|
199
382
|
const installed = await getInstalledPlugins();
|
|
@@ -217,6 +400,55 @@ export const uninstallPlugin = async (pluginKey, uninstalledBy) => {
|
|
|
217
400
|
return { success: false, error: message };
|
|
218
401
|
}
|
|
219
402
|
};
|
|
403
|
+
/**
|
|
404
|
+
* Re-downloads admin-installed plugins whose files are missing from the
|
|
405
|
+
* plugins directory (e.g. after a container recreate whose plugins path was
|
|
406
|
+
* not a persistent volume). Credentials are not stored, so plugins installed
|
|
407
|
+
* from private sources cannot be re-fetched — they are reported for manual
|
|
408
|
+
* re-install instead. Returns pluginKey -> reason for every plugin that is
|
|
409
|
+
* still unavailable after the attempt.
|
|
410
|
+
*/
|
|
411
|
+
export const selfHealInstalledPlugins = async () => {
|
|
412
|
+
var _a;
|
|
413
|
+
const installed = await getInstalledPlugins();
|
|
414
|
+
const pluginsDir = await getPluginDir();
|
|
415
|
+
const failures = {};
|
|
416
|
+
for (const [pluginKey, record] of Object.entries(installed)) {
|
|
417
|
+
const healthy = await fs
|
|
418
|
+
.access(path.join(pluginsDir, pluginKey, 'package.json'))
|
|
419
|
+
.then(() => true)
|
|
420
|
+
.catch(() => false);
|
|
421
|
+
if (healthy)
|
|
422
|
+
continue;
|
|
423
|
+
if (record.requiresAuth) {
|
|
424
|
+
log.error(`Plugin ${pluginKey} files are missing and it was installed from a private source; re-install it with credentials.`);
|
|
425
|
+
failures[pluginKey] =
|
|
426
|
+
'Plugin files are missing. It was installed from a private source, which cannot be re-downloaded automatically — reinstall it with its credentials.';
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
const source = parseInstallSource(record.source);
|
|
430
|
+
if (!source) {
|
|
431
|
+
log.error(`Plugin ${pluginKey} files are missing and its recorded source "${record.source}" could not be parsed.`);
|
|
432
|
+
failures[pluginKey] =
|
|
433
|
+
'Plugin files are missing and its recorded install source is no longer recognizable — reinstall it.';
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
try {
|
|
437
|
+
const result = await installPlugin(source, record.installedBy, {
|
|
438
|
+
selfHeal: true,
|
|
439
|
+
});
|
|
440
|
+
if (!result.success) {
|
|
441
|
+
log.error(new Error((_a = result.error) !== null && _a !== void 0 ? _a : 'unknown error'), `Self-heal failed for plugin ${pluginKey}.`);
|
|
442
|
+
failures[pluginKey] = `Automatic re-download failed: ${result.error}`;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
catch (e) {
|
|
446
|
+
log.error(e, `Self-heal failed for plugin ${pluginKey}.`);
|
|
447
|
+
failures[pluginKey] = `Automatic re-download failed: ${e instanceof Error ? e.message : String(e)}`;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return failures;
|
|
451
|
+
};
|
|
220
452
|
export const getInstalledPluginKeys = async () => {
|
|
221
453
|
const installed = await getInstalledPlugins();
|
|
222
454
|
return Object.keys(installed);
|
|
@@ -26,5 +26,5 @@ declare global {
|
|
|
26
26
|
* or verify whether the profile/account still exists. Plugin authors that need
|
|
27
27
|
* stronger guarantees or the handle should perform their own lookup.
|
|
28
28
|
*/
|
|
29
|
-
export declare const ensurePluginAuth: () => (req: Request, res: Response, next: NextFunction) => Promise<
|
|
29
|
+
export declare const ensurePluginAuth: () => (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
30
30
|
export {};
|
|
@@ -18,27 +18,31 @@ import { jwtUtil } from '../jwt/index.js';
|
|
|
18
18
|
*/
|
|
19
19
|
export const ensurePluginAuth = () => async (req, res, next) => {
|
|
20
20
|
var _a;
|
|
21
|
+
// Express 5's RequestHandler type requires `void | Promise<void>` — never
|
|
22
|
+
// `return res...`, which types as `Promise<Response>` and fails overload
|
|
23
|
+
// resolution wherever this middleware is passed to router.post/get/etc.
|
|
21
24
|
const authHeader = req.headers.authorization;
|
|
22
25
|
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
|
23
|
-
|
|
26
|
+
res.status(401).json({ success: false, message: 'Unauthorized' });
|
|
27
|
+
return;
|
|
24
28
|
}
|
|
25
29
|
const token = authHeader.slice(7);
|
|
26
30
|
if (!token) {
|
|
27
|
-
|
|
31
|
+
res.status(401).json({ success: false, message: 'Unauthorized' });
|
|
32
|
+
return;
|
|
28
33
|
}
|
|
29
34
|
try {
|
|
30
35
|
const jwt = await jwtUtil();
|
|
31
36
|
const verified = await jwt.verify(token);
|
|
32
37
|
const payload = verified === null || verified === void 0 ? void 0 : verified.payload;
|
|
33
38
|
if (!((_a = payload === null || payload === void 0 ? void 0 : payload.identities) === null || _a === void 0 ? void 0 : _a.profile)) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.json({ success: false, message: 'Invalid token' });
|
|
39
|
+
res.status(401).json({ success: false, message: 'Invalid token' });
|
|
40
|
+
return;
|
|
37
41
|
}
|
|
38
42
|
req.pluginProfile = { id: payload.identities.profile };
|
|
39
43
|
next();
|
|
40
44
|
}
|
|
41
45
|
catch (_b) {
|
|
42
|
-
|
|
46
|
+
res.status(401).json({ success: false, message: 'Unauthorized' });
|
|
43
47
|
}
|
|
44
48
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PgDb } from '../db/pg/client';
|
|
2
|
+
/**
|
|
3
|
+
* Walk outbound `reply_to` until there is no parent. A root post is itself.
|
|
4
|
+
*/
|
|
5
|
+
export declare const findReplyRootId: (db: PgDb, postId: string) => Promise<string>;
|
|
6
|
+
/** Bump conversation ordering without changing `created_at` or `updated_at`. */
|
|
7
|
+
export declare const touchPostActivity: (db: PgDb, postId: string) => Promise<void>;
|
|
8
|
+
/** Replies and reactions on any descendant bump the original/root post. */
|
|
9
|
+
export declare const bumpConversationActivity: (db: PgDb, postId: string) => Promise<void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
/**
|
|
3
|
+
* Walk outbound `reply_to` until there is no parent. A root post is itself.
|
|
4
|
+
*/
|
|
5
|
+
export const findReplyRootId = async (db, postId) => {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const result = (await db.execute(sql `
|
|
8
|
+
WITH RECURSIVE walk AS (
|
|
9
|
+
SELECT ${postId}::text AS node_id, 0 AS depth
|
|
10
|
+
UNION ALL
|
|
11
|
+
SELECT rt.to_id, walk.depth + 1
|
|
12
|
+
FROM reply_to rt
|
|
13
|
+
INNER JOIN walk ON rt.from_id = walk.node_id
|
|
14
|
+
WHERE walk.depth < 64
|
|
15
|
+
)
|
|
16
|
+
SELECT node_id
|
|
17
|
+
FROM walk
|
|
18
|
+
ORDER BY depth DESC
|
|
19
|
+
LIMIT 1
|
|
20
|
+
`));
|
|
21
|
+
return (_b = (_a = result.rows[0]) === null || _a === void 0 ? void 0 : _a.node_id) !== null && _b !== void 0 ? _b : postId;
|
|
22
|
+
};
|
|
23
|
+
/** Bump conversation ordering without changing `created_at` or `updated_at`. */
|
|
24
|
+
export const touchPostActivity = async (db, postId) => {
|
|
25
|
+
await db.execute(sql `
|
|
26
|
+
UPDATE posts
|
|
27
|
+
SET last_activity_at = now()
|
|
28
|
+
WHERE id = ${postId}::uuid
|
|
29
|
+
`);
|
|
30
|
+
};
|
|
31
|
+
/** Replies and reactions on any descendant bump the original/root post. */
|
|
32
|
+
export const bumpConversationActivity = async (db, postId) => {
|
|
33
|
+
const rootId = await findReplyRootId(db, postId);
|
|
34
|
+
await touchPostActivity(db, rootId);
|
|
35
|
+
};
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import type { AuthorizationData, DbPost, PostWithMeta } from '@openpeepshq/common/types';
|
|
2
|
-
import type { PgDb } from '../db/pg/client';
|
|
3
2
|
import type { Mapping } from '../db/pg/map';
|
|
4
|
-
export declare const CONTEXT_NODE_CAP = 100;
|
|
5
3
|
type ClosureDirection = 'ancestors' | 'descendents';
|
|
6
|
-
|
|
7
|
-
export declare const collectReplyClosureIds: (db: PgDb, startId: string, direction: ClosureDirection, { maxDepth, limit, newestFirst, }?: {
|
|
8
|
-
maxDepth?: number;
|
|
9
|
-
limit?: number;
|
|
10
|
-
newestFirst?: boolean;
|
|
11
|
-
}) => Promise<string[]>;
|
|
4
|
+
export { CONTEXT_NODE_CAP, collectReplyClosureIds } from './replyClosure';
|
|
12
5
|
/** Load and hydrate posts in a reply closure, then ACL-filter + transform. */
|
|
13
6
|
export declare const loadReplyContextPosts: (authData: AuthorizationData, startId: string, direction: ClosureDirection, mapping: Mapping<DbPost>, { maxDepth, limit, }?: {
|
|
14
7
|
maxDepth?: number;
|
|
15
8
|
limit?: number;
|
|
16
9
|
}) => Promise<PostWithMeta[]>;
|
|
17
|
-
export {};
|
|
@@ -1,53 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { blockedPairIds, toHiddenPost } from '@openpeepshq/common/lib';
|
|
2
2
|
import { allpeepDb } from '../db/index.js';
|
|
3
3
|
import { fetchRowsByIds, hydrateMapData } from '../db/pg/map/relations.js';
|
|
4
4
|
import { applySort } from '../db/pg/map/filters.js';
|
|
5
5
|
import { capabilitiesConfig } from '../config/index.js';
|
|
6
6
|
import { canReadPost, transformPost } from './helpers/index.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export const collectReplyClosureIds = async (db, startId, direction, { maxDepth = 9999, limit = CONTEXT_NODE_CAP,
|
|
10
|
-
/** Newest-first by uuidv7 id (useful for long DM threads). */
|
|
11
|
-
newestFirst = false, } = {}) => {
|
|
12
|
-
if (!startId || limit <= 0)
|
|
13
|
-
return [];
|
|
14
|
-
const orderClause = newestFirst ? sql `ORDER BY id DESC` : sql ``;
|
|
15
|
-
const query = direction === 'ancestors'
|
|
16
|
-
? sql `
|
|
17
|
-
WITH RECURSIVE t AS (
|
|
18
|
-
SELECT to_id AS id, 1 AS depth
|
|
19
|
-
FROM reply_to
|
|
20
|
-
WHERE from_id = ${startId}
|
|
21
|
-
UNION ALL
|
|
22
|
-
SELECT r.to_id, t.depth + 1
|
|
23
|
-
FROM reply_to r
|
|
24
|
-
INNER JOIN t ON r.from_id = t.id
|
|
25
|
-
WHERE t.depth < ${maxDepth}
|
|
26
|
-
)
|
|
27
|
-
SELECT id FROM t
|
|
28
|
-
${orderClause}
|
|
29
|
-
LIMIT ${limit}
|
|
30
|
-
`
|
|
31
|
-
: sql `
|
|
32
|
-
WITH RECURSIVE t AS (
|
|
33
|
-
SELECT from_id AS id, 1 AS depth
|
|
34
|
-
FROM reply_to
|
|
35
|
-
WHERE to_id = ${startId}
|
|
36
|
-
UNION ALL
|
|
37
|
-
SELECT r.from_id, t.depth + 1
|
|
38
|
-
FROM reply_to r
|
|
39
|
-
INNER JOIN t ON r.to_id = t.id
|
|
40
|
-
WHERE t.depth < ${maxDepth}
|
|
41
|
-
)
|
|
42
|
-
SELECT id FROM t
|
|
43
|
-
${orderClause}
|
|
44
|
-
LIMIT ${limit}
|
|
45
|
-
`;
|
|
46
|
-
const result = (await db.execute(query));
|
|
47
|
-
return result.rows.map((row) => row.id);
|
|
48
|
-
};
|
|
7
|
+
import { CONTEXT_NODE_CAP, collectReplyClosureIds } from './replyClosure.js';
|
|
8
|
+
export { CONTEXT_NODE_CAP, collectReplyClosureIds } from './replyClosure.js';
|
|
49
9
|
/** Load and hydrate posts in a reply closure, then ACL-filter + transform. */
|
|
50
10
|
export const loadReplyContextPosts = async (authData, startId, direction, mapping, { maxDepth = 9999, limit = CONTEXT_NODE_CAP, } = {}) => {
|
|
11
|
+
var _a, _b;
|
|
51
12
|
const { db } = await allpeepDb();
|
|
52
13
|
const mapData = mapping.data();
|
|
53
14
|
const ids = await collectReplyClosureIds(db, startId, direction, {
|
|
@@ -61,9 +22,19 @@ export const loadReplyContextPosts = async (authData, startId, direction, mappin
|
|
|
61
22
|
const sorted = applySort(hydrated, mapData.sort);
|
|
62
23
|
const config = await capabilitiesConfig();
|
|
63
24
|
const readable = canReadPost(config, authData);
|
|
25
|
+
const pair = new Set(blockedPairIds(authData.profile));
|
|
64
26
|
const posts = [];
|
|
65
27
|
for (const post of sorted) {
|
|
66
|
-
const transformed = await transformPost(post, authData.profile
|
|
28
|
+
const transformed = await transformPost(post, authData.profile, {
|
|
29
|
+
embedThreadPreview: false,
|
|
30
|
+
});
|
|
31
|
+
const creatorId = (_a = transformed.creatorId) !== null && _a !== void 0 ? _a : (_b = transformed.profile) === null || _b === void 0 ? void 0 : _b.id;
|
|
32
|
+
if (creatorId && pair.has(creatorId)) {
|
|
33
|
+
if (direction === 'descendents') {
|
|
34
|
+
posts.push(toHiddenPost(transformed));
|
|
35
|
+
}
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
67
38
|
if (readable(transformed))
|
|
68
39
|
posts.push(transformed);
|
|
69
40
|
}
|
|
@@ -13,6 +13,13 @@ export declare const findLatestThreadPostId: (rootId: string) => Promise<string>
|
|
|
13
13
|
* they are the same). Avoids walking full ancestor chains.
|
|
14
14
|
*/
|
|
15
15
|
export declare const listConversationPreviews: (authData: AuthorizationData) => Promise<PostWithMeta[][]>;
|
|
16
|
+
/**
|
|
17
|
+
* Archived conversations: threads the profile has left — detected by posts
|
|
18
|
+
* they authored but are no longer in the audience of. Returns
|
|
19
|
+
* [root, lastReadablePost] per conversation so the user can still find and
|
|
20
|
+
* view the conversation history after leaving.
|
|
21
|
+
*/
|
|
22
|
+
export declare const listLeftConversations: (authData: AuthorizationData) => Promise<PostWithMeta[][]>;
|
|
16
23
|
/**
|
|
17
24
|
* Conversation detail: root plus newest capped descendants (lean mapping +
|
|
18
25
|
* seenBatch). Prefer newest messages so long DMs stay usable.
|