mirror of
https://github.com/dergigi/boris.git
synced 2026-01-02 14:34:25 +01:00
feat: enhance bookmark debugging and fetch legacy formats
- Add detailed logging for events with content (potentially encrypted) - Fetch legacy bookmark format (kind 30001) in addition to NIP-51 standards - Show content preview for all events to identify encrypted content - Help identify if private bookmarks are in different event formats
This commit is contained in:
@@ -47,18 +47,18 @@ function dedupeNip51Events(events: NostrEvent[]): NostrEvent[] {
|
||||
for (const e of events) { if (e?.id && !byId.has(e.id)) byId.set(e.id, e) }
|
||||
const unique = Array.from(byId.values())
|
||||
|
||||
// Get the latest bookmark list (10003) - default bookmark list without 'd' tag
|
||||
// Get the latest bookmark list (10003/30001) - default bookmark list without 'd' tag
|
||||
const bookmarkLists = unique
|
||||
.filter(e => e.kind === 10003)
|
||||
.filter(e => e.kind === 10003 || e.kind === 30001)
|
||||
.sort((a, b) => (b.created_at || 0) - (a.created_at || 0))
|
||||
const latestBookmarkList = bookmarkLists.find(list =>
|
||||
!list.tags?.some((t: string[]) => t[0] === 'd')
|
||||
)
|
||||
|
||||
// Group bookmark sets (30003) and named bookmark lists (10003 with 'd' tag) by their 'd' identifier
|
||||
// Group bookmark sets (30003) and named bookmark lists (10003/30001 with 'd' tag) by their 'd' identifier
|
||||
const byD = new Map<string, NostrEvent>()
|
||||
for (const e of unique) {
|
||||
if (e.kind === 10003 || e.kind === 30003) {
|
||||
if (e.kind === 10003 || e.kind === 30003 || e.kind === 30001) {
|
||||
const d = (e.tags || []).find((t: string[]) => t[0] === 'd')?.[1] || ''
|
||||
const prev = byD.get(d)
|
||||
if (!prev || (e.created_at || 0) > (prev.created_at || 0)) byD.set(d, e)
|
||||
@@ -135,16 +135,30 @@ export const fetchBookmarks = async (
|
||||
}
|
||||
// Get relay URLs from the pool
|
||||
const relayUrls = Array.from(relayPool.relays.values()).map(relay => relay.url)
|
||||
// Fetch bookmark lists (10003) and bookmark sets (30003) - NIP-51 standards
|
||||
// Fetch bookmark events - NIP-51 standards and legacy formats
|
||||
console.log('🔍 Fetching bookmark events from relays:', relayUrls)
|
||||
const rawEvents = await lastValueFrom(
|
||||
relayPool
|
||||
.req(relayUrls, { kinds: [10003, 30003], authors: [activeAccount.pubkey] })
|
||||
.req(relayUrls, { kinds: [10003, 30003, 30001], authors: [activeAccount.pubkey] })
|
||||
.pipe(completeOnEose(), takeUntil(timer(10000)), toArray())
|
||||
)
|
||||
console.log('📊 Raw events fetched:', rawEvents.length, 'events')
|
||||
|
||||
// Check for events with potentially encrypted content
|
||||
const eventsWithContent = rawEvents.filter(evt => evt.content && evt.content.length > 0)
|
||||
if (eventsWithContent.length > 0) {
|
||||
console.log('🔐 Events with content (potentially encrypted):', eventsWithContent.length)
|
||||
eventsWithContent.forEach((evt, i) => {
|
||||
const dTag = evt.tags?.find((t: string[]) => t[0] === 'd')?.[1] || 'none'
|
||||
const contentPreview = evt.content.slice(0, 60) + (evt.content.length > 60 ? '...' : '')
|
||||
console.log(` Encrypted Event ${i}: kind=${evt.kind}, id=${evt.id?.slice(0, 8)}, dTag=${dTag}, contentLength=${evt.content.length}, preview=${contentPreview}`)
|
||||
})
|
||||
}
|
||||
|
||||
rawEvents.forEach((evt, i) => {
|
||||
console.log(` Event ${i}: kind=${evt.kind}, id=${evt.id?.slice(0, 8)}, dTag=${evt.tags?.find((t: string[]) => t[0] === 'd')?.[1] || 'none'}`)
|
||||
const dTag = evt.tags?.find((t: string[]) => t[0] === 'd')?.[1] || 'none'
|
||||
const contentPreview = evt.content ? evt.content.slice(0, 50) + (evt.content.length > 50 ? '...' : '') : 'empty'
|
||||
console.log(` Event ${i}: kind=${evt.kind}, id=${evt.id?.slice(0, 8)}, dTag=${dTag}, contentLength=${evt.content?.length || 0}, contentPreview=${contentPreview}`)
|
||||
})
|
||||
|
||||
const bookmarkListEvents = dedupeNip51Events(rawEvents)
|
||||
|
||||
Reference in New Issue
Block a user