Fix broken DM rendering

Currently NostrDB does not seem to handle encryption/decryption of DMs.
Since NostrDB now controls the block parsing process and fetches note
contents directly from the database, we have to add a specific condition
that injects decrypted content directly to the ndb content parser.

This is done in conjunction with some minor refactoring to `NdbBlocks`
and associated structs, as in C those are separated between the content
string and the offsets for each block, but in Swift this is more
ergonomically represented as a standalone/self-containing object.

No changelog entry is added because the previously broken version was
never released to the public, and therefore this fix produces no
user-facing changes compared to the last released version.

Changelog-None
Closes: https://github.com/damus-io/damus/issues/3106
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2025-06-27 19:27:42 -07:00
parent 9c47d2e0bd
commit caa7802bce
11 changed files with 350 additions and 129 deletions

View File

@@ -72,9 +72,9 @@ func generate_local_notification_object(ndb: Ndb, from ev: NostrEvent, state: He
if type == .text,
state.settings.mention_notification,
let blocks = ev.blocks(ndb: ndb)?.unsafeUnownedValue
let blockGroup = try? NdbBlockGroup.from(event: ev, using: ndb, and: state.keypair)
{
for case .mention(let mention) in blocks.iter(note: ev) {
for case .mention(let mention) in blockGroup.blocks {
guard case .npub = mention.bech32_type,
(memcmp(state.keypair.pubkey.id.bytes, mention.bech32.npub.pubkey, 32) == 0) else {
continue