From 43a4c7ce3ea0c4278232a0b93c4876372ca7e037 Mon Sep 17 00:00:00 2001 From: sostler Date: Fri, 14 May 2010 23:56:21 -0400 Subject: Fixed mute cancels --- src/admin.clj | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/admin.clj') diff --git a/src/admin.clj b/src/admin.clj index 76e690a..e5d3e04 100644 --- a/src/admin.clj +++ b/src/admin.clj @@ -66,10 +66,6 @@ LIMIT 1 *mute-refresh-period-sec* nil)) -(defn mute-status [session] - (if-vip - (println session))) - (defn parse-pos-interval [time unit] (let [t (maybe-parse-int time 0) u (lower-case unit)] @@ -106,25 +102,28 @@ WHERE mute_id = ? AND cancelled = false ") -(defn cancel-mute! [mute-id admin-id] +(defn cancel-mute! [mute-id admin-id reason] (let [mute (fetch-mute mute-id) active (nor (:expired mute) (:cancelled mute)) qry "mute_id = ? AND cancelled = false AND (set_on + duration) > now()"] (cond (not mute) (resp-error "INVALID_MUTE_ID") (not active) (resp-error "EXPIRED_MUTE") + (not reason) (resp-error "NO_REASON") :else (assert-update (do-update :mutes [qry mute-id] - {:cancelled true - :cancel_admin_id admin-id}) + {:cancelled true + :cancel_admin_id admin-id + :cancel_reason reason}) (resp-success "OK") (resp-error "UPDATE_ERROR"))))) (defn handle-cancel-mute! [session params] (if-vip (let [mute-id (maybe-parse-int (params :mute_id) 0) + reason (params :reason) admin-id (session :user_id)] - (cancel-mute! mute-id admin-id)))) + (cancel-mute! mute-id admin-id reason)))) (defn format-mute [mute] (format (str "I'm sorry, you've been muted for %s. " -- cgit v1.2.3-70-g09d2