mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-26 15:21:08 +00:00
Remove separate topic from group chats
Currently the separate topic was not used, as it's a bit tricky to coordinate when multiple devices from different versions are present, with the partitioned topic, probably this optimisation is not necessary anymore, so removing this for now. Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
71654a6829
commit
6a42580fc2
@ -128,15 +128,8 @@
|
|||||||
;; We check that it has explicitly joined, regardless of the local
|
;; We check that it has explicitly joined, regardless of the local
|
||||||
;; version of the group chat, for backward compatibility
|
;; version of the group chat, for backward compatibility
|
||||||
destinations (map (fn [member]
|
destinations (map (fn [member]
|
||||||
(if (and
|
|
||||||
config/group-chats-publish-to-topic?
|
|
||||||
(group-chats.db/joined-event? member chat)
|
|
||||||
(not= creator member)
|
|
||||||
(not= current-public-key member))
|
|
||||||
{:public-key member
|
{:public-key member
|
||||||
:chat chat-id}
|
:chat chat-id})
|
||||||
{:public-key member
|
|
||||||
:chat (transport.topic/public-key->discovery-topic member)}))
|
|
||||||
members)]
|
members)]
|
||||||
(fx/merge
|
(fx/merge
|
||||||
cofx
|
cofx
|
||||||
@ -463,10 +456,8 @@
|
|||||||
(not (group-chats.db/joined? my-public-key new-chat)))
|
(not (group-chats.db/joined? my-public-key new-chat)))
|
||||||
(apply fx/merge
|
(apply fx/merge
|
||||||
cofx
|
cofx
|
||||||
(conj
|
|
||||||
(map #(contact-code/stop-listening %)
|
(map #(contact-code/stop-listening %)
|
||||||
(:members new-chat))
|
(:members new-chat)))
|
||||||
(transport.chat/unsubscribe-from-chat chat-id)))
|
|
||||||
(apply fx/merge
|
(apply fx/merge
|
||||||
cofx
|
cofx
|
||||||
(concat
|
(concat
|
||||||
@ -474,8 +465,7 @@
|
|||||||
(:members new-chat))
|
(:members new-chat))
|
||||||
(map #(contact-code/stop-listening %)
|
(map #(contact-code/stop-listening %)
|
||||||
(clojure.set/difference (:members previous-chat)
|
(clojure.set/difference (:members previous-chat)
|
||||||
(:members new-chat)))
|
(:members new-chat))))))))
|
||||||
[(transport.public-chat/join-group-chat chat-id)])))))
|
|
||||||
|
|
||||||
(fx/defn handle-membership-update
|
(fx/defn handle-membership-update
|
||||||
"Upsert chat and receive message if valid"
|
"Upsert chat and receive message if valid"
|
||||||
@ -508,8 +498,7 @@
|
|||||||
:contacts (:contacts new-group)})
|
:contacts (:contacts new-group)})
|
||||||
(add-system-messages chat-id previous-chat new-group)
|
(add-system-messages chat-id previous-chat new-group)
|
||||||
|
|
||||||
(when config/group-chats-publish-to-topic?
|
(set-up-topic chat-id previous-chat)
|
||||||
(set-up-topic chat-id previous-chat))
|
|
||||||
#(when (and message
|
#(when (and message
|
||||||
;; don't allow anything but group messages
|
;; don't allow anything but group messages
|
||||||
(instance? protocol/Message message)
|
(instance? protocol/Message message)
|
||||||
|
@ -10,23 +10,6 @@
|
|||||||
(defn- has-already-joined? [{:keys [db]} chat-id]
|
(defn- has-already-joined? [{:keys [db]} chat-id]
|
||||||
(get-in db [:transport/chats chat-id]))
|
(get-in db [:transport/chats chat-id]))
|
||||||
|
|
||||||
(fx/defn join-group-chat
|
|
||||||
"Function producing all protocol level effects necessary for a group chat identified by chat-id"
|
|
||||||
[{:keys [db] :as cofx} chat-id]
|
|
||||||
(when-not (has-already-joined? cofx chat-id)
|
|
||||||
(let [public-key (get-in db [:account/account :public-key])
|
|
||||||
topic (transport.utils/get-topic chat-id)]
|
|
||||||
(fx/merge cofx
|
|
||||||
{:shh/add-discovery-filters {:web3 (:web3 db)
|
|
||||||
:private-key-id public-key
|
|
||||||
:topics [{:topic topic
|
|
||||||
:chat-id chat-id}]}}
|
|
||||||
(protocol/init-chat {:chat-id chat-id
|
|
||||||
:topic topic})
|
|
||||||
#(hash-map :data-store/tx [(transport-store/save-transport-tx
|
|
||||||
{:chat-id chat-id
|
|
||||||
:chat (get-in % [:db :transport/chats chat-id])})])))))
|
|
||||||
|
|
||||||
(fx/defn join-public-chat
|
(fx/defn join-public-chat
|
||||||
"Function producing all protocol level effects necessary for joining public chat identified by chat-id"
|
"Function producing all protocol level effects necessary for joining public chat identified by chat-id"
|
||||||
[{:keys [db] :as cofx} chat-id]
|
[{:keys [db] :as cofx} chat-id]
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
(def bootnodes-settings-enabled? (enabled? (get-config :BOOTNODES_SETTINGS_ENABLED "1")))
|
(def bootnodes-settings-enabled? (enabled? (get-config :BOOTNODES_SETTINGS_ENABLED "1")))
|
||||||
(def rpc-networks-only? (enabled? (get-config :RPC_NETWORKS_ONLY "1")))
|
(def rpc-networks-only? (enabled? (get-config :RPC_NETWORKS_ONLY "1")))
|
||||||
(def group-chats-publish-to-topic? (enabled? (get-config :GROUP_CHATS_PUBLISH_TO_TOPIC "0")))
|
|
||||||
(def show-contact-recovery-pop-up? (enabled? (get-config :SHOW_CONTACT_RECOVERY_POPUP)))
|
(def show-contact-recovery-pop-up? (enabled? (get-config :SHOW_CONTACT_RECOVERY_POPUP)))
|
||||||
(def mailserver-confirmations-enabled? (enabled? (get-config :MAILSERVER_CONFIRMATIONS_ENABLED)))
|
(def mailserver-confirmations-enabled? (enabled? (get-config :MAILSERVER_CONFIRMATIONS_ENABLED)))
|
||||||
(def mainnet-warning-enabled? (enabled? (get-config :MAINNET_WARNING_ENABLED 0)))
|
(def mainnet-warning-enabled? (enabled? (get-config :MAINNET_WARNING_ENABLED 0)))
|
||||||
|
@ -169,36 +169,6 @@
|
|||||||
"group-chat-name-changed"]
|
"group-chat-name-changed"]
|
||||||
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual-chat))))))))))))
|
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual-chat))))))))))))
|
||||||
|
|
||||||
(deftest set-up-topic
|
|
||||||
(with-redefs [config/group-chats-publish-to-topic? true]
|
|
||||||
(let [cofx {:now 0 :db {:account/account {:public-key admin}}}]
|
|
||||||
(testing "a brand new chat"
|
|
||||||
(let [actual (group-chats/handle-membership-update cofx initial-message "payload" admin)]
|
|
||||||
(testing "it sets up a topic"
|
|
||||||
(is (:shh/add-discovery-filters actual)))))
|
|
||||||
(testing "an existing chat"
|
|
||||||
(let [cofx (assoc cofx
|
|
||||||
:db
|
|
||||||
(:db (group-chats/handle-membership-update cofx initial-message "payload" admin)))
|
|
||||||
new-message {:chat-id chat-id
|
|
||||||
:membership-updates [{:from member-1
|
|
||||||
:events [{:type "chat-created"
|
|
||||||
:clock-value 1
|
|
||||||
:name "group-name"}
|
|
||||||
{:type "admins-added"
|
|
||||||
:clock-value 10
|
|
||||||
:members [member-2]}
|
|
||||||
{:type "admin-removed"
|
|
||||||
:clock-value 11
|
|
||||||
:member member-1}]}
|
|
||||||
{:from member-1
|
|
||||||
:events [{:type "member-removed"
|
|
||||||
:clock-value 12
|
|
||||||
:member member-1}]}]}
|
|
||||||
actual (group-chats/handle-membership-update cofx new-message "payload" admin)]
|
|
||||||
(testing "it removes the topic"
|
|
||||||
(is (:shh/remove-filters actual))))))))
|
|
||||||
|
|
||||||
(deftest build-group-test
|
(deftest build-group-test
|
||||||
(testing "only adds"
|
(testing "only adds"
|
||||||
(let [events [{:type "chat-created"
|
(let [events [{:type "chat-created"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user