mirror of
https://github.com/dergigi/boris.git
synced 2025-12-24 10:04:19 +01:00
fix: detect NIP-04 encrypted content in bookmark events
Added explicit detection for NIP-04 encrypted content format: - NIP-04: base64 content with ?iv= suffix - NIP-44: detected by Helpers.hasHiddenContent() - Encrypted tags: detected by Helpers.hasHiddenTags() Created hasEncryptedContent() helper that checks all three cases. Now properly shows padlock emoji and decrypt button for events with NIP-04 encrypted content (like the example with ?iv=5KzDXv09...).
This commit is contained in:
@@ -95,9 +95,22 @@ const Debug: React.FC<DebugProps> = ({ relayPool }) => {
|
||||
return content.length + tags.length
|
||||
}
|
||||
|
||||
const hasEncryptedContent = (evt: NostrEvent): boolean => {
|
||||
// Check for NIP-44 encrypted content (detected by Helpers)
|
||||
if (Helpers.hasHiddenContent(evt)) return true
|
||||
|
||||
// Check for NIP-04 encrypted content (base64 with ?iv= suffix)
|
||||
if (evt.content && evt.content.includes('?iv=')) return true
|
||||
|
||||
// Check for encrypted tags
|
||||
if (Helpers.hasHiddenTags(evt) && !Helpers.isHiddenTagsUnlocked(evt)) return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
const getBookmarkCount = (evt: NostrEvent): { public: number; private: number } => {
|
||||
const publicTags = (evt.tags || []).filter((t: string[]) => t[0] === 'e' || t[0] === 'a')
|
||||
const hasEncrypted = Helpers.hasHiddenContent(evt) || (Helpers.hasHiddenTags(evt) && !Helpers.isHiddenTagsUnlocked(evt))
|
||||
const hasEncrypted = hasEncryptedContent(evt)
|
||||
return {
|
||||
public: publicTags.length,
|
||||
private: hasEncrypted ? 1 : 0 // Can't know exact count until decrypted
|
||||
@@ -670,7 +683,7 @@ const Debug: React.FC<DebugProps> = ({ relayPool }) => {
|
||||
const titleTag = evt.tags?.find((t: string[]) => t[0] === 'title')?.[1]
|
||||
const size = getEventSize(evt)
|
||||
const counts = getBookmarkCount(evt)
|
||||
const hasEncrypted = Helpers.hasHiddenContent(evt) || (Helpers.hasHiddenTags(evt) && !Helpers.isHiddenTagsUnlocked(evt))
|
||||
const hasEncrypted = hasEncryptedContent(evt)
|
||||
const isDecrypting = decryptingEventIds.has(evt.id)
|
||||
const decryptResult = decryptedEvents.get(evt.id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user