From 972716882c12c6367e08edad780c101dd4b974aa Mon Sep 17 00:00:00 2001 From: William Casarin Date: Fri, 23 Dec 2022 09:20:44 -0800 Subject: [PATCH] profile: add ability to gets/set nip05 --- damus/Nostr/Nostr.swift | 8 +++++++- damus/Views/ProfilePicView.swift | 2 +- damus/Views/ProfileView.swift | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/damus/Nostr/Nostr.swift b/damus/Nostr/Nostr.swift index 9845ecb..d809341 100644 --- a/damus/Nostr/Nostr.swift +++ b/damus/Nostr/Nostr.swift @@ -10,7 +10,7 @@ import Foundation struct Profile: Codable { var value: [String: String] - init (name: String?, display_name: String?, about: String?, picture: String?, website: String?, lud06: String?, lud16: String?) { + init (name: String?, display_name: String?, about: String?, picture: String?, website: String?, lud06: String?, lud16: String?, nip05: String?) { self.value = [:] self.name = name self.display_name = display_name @@ -19,6 +19,7 @@ struct Profile: Codable { self.website = website self.lud06 = lud06 self.lud16 = lud16 + self.nip05 = nip05 } var display_name: String? { @@ -56,6 +57,11 @@ struct Profile: Codable { set(s) { value["lud16"] = s } } + var nip05: String? { + get { return value["nip05"]; } + set(s) { value["nip05"] = s } + } + var lightning_uri: URL? { return make_ln_url(self.lud06) ?? make_ln_url(self.lud16) } diff --git a/damus/Views/ProfilePicView.swift b/damus/Views/ProfilePicView.swift index d614a7f..e0e266b 100644 --- a/damus/Views/ProfilePicView.swift +++ b/damus/Views/ProfilePicView.swift @@ -101,7 +101,7 @@ struct ProfilePicView: View { func make_preview_profiles(_ pubkey: String) -> Profiles { let profiles = Profiles() let picture = "http://cdn.jb55.com/img/red-me.jpg" - let profile = Profile(name: "jb55", display_name: "William Casarin", about: "It's me", picture: picture, website: "https://jb55.com", lud06: nil, lud16: nil) + let profile = Profile(name: "jb55", display_name: "William Casarin", about: "It's me", picture: picture, website: "https://jb55.com", lud06: nil, lud16: nil, nip05: "jb55.com") let ts_profile = TimestampedProfile(profile: profile, timestamp: 0) profiles.add(id: pubkey, profile: ts_profile) return profiles diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift index b924f2e..f450824 100644 --- a/damus/Views/ProfileView.swift +++ b/damus/Views/ProfileView.swift @@ -211,7 +211,7 @@ func test_damus_state() -> DamusState { let pubkey = "3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681" let damus = DamusState(pool: RelayPool(), keypair: Keypair(pubkey: pubkey, privkey: "privkey"), likes: EventCounter(our_pubkey: pubkey), boosts: EventCounter(our_pubkey: pubkey), contacts: Contacts(), tips: TipCounter(our_pubkey: pubkey), profiles: Profiles(), dms: DirectMessagesModel()) - let prof = Profile(name: "damus", display_name: "Damus", about: "iOS app!", picture: "https://damus.io/img/logo.png", website: "https://damus.io", lud06: nil, lud16: "jb55@sendsats.lol") + let prof = Profile(name: "damus", display_name: "Damus", about: "iOS app!", picture: "https://damus.io/img/logo.png", website: "https://damus.io", lud06: nil, lud16: "jb55@sendsats.lol", nip05: "damus.io") let tsprof = TimestampedProfile(profile: prof, timestamp: 0) damus.profiles.add(id: pubkey, profile: tsprof) return damus