damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit ed30b123db2ba5122e4b9134ae2d9223c82721ac
parent bfad2ab42d47ea91e042ee458a716051a243ff8b
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 10 Jan 2024 14:39:45 -0800

notifications: don't hold onto note ref outside of txn

It's never safe to return an unsafeUnownedValue

Fixes: c4f0e833ff1f ("Reuse local notification logic with push notifications")
Cc: Daniel DAquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus/Models/NotificationsManager.swift | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/damus/Models/NotificationsManager.swift b/damus/Models/NotificationsManager.swift @@ -78,7 +78,7 @@ func generate_local_notification_object(from ev: NostrEvent, state: HeadlessDamu state.settings.like_notification, let evid = ev.referenced_ids.last, let txn = state.ndb.lookup_note(evid), - let liked_event = txn.unsafeUnownedValue // We are only accessing it temporarily to generate notification content + let liked_event = txn.unsafeUnownedValue?.to_owned() { let content_preview = render_notification_content_preview(ev: liked_event, profiles: state.profiles, keypair: state.keypair) return LocalNotification(type: .like, event: ev, target: liked_event, content: content_preview)