mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-15 11:14:26 +00:00
Fixup command validation
Signed-off-by: yenda <eric@status.im>
This commit is contained in:
parent
df6432240a
commit
0caab1f7ce
@ -51,12 +51,7 @@
|
||||
(spec/def :message.content/command-path (spec/tuple string? (spec/coll-of (spec/or :scope keyword? :chat-id string?) :kind set? :min-count 1)))
|
||||
(spec/def :message.content/params (spec/map-of keyword? any?))
|
||||
|
||||
(spec/def ::content (spec/conformer (fn [content]
|
||||
(cond
|
||||
(string? content) {:text content}
|
||||
(map? content) content
|
||||
:else :clojure.spec/invalid))))
|
||||
(spec/def ::content-type #{"text/plain" "command"})
|
||||
(spec/def ::content-type #{"text/plain" "command" "command-request"})
|
||||
(spec/def ::message-type #{:group-user-message :public-group-user-message :user-message})
|
||||
(spec/def ::clock-value (spec/nilable pos-int?))
|
||||
(spec/def ::timestamp (spec/nilable pos-int?))
|
||||
@ -91,6 +86,10 @@
|
||||
(spec/merge :message/message-common
|
||||
(spec/keys :req-un [:message.command/content])))
|
||||
|
||||
(defmethod content-type "command-request" [_]
|
||||
(spec/merge :message/message-common
|
||||
(spec/keys :req-un [:message.command/content])))
|
||||
|
||||
(defmethod content-type :default [_]
|
||||
(spec/merge :message/message-common
|
||||
(spec/keys :req-un [:message.text/content])))
|
||||
|
@ -111,7 +111,7 @@
|
||||
:js-obj (:js-obj cofx))]})
|
||||
(validate [this]
|
||||
(when (spec/valid? :message/message this)
|
||||
(spec/conform :message/message this))))
|
||||
this)))
|
||||
|
||||
(defrecord MessagesSeen [message-ids]
|
||||
message/StatusMessage
|
||||
|
Loading…
x
Reference in New Issue
Block a user