mirror of
https://github.com/penpot/penpot.git
synced 2025-07-30 10:38:34 +02:00
✨ Improve how topic is managed on ws notifications
This commit is contained in:
parent
9409078069
commit
97a1bf15ef
6 changed files with 16 additions and 21 deletions
|
@ -112,7 +112,6 @@
|
|||
fsub (::file-subscription @state)
|
||||
tsub (::team-subscription @state)
|
||||
msg {:type :disconnect
|
||||
:subs-id profile-id
|
||||
:profile-id profile-id
|
||||
:session-id session-id}]
|
||||
|
||||
|
@ -137,9 +136,7 @@
|
|||
(l/trace :fn "handle-message" :event "subscribe-team" :team-id team-id :conn-id id)
|
||||
(let [prev-subs (get @state ::team-subscription)
|
||||
channel (sp/chan :buf (sp/dropping-buffer 64)
|
||||
:xf (comp
|
||||
(remove #(= (:session-id %) session-id))
|
||||
(map #(assoc % :subs-id team-id))))]
|
||||
:xf (remove #(= (:session-id %) session-id)))]
|
||||
|
||||
(sp/pipe channel output-ch false)
|
||||
(mbus/sub! msgbus :topic team-id :chan channel)
|
||||
|
@ -158,8 +155,7 @@
|
|||
(l/trace :fn "handle-message" :event "subscribe-file" :file-id file-id :conn-id id)
|
||||
(let [psub (::file-subscription @state)
|
||||
fch (sp/chan :buf (sp/dropping-buffer 64)
|
||||
:xf (comp (remove #(= (:session-id %) session-id))
|
||||
(map #(assoc % :subs-id file-id))))]
|
||||
:xf (remove #(= (:session-id %) session-id)))]
|
||||
|
||||
(let [subs {:file-id file-id :channel fch :topic file-id}]
|
||||
(swap! state assoc ::file-subscription subs))
|
||||
|
@ -190,7 +186,6 @@
|
|||
;; Notifify the rest of participants of the new connection.
|
||||
(let [message {:type :join-file
|
||||
:file-id file-id
|
||||
:subs-id file-id
|
||||
:session-id session-id
|
||||
:profile-id profile-id}]
|
||||
(mbus/pub! msgbus :topic file-id :message message))))
|
||||
|
|
|
@ -99,8 +99,9 @@
|
|||
nil))
|
||||
|
||||
(defn pub!
|
||||
[{::keys [pub-ch]} & {:as params}]
|
||||
(sp/put! pub-ch params))
|
||||
[{::keys [pub-ch]} & {:keys [topic] :as params}]
|
||||
(let [params (update params :message assoc :topic topic)]
|
||||
(sp/put! pub-ch params)))
|
||||
|
||||
(defn purge!
|
||||
[{:keys [::state ::wrk/executor] :as msgbus} chans]
|
||||
|
@ -230,7 +231,6 @@
|
|||
|
||||
(l/debug :hint "io-loop thread terminated")))))
|
||||
|
||||
|
||||
(defn- redis-pub!
|
||||
"Publish a message to the redis server. Asynchronous operation,
|
||||
intended to be used in core.async go blocks."
|
||||
|
|
|
@ -653,7 +653,7 @@
|
|||
(mbus/pub! msgbus
|
||||
:topic member-id
|
||||
:message {:type :team-role-change
|
||||
:subs-id member-id
|
||||
:topic member-id
|
||||
:team-id team-id
|
||||
:role role})
|
||||
|
||||
|
@ -713,7 +713,6 @@
|
|||
:topic member-id
|
||||
:message {:type :team-membership-change
|
||||
:change :removed
|
||||
:subs-id member-id
|
||||
:team-id team-id
|
||||
:team-name (:name team)})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue