summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Ostler <scottbot9000@gmail.com>2011-02-13 01:03:29 -0500
committerScott Ostler <scottbot9000@gmail.com>2011-02-13 01:03:29 -0500
commit6fc29f2c44ac555f8d5ef1ec6a2df3503edcd583 (patch)
treeac5407ba6233701062aa2621c1015002850e020f
parent157c865f7486cd4ed684d2bf90c8a03d5b2164b5 (diff)
Fixed buggy assert-update logic
-rw-r--r--src/admin.clj18
-rwxr-xr-xsrc/utils.clj3
2 files changed, 10 insertions, 11 deletions
diff --git a/src/admin.clj b/src/admin.clj
index 9dbc65c..3593072 100644
--- a/src/admin.clj
+++ b/src/admin.clj
@@ -130,15 +130,15 @@ AND cancelled = false
(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
- :cancel_reason reason})
- (do
- (update! *active-mutes*)
- (resp-success "OK"))
- (resp-error "UPDATE_ERROR")))))
+ :else (if (assert-update
+ (do-update :mutes [qry mute-id]
+ {:cancelled true
+ :cancel_admin_id admin-id
+ :cancel_reason reason}))
+ (do
+ (update! *active-mutes*)
+ (resp-success "OK"))
+ (resp-error "UPDATE_ERROR")))))
(defn handle-cancel-mute! [session params]
(if-vip
diff --git a/src/utils.clj b/src/utils.clj
index ee64789..25814f9 100755
--- a/src/utils.clj
+++ b/src/utils.clj
@@ -269,8 +269,7 @@
(insert-values table cols values)))
(defn assert-update
- ([res ok err] (if (not (= (first res) 1)) err ok))
- ([res] (assert-update res true false)))
+ ([res] (= (first res) 1)))
(defn sql-array [type arr]
(with-connection *db*