Remove unused code

Closes: #1105
This commit is contained in:
Bryan Montz
2023-05-07 14:13:06 -05:00
committed by William Casarin
parent 0da10eb716
commit 9847f12c95
105 changed files with 52 additions and 1873 deletions

View File

@@ -56,12 +56,6 @@ class Contacts {
}
}
func get_friendosphere() -> [String] {
var fs = get_friend_list()
fs.append(contentsOf: get_friend_of_friend_list())
return fs
}
func remove_friend(_ pubkey: String) {
friends.remove(pubkey)
}
@@ -70,10 +64,6 @@ class Contacts {
return Array(friends)
}
func get_friend_of_friend_list() -> [String] {
return Array(friend_of_friends)
}
func add_friend_pubkey(_ pubkey: String) {
friends.insert(pubkey)
}
@@ -108,24 +98,6 @@ class Contacts {
}
}
func create_contacts(relays: [RelayDescriptor], our_pubkey: String, follow: ReferencedId) -> NostrEvent {
let kind = NostrKind.contacts.rawValue
let content = create_contacts_content(relays) ?? "{}"
let tags = [refid_to_tag(follow)]
return NostrEvent(content: content, pubkey: our_pubkey, kind: kind, tags: tags)
}
func create_contacts_content(_ relays: [RelayDescriptor]) -> String? {
// TODO: just create a new one of this is corrupted?
let crelays = make_contact_relays(relays)
guard let encoded = encode_json(crelays) else {
return nil
}
return encoded
}
func follow_user(pool: RelayPool, our_contacts: NostrEvent?, pubkey: String, privkey: String, follow: ReferencedId) -> NostrEvent? {
guard let ev = follow_user_event(our_contacts: our_contacts, our_pubkey: pubkey, follow: follow) else {
return nil
@@ -245,37 +217,3 @@ func make_contact_relays(_ relays: [RelayDescriptor]) -> [String: RelayInfo] {
acc[relay.url.url.absoluteString] = relay.info
}
}
// TODO: tests for this
func is_friend_event(_ ev: NostrEvent, keypair: Keypair, contacts: Contacts) -> Bool
{
if !contacts.is_friend(ev.pubkey) {
return false
}
if ev.is_reply(keypair.privkey) {
return true
}
let pks = get_referenced_id_set(tags: ev.tags, key: "p")
// reply to self
if pks.count == 0 {
return true
}
// allow reply-to-self-or-friend case
if pks.count == 1 && contacts.is_friend(pks.first!.ref_id) {
return true
}
// show our replies?
for pk in pks {
// don't count self mentions here
if pk.ref_id != ev.pubkey && contacts.is_friend(pk.ref_id) {
return true
}
}
return false
}