@openpeepshq/core 0.1.34 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accessTokens/finders.js +5 -6
- package/dist/accessTokens/mutations.js +1 -1
- package/dist/accessTokens/tokens.js +8 -11
- package/dist/accounts/helpers.js +6 -2
- package/dist/accounts/mutations.js +13 -8
- package/dist/analytics/cache.js +3 -3
- package/dist/analytics/clicks.js +14 -22
- package/dist/analytics/compile.js +1 -2
- package/dist/analytics/dateRange.js +3 -5
- package/dist/analytics/jobs.js +3 -4
- package/dist/analytics/pdfReport.js +45 -61
- package/dist/analytics/privacy.js +1 -1
- package/dist/analytics/read.js +116 -135
- package/dist/analytics/report.d.ts +2 -1
- package/dist/analytics/report.js +2 -3
- package/dist/analytics/settings.js +3 -4
- package/dist/backups/index.js +13 -16
- package/dist/backups/metadata.js +1 -1
- package/dist/config/db.js +2 -4
- package/dist/config/defaults/community.js +1 -0
- package/dist/config/defaults/core.js +13 -8
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +9 -11
- package/dist/db/explorer/query.js +9 -8
- package/dist/db/explorer/sql.js +8 -8
- package/dist/db/helpers.js +15 -5
- package/dist/db/migration/importCollections.js +15 -18
- package/dist/db/migration/shared.js +15 -35
- package/dist/db/pg/client.js +4 -7
- package/dist/db/pg/filters/index.js +1 -1
- package/dist/db/pg/filters/posts.d.ts +2 -0
- package/dist/db/pg/filters/posts.js +2 -0
- package/dist/db/pg/helpers.js +2 -14
- package/dist/db/pg/map/filters.js +8 -8
- package/dist/db/pg/map/helpers.js +5 -1
- package/dist/db/pg/map/index.js +46 -51
- package/dist/db/pg/map/mutations.js +56 -21
- package/dist/db/pg/map/registry.js +87 -50
- package/dist/db/pg/map/relations.js +67 -63
- package/dist/db/pg/map/search.js +15 -37
- package/dist/db/pg/mappers.js +13 -7
- package/dist/db/pg/migrate.js +2 -3
- package/dist/db/pg/queries/activity.js +2 -2
- package/dist/db/pg/queries/derived.js +8 -12
- package/dist/db/pg/schema/documents.js +119 -18
- package/dist/db/pg/schema/edges.js +7 -1
- package/dist/db/pg/schema/index.js +5 -1
- package/dist/db/pg/sql/0016_posts_search_vector_title_tags_path.sql +54 -0
- package/dist/db/pg/sql/meta/_journal.json +8 -1
- package/dist/db/replaceOrigin.js +1 -1
- package/dist/email/queueStats.js +8 -11
- package/dist/email/render.js +7 -4
- package/dist/email/send.js +19 -17
- package/dist/email/smtpTest.js +10 -6
- package/dist/errors/index.js +1 -1
- package/dist/events/once.js +2 -4
- package/dist/federation/activities.js +1 -2
- package/dist/groups/helpers.js +1 -2
- package/dist/groups/mutations.js +1 -1
- package/dist/hashtags/finders.js +2 -2
- package/dist/inviteLinks/mutations.js +2 -3
- package/dist/jams/export.js +5 -7
- package/dist/jams/finders.js +4 -1
- package/dist/jams/health.d.ts +6 -4
- package/dist/jams/health.js +15 -11
- package/dist/jams/helpers.js +6 -2
- package/dist/jams/index.js +2 -2
- package/dist/jams/jobs.js +1 -2
- package/dist/jams/livekit.js +8 -8
- package/dist/jams/recording.js +1 -1
- package/dist/jams/token.js +13 -17
- package/dist/jobs/index.js +7 -6
- package/dist/jobs/jobDetail.js +5 -6
- package/dist/jobs/jobLog.js +2 -3
- package/dist/lib/streams.js +4 -39
- package/dist/lib/zodDeepPartial.d.ts +1 -1
- package/dist/lib/zodDeepPartial.js +1 -1
- package/dist/log/index.js +13 -29
- package/dist/media/index.js +50 -4
- package/dist/media/jobs.js +1 -2
- package/dist/media/openpeeps/index.js +11 -46
- package/dist/media/processing.js +7 -4
- package/dist/media/streaming.js +5 -5
- package/dist/media/streamingCleanupJobs.js +1 -2
- package/dist/media/streamingJobs.js +3 -4
- package/dist/media/streamingPrewarm.js +7 -11
- package/dist/mediaAttachments/index.js +6 -2
- package/dist/notifications/defaultNotifications/announcement/index.js +15 -18
- package/dist/notifications/defaultNotifications/directMessage/index.js +9 -8
- package/dist/notifications/defaultNotifications/follow/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupAdded/index.js +14 -17
- package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +15 -18
- package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +15 -18
- package/dist/notifications/defaultNotifications/jamModerator/index.js +3 -5
- package/dist/notifications/defaultNotifications/jamSpeaker/index.js +14 -18
- package/dist/notifications/defaultNotifications/jamStarted/index.js +18 -22
- package/dist/notifications/defaultNotifications/mention/index.js +20 -24
- package/dist/notifications/defaultNotifications/newGroupPost/index.js +6 -7
- package/dist/notifications/defaultNotifications/newProfile/index.js +14 -17
- package/dist/notifications/defaultNotifications/pollEnded/index.js +21 -21
- package/dist/notifications/defaultNotifications/pollEnded/recipients.js +2 -3
- package/dist/notifications/defaultNotifications/pollVote/index.js +14 -17
- package/dist/notifications/defaultNotifications/reaction/index.js +18 -21
- package/dist/notifications/defaultNotifications/reply/index.js +21 -22
- package/dist/notifications/defaultNotifications/repost/index.js +16 -20
- package/dist/notifications/defaultNotifications/rsvp/index.js +24 -18
- package/dist/notifications/defaultNotifications/rsvpCanceled/index.js +20 -13
- package/dist/notifications/fcmCredential.js +1 -1
- package/dist/notifications/finders.js +1 -1
- package/dist/notifications/helpers.js +13 -10
- package/dist/notifications/jobs.js +10 -7
- package/dist/notifications/mutations.js +4 -1
- package/dist/notifications/push.js +11 -16
- package/dist/performance/index.js +3 -3
- package/dist/plugins/helpers.js +3 -6
- package/dist/plugins/index.js +2 -3
- package/dist/plugins/install.js +31 -17
- package/dist/plugins/pluginAuth.js +3 -4
- package/dist/plugins/state.js +2 -3
- package/dist/posts/activity.js +1 -2
- package/dist/posts/contextClosure.js +1 -2
- package/dist/posts/conversationQueries.js +2 -4
- package/dist/posts/eventAgenda.js +8 -5
- package/dist/posts/eventOccurrences.js +2 -2
- package/dist/posts/finders.d.ts +42 -2
- package/dist/posts/finders.js +21 -9
- package/dist/posts/helpers/filters.js +2 -3
- package/dist/posts/helpers/index.d.ts +152 -0
- package/dist/posts/helpers/index.js +43 -27
- package/dist/posts/mapping.d.ts +546 -14
- package/dist/posts/mapping.js +60 -18
- package/dist/posts/mutations.d.ts +76 -0
- package/dist/posts/mutations.js +46 -31
- package/dist/posts/pollEnd.js +3 -6
- package/dist/posts/rsvpConfirmationEmail.js +18 -8
- package/dist/posts/threadPreview.js +1 -1
- package/dist/processingStats/queries.js +6 -7
- package/dist/profileSettings/cache.js +1 -2
- package/dist/profiles/activitySummary.js +23 -28
- package/dist/profiles/cache.js +15 -8
- package/dist/profiles/export.js +30 -39
- package/dist/profiles/finders.js +7 -5
- package/dist/profiles/mutations.js +3 -5
- package/dist/redis/connection.js +1 -1
- package/dist/reports/helpers.js +7 -3
- package/dist/roles/mutations.js +20 -21
- package/dist/search/finders.js +15 -3
- package/dist/search/helpers.js +1 -1
- package/dist/sentry/index.js +9 -11
- package/dist/seo/index.d.ts +50 -0
- package/dist/seo/index.js +145 -0
- package/dist/seo/route.d.ts +18 -0
- package/dist/seo/route.js +19 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +16 -11
- package/dist/server/status.js +6 -7
- package/dist/session/index.js +2 -2
- package/dist/stats/finders.js +13 -4
- package/dist/stats/helpers.js +4 -1
- package/dist/stats/mapping.d.ts +39 -1
- package/dist/stats/mapping.js +9 -2
- package/dist/stripe/cache.js +5 -6
- package/dist/stripe/connection.js +3 -4
- package/dist/stripe/helpers.js +15 -20
- package/package.json +5 -6
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
2
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
3
|
-
var m = o[Symbol.asyncIterator], i;
|
|
4
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
5
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
6
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
7
|
-
};
|
|
8
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
9
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
10
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
11
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
12
|
-
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
13
|
-
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
14
|
-
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
15
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
16
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
17
|
-
function fulfill(value) { resume("next", value); }
|
|
18
|
-
function reject(value) { resume("throw", value); }
|
|
19
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
20
|
-
};
|
|
21
1
|
import { createHash, randomBytes } from 'node:crypto';
|
|
22
2
|
import { createReadStream, createWriteStream } from 'node:fs';
|
|
23
3
|
import fs from 'node:fs/promises';
|
|
@@ -48,32 +28,17 @@ const allpeepStorage = async (params) => {
|
|
|
48
28
|
let size = 0;
|
|
49
29
|
const source = Readable.fromWeb(stream);
|
|
50
30
|
try {
|
|
51
|
-
await pipeline(source, function (input) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
? chunk
|
|
63
|
-
: Buffer.from(chunk);
|
|
64
|
-
hash.update(buf);
|
|
65
|
-
size += buf.length;
|
|
66
|
-
yield yield __await(buf);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
70
|
-
finally {
|
|
71
|
-
try {
|
|
72
|
-
if (!_d && !_a && (_b = input_1.return)) yield __await(_b.call(input_1));
|
|
73
|
-
}
|
|
74
|
-
finally { if (e_1) throw e_1.error; }
|
|
75
|
-
}
|
|
76
|
-
});
|
|
31
|
+
await pipeline(source, async function* (input) {
|
|
32
|
+
for await (const chunk of input) {
|
|
33
|
+
// pipeline can yield Buffer or string depending on encoding; force
|
|
34
|
+
// through the Buffer path so the hash and byte count are correct.
|
|
35
|
+
const buf = chunk instanceof Buffer
|
|
36
|
+
? chunk
|
|
37
|
+
: Buffer.from(chunk);
|
|
38
|
+
hash.update(buf);
|
|
39
|
+
size += buf.length;
|
|
40
|
+
yield buf;
|
|
41
|
+
}
|
|
77
42
|
}, createWriteStream(tempPath));
|
|
78
43
|
}
|
|
79
44
|
catch (err) {
|
package/dist/media/processing.js
CHANGED
|
@@ -16,7 +16,6 @@ export const runProcessing = async (input) => withSpan('worker.media.processing'
|
|
|
16
16
|
mediaAttachmentId: input.mediaAttachmentId,
|
|
17
17
|
});
|
|
18
18
|
const runProcessingBody = async ({ mediaAttachmentId, sourceStorageKey, thumbnail, }) => {
|
|
19
|
-
var _a, _b;
|
|
20
19
|
const startedAt = Date.now();
|
|
21
20
|
const attachment = await findMediaAttachment(mediaAttachmentId);
|
|
22
21
|
if (!attachment) {
|
|
@@ -24,7 +23,7 @@ const runProcessingBody = async ({ mediaAttachmentId, sourceStorageKey, thumbnai
|
|
|
24
23
|
}
|
|
25
24
|
const filetype = attachment.type;
|
|
26
25
|
const originalName = attachment.filename;
|
|
27
|
-
const sourceMimetype =
|
|
26
|
+
const sourceMimetype = attachment.meta.mimetype ?? '';
|
|
28
27
|
const temps = new Set();
|
|
29
28
|
try {
|
|
30
29
|
const storage = await mediaStorage();
|
|
@@ -66,14 +65,18 @@ const runProcessingBody = async ({ mediaAttachmentId, sourceStorageKey, thumbnai
|
|
|
66
65
|
const updated = await updateMediaAttachment(mediaAttachmentId, {
|
|
67
66
|
url,
|
|
68
67
|
previewUrl,
|
|
69
|
-
meta:
|
|
68
|
+
meta: {
|
|
69
|
+
...attachment.meta,
|
|
70
|
+
mimetype: transcoded.mimetype,
|
|
71
|
+
size: storedSize,
|
|
72
|
+
},
|
|
70
73
|
status: 'ready',
|
|
71
74
|
error: undefined,
|
|
72
75
|
});
|
|
73
76
|
const durationMs = Date.now() - startedAt;
|
|
74
77
|
await recordProcessingStats({
|
|
75
78
|
mediaAttachmentId,
|
|
76
|
-
filesize:
|
|
79
|
+
filesize: attachment.meta.size ?? storedSize,
|
|
77
80
|
filetype,
|
|
78
81
|
durationMs,
|
|
79
82
|
}).catch((e) => log.error('Failed to record processing stats', e));
|
package/dist/media/streaming.js
CHANGED
|
@@ -13,7 +13,7 @@ const STREAM_ACCESS_KEY = 'media:streaming:lastAccess';
|
|
|
13
13
|
// segments and we don't need to hammer Redis with a write for each. The
|
|
14
14
|
// debounce is per-process; multiple app/worker processes will each issue at
|
|
15
15
|
// most one write per window which is still fine.
|
|
16
|
-
const ACCESS_WRITE_DEBOUNCE_MS =
|
|
16
|
+
const ACCESS_WRITE_DEBOUNCE_MS = 60_000;
|
|
17
17
|
const lastAccessWriteCache = new Map();
|
|
18
18
|
const getStorageParams = async () => (await config()).media.storage.params;
|
|
19
19
|
const getHlsRoot = async () => {
|
|
@@ -47,7 +47,7 @@ export const parseLocalStorageUrl = async (rawUrl) => {
|
|
|
47
47
|
try {
|
|
48
48
|
url = new URL(rawUrl);
|
|
49
49
|
}
|
|
50
|
-
catch
|
|
50
|
+
catch {
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
const rootUrl = await serverRootUrl();
|
|
@@ -115,7 +115,7 @@ export const getStreamStatus = async (storageId) => {
|
|
|
115
115
|
return null;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
catch
|
|
118
|
+
catch {
|
|
119
119
|
return null;
|
|
120
120
|
}
|
|
121
121
|
const errorsPath = join(streamDir, HLS_ERRORS_LOG);
|
|
@@ -140,7 +140,7 @@ export const buildStream = async (storageId) => {
|
|
|
140
140
|
if (!status) {
|
|
141
141
|
return null;
|
|
142
142
|
}
|
|
143
|
-
return
|
|
143
|
+
return { storageId, ...status };
|
|
144
144
|
};
|
|
145
145
|
export const ensureStreamDir = async (storageId) => {
|
|
146
146
|
const streamDir = await getStreamDir(storageId);
|
|
@@ -225,7 +225,7 @@ export const cleanupStaleStreams = async (maxAgeMs) => {
|
|
|
225
225
|
try {
|
|
226
226
|
stat = await fs.stat(fullPath);
|
|
227
227
|
}
|
|
228
|
-
catch
|
|
228
|
+
catch {
|
|
229
229
|
continue;
|
|
230
230
|
}
|
|
231
231
|
if (!stat.isDirectory())
|
|
@@ -10,8 +10,7 @@ export const STREAM_CLEANUP_CRON = '0 3 * * *';
|
|
|
10
10
|
const SCHEDULER_ID = 'streaming-cleanup-daily';
|
|
11
11
|
const JOB_NAME = 'cleanup';
|
|
12
12
|
const [mediaStreamingCleanupQueue, mediaStreamingCleanupWorker] = queueAndWorker('media-streaming-cleanup', async (job) => {
|
|
13
|
-
|
|
14
|
-
const maxAgeMs = (_a = job.data.maxAgeMs) !== null && _a !== void 0 ? _a : STREAM_INACTIVITY_TTL_MS;
|
|
13
|
+
const maxAgeMs = job.data.maxAgeMs ?? STREAM_INACTIVITY_TTL_MS;
|
|
15
14
|
log.info(`Running stream cleanup (maxAgeMs=${maxAgeMs}, ~${Math.round(maxAgeMs / DAY_MS)}d)`);
|
|
16
15
|
const result = await cleanupStaleStreams(maxAgeMs);
|
|
17
16
|
log.info(`Stream cleanup done: deleted=${result.deleted.length}, ` +
|
|
@@ -45,7 +45,6 @@ const SOURCE_BITRATE_FALLBACK_KBPS = {
|
|
|
45
45
|
};
|
|
46
46
|
const probeSource = (inputPath) => new Promise((resolve, reject) => {
|
|
47
47
|
ffmpeg.ffprobe(inputPath, (err, metadata) => {
|
|
48
|
-
var _a, _b;
|
|
49
48
|
if (err) {
|
|
50
49
|
reject(err);
|
|
51
50
|
return;
|
|
@@ -72,10 +71,10 @@ const probeSource = (inputPath) => new Promise((resolve, reject) => {
|
|
|
72
71
|
}
|
|
73
72
|
if (!videoBitrateKbps) {
|
|
74
73
|
const shorter = Math.min(video.width, video.height);
|
|
75
|
-
const fallback =
|
|
74
|
+
const fallback = Object.entries(SOURCE_BITRATE_FALLBACK_KBPS)
|
|
76
75
|
.map(([s, kbps]) => ({ s: Number(s), kbps }))
|
|
77
76
|
.filter(({ s }) => s <= shorter)
|
|
78
|
-
.sort((a, b) => b.s - a.s)[0]
|
|
77
|
+
.sort((a, b) => b.s - a.s)[0]?.kbps ?? 500;
|
|
79
78
|
videoBitrateKbps = fallback;
|
|
80
79
|
}
|
|
81
80
|
resolve({
|
|
@@ -246,7 +245,7 @@ const runHls = async (inputPath, streamDir, source, variants) => {
|
|
|
246
245
|
// Conversion failed!" — the actual diagnostic is in stderr. We attach
|
|
247
246
|
// the last ~40 lines so the worker log (and errors.log) show what
|
|
248
247
|
// ffmpeg actually complained about instead of a useless exit code.
|
|
249
|
-
const tail = String(stderr
|
|
248
|
+
const tail = String(stderr ?? '')
|
|
250
249
|
.trim()
|
|
251
250
|
.split(/\r?\n/)
|
|
252
251
|
.slice(-40)
|
|
@@ -18,14 +18,13 @@ const log = logger('app:media:streamingPrewarm');
|
|
|
18
18
|
* being created right now?" semantics.
|
|
19
19
|
*/
|
|
20
20
|
export const ensureStreamingJob = async (storageId) => {
|
|
21
|
-
var _a;
|
|
22
21
|
// Refresh the last-access marker so the daily cleanup job doesn't evict a
|
|
23
22
|
// stream that someone just expressed interest in. Fire-and-forget and
|
|
24
23
|
// debounced; safe to call from many sites.
|
|
25
24
|
void recordStreamAccess(storageId);
|
|
26
25
|
const existing = await getStreamStatus(storageId);
|
|
27
26
|
if (existing) {
|
|
28
|
-
return
|
|
27
|
+
return { storageId, ...existing };
|
|
29
28
|
}
|
|
30
29
|
// Create the directory before enqueueing so any subsequent caller hitting
|
|
31
30
|
// this code path immediately observes `processing` via `getStreamStatus`
|
|
@@ -42,7 +41,7 @@ export const ensureStreamingJob = async (storageId) => {
|
|
|
42
41
|
// next POST will report it as `processing`.
|
|
43
42
|
await queue.remove(jobId).catch(() => undefined);
|
|
44
43
|
await queue.add('transcode', { storageId }, { jobId });
|
|
45
|
-
return (
|
|
44
|
+
return (await buildStream(storageId)) ?? { storageId, status: 'processing' };
|
|
46
45
|
};
|
|
47
46
|
/**
|
|
48
47
|
* Pre-warms HLS streams for any local-storage-hosted videos in the given
|
|
@@ -50,7 +49,6 @@ export const ensureStreamingJob = async (storageId) => {
|
|
|
50
49
|
* skipped.
|
|
51
50
|
*/
|
|
52
51
|
const prewarmVideoAttachments = async (attachments, context) => {
|
|
53
|
-
var _a;
|
|
54
52
|
for (const attachment of attachments) {
|
|
55
53
|
if (!attachment || attachment.type !== 'video' || !attachment.url) {
|
|
56
54
|
continue;
|
|
@@ -66,7 +64,7 @@ const prewarmVideoAttachments = async (attachments, context) => {
|
|
|
66
64
|
}
|
|
67
65
|
catch (e) {
|
|
68
66
|
// A single bad attachment shouldn't block prewarming siblings.
|
|
69
|
-
log.warn(`Failed to prewarm HLS for ${context} attachment ${
|
|
67
|
+
log.warn(`Failed to prewarm HLS for ${context} attachment ${attachment.url ?? '?'}: ${e.message}`);
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
70
|
};
|
|
@@ -76,12 +74,11 @@ const prewarmVideoAttachments = async (attachments, context) => {
|
|
|
76
74
|
* play them the transcoded ladder is already (or nearly) ready.
|
|
77
75
|
*/
|
|
78
76
|
export const prewarmPostStreams = async (rawPost) => {
|
|
79
|
-
var _a, _b;
|
|
80
77
|
const post = rawPost;
|
|
81
|
-
const attachments =
|
|
78
|
+
const attachments = post?.data?.attachments;
|
|
82
79
|
if (!attachments || attachments.length === 0)
|
|
83
80
|
return;
|
|
84
|
-
await prewarmVideoAttachments(attachments, `post ${
|
|
81
|
+
await prewarmVideoAttachments(attachments, `post ${post?.id ?? '?'}`);
|
|
85
82
|
};
|
|
86
83
|
/**
|
|
87
84
|
* Pre-warms HLS for a completed jam recording's video attachment as soon as
|
|
@@ -89,12 +86,11 @@ export const prewarmPostStreams = async (rawPost) => {
|
|
|
89
86
|
* recording post.
|
|
90
87
|
*/
|
|
91
88
|
export const prewarmJamRecordingStream = async (rawRecording) => {
|
|
92
|
-
var _a;
|
|
93
89
|
const recording = rawRecording;
|
|
94
|
-
const attachment = recording
|
|
90
|
+
const attachment = recording?.attachment;
|
|
95
91
|
if (!attachment)
|
|
96
92
|
return;
|
|
97
|
-
await prewarmVideoAttachments([attachment], `jam recording ${
|
|
93
|
+
await prewarmVideoAttachments([attachment], `jam recording ${recording?.id ?? '?'}`);
|
|
98
94
|
};
|
|
99
95
|
/**
|
|
100
96
|
* Registers event handlers that pre-warm HLS streams for post videos and
|
|
@@ -7,6 +7,10 @@ const setUrlToCurrentHost = async (url) => {
|
|
|
7
7
|
parsedUrl.host = (await config()).server.host;
|
|
8
8
|
return parsedUrl.toString();
|
|
9
9
|
};
|
|
10
|
-
export const convertUrls = async (data) => (
|
|
10
|
+
export const convertUrls = async (data) => ({
|
|
11
|
+
...data,
|
|
12
|
+
url: await setUrlToCurrentHost(data.url),
|
|
13
|
+
previewUrl: data.previewUrl
|
|
11
14
|
? await setUrlToCurrentHost(data.previewUrl)
|
|
12
|
-
: null
|
|
15
|
+
: null,
|
|
16
|
+
});
|
|
@@ -7,7 +7,7 @@ import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
|
|
|
7
7
|
const eventHandler = async (data) => {
|
|
8
8
|
const post = data;
|
|
9
9
|
for (const recipientProfile of await listProfiles()) {
|
|
10
|
-
if (post.profile.id !==
|
|
10
|
+
if (post.profile.id !== recipientProfile?.id) {
|
|
11
11
|
await maybeCreateNotification(recipientProfile, {
|
|
12
12
|
type: 'announcement',
|
|
13
13
|
postId: post.id,
|
|
@@ -16,23 +16,20 @@ const eventHandler = async (data) => {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
const pushRenderer = async (notification) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
invalidateQueries: [PUSH_INVALIDATE.posts],
|
|
34
|
-
});
|
|
35
|
-
};
|
|
19
|
+
const pushRenderer = async (notification) => ({
|
|
20
|
+
title: `${profileName(notification.post?.profile)} posted an announcement`,
|
|
21
|
+
options: {
|
|
22
|
+
body: notification.post?.data?.content,
|
|
23
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
24
|
+
actions: [
|
|
25
|
+
{
|
|
26
|
+
action: `goto:/posts/${notification.post?.id}`,
|
|
27
|
+
title: 'Go to announcement',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
invalidateQueries: [PUSH_INVALIDATE.posts],
|
|
32
|
+
});
|
|
36
33
|
export default {
|
|
37
34
|
type: 'announcement',
|
|
38
35
|
event: 'postAnnounced',
|
|
@@ -5,9 +5,8 @@ import { getConversationByEnd } from '@openpeepshq/core/posts';
|
|
|
5
5
|
import { communityConfig } from '../../../config/index.js';
|
|
6
6
|
import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
|
|
7
7
|
const eventHandler = async (data) => {
|
|
8
|
-
var _a;
|
|
9
8
|
const post = data;
|
|
10
|
-
if (
|
|
9
|
+
if (post.data?.type === 'event')
|
|
11
10
|
return;
|
|
12
11
|
if (post.visibility === 'direct' && post.audience) {
|
|
13
12
|
for (const recipientProfile of post.audience) {
|
|
@@ -22,12 +21,11 @@ const eventHandler = async (data) => {
|
|
|
22
21
|
}
|
|
23
22
|
};
|
|
24
23
|
const pushRenderer = async (notification) => {
|
|
25
|
-
|
|
26
|
-
const path = `/conversations/${(_a = notification.data.conversationStart) === null || _a === void 0 ? void 0 : _a.id}`;
|
|
24
|
+
const path = `/conversations/${notification.data.conversationStart?.id}`;
|
|
27
25
|
return {
|
|
28
26
|
title: `${profileName(notification.senderProfile)} sent you a direct message`,
|
|
29
27
|
options: {
|
|
30
|
-
body:
|
|
28
|
+
body: notification.post?.data?.content,
|
|
31
29
|
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
32
30
|
data: {
|
|
33
31
|
url: path,
|
|
@@ -47,17 +45,20 @@ const pushRenderer = async (notification) => {
|
|
|
47
45
|
};
|
|
48
46
|
const expander = async (notification) => {
|
|
49
47
|
const { post, recipientProfile } = notification;
|
|
50
|
-
const previousPost = post
|
|
48
|
+
const previousPost = post?.replyTo;
|
|
51
49
|
const conversationStart = post &&
|
|
52
50
|
recipientProfile &&
|
|
53
51
|
(await getConversationByEnd(post, {
|
|
54
52
|
profile: recipientProfile,
|
|
55
53
|
scopes: [],
|
|
56
54
|
}))[0];
|
|
57
|
-
return
|
|
55
|
+
return {
|
|
56
|
+
...notification,
|
|
57
|
+
data: {
|
|
58
58
|
conversationStart,
|
|
59
59
|
previousPost,
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
|
+
};
|
|
61
62
|
};
|
|
62
63
|
export default {
|
|
63
64
|
type: 'directMessage',
|
|
@@ -11,21 +11,18 @@ export default {
|
|
|
11
11
|
type: 'follow',
|
|
12
12
|
fromProfileId: follower.id,
|
|
13
13
|
}),
|
|
14
|
-
pushRenderer: async (notification) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
invalidateQueries: [PUSH_INVALIDATE.profiles],
|
|
29
|
-
});
|
|
30
|
-
},
|
|
14
|
+
pushRenderer: async (notification) => ({
|
|
15
|
+
title: `${profileName(notification.senderProfile)} followed you`,
|
|
16
|
+
options: {
|
|
17
|
+
body: truncateText(markdownPlainText(notification.senderProfile?.bio)),
|
|
18
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
19
|
+
actions: [
|
|
20
|
+
{
|
|
21
|
+
action: `goto:/@${notification.senderProfile?.handle}`,
|
|
22
|
+
title: 'View Profile',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
invalidateQueries: [PUSH_INVALIDATE.profiles],
|
|
27
|
+
}),
|
|
31
28
|
};
|
|
@@ -13,21 +13,18 @@ export default {
|
|
|
13
13
|
groupId: group.id,
|
|
14
14
|
});
|
|
15
15
|
},
|
|
16
|
-
pushRenderer: async (notification) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
31
|
-
});
|
|
32
|
-
},
|
|
16
|
+
pushRenderer: async (notification) => ({
|
|
17
|
+
title: `You've been added to ${groupName(notification.group)}`,
|
|
18
|
+
options: {
|
|
19
|
+
body: 'Welcome to the group!',
|
|
20
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
21
|
+
actions: [
|
|
22
|
+
{
|
|
23
|
+
action: `goto:/groups/@${notification.group?.handle}`,
|
|
24
|
+
title: 'View Group',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
29
|
+
}),
|
|
33
30
|
};
|
|
@@ -9,7 +9,7 @@ export default {
|
|
|
9
9
|
eventHandler: async (...args) => {
|
|
10
10
|
const [group, profile] = args;
|
|
11
11
|
for (const groupAdmin of await listGroupMembers(group).then((members) => members
|
|
12
|
-
.filter((m) =>
|
|
12
|
+
.filter((m) => m.roles?.includes('owner') || m.roles?.includes('admin'))
|
|
13
13
|
.map((m) => m.profile))) {
|
|
14
14
|
await maybeCreateNotification(groupAdmin, {
|
|
15
15
|
type: 'groupMemberJoined',
|
|
@@ -18,21 +18,18 @@ export default {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
pushRenderer: async (notification) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
36
|
-
});
|
|
37
|
-
},
|
|
21
|
+
pushRenderer: async (notification) => ({
|
|
22
|
+
title: `New member ${profileName(notification.senderProfile)} joined ${groupName(notification.group)}`,
|
|
23
|
+
options: {
|
|
24
|
+
body: "Let's welcome them!",
|
|
25
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
26
|
+
actions: [
|
|
27
|
+
{
|
|
28
|
+
action: `goto:/@${notification.senderProfile?.handle}`,
|
|
29
|
+
title: 'View Profile',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
34
|
+
}),
|
|
38
35
|
};
|
|
@@ -9,7 +9,7 @@ export default {
|
|
|
9
9
|
eventHandler: async (...args) => {
|
|
10
10
|
const [group, profile] = args;
|
|
11
11
|
for (const groupAdmin of await listGroupMembers(group).then((members) => members
|
|
12
|
-
.filter((m) =>
|
|
12
|
+
.filter((m) => m.roles?.includes('owner') || m.roles?.includes('admin'))
|
|
13
13
|
.map((m) => m.profile))) {
|
|
14
14
|
await maybeCreateNotification(groupAdmin, {
|
|
15
15
|
type: 'groupMemberLeft',
|
|
@@ -18,21 +18,18 @@ export default {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
pushRenderer: async (notification) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
36
|
-
});
|
|
37
|
-
},
|
|
21
|
+
pushRenderer: async (notification) => ({
|
|
22
|
+
title: `Group member ${profileName(notification.senderProfile)} exited ${groupName(notification.group)}`,
|
|
23
|
+
options: {
|
|
24
|
+
body: "They're no longer a member of the group.",
|
|
25
|
+
icon: getProfileAvatar(notification.senderProfile, await communityConfig()),
|
|
26
|
+
actions: [
|
|
27
|
+
{
|
|
28
|
+
action: `goto:/groups/@${notification.group?.handle}`,
|
|
29
|
+
title: 'View Group',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
invalidateQueries: [PUSH_INVALIDATE.groups],
|
|
34
|
+
}),
|
|
38
35
|
};
|
|
@@ -5,9 +5,8 @@ import { profileName } from '@openpeepshq/common/lib';
|
|
|
5
5
|
import { initI18nEmailContext } from '../../../i18n/index.js';
|
|
6
6
|
import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
|
|
7
7
|
const eventHandler = async (eventData) => {
|
|
8
|
-
var _a, _b;
|
|
9
8
|
const post = eventData;
|
|
10
|
-
const jam =
|
|
9
|
+
const jam = post.data?.type === 'event' && post.data?.jam;
|
|
11
10
|
if (!jam) {
|
|
12
11
|
return;
|
|
13
12
|
}
|
|
@@ -24,15 +23,14 @@ const eventHandler = async (eventData) => {
|
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
25
|
const pushRenderer = async (notification) => {
|
|
27
|
-
var _a, _b;
|
|
28
26
|
const { t } = await initI18nEmailContext();
|
|
29
27
|
return {
|
|
30
28
|
title: `${profileName(notification.senderProfile)} invited you to moderate a jam`,
|
|
31
29
|
options: {
|
|
32
|
-
body: (
|
|
30
|
+
body: (notification.post?.data).name,
|
|
33
31
|
actions: [
|
|
34
32
|
{
|
|
35
|
-
action: `goto:/posts/${
|
|
33
|
+
action: `goto:/posts/${notification.post?.id}`,
|
|
36
34
|
title: t('emails.jamModerator.cta'),
|
|
37
35
|
},
|
|
38
36
|
],
|
|
@@ -4,9 +4,8 @@ import { maybeCreateNotification } from '@openpeepshq/core/notifications';
|
|
|
4
4
|
import { profileName } from '@openpeepshq/common/lib';
|
|
5
5
|
import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
|
|
6
6
|
const eventHandler = async (eventData) => {
|
|
7
|
-
var _a, _b;
|
|
8
7
|
const post = eventData;
|
|
9
|
-
const jam =
|
|
8
|
+
const jam = post.data?.type === 'event' && post.data?.jam;
|
|
10
9
|
if (!jam) {
|
|
11
10
|
return;
|
|
12
11
|
}
|
|
@@ -22,22 +21,19 @@ const eventHandler = async (eventData) => {
|
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
};
|
|
25
|
-
const pushRenderer = async (notification) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
invalidateQueries: [PUSH_INVALIDATE.posts],
|
|
39
|
-
});
|
|
40
|
-
};
|
|
24
|
+
const pushRenderer = async (notification) => ({
|
|
25
|
+
title: `${profileName(notification.senderProfile)} invited you to speak at a jam`,
|
|
26
|
+
options: {
|
|
27
|
+
body: (notification.post?.data).name,
|
|
28
|
+
actions: [
|
|
29
|
+
{
|
|
30
|
+
action: `goto:/events/${notification.post?.id}/jam`,
|
|
31
|
+
title: 'Join Jam',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
invalidateQueries: [PUSH_INVALIDATE.posts],
|
|
36
|
+
});
|
|
41
37
|
export default {
|
|
42
38
|
event: 'postCreated',
|
|
43
39
|
type: 'jamSpeaker',
|