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:
@@ -342,6 +342,20 @@ class NoteContentViewTests: XCTestCase {
|
||||
XCTAssertTrue((parsed.blocks[0].asURL != nil), "NoteContentView does not correctly parse an image block when url in JSON content contains optional escaped slashes.")
|
||||
}
|
||||
|
||||
/// Quick test that exercises the direct parsing methods (i.e. not fetching blocks from nostrdb) from `NdbBlockGroup`, and its bridging code with C.
|
||||
/// The parsing logic itself already has test coverage at the nostrdb level.
|
||||
func testDirectBlockParsing() {
|
||||
let kp = test_keypair_full
|
||||
let dm: NdbNote = NIP04.create_dm("Test", to_pk: kp.pubkey, tags: [], keypair: kp.to_keypair())!
|
||||
let blocks = try! NdbBlockGroup.from(event: dm, using: test_damus_state.ndb, and: kp.to_keypair())
|
||||
XCTAssertEqual(blocks.blocks.count, 1)
|
||||
|
||||
let post = NostrPost(content: "Test", kind: .text)
|
||||
let event = post.to_event(keypair: kp)!
|
||||
let blocks2 = try! NdbBlockGroup.from(event: event, using: test_damus_state.ndb, and: kp.to_keypair())
|
||||
XCTAssertEqual(blocks2.blocks.count, 1)
|
||||
}
|
||||
|
||||
func testMentionStr_Pubkey_ContainsAbbreviated() throws {
|
||||
let compatibleText = createCompatibleText(test_pubkey.npub)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user