From 88801c276269411416ddd6c9d0165d43fc9fb006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Fri, 1 Dec 2023 21:26:34 +0000 Subject: [PATCH] Fix user setting access issue in the notification extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Notification settings test -------------------------- PASS Device: iPhone 15 Pro simulator iOS: 17.0.1 Damus: This commit Setup: - Two phones running Damus on different accounts - Local relay with strfry-push-notify test setup - Apple push notification test tool Coverage: 1. Mention notifications 2. DM notifications 3. Reaction notifications 4. Repost notifications Steps for each notification type: 1. Trigger a push notification (Resend push notification from test tool) 2. Ensure that the notification is received on the other device 3. Turn off notifications for that type on settings 4. Trigger a push notification (Resend push notification from test tool) 5. Ensure that the notification is not received on the other device Result: PASS (notifications are received when enabled and not received when disabled) Closes: https://github.com/damus-io/damus/issues/1764 Signed-off-by: Daniel D’Aquino Signed-off-by: William Casarin --- DamusNotificationService/NotificationExtensionState.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DamusNotificationService/NotificationExtensionState.swift b/DamusNotificationService/NotificationExtensionState.swift index ea23d391..d6db01b4 100644 --- a/DamusNotificationService/NotificationExtensionState.swift +++ b/DamusNotificationService/NotificationExtensionState.swift @@ -20,9 +20,13 @@ struct NotificationExtensionState: HeadlessDamusState { init?() { guard let ndb = try? Ndb(owns_db_file: false) else { return nil } self.ndb = ndb - self.settings = UserSettingsStore() guard let keypair = get_saved_keypair() else { return nil } + + // dumb stuff needed for property wrappers + UserSettingsStore.pubkey = keypair.pubkey + self.settings = UserSettingsStore() + self.contacts = Contacts(our_pubkey: keypair.pubkey) self.muted_threads = MutedThreadsManager(keypair: keypair) self.keypair = keypair