mirror of
https://github.com/unclebob/more-speech.git
synced 2024-09-29 18:10:45 +00:00
A little cleanup.
This commit is contained in:
parent
b8169c1a0a
commit
9fe491ded1
@ -1,11 +1,11 @@
|
||||
(ns more-speech.nostr.contact-list
|
||||
(:require [more-speech.nostr.util :as util]
|
||||
(:require [more-speech.bech32 :as bech32]
|
||||
[more-speech.config :refer [get-db]]
|
||||
[more-speech.config :as config]
|
||||
[more-speech.db.gateway :as gateway]
|
||||
[more-speech.logger.default :refer [log-pr]]
|
||||
[more-speech.mem :refer :all]
|
||||
[more-speech.db.gateway :as gateway]
|
||||
[more-speech.bech32 :as bech32]
|
||||
[more-speech.config :refer [get-db]]
|
||||
[more-speech.config :as config]))
|
||||
[more-speech.nostr.util :as util]))
|
||||
|
||||
|
||||
(defn make-contact-from-tag [[_p pubkey relay petname]]
|
||||
@ -39,18 +39,22 @@
|
||||
(or (= candidate-pubkey my-pubkey)
|
||||
(contains? my-contact-pubkeys candidate-pubkey))))
|
||||
|
||||
(defn which-contact-trusts [candidate-pubkey]
|
||||
(defn- my-contact-trusts-candidate? [my-contact candidate-id]
|
||||
(let [his-contacts (gateway/get-contacts (get-db) my-contact)
|
||||
his-contact-ids (set (map :pubkey his-contacts))]
|
||||
(contains? his-contact-ids candidate-id)))
|
||||
|
||||
(defn which-contact-trusts [candidate-id]
|
||||
(let [my-pubkey (get-mem :pubkey)
|
||||
my-contacts (gateway/get-contacts (get-db) my-pubkey)]
|
||||
(loop [my-contact-ids (map :pubkey my-contacts)]
|
||||
(if (empty? my-contact-ids)
|
||||
(cond
|
||||
(empty? my-contact-ids)
|
||||
nil
|
||||
(let [my-contact (first my-contact-ids)
|
||||
his-contacts (gateway/get-contacts (get-db) my-contact)
|
||||
his-contact-ids (set (map :pubkey his-contacts))]
|
||||
(if (contains? his-contact-ids candidate-pubkey)
|
||||
my-contact
|
||||
(recur (rest my-contact-ids))))))))
|
||||
(my-contact-trusts-candidate? (first my-contact-ids) candidate-id)
|
||||
(first my-contact-ids)
|
||||
:else
|
||||
(recur (rest my-contact-ids))))))
|
||||
|
||||
(defn get-petname [his-pubkey]
|
||||
(let [my-pubkey (get-mem :pubkey)
|
||||
@ -72,7 +76,7 @@
|
||||
([id]
|
||||
(let [contacts (gateway/get-contacts (get-db) id)]
|
||||
(set (concat [(get-mem :pubkey)]
|
||||
(map :pubkey contacts))))))
|
||||
(map :pubkey contacts))))))
|
||||
|
||||
(defn get-web-of-trust
|
||||
([]
|
||||
|
@ -43,14 +43,9 @@
|
||||
(set-mem :refresh-main-window true)
|
||||
(try
|
||||
(let [profile (json/read-str content)
|
||||
name (get profile "name")
|
||||
{:strs [name lud16 nip05 lud06 website banner]} profile
|
||||
about (get profile "about" "")
|
||||
picture (get profile "picture" "")
|
||||
lud16 (get profile "lud16")
|
||||
nip05 (get profile "nip05")
|
||||
lud06 (get profile "lud06")
|
||||
website (get profile "website")
|
||||
banner (get profile "banner")
|
||||
display-name (get profile "display_name")
|
||||
possible-alias (if (empty? display-name)
|
||||
""
|
||||
@ -223,13 +218,15 @@
|
||||
;nip-42 authorization challenge.
|
||||
(defn handle-authorization-challenge [envelope url]
|
||||
(let [response-event (event-composers/body->event
|
||||
{:kind 22242
|
||||
:tags [["relay" url]
|
||||
["challenge" (second envelope)]]
|
||||
:content ""})
|
||||
{:kind 22242
|
||||
:tags [["relay" url]
|
||||
["challenge" (second envelope)]]
|
||||
:content ""})
|
||||
auth-event ["AUTH" (second response-event)]
|
||||
relay (relays/get-relay-for url)]
|
||||
(relay/send relay auth-event)))
|
||||
(if (nil? relay)
|
||||
(log-pr 2 'handle-authorization-challenge 'nil-relay-for url)
|
||||
(relay/send relay auth-event))))
|
||||
|
||||
(defn handle-unknown-notice-type [_envelope _url]
|
||||
)
|
||||
@ -281,11 +278,15 @@
|
||||
(try
|
||||
(validate-and-process-event url envelope)
|
||||
(catch Exception e
|
||||
(do (log-pr 1 'handle-event url (.getMessage e))
|
||||
(do (log-pr 1 'validate-and-process-event url (.getMessage e))
|
||||
(log-pr 1 "--on event: " envelope)))))
|
||||
|
||||
(defn handle-event [_agent envelope url]
|
||||
(count-event url)
|
||||
(if (not= "EVENT" (first envelope))
|
||||
(handle-notification envelope url)
|
||||
(try-validate-and-process-event url envelope)))
|
||||
(try
|
||||
(count-event url)
|
||||
(if (not= "EVENT" (first envelope))
|
||||
(handle-notification envelope url)
|
||||
(try-validate-and-process-event url envelope))
|
||||
(catch Exception e
|
||||
(do (log-pr 1 'handle-event url (.getMessage e))
|
||||
(log-pr 1 "--on event: " envelope)))))
|
||||
|
@ -233,7 +233,7 @@
|
||||
[type id event] message]
|
||||
|
||||
(cond
|
||||
(= type "EVENT") ;nobody uses this right now...
|
||||
(= type "EVENT")
|
||||
(update-mem [:active-subscriptions url id] count-event event)
|
||||
|
||||
(= type "EOSE")
|
||||
|
Loading…
Reference in New Issue
Block a user