mirror of
git://jb55.com/damus
synced 2024-09-05 21:03:51 +00:00
This change includes several source files related to NostrDB into the extension target as well, so that we can use it from that context (and thus enable more advanced push notification formatting and suppression) To make this change possible, I had to split some source files as well as to move some functions to different files, to ensure we don't have to pull too much unnecessary code into the extension. Testing ------- PASS Device: iPhone 15 Pro simulator iOS: 17.0.1 Damus: This commit Test steps: 1. Build DamusNotificationService. Should succeed. PASS 2. Build Damus (the app). PASS 3. Run app, scroll around some notes, go to a few different views, post a note. Should work as normal. PASS
31 lines
701 B
Swift
31 lines
701 B
Swift
//
|
||
// 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 {
|
||
private var inner_event: NdbNote? {
|
||
get {
|
||
return NdbNote.owned_from_json_cstr(json: content_raw, json_len: content_len)
|
||
}
|
||
}
|
||
|
||
func get_inner_event(cache: EventCache) -> NdbNote? {
|
||
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)
|
||
}
|
||
|
||
return self.inner_event
|
||
}
|
||
}
|