Requesting message in group chat now contains recipient name (#1396); restructuring of commands
This commit is contained in:
parent
29ccf9546f
commit
a0de31ebb6
|
@ -424,7 +424,7 @@ function previewSend(params, context) {
|
||||||
lineHeight: 18
|
lineHeight: 18
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"to " + params["bot-db"]["public"]["recipient"]["name"]
|
I18n.t('send_sending_to') + " " + params["bot-db"]["public"]["recipient"]["name"]
|
||||||
);
|
);
|
||||||
markup = [firstRow, secondRow];
|
markup = [firstRow, secondRow];
|
||||||
} else {
|
} else {
|
||||||
|
@ -506,18 +506,51 @@ status.command({
|
||||||
},
|
},
|
||||||
prefill: [context["current-account"]["name"], val],
|
prefill: [context["current-account"]["name"], val],
|
||||||
prefillBotDb: {
|
prefillBotDb: {
|
||||||
contact: context["current-account"]
|
public: {
|
||||||
|
recipient: context["current-account"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
preview: function (params, context) {
|
preview: function (params, context) {
|
||||||
return {
|
var firstRow = status.components.text(
|
||||||
markup: status.components.text(
|
|
||||||
{},
|
{},
|
||||||
I18n.t('request_requesting') + " "
|
I18n.t('request_requesting') + " "
|
||||||
+ status.localizeNumber(params.amount, context.delimiter, context.separator)
|
+ status.localizeNumber(params.amount, context.delimiter, context.separator)
|
||||||
+ " ETH"
|
+ " ETH"
|
||||||
|
);
|
||||||
|
|
||||||
|
var markup;
|
||||||
|
|
||||||
|
if (params["bot-db"]
|
||||||
|
&& params["bot-db"]["public"]
|
||||||
|
&& params["bot-db"]["public"]["recipient"]
|
||||||
|
&& context["chat"]["group-chat"] === true) {
|
||||||
|
|
||||||
|
var secondRow = status.components.text(
|
||||||
|
{
|
||||||
|
style: {
|
||||||
|
color: "#9199a0",
|
||||||
|
fontSize: 14,
|
||||||
|
lineHeight: 18
|
||||||
|
}
|
||||||
|
},
|
||||||
|
I18n.t('request_requesting_from') + " " + params["bot-db"]["public"]["recipient"]["name"]
|
||||||
|
);
|
||||||
|
markup = [firstRow, secondRow];
|
||||||
|
} else {
|
||||||
|
markup = [firstRow];
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
markup: status.components.view(
|
||||||
|
{
|
||||||
|
style: {
|
||||||
|
flexDirection: "column"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
markup
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,12 +13,14 @@ I18n.translations = {
|
||||||
send_explanation_2: 'usually within a minute.',
|
send_explanation_2: 'usually within a minute.',
|
||||||
send_explanation_3: 'probably within 30 seconds.',
|
send_explanation_3: 'probably within 30 seconds.',
|
||||||
send_explanation_4: 'probably within a few seconds.',
|
send_explanation_4: 'probably within a few seconds.',
|
||||||
|
send_sending_to: 'to ',
|
||||||
|
|
||||||
eth: 'ETH',
|
eth: 'ETH',
|
||||||
|
|
||||||
request_title: 'Request ETH',
|
request_title: 'Request ETH',
|
||||||
request_description: 'Request a payment',
|
request_description: 'Request a payment',
|
||||||
request_requesting: 'Requesting ',
|
request_requesting: 'Requesting ',
|
||||||
|
request_requesting_from: 'from ',
|
||||||
|
|
||||||
validation_title: 'Amount',
|
validation_title: 'Amount',
|
||||||
validation_amount_specified: 'Amount must be specified',
|
validation_amount_specified: 'Amount must be specified',
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
(handlers/side-effect!
|
(handlers/side-effect!
|
||||||
(fn [{:keys [contacts current-account-id chats] :as db}
|
(fn [{:keys [contacts current-account-id chats] :as db}
|
||||||
[_ {{:keys [command params content-command type]} :content
|
[_ {{:keys [command params content-command type]} :content
|
||||||
:keys [message-id from chat-id on-requested jail-id] :as message} data-type]]
|
:keys [message-id chat-id jail-id on-requested from] :as message} data-type]]
|
||||||
(let [jail-id (or jail-id chat-id)
|
(let [jail-id (or jail-id chat-id)
|
||||||
jail-id' (if (get-in chats [jail-id :group-chat])
|
jail-id' (if (get-in chats [jail-id :group-chat])
|
||||||
(get-in chats [jail-id :command-suggestions (keyword command) :owner-id])
|
(get-in chats [jail-id :command-suggestions (keyword command) :owner-id])
|
||||||
|
|
|
@ -10,24 +10,24 @@
|
||||||
|
|
||||||
(def console-commands
|
(def console-commands
|
||||||
{:password
|
{:password
|
||||||
(fn [params _]
|
(fn [{:keys [password]} _]
|
||||||
(dispatch [:create-account (params "password")]))
|
(dispatch [:create-account password]))
|
||||||
|
|
||||||
:phone
|
:phone
|
||||||
(fn [params id]
|
(fn [{:keys [phone]} id]
|
||||||
(dispatch [:sign-up (params "phone") id]))
|
(dispatch [:sign-up phone id]))
|
||||||
|
|
||||||
:confirmation-code
|
:confirmation-code
|
||||||
(fn [params id]
|
(fn [{:keys [code]} id]
|
||||||
(dispatch [:sign-up-confirm (params "code") id]))
|
(dispatch [:sign-up-confirm code id]))
|
||||||
|
|
||||||
:faucet
|
:faucet
|
||||||
(fn [params id]
|
(fn [{:keys [url]} id]
|
||||||
(dispatch [:open-faucet (params "url") id]))
|
(dispatch [:open-faucet url id]))
|
||||||
|
|
||||||
:debug
|
:debug
|
||||||
(fn [params id]
|
(fn [{:keys [mode]} id]
|
||||||
(let [debug-on? (= (params "mode") "On")]
|
(let [debug-on? (= mode "On")]
|
||||||
(dispatch [:account-update {:debug? debug-on?}])
|
(dispatch [:account-update {:debug? debug-on?}])
|
||||||
(if debug-on?
|
(if debug-on?
|
||||||
(do
|
(do
|
||||||
|
@ -49,10 +49,14 @@
|
||||||
|
|
||||||
(register-handler :invoke-console-command-handler!
|
(register-handler :invoke-console-command-handler!
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [_ [_ {:keys [chat-id command-message] :as parameters}]]
|
(fn [_ [_ {{:keys [command
|
||||||
(let [{:keys [id command params]} command-message
|
params
|
||||||
{:keys [name]} command]
|
id]
|
||||||
(dispatch [:prepare-command! chat-id parameters])
|
:as content} :command
|
||||||
|
chat-id :chat-id
|
||||||
|
:as all-params}]]
|
||||||
|
(let [{:keys [name]} command]
|
||||||
|
(dispatch [:prepare-command! chat-id all-params])
|
||||||
((console-commands (keyword name)) params id)))))
|
((console-commands (keyword name)) params id)))))
|
||||||
|
|
||||||
(register-handler :set-message-status
|
(register-handler :set-message-status
|
||||||
|
|
|
@ -168,10 +168,10 @@
|
||||||
|
|
||||||
(handlers/register-handler ::send-message
|
(handlers/register-handler ::send-message
|
||||||
(handlers/side-effect!
|
(handlers/side-effect!
|
||||||
(fn [{:keys [current-public-key current-account-id] :as db} [_ command-message chat-id]]
|
(fn [{:keys [current-public-key current-account-id] :as db} [_ command chat-id]]
|
||||||
(let [text (get-in db [:chats chat-id :input-text])
|
(let [text (get-in db [:chats chat-id :input-text])
|
||||||
data {:message text
|
data {:message text
|
||||||
:command command-message
|
:command command
|
||||||
:chat-id chat-id
|
:chat-id chat-id
|
||||||
:identity current-public-key
|
:identity current-public-key
|
||||||
:address current-account-id}]
|
:address current-account-id}]
|
||||||
|
@ -179,41 +179,30 @@
|
||||||
(dispatch [:set-chat-input-metadata nil chat-id])
|
(dispatch [:set-chat-input-metadata nil chat-id])
|
||||||
(dispatch [:set-chat-ui-props {:sending-in-progress? false}])
|
(dispatch [:set-chat-ui-props {:sending-in-progress? false}])
|
||||||
(cond
|
(cond
|
||||||
command-message
|
command
|
||||||
(dispatch [:check-commands-handlers! data])
|
(dispatch [:check-commands-handlers! data])
|
||||||
(not (str/blank? text))
|
(not (str/blank? text))
|
||||||
(dispatch [:prepare-message data]))))))
|
(dispatch [:prepare-message data]))))))
|
||||||
|
|
||||||
(handlers/register-handler :proceed-command
|
(handlers/register-handler :proceed-command
|
||||||
(handlers/side-effect!
|
(handlers/side-effect!
|
||||||
(fn [db [_ command chat-id]]
|
(fn [db [_ {{:keys [bot]} :command :as content} chat-id]]
|
||||||
(let [jail-id (or (get-in command [:command :bot]) chat-id)]
|
(let [params {:content content
|
||||||
;:check-and-load-commands!
|
|
||||||
(let [params
|
|
||||||
{:command command
|
|
||||||
:chat-id chat-id
|
:chat-id chat-id
|
||||||
:jail-id jail-id}
|
:jail-id (or bot chat-id)}
|
||||||
|
on-send-params (merge params
|
||||||
on-send-params
|
|
||||||
(merge params
|
|
||||||
{:data-type :on-send
|
{:data-type :on-send
|
||||||
:after (fn [_ res]
|
:after #(dispatch [::send-command %2 content chat-id])})
|
||||||
(dispatch [::send-command res command chat-id]))})
|
after-validation #(dispatch [::request-command-data on-send-params])
|
||||||
|
validation-params (merge params
|
||||||
after-validation
|
|
||||||
#(dispatch [::request-command-data on-send-params])
|
|
||||||
|
|
||||||
validation-params
|
|
||||||
(merge params
|
|
||||||
{:data-type :validator
|
{:data-type :validator
|
||||||
:after #(dispatch [::proceed-validation-messages
|
:after #(dispatch [::proceed-validation %2 after-validation])})]
|
||||||
command chat-id %2 after-validation])})]
|
|
||||||
|
|
||||||
(dispatch [::request-command-data validation-params]))))))
|
(dispatch [::request-command-data validation-params])))))
|
||||||
|
|
||||||
(handlers/register-handler ::proceed-validation-messages
|
(handlers/register-handler ::proceed-validation
|
||||||
(handlers/side-effect!
|
(handlers/side-effect!
|
||||||
(fn [db [_ command chat-id {:keys [markup validationHandler parameters]} proceed-fn]]
|
(fn [db [_ {:keys [markup validationHandler parameters]} proceed-fn]]
|
||||||
(let [set-errors #(do (dispatch [:set-chat-ui-props {:validation-messages %
|
(let [set-errors #(do (dispatch [:set-chat-ui-props {:validation-messages %
|
||||||
:sending-in-progress? false}]))]
|
:sending-in-progress? false}]))]
|
||||||
(cond
|
(cond
|
||||||
|
@ -235,7 +224,7 @@
|
||||||
|
|
||||||
(handlers/register-handler ::send-command
|
(handlers/register-handler ::send-command
|
||||||
(handlers/side-effect!
|
(handlers/side-effect!
|
||||||
(fn [db [_ on-send {{:keys [fullscreen]} :command :as command} chat-id]]
|
(fn [db [_ on-send {{:keys [fullscreen bot]} :command :as content} chat-id]]
|
||||||
(if on-send
|
(if on-send
|
||||||
(do
|
(do
|
||||||
(when fullscreen
|
(when fullscreen
|
||||||
|
@ -244,9 +233,9 @@
|
||||||
:sending-in-progress? false}])
|
:sending-in-progress? false}])
|
||||||
(react-comp/dismiss-keyboard!))
|
(react-comp/dismiss-keyboard!))
|
||||||
(dispatch [::request-command-data
|
(dispatch [::request-command-data
|
||||||
{:command command
|
{:content content
|
||||||
:chat-id chat-id
|
:chat-id chat-id
|
||||||
:jail-id (get-in command [:command :bot])
|
:jail-id (or bot chat-id)
|
||||||
:data-type :preview
|
:data-type :preview
|
||||||
:after #(dispatch [::send-message % chat-id])}])))))
|
:after #(dispatch [::send-message % chat-id])}])))))
|
||||||
|
|
||||||
|
@ -256,8 +245,8 @@
|
||||||
[_ {{:keys [command
|
[_ {{:keys [command
|
||||||
metadata
|
metadata
|
||||||
args]
|
args]
|
||||||
:as c} :command
|
:as content} :content
|
||||||
:keys [message-id chat-id jail-id data-type after]}]]
|
:keys [chat-id jail-id data-type after]}]]
|
||||||
(let [{:keys [dapp? dapp-url name]} (get contacts chat-id)
|
(let [{:keys [dapp? dapp-url name]} (get contacts chat-id)
|
||||||
message-id (random/id)
|
message-id (random/id)
|
||||||
metadata (merge metadata
|
metadata (merge metadata
|
||||||
|
@ -266,7 +255,10 @@
|
||||||
:name (i18n/get-contact-translated chat-id :name name)}))
|
:name (i18n/get-contact-translated chat-id :name name)}))
|
||||||
owner-id (:owner-id command)
|
owner-id (:owner-id command)
|
||||||
bot-db (get bot-db chat-id)
|
bot-db (get bot-db chat-id)
|
||||||
params (assoc (input-model/args->params c) :bot-db bot-db)
|
params (merge (input-model/args->params content)
|
||||||
|
{:bot-db bot-db
|
||||||
|
:metadata metadata})
|
||||||
|
|
||||||
command-message {:command command
|
command-message {:command command
|
||||||
:params params
|
:params params
|
||||||
:to-message (:to-message-id metadata)
|
:to-message (:to-message-id metadata)
|
||||||
|
@ -274,11 +266,12 @@
|
||||||
:id message-id
|
:id message-id
|
||||||
:chat-id chat-id
|
:chat-id chat-id
|
||||||
:jail-id (or owner-id jail-id)}
|
:jail-id (or owner-id jail-id)}
|
||||||
|
|
||||||
request-data {:message-id message-id
|
request-data {:message-id message-id
|
||||||
:chat-id chat-id
|
:chat-id chat-id
|
||||||
:jail-id (or owner-id jail-id)
|
:jail-id (or owner-id jail-id)
|
||||||
:content {:command (:name command)
|
:content {:command (:name command)
|
||||||
:params (assoc params :metadata metadata :bot-db bot-db)
|
:params params
|
||||||
:type (:type command)}
|
:type (:type command)}
|
||||||
:on-requested #(after command-message %)}]
|
:on-requested #(after command-message %)}]
|
||||||
(dispatch [:request-command-data request-data data-type])))))
|
(dispatch [:request-command-data request-data data-type])))))
|
||||||
|
@ -344,11 +337,11 @@
|
||||||
(dispatch [:update-seq-arguments chat-id])
|
(dispatch [:update-seq-arguments chat-id])
|
||||||
(dispatch [:send-current-message]))]
|
(dispatch [:send-current-message]))]
|
||||||
(dispatch [::request-command-data
|
(dispatch [::request-command-data
|
||||||
{:command command
|
{:content command
|
||||||
:chat-id chat-id
|
:chat-id chat-id
|
||||||
|
;;TODO(alwx): jail-id ?
|
||||||
:data-type :validator
|
:data-type :validator
|
||||||
:after #(dispatch [::proceed-validation-messages
|
:after #(dispatch [::proceed-validation %2 after-validation])}])))))
|
||||||
command chat-id %2 after-validation])}])))))
|
|
||||||
|
|
||||||
(handlers/register-handler :set-chat-seq-arg-input-text
|
(handlers/register-handler :set-chat-seq-arg-input-text
|
||||||
(fn [{:keys [current-chat-id] :as db} [_ text chat-id]]
|
(fn [{:keys [current-chat-id] :as db} [_ text chat-id]]
|
||||||
|
|
|
@ -22,19 +22,28 @@
|
||||||
[status-im.utils.types :as types]))
|
[status-im.utils.types :as types]))
|
||||||
|
|
||||||
(defn prepare-command
|
(defn prepare-command
|
||||||
[identity chat-id clock-value request
|
[identity chat-id clock-value
|
||||||
{:keys [id preview preview-string params command
|
{request-params :params
|
||||||
to-message handler-data content-type]}]
|
request-command :command
|
||||||
(let [content (or request {:command (command :name)
|
:keys [prefill prefillBotDb]
|
||||||
:params params})]
|
:as request}
|
||||||
|
{:keys [id params command to-message handler-data content-type]}]
|
||||||
|
(let [content (if request
|
||||||
|
{:command request-command
|
||||||
|
:params (assoc request-params :bot-db (:bot-db params))
|
||||||
|
:prefill prefill
|
||||||
|
:prefill-bot-db prefillBotDb}
|
||||||
|
{:command (:name command)
|
||||||
|
:params params})
|
||||||
|
content' (assoc content :handler-data handler-data
|
||||||
|
:type (name (:type command))
|
||||||
|
:content-command (:name command)
|
||||||
|
:bot (:bot command))]
|
||||||
{:message-id id
|
{:message-id id
|
||||||
:from identity
|
:from identity
|
||||||
:to chat-id
|
:to chat-id
|
||||||
:timestamp (time/now-ms)
|
:timestamp (time/now-ms)
|
||||||
:content (assoc content :handler-data handler-data
|
:content content'
|
||||||
:type (name (:type command))
|
|
||||||
:content-command (:name command)
|
|
||||||
:bot (:bot command))
|
|
||||||
:content-type (or content-type
|
:content-type (or content-type
|
||||||
(if request
|
(if request
|
||||||
content-type-command-request
|
content-type-command-request
|
||||||
|
@ -53,47 +62,47 @@
|
||||||
(register-handler :check-commands-handlers!
|
(register-handler :check-commands-handlers!
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [_ [_ {:keys [command message chat-id] :as params}]]
|
(fn [_ [_ {:keys [command message chat-id] :as params}]]
|
||||||
(let [{:keys [command] :as message} command]
|
(let [{:keys [command] :as content} command]
|
||||||
(let [params' (assoc params :command-message message)
|
|
||||||
command-name (:name (:command message))]
|
|
||||||
(cond
|
(cond
|
||||||
(console-command? chat-id command-name)
|
(console-command? chat-id (:name command))
|
||||||
(dispatch [:invoke-console-command-handler! params'])
|
(dispatch [:invoke-console-command-handler! params])
|
||||||
|
|
||||||
(:has-handler command)
|
(:has-handler command)
|
||||||
(dispatch [::invoke-command-handlers! params'])
|
(dispatch [::invoke-command-handlers! params])
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(dispatch [:prepare-command! chat-id params']))))
|
(dispatch [:prepare-command! chat-id params])))
|
||||||
(dispatch [:set-chat-ui-props {:sending-in-progress? false}]))))
|
(dispatch [:set-chat-ui-props {:sending-in-progress? false}]))))
|
||||||
|
|
||||||
(register-handler :prepare-command!
|
(register-handler :prepare-command!
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [{:keys [current-public-key network-status] :as db}
|
(fn [{:keys [current-public-key network-status] :as db}
|
||||||
[_ add-to-chat-id {:keys [chat-id command-message command] :as params}]]
|
[_ add-to-chat-id {{:keys [handler-data
|
||||||
|
command]
|
||||||
|
:as content} :command
|
||||||
|
chat-id :chat-id
|
||||||
|
:as params}]]
|
||||||
(let [clock-value (messages/get-last-clock-value chat-id)
|
(let [clock-value (messages/get-last-clock-value chat-id)
|
||||||
request (:request (:handler-data command))
|
request (:request handler-data)
|
||||||
handler-data (:handler-data command)
|
hidden-params (->> (:params command)
|
||||||
hidden-params (->> (:params (:command command))
|
(filter :hidden)
|
||||||
(filter #(= (:hidden %) true))
|
|
||||||
(map :name))
|
(map :name))
|
||||||
command' (->> (assoc command-message :handler-data handler-data)
|
command' (->> (prepare-command current-public-key chat-id clock-value request content)
|
||||||
(prepare-command current-public-key chat-id clock-value request)
|
|
||||||
(cu/check-author-direction db chat-id))]
|
(cu/check-author-direction db chat-id))]
|
||||||
(log/debug "Handler data: " request handler-data (dissoc params :commands :command-message))
|
(log/debug "Handler data: " request handler-data params)
|
||||||
(dispatch [:update-message-overhead! chat-id network-status])
|
(dispatch [:update-message-overhead! chat-id network-status])
|
||||||
(dispatch [:set-chat-ui-props {:sending-in-progress? false}])
|
(dispatch [:set-chat-ui-props {:sending-in-progress? false}])
|
||||||
(dispatch [::send-command! add-to-chat-id (assoc params :command command') hidden-params])
|
(dispatch [::send-command! add-to-chat-id (assoc params :command command') hidden-params])
|
||||||
(when (cu/console? chat-id)
|
(when (cu/console? chat-id)
|
||||||
(dispatch [:console-respond-command params]))
|
(dispatch [:console-respond-command params]))
|
||||||
(when (and (= "send" (get-in command-message [:command :name]))
|
(when (and (= "send" (:name command))
|
||||||
(not= add-to-chat-id wallet-chat-id))
|
(not= add-to-chat-id wallet-chat-id))
|
||||||
(let [ct (if request
|
(let [ct (if request
|
||||||
c/content-type-wallet-request
|
c/content-type-wallet-request
|
||||||
c/content-type-wallet-command)
|
c/content-type-wallet-command)
|
||||||
command-message' (assoc command-message :id (random/id)
|
content' (assoc content :id (random/id)
|
||||||
:content-type ct)
|
:content-type ct)
|
||||||
params' (assoc params :command-message command-message')]
|
params' (assoc params :command content')]
|
||||||
(dispatch [:prepare-command! wallet-chat-id params'])))))))
|
(dispatch [:prepare-command! wallet-chat-id params'])))))))
|
||||||
|
|
||||||
(register-handler ::send-command!
|
(register-handler ::send-command!
|
||||||
|
@ -129,17 +138,17 @@
|
||||||
(register-handler ::invoke-command-handlers!
|
(register-handler ::invoke-command-handlers!
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [{:keys [bot-db accounts current-account-id] :as db}
|
(fn [{:keys [bot-db accounts current-account-id] :as db}
|
||||||
[_ {:keys [chat-id address command-message]
|
[_ {{:keys [command
|
||||||
:as parameters}]]
|
params
|
||||||
(let [{:keys [id command params]} command-message
|
id]} :command
|
||||||
{:keys [type name bot owner-id]} command
|
:keys [chat-id address]
|
||||||
path [(if (= :command type) :commands :responses)
|
:as orig-params}]]
|
||||||
name
|
(let [{:keys [type name bot owner-id]} command
|
||||||
:handler]
|
handler-type (if (= :command type) :commands :responses)
|
||||||
to (get-in db [:contacts chat-id :address])
|
to (get-in db [:contacts chat-id :address])
|
||||||
identity (or owner-id bot chat-id)
|
identity (or owner-id bot chat-id)
|
||||||
bot-db (get bot-db (or bot chat-id))
|
bot-db (get bot-db (or bot chat-id))
|
||||||
params {:parameters (assoc params :bot-db bot-db)
|
params {:parameters params
|
||||||
:context {:from address
|
:context {:from address
|
||||||
:to to
|
:to to
|
||||||
:current-account (get accounts current-account-id)
|
:current-account (get accounts current-account-id)
|
||||||
|
@ -149,10 +158,10 @@
|
||||||
identity
|
identity
|
||||||
#(status/call-jail
|
#(status/call-jail
|
||||||
{:jail-id identity
|
{:jail-id identity
|
||||||
:path path
|
:path [handler-type name :handler]
|
||||||
:params params
|
:params params
|
||||||
:callback (fn [res]
|
:callback (fn [res]
|
||||||
(dispatch [:command-handler! chat-id parameters res]))})])))))
|
(dispatch [:command-handler! chat-id orig-params res]))})])))))
|
||||||
|
|
||||||
(register-handler :prepare-message
|
(register-handler :prepare-message
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
|
|
|
@ -158,7 +158,7 @@
|
||||||
(let [params (:params command)]
|
(let [params (:params command)]
|
||||||
(->> args
|
(->> args
|
||||||
(map-indexed (fn [i value]
|
(map-indexed (fn [i value]
|
||||||
(vector (get-in params [i :name]) value)))
|
[(keyword (get-in params [i :name])) value]))
|
||||||
(into {}))))
|
(into {}))))
|
||||||
|
|
||||||
(defn command-dependent-context-params
|
(defn command-dependent-context-params
|
||||||
|
|
|
@ -77,12 +77,12 @@
|
||||||
markup (subscribe [:get-in [:message-data :preview message-id :markup]])]
|
markup (subscribe [:get-in [:message-data :preview message-id :markup]])]
|
||||||
(fn [{:keys [message-id content from incoming-group]}]
|
(fn [{:keys [message-id content from incoming-group]}]
|
||||||
(let [commands @commands-atom
|
(let [commands @commands-atom
|
||||||
{:keys [prefill prefillBotDb params]
|
{:keys [prefill prefill-bot-db prefillBotDb params]
|
||||||
text-content :text} content
|
text-content :text} content
|
||||||
{:keys [command content]} (parse-command-request commands content)
|
{:keys [command content]} (parse-command-request commands content)
|
||||||
command (if (and params command)
|
command (if (and params command)
|
||||||
(merge command {:prefill prefill
|
(merge command {:prefill prefill
|
||||||
:prefill-bot-db prefillBotDb})
|
:prefill-bot-db (or prefill-bot-db prefillBotDb)})
|
||||||
command)]
|
command)]
|
||||||
[view st/comand-request-view
|
[view st/comand-request-view
|
||||||
[touchable-highlight
|
[touchable-highlight
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
(defn command-handler!
|
(defn command-handler!
|
||||||
[_ [chat-id
|
[_ [chat-id
|
||||||
{:keys [command-message] :as parameters}
|
{:keys [command] :as params}
|
||||||
{:keys [result error]}]]
|
{:keys [result error]}]]
|
||||||
(let [{:keys [context returned]} result
|
(let [{:keys [context returned]} result
|
||||||
{handler-error :error} returned]
|
{handler-error :error} returned]
|
||||||
|
@ -25,14 +25,14 @@
|
||||||
(dispatch [:set-chat-ui-props {:validation-messages (cu/generate-hiccup markup)}]))
|
(dispatch [:set-chat-ui-props {:validation-messages (cu/generate-hiccup markup)}]))
|
||||||
|
|
||||||
result
|
result
|
||||||
(let [command' (assoc command-message :handler-data returned)
|
(let [command' (assoc command :handler-data returned)
|
||||||
parameters' (assoc parameters :command command')]
|
params' (assoc params :command command')]
|
||||||
(if (:eth_sendTransaction context)
|
(if (:eth_sendTransaction context)
|
||||||
(dispatch [:wait-for-transaction (:id command-message) parameters'])
|
(dispatch [:wait-for-transaction (:id command) params'])
|
||||||
(dispatch [:prepare-command! chat-id parameters'])))
|
(dispatch [:prepare-command! chat-id params'])))
|
||||||
|
|
||||||
(not (or error handler-error))
|
(not (or error handler-error))
|
||||||
(dispatch [:prepare-command! chat-id parameters])
|
(dispatch [:prepare-command! chat-id params])
|
||||||
|
|
||||||
:else nil)))
|
:else nil)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue