Fix quote relays, add backwards compat for reading legacy messages/threads

This commit is contained in:
Jon Staab
2024-12-10 10:49:21 -08:00
parent 523c54a1f1
commit a65f6f6323
10 changed files with 55 additions and 17 deletions
+22 -1
View File
@@ -73,8 +73,12 @@ export const PROTECTED = ["-"]
export const MESSAGE = 9
export const LEGACY_MESSAGE = 209
export const THREAD = 11
export const LEGACY_THREAD = 309
export const COMMENT = 1111
export const MEMBERSHIPS = 10009
@@ -454,7 +458,24 @@ export const chatSearch = derived(chats, $chats =>
// Messages
export const messages = deriveEvents(repository, {filters: [{kinds: [MESSAGE]}]})
// TODO: remove support for legacy messages
export const messages = derived(
deriveEvents(repository, {filters: [{kinds: [MESSAGE, LEGACY_MESSAGE]}]}),
$events =>
$events.map(e => {
if (e.kind === LEGACY_MESSAGE) {
let room = e.tags.find(nthEq(0, "~"))?.[1] || GENERAL
if (room === "general") {
room = GENERAL
}
return {...e, kind: MESSAGE, tags: [...e.tags, tagRoom(room, "")]}
}
return e
}),
)
// Group Meta