summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2026-04-29 11:07:31 -0300
committerEuAndreh <eu@euandre.org>2026-04-29 11:07:31 -0300
commitfbbf7ad005ec21436bc9e3c18180a474b5e25865 (patch)
treefa10482959f59f34ed88a9495f7b0aa032fd1cec /src
parentChannel modes, channel-rename, extended-isupport, metadata-2 (diff)
downloadpapod-fbbf7ad005ec21436bc9e3c18180a474b5e25865.tar.gz
papod-fbbf7ad005ec21436bc9e3c18180a474b5e25865.tar.xz
metadata-2: push subscribed values on JOIN
When a subscriber joins a channel, the server now pushes any already-set metadata for the channel itself and for each existing member, gated on the subscription set. This is what irctest's testSubUserSetBeforeJoin and testSubChannelSetBeforeJoin want: a client that SUBs a key and then joins should receive the current value as if the SET had happened post-join, in a single METADATA push from the server. The push iterates (cons handle members) so the channel's own metadata is delivered first, then each member's. Self is excluded so the joiner doesn't echo their own keys back. Metadata propagation on later SETs is unchanged — notify-metadata-subs! still handles those. Brings the metadata_2 suite to 24 passed / 1 skipped (only metadata-before-connect remains, which we don't advertise).
Diffstat (limited to 'src')
-rw-r--r--src/papod.clj19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/papod.clj b/src/papod.clj
index 4be8edd..1015cb8 100644
--- a/src/papod.clj
+++ b/src/papod.clj
@@ -2794,6 +2794,25 @@
:when member]
(deliver-to-client! (:w member)
(if ej? ext-line line))))
+ ;; metadata-2 sync: push subscribed key values
+ ;; from existing channel members and the channel
+ ;; itself to the joiner.
+ (when-let [meta-atom (:metadata components)]
+ (let [subs-atom (:metadata-subs components)
+ subs (when subs-atom
+ (get @subs-atom
+ (string/lower-case nick) #{}))
+ members (get @channels handle)]
+ (when (and (seq subs) clients)
+ (doseq [target (cons handle members)
+ :when (not= target nick)
+ :let [low (string/lower-case target)
+ kv (get @meta-atom low {})]
+ [k v] kv
+ :when (contains? subs k)]
+ (deliver-to-client! (:w @client)
+ (str ":" +server-name+ " METADATA "
+ target " " k " * :" v))))))
;; away-notify: notify channel that joiner
;; is away
(when-let [a (:away @client)]