ndb: sync up a few remaining NdbNote tag differences
This commit is contained in:
@@ -21,6 +21,8 @@ enum ValidationResult: Decodable {
|
||||
}
|
||||
|
||||
//typealias NostrEvent = NdbNote
|
||||
//typealias Tags = TagsSequence
|
||||
typealias Tags = [[String]]
|
||||
typealias NostrEvent = NostrEventOld
|
||||
|
||||
let MAX_NOTE_SIZE: Int = 2 << 18
|
||||
@@ -54,7 +56,7 @@ class NostrEventOld: Codable, Identifiable, CustomStringConvertible, Equatable,
|
||||
let id: String
|
||||
let content: String
|
||||
let sig: String
|
||||
let tags: [[String]]
|
||||
let tags: Tags
|
||||
|
||||
//var boosted_by: String?
|
||||
|
||||
@@ -88,6 +90,18 @@ class NostrEventOld: Codable, Identifiable, CustomStringConvertible, Equatable,
|
||||
hasher.combine(id)
|
||||
}
|
||||
|
||||
static func owned_from_json(json: String) -> NostrEvent? {
|
||||
let decoder = JSONDecoder()
|
||||
guard let dat = json.data(using: .utf8) else {
|
||||
return nil
|
||||
}
|
||||
guard let ev = try? decoder.decode(NostrEvent.self, from: dat) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return ev
|
||||
}
|
||||
|
||||
init?(content: String, keypair: Keypair, kind: UInt32 = 1, tags: [[String]] = [], createdAt: UInt32 = UInt32(Date().timeIntervalSince1970)) {
|
||||
|
||||
self.content = content
|
||||
@@ -937,16 +951,6 @@ func validate_event(ev: NostrEvent) -> ValidationResult {
|
||||
return ok ? .ok : .bad_sig
|
||||
}
|
||||
|
||||
func last_etag(tags: [[String]]) -> String? {
|
||||
var e: String? = nil
|
||||
for tag in tags {
|
||||
if tag.count >= 2 && tag[0] == "e" {
|
||||
e = tag[1]
|
||||
}
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
func first_eref_mention(ev: NostrEvent, privkey: String?) -> Mention? {
|
||||
let blocks = ev.blocks(privkey).blocks.filter { block in
|
||||
guard case .mention(let mention) = block else {
|
||||
|
||||
Reference in New Issue
Block a user