mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
fix(relay.ts): purify event
This commit is contained in:
parent
17be4ab48f
commit
df27959d35
1 changed files with 3 additions and 2 deletions
|
|
@ -18,6 +18,7 @@ import * as pipeline from '@/pipeline.ts';
|
||||||
import { RelayError } from '@/RelayError.ts';
|
import { RelayError } from '@/RelayError.ts';
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '@/storages.ts';
|
||||||
import { Time } from '@/utils/time.ts';
|
import { Time } from '@/utils/time.ts';
|
||||||
|
import { purifyEvent } from '@/utils/purify.ts';
|
||||||
|
|
||||||
/** Limit of initial events returned for a subscription. */
|
/** Limit of initial events returned for a subscription. */
|
||||||
const FILTER_LIMIT = 100;
|
const FILTER_LIMIT = 100;
|
||||||
|
|
@ -105,7 +106,7 @@ function connectStream(socket: WebSocket, ip: string | undefined) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const event of await store.query(filters, { limit: FILTER_LIMIT, timeout: Conf.db.timeouts.relay })) {
|
for (const event of await store.query(filters, { limit: FILTER_LIMIT, timeout: Conf.db.timeouts.relay })) {
|
||||||
send(['EVENT', subId, event]);
|
send(['EVENT', subId, purifyEvent(event)]);
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
if (e instanceof RelayError) {
|
if (e instanceof RelayError) {
|
||||||
|
|
@ -137,7 +138,7 @@ function connectStream(socket: WebSocket, ip: string | undefined) {
|
||||||
relayEventsCounter.inc({ kind: event.kind.toString() });
|
relayEventsCounter.inc({ kind: event.kind.toString() });
|
||||||
try {
|
try {
|
||||||
// This will store it (if eligible) and run other side-effects.
|
// This will store it (if eligible) and run other side-effects.
|
||||||
await pipeline.handleEvent(event, AbortSignal.timeout(1000));
|
await pipeline.handleEvent(purifyEvent(event), AbortSignal.timeout(1000));
|
||||||
send(['OK', event.id, true, '']);
|
send(['OK', event.id, true, '']);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof RelayError) {
|
if (e instanceof RelayError) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue