diff options
| author | sostler <sbostler@gmail.com> | 2010-04-23 19:10:38 -0400 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2010-04-23 19:10:38 -0400 |
| commit | a3476c0dbb0069a48cc23564c82f5a5b44c20bee (patch) | |
| tree | 0b0bc73892dd4591ef79694ae9dc70d477246fd8 | |
| parent | bf2fdf22cd7a87402195ee3bd799d476ceb0df1a (diff) | |
Fixed admin.clj whitespace
| -rw-r--r-- | src/admin.clj | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/admin.clj b/src/admin.clj index c1a6c07..ef33aa2 100644 --- a/src/admin.clj +++ b/src/admin.clj @@ -12,7 +12,7 @@ (def fetch-active-mutes-query " SELECT m.*, - (m.set_on + m.duration) AS expiry, + (m.set_on + m.duration) AS expiry, a.nick AS admin_nick, o.nick AS nick FROM mutes m, users a, users o @@ -24,7 +24,7 @@ AND NOT m.cancelled (def fetch-inactive-mutes-query " SELECT m.*, - (m.set_on + m.duration) AS expiry, + (m.set_on + m.duration) AS expiry, a.nick AS admin_nick, o.nick AS nick, c.nick AS cancel_nick @@ -37,7 +37,7 @@ WHERE m.cancelled OR (m.set_on + m.duration < now()) (def fetch-mute-query " SELECT m.*, - (m.set_on + m.duration) AS expiry, + (m.set_on + m.duration) AS expiry, (m.set_on + m.duration) < now() as expired, a.nick AS admin_nick FROM mutes m, users a @@ -60,7 +60,7 @@ LIMIT 1 (defn fetch-mute [mute-id] (first (do-select [fetch-mute-query mute-id]))) -(def *active-mutes* +(def *active-mutes* (scheduled-agent (no-args-adaptor fetch-active-mute-map) *mute-refresh-period-sec* nil)) @@ -78,7 +78,8 @@ LIMIT 1 (defn insert-mute! [user-id admin-id reason duration] (do-prepared! "INSERT INTO mutes (user_id, admin_id, duration, reason) - VALUES (?, ?, CAST (? AS INTERVAL), ?)" [user-id admin-id duration reason]) + VALUES (?, ?, CAST (? AS INTERVAL), ?)" + [user-id admin-id duration reason]) (update! *active-mutes*)) (defn mute! [session params] @@ -100,23 +101,23 @@ LIMIT 1 (def mute-cancel-query " UPDATE mutes SET cancelled=true, cancel_admin_id=? -WHERE mute_id = ? +WHERE mute_id = ? AND cancelled = false ") (defn- assert-update [res ok err] - (if (zero? (first res)) err ok)) + (if (zero? (first res)) err ok)) (defn cancel-mute! [mute-id admin-id] (let [mute (fetch-mute mute-id) active (nor (:expired mute) (:cancelled mute)) - qry "mute_id = ? AND cancelled = false + 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") :else (assert-update (do-update :mutes [qry mute-id] - {:cancelled true + {:cancelled true :cancel_admin_id admin-id}) (resp-success "OK") (resp-error "UPDATE_ERROR"))))) @@ -175,15 +176,17 @@ AND cancelled = false (defn debug-commmand! [session params] (if-vip (let [action (:action params) - msg (try + msg (try (cond (= action "regemail") - (do (send-registration-email (params :nick) (params :to) (params :template)) + (do (send-registration-email (params :nick) + (params :to) + (params :template)) (str "Sent registration mail to " (params :to))) :else (str "Unknown action: " action)) - (catch Exception e + (catch Exception e (str "<h2 color=\"red\">Caught Exception in " action " --" (.getMessage e) - "</h2><br><pre>" + "</h2><br><pre>" (exception-to-string e) "</pre>")))] [(flash-assoc :msg msg) |
