[BUG #2242]: Quickfix to make phone command reanswerable again

This commit is contained in:
Oskar Thorén 2017-10-20 17:26:47 +02:00 committed by Roman Volosovskyi
parent 070c8bd91a
commit 0f97f16a38
3 changed files with 21 additions and 1 deletions

View File

@ -26,7 +26,7 @@
[{:keys [current-chat-id] :as db} [_ chat-id]] [{:keys [current-chat-id] :as db} [_ chat-id]]
(let [chat-id' (or chat-id current-chat-id) (let [chat-id' (or chat-id current-chat-id)
;; todo maybe limit is needed ;; todo maybe limit is needed
requests (requests/get-open-by-chat-id chat-id') requests (requests/get-available-by-chat-id chat-id')
requests' (map #(update % :type keyword) requests)] requests' (map #(update % :type keyword) requests)]
(assoc-in db [:chats chat-id' :requests] requests'))) (assoc-in db [:chats chat-id' :requests] requests')))

View File

@ -16,6 +16,22 @@
(realm/sorted :added :desc) (realm/sorted :added :desc)
(realm/realm-collection->list))) (realm/realm-collection->list)))
;; NOTE(oskarth): phone command in Console can be answered again, so we want to list this
;; TODO(oskarth): Refactor this, either by extending and/or query or changing status of message
(defn- get-reanswerable-by-chat-id
[chat-id]
(-> (realm/get-by-fields @realm/account-realm :request :and [[:chat-id chat-id]
[:type "phone"]
[:status "answered"]])
(realm/sorted :added :desc)
(realm/realm-collection->list)))
(defn get-available-by-chat-id
[chat-id]
(-> ((juxt get-open-by-chat-id get-reanswerable-by-chat-id) chat-id)
flatten
vec))
(defn save (defn save
[request] [request]
(realm/save @realm/account-realm :request request true)) (realm/save @realm/account-realm :request request true))

View File

@ -9,6 +9,10 @@
[chat-id] [chat-id]
(data-store/get-open-by-chat-id chat-id)) (data-store/get-open-by-chat-id chat-id))
(defn get-available-by-chat-id
[chat-id]
(data-store/get-available-by-chat-id chat-id))
(defn save (defn save
[request] [request]
(data-store/save request)) (data-store/save request))