Drop support for legacy messages
This commit is contained in:
@@ -3,16 +3,9 @@ import {synced, throttled} from "@welshman/store"
|
||||
import {pubkey} from "@welshman/app"
|
||||
import {prop, spec, identity, now, groupBy} from "@welshman/lib"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {MESSAGE, COMMENT, getTagValue} from "@welshman/util"
|
||||
import {MESSAGE, THREAD, COMMENT, getTagValue} from "@welshman/util"
|
||||
import {makeSpacePath, makeChatPath, makeThreadPath, makeRoomPath} from "@app/routes"
|
||||
import {
|
||||
THREAD_FILTER,
|
||||
COMMENT_FILTER,
|
||||
chats,
|
||||
getUrlsForEvent,
|
||||
userRoomsByUrl,
|
||||
repositoryStore,
|
||||
} from "@app/state"
|
||||
import {chats, getUrlsForEvent, userRoomsByUrl, repositoryStore} from "@app/state"
|
||||
|
||||
// Checked state
|
||||
|
||||
@@ -60,7 +53,10 @@ export const notifications = derived(
|
||||
}
|
||||
}
|
||||
|
||||
const allThreadEvents = $repository.query([THREAD_FILTER, COMMENT_FILTER])
|
||||
const allThreadEvents = $repository.query([
|
||||
{kinds: [THREAD]},
|
||||
{kinds: [COMMENT], "#K": [String(THREAD)]},
|
||||
])
|
||||
const allMessageEvents = $repository.query([{kinds: [MESSAGE]}])
|
||||
|
||||
for (const [url, rooms] of $userRoomsByUrl.entries()) {
|
||||
|
||||
+2
-28
@@ -80,10 +80,6 @@ export const GENERAL = "_"
|
||||
|
||||
export const PROTECTED = ["-"]
|
||||
|
||||
export const LEGACY_MESSAGE = 209
|
||||
|
||||
export const LEGACY_THREAD = 309
|
||||
|
||||
export const INDEXER_RELAYS = [
|
||||
"wss://purplepag.es/",
|
||||
"wss://relay.damus.io/",
|
||||
@@ -118,13 +114,6 @@ export const IMGPROXY_URL = "https://imgproxy.coracle.social"
|
||||
|
||||
export const REACTION_KINDS = [REACTION, ZAP_RESPONSE]
|
||||
|
||||
export const THREAD_FILTER: Filter = {kinds: [THREAD, LEGACY_THREAD]}
|
||||
|
||||
export const COMMENT_FILTER: Filter = {
|
||||
kinds: [COMMENT],
|
||||
"#K": [String(THREAD), String(LEGACY_THREAD)],
|
||||
}
|
||||
|
||||
export const NIP46_PERMS =
|
||||
"nip04_encrypt,nip04_decrypt,nip44_encrypt,nip44_decrypt," +
|
||||
[CLIENT_AUTH, AUTH_JOIN, MESSAGE, THREAD, COMMENT, GROUPS, WRAP, REACTION]
|
||||
@@ -463,24 +452,9 @@ export const chatSearch = derived(chats, $chats =>
|
||||
|
||||
// Messages
|
||||
|
||||
// TODO: remove support for legacy messages
|
||||
export const adaptLegacyMessage = (event: TrustedEvent) => {
|
||||
if (event.kind === LEGACY_MESSAGE) {
|
||||
let room = event.tags.find(nthEq(0, "~"))?.[1] || GENERAL
|
||||
|
||||
if (room === "general") {
|
||||
room = GENERAL
|
||||
}
|
||||
|
||||
return {...event, kind: MESSAGE, tags: [...event.tags, tagRoom(room, "")]}
|
||||
}
|
||||
|
||||
return event
|
||||
}
|
||||
|
||||
export const messages = derived(
|
||||
deriveEvents(repository, {filters: [{kinds: [MESSAGE, LEGACY_MESSAGE]}]}),
|
||||
$events => $events.map(adaptLegacyMessage),
|
||||
deriveEvents(repository, {filters: [{kinds: [MESSAGE]}]}),
|
||||
$events => $events,
|
||||
)
|
||||
|
||||
// Nip29
|
||||
|
||||
Reference in New Issue
Block a user