This commit is contained in:
Roman Volosovskyi 2017-03-06 12:27:55 +02:00
parent 878b8b2b81
commit e28b1aeea1
1 changed files with 12 additions and 6 deletions

View File

@ -8,7 +8,11 @@
(defn- parse-payload [payload]
(debug :parse-payload)
(r/read-string (u/to-utf8 payload)))
(try
{:payload (r/read-string (u/to-utf8 payload))}
(catch :default err
(debug :parse-payload-error err)
{:error err})))
(defn- decrypt [key content]
(try
@ -36,12 +40,14 @@
(let [{:keys [from payload to] :as message}
(js->clj js-message :keywordize-keys true)
{:keys [type ack?] :as payload'}
{{:keys [type ack?] :as payload'} :payload
payload-error :error}
(parse-payload payload)]
(when (or (not= (i/normalize-hex identity)
(i/normalize-hex from))
;; allow user to receive his own discoveries
(= type :discover))
(when (and (not payload-error)
(or (not= (i/normalize-hex identity)
(i/normalize-hex from))
;; allow user to receive his own discoveries
(= type :discover)))
(let [{:keys [content error]} (parse-content (:private keypair)
payload'
(not= "0x0" to))]