mirror of
https://github.com/unclebob/more-speech.git
synced 2024-09-30 10:30:56 +00:00
Some tweaks for performance and logging. And fixing a DB query.
This commit is contained in:
parent
7789d54338
commit
8469fd2039
@ -151,8 +151,10 @@
|
||||
(let [node (:node db)
|
||||
result (xt/q (xt/db node)
|
||||
'{:find [id]
|
||||
:in [user-name]
|
||||
:where [[profile :name user-name]
|
||||
[profile :xt/id id]]})
|
||||
[profile :xt/id id]]}
|
||||
user-name)
|
||||
[{:keys [id]}] (first result)]
|
||||
id))
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
body (assoc body :pubkey (util/bytes->hex-string pubkey)
|
||||
:created_at now)
|
||||
[id body] (events/make-id-with-pow config/proof-of-work-default body)
|
||||
;id (make-id body)
|
||||
aux-rand (util/num->bytes 32 (biginteger (System/currentTimeMillis)))
|
||||
signature (ecc/do-sign id private-key aux-rand)
|
||||
event (assoc body :id (util/bytes->hex-string id)
|
||||
@ -66,7 +65,7 @@
|
||||
[]
|
||||
[[:e (events/hexify reply-to) "" "reply"]])))
|
||||
|
||||
(defn make-people-reference-tags [pubkey reply-to-or-nil]
|
||||
(defn make-people-reference-tags [reply-to-or-nil]
|
||||
(if (nil? reply-to-or-nil)
|
||||
[]
|
||||
(let [parent-event-id reply-to-or-nil
|
||||
@ -75,7 +74,10 @@
|
||||
people-ids (map second (filter #(= :p (first %)) parent-tags))
|
||||
parent-author (:pubkey parent-event)
|
||||
people-ids (conj people-ids (events/hexify parent-author))
|
||||
people-ids (remove #(= (events/hexify pubkey) %) people-ids)]
|
||||
my-pubkey (get-mem :pubkey)
|
||||
people-ids (if (= (:pubkey parent-event) my-pubkey)
|
||||
people-ids
|
||||
(remove #(= (events/hexify my-pubkey) %) people-ids))]
|
||||
(map #(vector :p %) people-ids))))
|
||||
|
||||
(defn make-subject-tag [subject]
|
||||
@ -160,10 +162,9 @@
|
||||
(compose-text-event subject text nil))
|
||||
|
||||
([subject text reply-to-or-nil]
|
||||
(let [pubkey (get-mem :pubkey)
|
||||
root (get-reply-root reply-to-or-nil)
|
||||
(let [root (get-reply-root reply-to-or-nil)
|
||||
tags (concat (make-event-reference-tags reply-to-or-nil root)
|
||||
(make-people-reference-tags pubkey reply-to-or-nil)
|
||||
(make-people-reference-tags reply-to-or-nil)
|
||||
(make-subject-tag subject)
|
||||
[[:client (str "more-speech - " config/version)]])
|
||||
[content tags] (emplace-references text tags)
|
||||
|
@ -27,11 +27,11 @@
|
||||
(defn start-nostr [subscription-time]
|
||||
(let [subscription-id "more-speech"
|
||||
metadata-request-id "more-speech-metadata"
|
||||
contact-lists-request-id "more-speech-contact-lists"
|
||||
;contact-lists-request-id "more-speech-contact-lists"
|
||||
event-handler (get-mem :event-handler)
|
||||
now-in-seconds (quot (System/currentTimeMillis) 1000)]
|
||||
(protocol/connect-to-relays)
|
||||
(protocol/request-contact-lists-from-relays contact-lists-request-id)
|
||||
;(protocol/request-contact-lists-from-relays contact-lists-request-id)
|
||||
(when (user-configuration/should-import-metadata? now-in-seconds)
|
||||
(protocol/request-metadata-from-relays metadata-request-id (- now-in-seconds 86400))
|
||||
(user-configuration/set-last-time-metadata-imported now-in-seconds))
|
||||
|
@ -67,7 +67,7 @@
|
||||
cl (.newWebSocketBuilder client)
|
||||
cws (.buildAsync cl (URI/create url) (->listener (StringBuffer.) relay))
|
||||
wsf (future (.get cws))
|
||||
ws (deref wsf 1000 :time-out)]
|
||||
ws (deref wsf 5000 :time-out)]
|
||||
(if (= ws :time-out)
|
||||
(do
|
||||
(prn 'connection-time-out url)
|
||||
|
Loading…
Reference in New Issue
Block a user