This commit is contained in:
Martti Malmi
2023-12-21 21:50:43 +02:00
parent 782a2217b4
commit 9e6971423e
10 changed files with 85 additions and 21 deletions

View File

@ -88,6 +88,8 @@ export interface SystemInterface {
*/
DisconnectRelay(address: string): void;
HandleEvent(ev: TaggedNostrEvent): void;
/**
* Send an event to all permanent connections
* @param ev Event to broadcast

View File

@ -387,10 +387,15 @@ export class NostrSystem extends EventEmitter<NostrSystemEvents> implements Syst
return [];
}
HandleEvent(ev: TaggedNostrEvent) {
this.#onEvent("*", ev);
}
/**
* Send events to writable relays
*/
async BroadcastEvent(ev: NostrEvent, cb?: (rsp: OkResponse) => void) {
this.HandleEvent({ ...ev, relays: [] });
const socks = [...this.#sockets.values()].filter(a => !a.Ephemeral && a.Settings.write);
const replyRelays = await pickRelaysForReply(ev, this);
const oks = await Promise.all([

View File

@ -195,7 +195,7 @@ export class Query extends EventEmitter<QueryEvents> implements QueryBase {
handleEvent(sub: string, e: TaggedNostrEvent) {
for (const t of this.#tracing) {
if (t.id === sub) {
if (t.id === sub || sub === "*") {
if (t.filters.some(v => eventMatchesFilter(e, v))) {
this.feed.add(e);
} else {