damus

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

NotificationExtensionState.swift (1246B)


      1 //
      2 //  NotificationExtensionState.swift
      3 //  DamusNotificationService
      4 //
      5 //  Created by Daniel D’Aquino on 2023-11-27.
      6 //
      7 
      8 import Foundation
      9 
     10 struct NotificationExtensionState: HeadlessDamusState {
     11     let ndb: Ndb
     12     let settings: UserSettingsStore
     13     let contacts: Contacts
     14     let mutelist_manager: MutelistManager
     15     let keypair: Keypair
     16     let profiles: Profiles
     17     let zaps: Zaps
     18     let lnurls: LNUrls
     19     
     20     init?() {
     21         guard let ndb = try? Ndb(owns_db_file: false) else { return nil }
     22         self.ndb = ndb
     23         
     24         guard let keypair = get_saved_keypair() else { return nil }
     25         
     26         // dumb stuff needed for property wrappers
     27         UserSettingsStore.pubkey = keypair.pubkey
     28         self.settings = UserSettingsStore()
     29         
     30         self.contacts = Contacts(our_pubkey: keypair.pubkey)
     31         self.mutelist_manager = MutelistManager(user_keypair: keypair)
     32         self.keypair = keypair
     33         self.profiles = Profiles(ndb: ndb)
     34         self.zaps = Zaps(our_pubkey: keypair.pubkey)
     35         self.lnurls = LNUrls()
     36     }
     37     
     38     @discardableResult
     39     func add_zap(zap: Zapping) -> Bool {
     40         // store generic zap mapping
     41         self.zaps.add_zap(zap: zap)
     42         
     43         return true
     44     }
     45 }