Files
damus/damus/Nostr/Profiles.swift
William Casarin 0a4e75bfec Add nip05 search
Changelog-Added: Added ability to lookup users by nip05 identifiers
2023-03-29 19:24:06 -04:00

42 lines
868 B
Swift

//
// Profiles.swift
// damus
//
// Created by William Casarin on 2022-04-17.
//
import Foundation
import UIKit
class Profiles {
var profiles: [String: TimestampedProfile] = [:]
var validated: [String: NIP05] = [:]
var nip05_pubkey: [String: String] = [:]
var zappers: [String: String] = [:]
func is_validated(_ pk: String) -> NIP05? {
return validated[pk]
}
func lookup_zapper(pubkey: String) -> String? {
if let zapper = zappers[pubkey] {
return zapper
}
return nil
}
func add(id: String, profile: TimestampedProfile) {
profiles[id] = profile
}
func lookup(id: String) -> Profile? {
return profiles[id]?.profile
}
func lookup_with_timestamp(id: String) -> TimestampedProfile? {
return profiles[id]
}
}