summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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))])))