Andrey Shovkoplyas 2017-05-04 16:37:51 +03:00 committed by Roman Volosovskyi
parent 52c10562dc
commit 3936d85c77
1 changed files with 14 additions and 5 deletions

View File

@ -6,6 +6,13 @@
[[_ {:keys [name] :as command}]] [[_ {:keys [name] :as command}]]
[(keyword name) command]) [(keyword name) command])
(defn- commands-map->commands-list
[commands-map]
(or (if (and commands-map (map? commands-map))
(vals commands-map)
commands-map)
'()))
(defn get-all (defn get-all
[] []
(map (map
@ -23,11 +30,13 @@
[{:keys [whisper-identity pending?] :as contact}] [{:keys [whisper-identity pending?] :as contact}]
(let [{pending-db? :pending? (let [{pending-db? :pending?
:as contact-db} (data-store/get-by-id whisper-identity) :as contact-db} (data-store/get-by-id whisper-identity)
contact (assoc contact :pending? contact' (-> contact
(boolean (if contact-db (assoc :pending? (boolean (if contact-db
(if (nil? pending?) pending-db? pending?) (if (nil? pending?) pending-db? pending?)
pending?)))] pending?)))
(data-store/save contact (if contact-db true false)))) (update :commands commands-map->commands-list)
(update :responses commands-map->commands-list))]
(data-store/save contact' (boolean contact-db))))
(defn save-all (defn save-all
[contacts] [contacts]