diff --git a/src/status_im/protocol/handlers.cljs b/src/status_im/protocol/handlers.cljs index e80ef96f2c..ebb0e7b525 100644 --- a/src/status_im/protocol/handlers.cljs +++ b/src/status_im/protocol/handlers.cljs @@ -3,7 +3,6 @@ [re-frame.core :as re-frame] [status-im.constants :as constants] [status-im.native-module.core :as status] - [status-im.transport.message-cache :as message-cache] [status-im.utils.datetime :as datetime] [status-im.utils.ethereum.core :as utils] [status-im.utils.handlers :as handlers] diff --git a/src/status_im/transport/message/v1/contact.cljs b/src/status_im/transport/message/v1/contact.cljs index 530cca414b..52ea8dbc90 100644 --- a/src/status_im/transport/message/v1/contact.cljs +++ b/src/status_im/transport/message/v1/contact.cljs @@ -30,8 +30,7 @@ (defrecord ContactRequest [name profile-image address fcm-token] message/StatusMessage (send [this chat-id {:keys [db random-id] :as cofx}] - (let [message-id (transport.utils/message-id this) - topic (transport.utils/get-topic random-id) + (let [topic (transport.utils/get-topic random-id) on-success (fn [sym-key sym-key-id] (re-frame/dispatch [:contact/send-new-sym-key {:sym-key-id sym-key-id @@ -42,46 +41,34 @@ (handlers-macro/merge-fx cofx {:shh/get-new-sym-key {:web3 (:web3 db) :on-success on-success}} - (protocol/init-chat chat-id topic) - #_(protocol/requires-ack message-id chat-id)))) + (protocol/init-chat chat-id topic)))) (receive [this chat-id signature {:keys [db] :as cofx}] - (let [message-id (transport.utils/message-id this) - topic (transport.utils/get-topic chat-id)] - (when (protocol/is-new? message-id) - (handlers-macro/merge-fx cofx - #_(protocol/ack message-id chat-id) - {:dispatch [:inbox/request-messages {:topics [topic]}]} - (contacts/receive-contact-request signature - this)))))) + (let [topic (transport.utils/get-topic chat-id)] + (handlers-macro/merge-fx cofx + {:dispatch [:inbox/request-messages {:topics [topic]}]} + (contacts/receive-contact-request signature + this))))) (defrecord ContactRequestConfirmed [name profile-image address fcm-token] message/StatusMessage (send [this chat-id cofx] - (let [message-id (transport.utils/message-id this)] - (handlers-macro/merge-fx cofx - #_(protocol/requires-ack message-id chat-id) - (protocol/send {:chat-id chat-id - :payload this})))) + (handlers-macro/merge-fx cofx + (protocol/send {:chat-id chat-id + :payload this}))) (receive [this chat-id signature cofx] - (let [message-id (transport.utils/message-id this)] - (when (protocol/is-new? message-id) - (handlers-macro/merge-fx cofx - #_(protocol/ack message-id chat-id) - (contacts/receive-contact-request-confirmation signature - this)))))) + (handlers-macro/merge-fx cofx + (contacts/receive-contact-request-confirmation signature + this)))) (defrecord ContactUpdate [name profile-image] message/StatusMessage (send [this _ {:keys [db] :as cofx}] - (let [message-id (transport.utils/message-id this) - public-keys (remove nil? (map :public-key (vals (:contacts/contacts db))))] + (let [public-keys (remove nil? (map :public-key (vals (:contacts/contacts db))))] (handlers-macro/merge-fx cofx (protocol/multi-send-by-pubkey {:public-keys public-keys :payload this})))) (receive [this chat-id signature cofx] - (let [message-id (transport.utils/message-id this)] - (when (protocol/is-new? message-id) - (handlers-macro/merge-fx cofx - (contacts/receive-contact-update chat-id - signature - this)))))) + (handlers-macro/merge-fx cofx + (contacts/receive-contact-update chat-id + signature + this)))) diff --git a/src/status_im/transport/message/v1/protocol.cljs b/src/status_im/transport/message/v1/protocol.cljs index baacc8f624..ae62466e26 100644 --- a/src/status_im/transport/message/v1/protocol.cljs +++ b/src/status_im/transport/message/v1/protocol.cljs @@ -3,7 +3,6 @@ (:require [status-im.utils.config :as config] [status-im.constants :as constants] [status-im.chat.core :as chat] - [status-im.transport.message-cache :as message-cache] [status-im.transport.db :as transport.db] [status-im.transport.message.core :as message] [status-im.transport.utils :as transport.utils])) @@ -22,12 +21,6 @@ ([chat-id topic {:keys [db] :as cofx}] {:db (assoc-in db [:transport/chats chat-id] (transport.db/create-chat topic))})) -(defn is-new? - "Determines if given message-id already exists in in-memory message cache" - [message-id] - (when-not (message-cache/exists? message-id) - (message-cache/add! message-id))) - #_(defn requires-ack [message-id chat-id {:keys [db] :as cofx}] {:db (update-in db [:transport/chats chat-id :pending-ack] conj message-id)}) diff --git a/src/status_im/transport/message_cache.cljs b/src/status_im/transport/message_cache.cljs deleted file mode 100644 index 48b12f0def..0000000000 --- a/src/status_im/transport/message_cache.cljs +++ /dev/null @@ -1,19 +0,0 @@ -(ns ^{:doc "Message caching API for message deduplication"} - status-im.transport.message-cache - (:refer-clojure :exclude [exists?])) - -(defonce messages-set (atom #{})) - -(defn init! - [messages] - (reset! messages-set (set (map :message-id messages)))) - -(defn add! - [message-id] - (when message-id - (swap! messages-set conj message-id))) - -(defn exists? - [message-id] - (when message-id - (@messages-set message-id)))