1
0
mirror of git://jb55.com/damus synced 2024-09-05 21:03:51 +00:00

ndb: add content and owned_size

This commit is contained in:
William Casarin 2023-07-22 07:40:20 -07:00
parent 6d43754e71
commit 0263c11a94
3 changed files with 9 additions and 2 deletions

View File

@ -17,6 +17,14 @@ struct NdbNote {
self.owned = data
}
var owned_size: Int? {
return owned?.count
}
var content: String {
String(cString: ndb_note_content(note), encoding: .utf8) ?? ""
}
var id: Data {
Data(buffer: UnsafeBufferPointer(start: ndb_note_id(note), count: 32))
}

View File

@ -28,7 +28,7 @@ final class NdbTests: XCTestCase {
XCTAssertEqual(hex_encode(note.id), id)
XCTAssertEqual(hex_encode(note.pubkey), pubkey)
XCTAssertEqual(note.tags().reduce(0, { sum, _ in sum + 1 }), 786)
XCTAssertEqual(note.owned_size, 59106)
XCTAssertEqual(note.tags().reduce(0, { sum, _ in sum + 1 }), 786)
//let tags = note.tags()

View File

@ -409,7 +409,6 @@ static int parse_unsigned_int(const char *start, int len, unsigned int *num)
}
int ndb_note_from_json(const char *json, int len, struct ndb_note **note,
unsigned char *buf, int bufsize)
{