diff options
| author | EuAndreh <eu@euandre.org> | 2026-04-26 17:50:05 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2026-04-26 17:50:05 -0300 |
| commit | 8ae6c1baeb4f1e5496906ede02bcce779e9c77b2 (patch) | |
| tree | 5f554cb455a62b8e6b2b53b7ccc185e20924d6d4 /src/papod.clj | |
| parent | MODE channel: validate target/channel/key/limit, strip leading colon (diff) | |
| download | papod-8ae6c1baeb4f1e5496906ede02bcce779e9c77b2.tar.gz papod-8ae6c1baeb4f1e5496906ede02bcce779e9c77b2.tar.xz | |
Honor +n (no external messages) and +m (moderated) on PRIVMSG
Sending PRIVMSG to a +n channel from outside the channel now returns
404 ERR_CANNOTSENDTOCHAN. Sending to a +m channel without op/voice
returns the same numeric.
Diffstat (limited to 'src/papod.clj')
| -rw-r--r-- | src/papod.clj | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/papod.clj b/src/papod.clj index a63e5b5..83301fb 100644 --- a/src/papod.clj +++ b/src/papod.clj @@ -1991,7 +1991,7 @@ (try (java.util.UUID/fromString r) (catch Exception _ nil)))] (cond - (and chan? (not (get @channels target))) + (and chan? (empty? (get @channels target))) [(numeric-reply client "403" (str target " :No such channel"))] @@ -2000,6 +2000,38 @@ [(numeric-reply client "401" (str target " :No such nick/channel"))] + ;; +n: no external messages + (and chan? + (string/includes? + (or (get @(:chan-modes components) + target) + "+nt") + "n") + (not (contains? + (get @channels target) nick))) + [(numeric-reply client "404" + (str target + " :Cannot send to channel"))] + + ;; +m: moderated — only ops/voiced may speak + (and chan? + (string/includes? + (or (get @(:chan-modes components) + target) + "+nt") + "m") + (not (and (:ops components) + (contains? + (get @(:ops components) target) + nick))) + (not (and (:voiced components) + (contains? + (get @(:voiced components) target) + nick)))) + [(numeric-reply client "404" + (str target + " :Cannot send to channel"))] + :else (do ;; PERSIST FIRST |
