integrate mailserver-ranges api
This commit is contained in:
parent
277f9ffda5
commit
172038b70d
|
@ -197,10 +197,8 @@
|
||||||
#(re-frame/dispatch [::verify-success % realm-error]))))
|
#(re-frame/dispatch [::verify-success % realm-error]))))
|
||||||
|
|
||||||
(fx/defn handle-change-multiaccount-success
|
(fx/defn handle-change-multiaccount-success
|
||||||
{:events [::multiaccount-change-success]
|
{:events [::multiaccount-change-success]}
|
||||||
:interceptors [(re-frame/inject-cofx :data-store/all-chat-requests-ranges)]}
|
[cofx])
|
||||||
[{:data-store/keys [mailserver-ranges] :as cofx}]
|
|
||||||
(protocol/initialize-protocol cofx {:mailserver-ranges mailserver-ranges}))
|
|
||||||
|
|
||||||
(defn change-multiaccount!
|
(defn change-multiaccount!
|
||||||
[address password create-database-if-not-exist?]
|
[address password create-database-if-not-exist?]
|
||||||
|
|
|
@ -42,27 +42,3 @@
|
||||||
:params [chat-id]
|
:params [chat-id]
|
||||||
:on-success #(log/info "deleted gaps successfully")
|
:on-success #(log/info "deleted gaps successfully")
|
||||||
:on-failure #(log/error "failed to delete gap" %)}]})
|
:on-failure #(log/error "failed to delete gap" %)}]})
|
||||||
|
|
||||||
(defn save-chat-requests-range
|
|
||||||
[chat-requests-range]
|
|
||||||
(fn [realm]
|
|
||||||
(log/debug "saving ranges" chat-requests-range)
|
|
||||||
(core/create realm :chat-requests-range chat-requests-range true)))
|
|
||||||
|
|
||||||
(re-frame/reg-cofx
|
|
||||||
:data-store/all-chat-requests-ranges
|
|
||||||
(fn [cofx _]
|
|
||||||
(assoc cofx :data-store/mailserver-ranges
|
|
||||||
(reduce (fn [acc {:keys [chat-id] :as range}]
|
|
||||||
(assoc acc chat-id range))
|
|
||||||
{}
|
|
||||||
(-> @core/account-realm
|
|
||||||
(core/get-all :chat-requests-range)
|
|
||||||
(core/all-clj :chat-requests-range))))))
|
|
||||||
|
|
||||||
(defn delete-range
|
|
||||||
[chat-id]
|
|
||||||
(fn [realm]
|
|
||||||
(log/debug "deleting range" chat-id)
|
|
||||||
(core/delete realm
|
|
||||||
(core/get-by-field realm :chat-requests-range :chat-id chat-id))))
|
|
||||||
|
|
|
@ -81,7 +81,10 @@
|
||||||
"mailservers_deleteMailserver" {}
|
"mailservers_deleteMailserver" {}
|
||||||
"mailservers_addMailserverTopic" {}
|
"mailservers_addMailserverTopic" {}
|
||||||
"mailservers_getMailserverTopics" {}
|
"mailservers_getMailserverTopics" {}
|
||||||
"mailservers_deleteMailserverTopic" {}})
|
"mailservers_deleteMailserverTopic" {}
|
||||||
|
"mailservers_addChatRequestRange" {}
|
||||||
|
"mailservers_getChatRequestRanges" {}
|
||||||
|
"mailservers_deleteChatRequestRange" {}})
|
||||||
|
|
||||||
(defn call
|
(defn call
|
||||||
[{:keys [method params on-success on-error] :as p}]
|
[{:keys [method params on-success on-error] :as p}]
|
||||||
|
|
|
@ -491,7 +491,11 @@
|
||||||
(fx/defn remove-range
|
(fx/defn remove-range
|
||||||
[{:keys [db]} chat-id]
|
[{:keys [db]} chat-id]
|
||||||
{:db (update db :mailserver/ranges dissoc chat-id)
|
{:db (update db :mailserver/ranges dissoc chat-id)
|
||||||
:data-store/tx [(data-store.mailservers/delete-range chat-id)]})
|
::json-rpc/call
|
||||||
|
[{:method "mailservers_deleteChatRequestRange"
|
||||||
|
:params [chat-id]
|
||||||
|
:on-success #(log/debug "deleted chat request range successfully")
|
||||||
|
:on-failure #(log/error "failed to delete chat request range" %)}]})
|
||||||
|
|
||||||
(defn update-mailserver-topic
|
(defn update-mailserver-topic
|
||||||
[{:keys [last-request] :as config}
|
[{:keys [last-request] :as config}
|
||||||
|
@ -609,11 +613,16 @@
|
||||||
(< from lowest-request-from))
|
(< from lowest-request-from))
|
||||||
(assoc :lowest-request-from from))])))
|
(assoc :lowest-request-from from))])))
|
||||||
chat-ids)]
|
chat-ids)]
|
||||||
(fx/merge
|
(fx/merge cofx
|
||||||
cofx
|
{:db (update db :mailserver/ranges merge updated-ranges)
|
||||||
{:db (update db :mailserver/ranges merge updated-ranges)
|
::json-rpc/call
|
||||||
:data-store/tx (map data-store.mailservers/save-chat-requests-range
|
(mapv (fn [chat-requests-range]
|
||||||
(vals updated-ranges))})))
|
{:method "mailservers_addChatRequestRange"
|
||||||
|
:params [chat-requests-range]
|
||||||
|
:on-success #()
|
||||||
|
:on-failure
|
||||||
|
#(log/error "failed to save chat request range" %)})
|
||||||
|
(vals updated-ranges))})))
|
||||||
|
|
||||||
(defn prepare-new-gaps [new-gaps ranges {:keys [from to] :as req} chat-ids]
|
(defn prepare-new-gaps [new-gaps ranges {:keys [from to] :as req} chat-ids]
|
||||||
(into
|
(into
|
||||||
|
|
|
@ -164,6 +164,8 @@
|
||||||
::json-rpc/call
|
::json-rpc/call
|
||||||
[{:method "mailservers_getMailserverTopics"
|
[{:method "mailservers_getMailserverTopics"
|
||||||
:on-success #(re-frame/dispatch [::protocol/initialize-protocol {:mailserver-topics (or % {})}])}
|
:on-success #(re-frame/dispatch [::protocol/initialize-protocol {:mailserver-topics (or % {})}])}
|
||||||
|
{:method "mailservers_getChatRequestRanges"
|
||||||
|
:on-success #(re-frame/dispatch [::protocol/initialize-protocol {:mailserver-ranges (or % {})}])}
|
||||||
{:method "browsers_getBrowsers"
|
{:method "browsers_getBrowsers"
|
||||||
:on-success #(re-frame/dispatch [::initialize-browsers %])}
|
:on-success #(re-frame/dispatch [::initialize-browsers %])}
|
||||||
{:method "permissions_getDappPermissions"
|
{:method "permissions_getDappPermissions"
|
||||||
|
|
|
@ -59,6 +59,15 @@
|
||||||
{}
|
{}
|
||||||
mailserver-topics)))
|
mailserver-topics)))
|
||||||
|
|
||||||
|
(defn add-mailserver-ranges
|
||||||
|
[db mailserver-ranges]
|
||||||
|
(assoc db
|
||||||
|
:mailserver/ranges
|
||||||
|
(reduce (fn [acc {:keys [chat-id] :as range}]
|
||||||
|
(assoc acc chat-id range))
|
||||||
|
{}
|
||||||
|
mailserver-ranges)))
|
||||||
|
|
||||||
(fx/defn initialize-protocol
|
(fx/defn initialize-protocol
|
||||||
{:events [::initialize-protocol]}
|
{:events [::initialize-protocol]}
|
||||||
[{:keys [db] :as cofx}
|
[{:keys [db] :as cofx}
|
||||||
|
@ -77,7 +86,7 @@
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (cond-> db
|
{:db (cond-> db
|
||||||
mailserver-ranges
|
mailserver-ranges
|
||||||
(assoc :mailserver/ranges mailserver-ranges)
|
(add-mailserver-ranges mailserver-ranges)
|
||||||
mailserver-topics
|
mailserver-topics
|
||||||
(add-mailserver-topics mailserver-topics)
|
(add-mailserver-topics mailserver-topics)
|
||||||
mailservers
|
mailservers
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "develop",
|
"version": "develop",
|
||||||
"commit-sha1": "9df64efe2c3d88596ab5cfe358741ed8f9be86b7",
|
"commit-sha1": "76d184b4c9e666383ba54303b3c4a438ac4519de",
|
||||||
"src-sha256": "0yc76v2kcamxjv7g7b9x4ywmbzch4azzb4sj49rhcdkg0wz8qi5j"
|
"src-sha256": "141glfhal3chlykz5m3jbmzrv10rprly9yk4xf1ss4a3hd8hj90c"
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,10 +113,10 @@
|
||||||
(testing "it sets the chat as inactive"
|
(testing "it sets the chat as inactive"
|
||||||
(let [actual (chat/remove-chat cofx chat-id)]
|
(let [actual (chat/remove-chat cofx chat-id)]
|
||||||
(is (= false (get-in actual [:db :chats chat-id :is-active])))))
|
(is (= false (get-in actual [:db :chats chat-id :is-active])))))
|
||||||
(testing "it adds the relevant transactions for realm"
|
(testing "it makes the relevant json-rpc calls"
|
||||||
(let [actual (chat/remove-chat cofx chat-id)]
|
(let [actual (chat/remove-chat cofx chat-id)]
|
||||||
(is (:data-store/tx actual))
|
(is (::json-rpc/call actual))
|
||||||
(is (= 1 (count (:data-store/tx actual))))))))
|
(is (= 5 (count (::json-rpc/call actual))))))))
|
||||||
|
|
||||||
(deftest multi-user-chat?
|
(deftest multi-user-chat?
|
||||||
(let [chat-id "1"]
|
(let [chat-id "1"]
|
||||||
|
|
Loading…
Reference in New Issue