Command scopes spec fix, removed contacts leftovers
This commit is contained in:
parent
6c7ca9648f
commit
1eba86b7bf
|
@ -2,32 +2,9 @@
|
||||||
(:require [status-im.data-store.realm.contacts :as data-store])
|
(:require [status-im.data-store.realm.contacts :as data-store])
|
||||||
(:refer-clojure :exclude [exists?]))
|
(:refer-clojure :exclude [exists?]))
|
||||||
|
|
||||||
(defn- command->map-item
|
|
||||||
[[_ {:keys [name] :as command}]]
|
|
||||||
[(keyword name) command])
|
|
||||||
|
|
||||||
(defn- enrich-with-owner-id [owner-id]
|
|
||||||
(fn [[k v]]
|
|
||||||
[k (assoc v :owner-id owner-id)]))
|
|
||||||
|
|
||||||
(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
|
(data-store/get-all-as-list))
|
||||||
(fn [{:keys [commands responses whisper-identity] :as contact}]
|
|
||||||
(assoc contact
|
|
||||||
:commands (->> commands
|
|
||||||
(map command->map-item)
|
|
||||||
(map (enrich-with-owner-id whisper-identity))
|
|
||||||
(into {}))
|
|
||||||
:responses (into {} (map command->map-item responses))))
|
|
||||||
(data-store/get-all-as-list)))
|
|
||||||
|
|
||||||
(defn get-by-id
|
(defn get-by-id
|
||||||
[whisper-identity]
|
[whisper-identity]
|
||||||
|
@ -41,8 +18,7 @@
|
||||||
(assoc :pending? (boolean (if contact-db
|
(assoc :pending? (boolean (if contact-db
|
||||||
(if (nil? pending?) pending-db? pending?)
|
(if (nil? pending?) pending-db? pending?)
|
||||||
pending?)))
|
pending?)))
|
||||||
(update :commands commands-map->commands-list)
|
(dissoc :commands :responses :global-command))]
|
||||||
(update :responses commands-map->commands-list))]
|
|
||||||
(data-store/save contact' (boolean contact-db))))
|
(data-store/save contact' (boolean contact-db))))
|
||||||
|
|
||||||
(defn save-all
|
(defn save-all
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
(ns status-im.data-store.realm.schemas.account.v16.contact
|
||||||
|
(:require [taoensso.timbre :as log]))
|
||||||
|
|
||||||
|
(def schema {:name :contact
|
||||||
|
:primaryKey :whisper-identity
|
||||||
|
:properties {:address {:type :string :optional true}
|
||||||
|
:whisper-identity :string
|
||||||
|
:name {:type :string :optional true}
|
||||||
|
:photo-path {:type :string :optional true}
|
||||||
|
:last-updated {:type :int :default 0}
|
||||||
|
:last-online {:type :int :default 0}
|
||||||
|
:pending? {:type :bool :default false}
|
||||||
|
:mixable? {:type :bool :default false}
|
||||||
|
:status {:type :string :optional true}
|
||||||
|
:fcm-token {:type :string :optional true}
|
||||||
|
:public-key {:type :string
|
||||||
|
:optional true}
|
||||||
|
:private-key {:type :string
|
||||||
|
:optional true}
|
||||||
|
:dapp? {:type :bool
|
||||||
|
:default false}
|
||||||
|
:dapp-url {:type :string
|
||||||
|
:optional true}
|
||||||
|
:bot-url {:type :string
|
||||||
|
:optional true}
|
||||||
|
:dapp-hash {:type :int
|
||||||
|
:optional true}
|
||||||
|
:debug? {:type :bool
|
||||||
|
:default false}}})
|
||||||
|
|
||||||
|
(defn migration [old-realm new-realm]
|
||||||
|
(log/debug "migrating contact schema v16"))
|
|
@ -3,7 +3,7 @@
|
||||||
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
|
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
|
||||||
[status-im.data-store.realm.schemas.account.v6.command :as command]
|
[status-im.data-store.realm.schemas.account.v6.command :as command]
|
||||||
[status-im.data-store.realm.schemas.account.v9.command-parameter :as command-parameter]
|
[status-im.data-store.realm.schemas.account.v9.command-parameter :as command-parameter]
|
||||||
[status-im.data-store.realm.schemas.account.v15.contact :as contact]
|
[status-im.data-store.realm.schemas.account.v16.contact :as contact]
|
||||||
[status-im.data-store.realm.schemas.account.v1.discover :as discover]
|
[status-im.data-store.realm.schemas.account.v1.discover :as discover]
|
||||||
[status-im.data-store.realm.schemas.account.v1.kv-store :as kv-store]
|
[status-im.data-store.realm.schemas.account.v1.kv-store :as kv-store]
|
||||||
[status-im.data-store.realm.schemas.account.v10.message :as message]
|
[status-im.data-store.realm.schemas.account.v10.message :as message]
|
||||||
|
|
Loading…
Reference in New Issue