mirror of
https://github.com/aljazceru/ditto.git
synced 2025-12-21 23:44:20 +01:00
pipeline: broadcast deletions to all known relays
This commit is contained in:
@@ -3,6 +3,7 @@ import * as eventsDB from '@/db/events.ts';
|
||||
import { addRelays } from '@/db/relays.ts';
|
||||
import { findUser } from '@/db/users.ts';
|
||||
import { type Event, LRUCache } from '@/deps.ts';
|
||||
import { publish } from '@/firehose.ts';
|
||||
import { isEphemeralKind } from '@/kinds.ts';
|
||||
import * as mixer from '@/mixer.ts';
|
||||
import { isLocallyFollowed } from '@/queries.ts';
|
||||
@@ -27,6 +28,7 @@ async function handleEvent(event: Event): Promise<void> {
|
||||
trackRelays(event),
|
||||
trackHashtags(event),
|
||||
streamOut(event, data),
|
||||
broadcast(event, data),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -130,6 +132,18 @@ function streamOut(event: Event, data: EventData) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish the event to other relays.
|
||||
* This should only be done in certain circumstances, like mentioning a user or publishing deletions.
|
||||
*/
|
||||
function broadcast(event: Event, data: EventData) {
|
||||
if (!data.user || !isFresh(event)) return;
|
||||
|
||||
if (event.kind === 5) {
|
||||
publish(event);
|
||||
}
|
||||
}
|
||||
|
||||
/** NIP-20 command line result. */
|
||||
class RelayError extends Error {
|
||||
constructor(prefix: 'duplicate' | 'pow' | 'blocked' | 'rate-limited' | 'invalid' | 'error', message: string) {
|
||||
|
||||
Reference in New Issue
Block a user