Make NostrDB (and related) code build under the new extension target as well.
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
This commit is contained in:
committed by
William Casarin
parent
ad75d8546c
commit
87860a7151
30
nostrdb/NdbNote+.swift
Normal file
30
nostrdb/NdbNote+.swift
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user