1
0
mirror of git://jb55.com/damus synced 2024-09-05 21:03:51 +00:00
damus/nostrdb/NdbNote+.swift
Daniel D’Aquino 87860a7151 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
2023-11-21 10:39:27 -08:00

31 lines
701 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// NdbNote+.swift
// damus
//
// Created by Daniel DAquino 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
}
}