mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 15:14:20 +01:00
feat(bookmarks): unlock hidden bookmarks via applesauce helpers and signer; reduce logs
This commit is contained in:
@@ -31,28 +31,6 @@ function isAccountWithExtension(account: unknown): account is AccountWithExtensi
|
|||||||
return typeof account === 'object' && account !== null && 'pubkey' in account
|
return typeof account === 'object' && account !== null && 'pubkey' in account
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const processBookmarks = (
|
|
||||||
bookmarks: unknown,
|
|
||||||
activeAccount: ActiveAccount,
|
|
||||||
isPrivate: boolean
|
|
||||||
): IndividualBookmark[] => {
|
|
||||||
if (!bookmarks) return []
|
|
||||||
|
|
||||||
const bookmarkArray = Array.isArray(bookmarks) ? bookmarks : [bookmarks]
|
|
||||||
return bookmarkArray.map((bookmark: BookmarkData) => ({
|
|
||||||
id: bookmark.id || `${isPrivate ? 'private' : 'public'}-${Date.now()}`,
|
|
||||||
content: bookmark.content || '',
|
|
||||||
created_at: bookmark.created_at || Date.now(),
|
|
||||||
pubkey: activeAccount.pubkey,
|
|
||||||
kind: bookmark.kind || 30001,
|
|
||||||
tags: bookmark.tags || [],
|
|
||||||
parsedContent: bookmark.content ? getParsedContent(bookmark.content) as ParsedContent : undefined,
|
|
||||||
type: 'event' as const,
|
|
||||||
isPrivate
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
const processApplesauceBookmarks = (
|
const processApplesauceBookmarks = (
|
||||||
bookmarks: unknown,
|
bookmarks: unknown,
|
||||||
activeAccount: ActiveAccount,
|
activeAccount: ActiveAccount,
|
||||||
@@ -83,8 +61,19 @@ const processApplesauceBookmarks = (
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to original processing for arrays
|
// Fallback: map array-like bookmarks
|
||||||
return processBookmarks(bookmarks, activeAccount, isPrivate)
|
const bookmarkArray = Array.isArray(bookmarks) ? bookmarks : [bookmarks]
|
||||||
|
return bookmarkArray.map((bookmark: BookmarkData) => ({
|
||||||
|
id: bookmark.id || `${isPrivate ? 'private' : 'public'}-${Date.now()}`,
|
||||||
|
content: bookmark.content || '',
|
||||||
|
created_at: bookmark.created_at || Date.now(),
|
||||||
|
pubkey: activeAccount.pubkey,
|
||||||
|
kind: bookmark.kind || 30001,
|
||||||
|
tags: bookmark.tags || [],
|
||||||
|
parsedContent: bookmark.content ? getParsedContent(bookmark.content) as ParsedContent : undefined,
|
||||||
|
type: 'event' as const,
|
||||||
|
isPrivate
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -132,7 +121,6 @@ export const fetchBookmarks = async (
|
|||||||
for (let i = 0; i < bookmarkListEvents.length; i++) {
|
for (let i = 0; i < bookmarkListEvents.length; i++) {
|
||||||
const event = bookmarkListEvents[i]
|
const event = bookmarkListEvents[i]
|
||||||
console.log(`Event ${i}: ${event.id}`)
|
console.log(`Event ${i}: ${event.id}`)
|
||||||
console.log(` Content: ${event.content}`)
|
|
||||||
console.log(` Tags: ${event.tags.length} tags`)
|
console.log(` Tags: ${event.tags.length} tags`)
|
||||||
|
|
||||||
// Check if this event has encrypted content
|
// Check if this event has encrypted content
|
||||||
@@ -156,23 +144,22 @@ export const fetchBookmarks = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('Selected bookmark list event:', bookmarkListEvent.id)
|
console.log('Selected bookmark list event:', bookmarkListEvent.id)
|
||||||
console.log('Bookmark list content:', bookmarkListEvent.content)
|
|
||||||
console.log('Bookmark list tags:', bookmarkListEvent.tags)
|
|
||||||
|
|
||||||
// Use applesauce helpers to get public bookmarks
|
// Use applesauce helpers to get public bookmarks
|
||||||
const publicBookmarks = Helpers.getPublicBookmarks(bookmarkListEvent)
|
const publicBookmarks = Helpers.getPublicBookmarks(bookmarkListEvent)
|
||||||
console.log('Public bookmarks:', publicBookmarks)
|
console.log('Public bookmarks:', publicBookmarks)
|
||||||
|
|
||||||
console.log('Content preview:', bookmarkListEvent.content?.substring(0, 100))
|
|
||||||
|
|
||||||
// Try to get private bookmarks - this should trigger browser extension if needed
|
// Try to get private bookmarks - this should trigger browser extension if needed
|
||||||
let privateBookmarks = null
|
let privateBookmarks = null
|
||||||
try {
|
try {
|
||||||
console.log('Attempting to get hidden bookmarks...')
|
console.log('Attempting to get hidden bookmarks...')
|
||||||
console.log('Active account signer:', !!activeAccount.signer)
|
const locked = Helpers.isHiddenTagsLocked(bookmarkListEvent)
|
||||||
console.log('Signer type:', typeof activeAccount.signer)
|
console.log('Hidden tags locked:', locked)
|
||||||
|
const maybeAccount = activeAccount as any
|
||||||
// This should trigger the browser extension if encrypted content exists
|
const signerCandidate = typeof maybeAccount?.signEvent === 'function' ? maybeAccount : maybeAccount?.signer
|
||||||
|
if (locked && signerCandidate) {
|
||||||
|
await Helpers.unlockHiddenTags(bookmarkListEvent, signerCandidate)
|
||||||
|
}
|
||||||
privateBookmarks = Helpers.getHiddenBookmarks(bookmarkListEvent)
|
privateBookmarks = Helpers.getHiddenBookmarks(bookmarkListEvent)
|
||||||
console.log('Private bookmarks result:', privateBookmarks)
|
console.log('Private bookmarks result:', privateBookmarks)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user