summaryrefslogtreecommitdiff
path: root/src/papod.clj
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2026-04-26 16:57:03 -0300
committerEuAndreh <eu@euandre.org>2026-04-26 16:57:03 -0300
commit5135b8cdcceefc42674bcf590bc0bd45a5f1a6fb (patch)
tree70f69150eb05203c1bb204277e5bdfdf2b6abfec /src/papod.clj
parentTrack unregistered connections and honor MODE -o (diff)
downloadpapod-5135b8cdcceefc42674bcf590bc0bd45a5f1a6fb.tar.gz
papod-5135b8cdcceefc42674bcf590bc0bd45a5f1a6fb.tar.xz
Improve INVITE: validate target, channel membership, op status
INVITE now returns: - 401 ERR_NOSUCHNICK if target user doesn't exist - 442 ERR_NOTONCHANNEL if inviter is not in the channel - 482 ERR_CHANOPRIVSNEEDED if channel is +i and inviter is not op The INVITE message delivered to the invitee now uses the full nickmask prefix (foo!user@host) rather than just the nick, so clients can match on prefix=StrRe('foo!.*').
Diffstat (limited to 'src/papod.clj')
-rw-r--r--src/papod.clj27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/papod.clj b/src/papod.clj
index a9b4e41..2f79aa3 100644
--- a/src/papod.clj
+++ b/src/papod.clj
@@ -3660,12 +3660,32 @@
(= command "INVITE")
(let [{:keys [clients channels]} components
target (first params)
- handle (second params)]
+ handle (second params)
+ nick (client-target client)]
(cond
(< (count params) 2)
[(numeric-reply client "461"
"INVITE :Not enough parameters")]
+ (and clients
+ (not (get @clients target)))
+ [(numeric-reply client "401"
+ (str target " :No such nick/channel"))]
+
+ (and channels handle
+ (seq (get @channels handle))
+ (not (contains? (get @channels handle) nick)))
+ [(numeric-reply client "442"
+ (str handle " :You're not on that channel"))]
+
+ (and channels handle
+ (let [m (chan-modes-for components handle)]
+ (and (string/includes? m "i")
+ (not (is-op? components handle nick)))))
+ [(numeric-reply client "482"
+ (str handle
+ " :You're not channel operator"))]
+
(and channels handle
(contains? (get @channels handle) target))
[(numeric-reply client "443"
@@ -3673,14 +3693,15 @@
" :is already on channel"))]
:else
- (let [nick (client-target client)]
+ (do
(when-let [invites (:invites components)]
(swap! invites update handle
(fnil conj #{}) target))
(when-let [m (and clients
(get @clients target))]
(deliver-to-client! (:w m)
- (str ":" nick " INVITE " target
+ (str ":" (client-prefix client)
+ " INVITE " target
" " handle)))
[(numeric-reply client "341"
(str target " " handle))])))