Generate `:short-preview` when msg received

This commit is contained in:
janherich 2017-12-20 21:25:23 +01:00
parent 46dc16599b
commit 1c85797121
No known key found for this signature in database
GPG Key ID: C23B473AFBE94D13
1 changed files with 16 additions and 11 deletions

View File

@ -26,7 +26,6 @@
(fn [cofx]
(assoc cofx :get-last-clock-value messages-store/get-last-clock-value)))
;;;; FX
(handlers/register-handler-fx
@ -41,15 +40,21 @@
(fn [{:keys [db] :as cofx} [{:keys [content] :as message}]]
(if (:command content)
;; we are dealing with received command message, we can't add it right away,
;; we first need to fetch preview and add it only after we already have the preview.
;; we first need to fetch short-preview + preview and add it only after we already have those.
;; note that `request-command-message-data` implicitly wait till jail is ready and
;; call is made only after that
;; calls are made only after that
(commands-events/request-command-message-data
db message
{:data-type :short-preview
:proceed-event-creator (fn [short-preview]
[:request-command-message-data
message
{:data-type :preview
:proceed-event-creator (fn [preview]
[::received-message
(assoc-in message [:content :preview] preview)])})
(update message :content merge
{:short-preview short-preview
:preview preview})])}])})
;; regular non command message, we can add it right away
(message-model/receive cofx message))))