From ed30b123db2ba5122e4b9134ae2d9223c82721ac Mon Sep 17 00:00:00 2001 From: William Casarin Date: Wed, 10 Jan 2024 14:39:45 -0800 Subject: [PATCH] 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 Signed-off-by: William Casarin --- damus/Models/NotificationsManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/damus/Models/NotificationsManager.swift b/damus/Models/NotificationsManager.swift index 66a5d3a0..6a832362 100644 --- 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)