add global-command to default_contacts
load browse first prefill global-commands before bot's jails are loaded
This commit is contained in:
parent
808aa46f4f
commit
4265e73f33
|
@ -1,4 +1,27 @@
|
|||
{
|
||||
"browse":
|
||||
{
|
||||
"name":
|
||||
{
|
||||
"en": "Browse"
|
||||
},
|
||||
"dapp?": true,
|
||||
"bot-url": "local://browse-bot",
|
||||
"global-command": {
|
||||
"description":"Launch the browser",
|
||||
"color": "#ffa500",
|
||||
"name": "global",
|
||||
"params": [{
|
||||
"name": "url",
|
||||
"placeholder":"URL",
|
||||
"type":"text"
|
||||
}],
|
||||
"title":"Browser",
|
||||
"registered-only":true,
|
||||
"has-handler": false,
|
||||
"fullscreen":true
|
||||
}
|
||||
},
|
||||
"wallet":
|
||||
{
|
||||
"name":
|
||||
|
@ -42,16 +65,6 @@
|
|||
"bot-url": "local://demo-bot"
|
||||
},
|
||||
|
||||
"browse":
|
||||
{
|
||||
"name":
|
||||
{
|
||||
"en": "Browse"
|
||||
},
|
||||
"dapp?": true,
|
||||
"bot-url": "local://browse-bot"
|
||||
},
|
||||
|
||||
"0x0428c9d6c1aaaa8369a7c63819684f30e34396dc0907d49afeac85a0a774ccb919b3482097d992e66bcc538e7a0c6acf874c77748f396f53c0a102e10d1a37765b":
|
||||
{
|
||||
"name":
|
||||
|
|
|
@ -201,13 +201,21 @@
|
|||
|
||||
(defn add-new-contacts
|
||||
[{:keys [contacts] :as db} [_ new-contacts]]
|
||||
(let [identities (set (keys contacts))
|
||||
new-contacts' (->> new-contacts
|
||||
(map #(update-pending-status contacts %))
|
||||
(remove #(identities (:whisper-identity %)))
|
||||
(map #(vector (:whisper-identity %) %))
|
||||
(into {}))]
|
||||
(let [identities (set (keys contacts))
|
||||
new-contacts' (->> new-contacts
|
||||
(map #(update-pending-status contacts %))
|
||||
(remove #(identities (:whisper-identity %)))
|
||||
(map #(vector (:whisper-identity %) %))
|
||||
(into {}))
|
||||
global-commands (->> new-contacts'
|
||||
(keep (fn [[n {:keys [global-command]}]]
|
||||
(when global-command
|
||||
[(keyword n) (assoc global-command
|
||||
:type :command
|
||||
:bot n)])))
|
||||
(into {}))]
|
||||
(-> db
|
||||
(update :global-commands merge global-commands)
|
||||
(update :contacts merge new-contacts')
|
||||
(assoc :new-contacts (vals new-contacts')))))
|
||||
|
||||
|
@ -234,23 +242,23 @@
|
|||
:timestamp (random/timestamp)
|
||||
:contacts (mapv #(hash-map :identity %) contacts)})
|
||||
default-groups)])
|
||||
(doseq [[id {:keys [name photo-path public-key add-chat? has-global-command?
|
||||
(doseq [[id {:keys [name photo-path public-key add-chat? global-command
|
||||
dapp? dapp-url dapp-hash bot-url]}] default-contacts]
|
||||
(let [id' (clojure.core/name id)]
|
||||
(when-not (get contacts id')
|
||||
(when add-chat?
|
||||
(dispatch [:add-chat id' {:name (:en name)}]))
|
||||
(let [contact
|
||||
{:whisper-identity id'
|
||||
:address (public-key->address id')
|
||||
:name (:en name)
|
||||
:photo-path photo-path
|
||||
:public-key public-key
|
||||
:dapp? dapp?
|
||||
:dapp-url (:en dapp-url)
|
||||
:bot-url bot-url
|
||||
:has-global-command? has-global-command?
|
||||
:dapp-hash dapp-hash}]
|
||||
{:whisper-identity id'
|
||||
:address (public-key->address id')
|
||||
:name (:en name)
|
||||
:photo-path photo-path
|
||||
:public-key public-key
|
||||
:dapp? dapp?
|
||||
:dapp-url (:en dapp-url)
|
||||
:bot-url bot-url
|
||||
:global-command global-command
|
||||
:dapp-hash dapp-hash}]
|
||||
(dispatch [:add-contacts [contact]])
|
||||
(when bot-url
|
||||
(dispatch [:load-commands! contact]))))))))))
|
||||
|
|
Loading…
Reference in New Issue