2023-11-16 02:09:28 +00:00
|
|
|
|
//
|
|
|
|
|
// NdbNote+.swift
|
|
|
|
|
// damus
|
|
|
|
|
//
|
|
|
|
|
// Created by Daniel D’Aquino on 2023-11-17.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
|
|
// Extension to make NdbNote compatible with NostrEvent's original API
|
|
|
|
|
extension NdbNote {
|
2024-01-10 19:32:38 +00:00
|
|
|
|
func parse_inner_event() -> NdbNote? {
|
|
|
|
|
return NdbNote.owned_from_json_cstr(json: content_raw, json_len: content_len)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func get_cached_inner_event(cache: EventCache) -> NdbNote? {
|
2023-11-16 02:09:28 +00:00
|
|
|
|
guard self.known_kind == .boost else {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if self.content_len == 0, let id = self.referenced_ids.first {
|
|
|
|
|
// TODO: raw id cache lookups
|
|
|
|
|
return cache.lookup(id)
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-10 19:32:38 +00:00
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func get_inner_event(cache: EventCache) -> NdbNote? {
|
|
|
|
|
if let ev = get_cached_inner_event(cache: cache) {
|
|
|
|
|
return ev
|
|
|
|
|
}
|
|
|
|
|
return self.parse_inner_event()
|
2023-11-16 02:09:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|