Fix some bugs with AI

This commit is contained in:
Jon Staab
2026-05-28 11:57:16 -07:00
parent 3b2f2b14e4
commit 76f65e1815
11 changed files with 69 additions and 50 deletions
+16 -6
View File
@@ -10,16 +10,26 @@ import {
} from "@welshman/store"
import {repository} from "./core.js"
import {ensurePlaintext} from "./plaintext.js"
import {getSession} from "./session.js"
import {makeOutboxLoader} from "./relayLists.js"
export const muteListsByPubkey = deriveItemsByKey<PublishedList>({
repository,
eventToItem: async (event: TrustedEvent) =>
readList(
asDecryptedEvent(event, {
content: await ensurePlaintext(event),
}),
),
eventToItem: async (event: TrustedEvent) => {
const content = await ensurePlaintext(event)
// If this is our own mute list (we have a session for it) but it couldn't be
// decrypted yet because no signer is available, don't cache a result with empty
// private tags — that would get stuck permanently since deriveItemsByKey won't
// re-process an already-seen event id. Returning undefined leaves it uncached so it's
// retried once a signer is available. For other pubkeys' lists (no session) we fall
// through and read just the public tags, as before.
if (event.content && content === undefined && getSession(event.pubkey)) {
return undefined
}
return readList(asDecryptedEvent(event, {content}))
},
filters: [{kinds: [MUTES]}],
getKey: mute => mute.event.pubkey,
})