Upgrade nostr-tools, add groups/circles to Tags

This commit is contained in:
Jon Staab
2024-01-09 11:01:10 -08:00
parent 0af0375f62
commit 7cb792ba17
3 changed files with 34 additions and 9 deletions
+6 -2
View File
@@ -1,6 +1,6 @@
import type {Event} from 'nostr-tools'
import normalizeUrl from "normalize-url"
import {verifySignature, getEventHash, matchFilter as nostrToolsMatchFilter} from 'nostr-tools'
import {verifyEvent, getEventHash, matchFilter as nostrToolsMatchFilter} from 'nostr-tools'
import {cached} from "./LRUCache"
// ===========================================================================
@@ -82,7 +82,7 @@ export const hasValidSignature = cached<string, boolean, [Event]>({
return 'invalid'
}
},
getValue: ([e]: [Event]) => verifySignature(e),
getValue: ([e]: [Event]) => verifyEvent(e),
})
// ==========================================================================
@@ -215,8 +215,12 @@ export class Tags extends Fluent<string[]> {
replies = (type = null) => this.getAncestors(type).replies
groups = () => this.type("a").values().filter(a => a.startsWith('35834:'))
communities = () => this.type("a").values().filter(a => a.startsWith('34550:'))
circles = () => this.type("a").values().filter(a => a.match(/^(34550|35834):/))
getReply = (type = null) => this.replies(type).values().first()
getRoot = (type = null) => this.roots(type).values().first()