profile: add ability to gets/set nip05
This commit is contained in:
@@ -10,7 +10,7 @@ import Foundation
|
|||||||
struct Profile: Codable {
|
struct Profile: Codable {
|
||||||
var value: [String: String]
|
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.value = [:]
|
||||||
self.name = name
|
self.name = name
|
||||||
self.display_name = display_name
|
self.display_name = display_name
|
||||||
@@ -19,6 +19,7 @@ struct Profile: Codable {
|
|||||||
self.website = website
|
self.website = website
|
||||||
self.lud06 = lud06
|
self.lud06 = lud06
|
||||||
self.lud16 = lud16
|
self.lud16 = lud16
|
||||||
|
self.nip05 = nip05
|
||||||
}
|
}
|
||||||
|
|
||||||
var display_name: String? {
|
var display_name: String? {
|
||||||
@@ -56,6 +57,11 @@ struct Profile: Codable {
|
|||||||
set(s) { value["lud16"] = s }
|
set(s) { value["lud16"] = s }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var nip05: String? {
|
||||||
|
get { return value["nip05"]; }
|
||||||
|
set(s) { value["nip05"] = s }
|
||||||
|
}
|
||||||
|
|
||||||
var lightning_uri: URL? {
|
var lightning_uri: URL? {
|
||||||
return make_ln_url(self.lud06) ?? make_ln_url(self.lud16)
|
return make_ln_url(self.lud06) ?? make_ln_url(self.lud16)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ struct ProfilePicView: View {
|
|||||||
func make_preview_profiles(_ pubkey: String) -> Profiles {
|
func make_preview_profiles(_ pubkey: String) -> Profiles {
|
||||||
let profiles = Profiles()
|
let profiles = Profiles()
|
||||||
let picture = "http://cdn.jb55.com/img/red-me.jpg"
|
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)
|
let ts_profile = TimestampedProfile(profile: profile, timestamp: 0)
|
||||||
profiles.add(id: pubkey, profile: ts_profile)
|
profiles.add(id: pubkey, profile: ts_profile)
|
||||||
return profiles
|
return profiles
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ func test_damus_state() -> DamusState {
|
|||||||
let pubkey = "3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681"
|
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 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)
|
let tsprof = TimestampedProfile(profile: prof, timestamp: 0)
|
||||||
damus.profiles.add(id: pubkey, profile: tsprof)
|
damus.profiles.add(id: pubkey, profile: tsprof)
|
||||||
return damus
|
return damus
|
||||||
|
|||||||
Reference in New Issue
Block a user