Auto register client plugins
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import {BLOCKED_RELAYS, asDecryptedEvent, readList, getRelaysFromList} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {RepositoryCollection} from "./repositoryCollection.js"
|
||||
import type {ClientContext} from "./client.js"
|
||||
import type {RelayLists} from "./relayLists.js"
|
||||
import {RelayLists} from "./relayLists.js"
|
||||
import type {IClient} from "./client.js"
|
||||
|
||||
/**
|
||||
* Kind-10006 blocked-relay lists, keyed by pubkey. Loaded via the outbox model,
|
||||
@@ -10,10 +10,7 @@ import type {RelayLists} from "./relayLists.js"
|
||||
* blocked relays are never selected.
|
||||
*/
|
||||
export class BlockedRelayLists extends RepositoryCollection<ReturnType<typeof readList>> {
|
||||
constructor(
|
||||
ctx: ClientContext,
|
||||
readonly relayLists: RelayLists,
|
||||
) {
|
||||
constructor(ctx: IClient) {
|
||||
super(ctx, {
|
||||
filters: [{kinds: [BLOCKED_RELAYS]}],
|
||||
eventToItem: (event: TrustedEvent) => readList(asDecryptedEvent(event)),
|
||||
@@ -22,7 +19,7 @@ export class BlockedRelayLists extends RepositoryCollection<ReturnType<typeof re
|
||||
}
|
||||
|
||||
fetch(pubkey: string, relayHints: string[] = []) {
|
||||
return this.relayLists.makeOutboxLoader(BLOCKED_RELAYS)(pubkey, relayHints)
|
||||
return this.ctx.use(RelayLists).makeOutboxLoader(BLOCKED_RELAYS)(pubkey, relayHints)
|
||||
}
|
||||
|
||||
getBlockedRelays = (pubkey: string) => getRelaysFromList(this.get(pubkey))
|
||||
|
||||
Reference in New Issue
Block a user