refactor: reactions grouping and other fixes

This commit is contained in:
2024-01-09 16:40:31 +00:00
parent 4455651d47
commit 80fa5a132b
58 changed files with 344 additions and 501 deletions

View File

@ -9,6 +9,7 @@ import { ConnectionStats } from "./connection-stats";
import { NostrEvent, ReqCommand, ReqFilter, TaggedNostrEvent, u256 } from "./nostr";
import { RelayInfo } from "./relay-info";
import EventKind from "./event-kind";
import { EventExt } from "./event-ext";
/**
* Relay settings
@ -225,10 +226,16 @@ export class Connection extends EventEmitter<ConnectionEvents> {
break;
}
case "EVENT": {
this.emit("event", msg[1] as string, {
const ev = {
...(msg[2] as NostrEvent),
relays: [this.Address],
});
} as TaggedNostrEvent;
if (!EventExt.isValid(ev)) {
//this.#log("Rejecting invalid event %O", ev);
return;
}
this.emit("event", msg[1] as string, ev);
this.Stats.EventsReceived++;
this.notifyChange();
break;