summaryrefslogtreecommitdiff
path: root/src/site.clj
diff options
context:
space:
mode:
authorsostler <sbostler@gmail.com>2010-04-16 13:41:02 -0400
committersostler <sbostler@gmail.com>2010-04-16 13:41:02 -0400
commit21922b749a5696a2ea4274e0968ad2d3d20dcc9d (patch)
tree49c1fdd33fffe318109e6609ad1b5db343d3d0ed /src/site.clj
parentff63970f9d785672f146d82cf1da0935db4b9b5e (diff)
Intermediate commit from muting admin
Diffstat (limited to 'src/site.clj')
-rw-r--r--src/site.clj34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/site.clj b/src/site.clj
index d45aa09..8342a09 100644
--- a/src/site.clj
+++ b/src/site.clj
@@ -138,17 +138,6 @@
(defn strip-empty-vals [m]
(into {} (filter (fn [[k v]] (non-empty-string? v)) m)))
-(declare stringify-and-escape)
-(defn escape-html-deep [o]
- (if (map? o)
- (stringify-and-escape o)
- (if (seq? o)
- (map escape-html-deep o)
- (escape-html o))))
-
-(defn stringify-and-escape [m]
- (zipmap (map str* (keys m)) (map escape-html-deep (vals m))))
-
(defn process-message-for-json [d]
(assoc d :created_on (.getTime (d :created_on))))
@@ -156,7 +145,7 @@
(escape-html-deep
(strip-empty-vals
(if (contains? d :created_on)
- (assoc d :created_on (.format formatter (d :created_on)))
+ (assoc d :created_on (format-timestamp (d :created_on)))
d))))
(defn new-messages [room since-ts]
@@ -867,6 +856,11 @@
(or (is-file-too-big? f vip)
(is-image-invalid? f)))
+; TODO:
+; The webcam code doesn't feature an error handler,
+; so all upload responses not equal to "OK" are considered
+; errors.
+
(defn do-upload [session image room]
(if-let [err (validate-upload-file (image :tempfile) (is-vip? session))]
(resp-error err)
@@ -880,7 +874,7 @@
(dosync
(add-message msg room))
(copy (:tempfile image) dest)
- "OK"))))
+ (resp-success "OK")))))
(defn upload [session params]
(let [room-key (params :room)
@@ -889,13 +883,10 @@
image (params :image)
mute ((poll *active-mutes*) user-id)
has-access (validate-room-access room-key session)]
- ; --TODO--
- ; Because ajaxupload.js doesn't feature an error-handler,
- ; all responses not equal to "OK" signal errors.
- (cond (not nick) (resp-success "NOT_LOGGED_IN")
- (not image) (resp-success "INVALID_REQUEST")
- mute (resp-success (format-mute mute))
- (not has-access) (resp-success "UNKNOWN_ROOM")
+ (cond (not nick) [200 "NOT_LOGGED_IN"]
+ (not image) [200 "INVALID_REQUEST"]
+ mute [200 (format-mute mute)]
+ (not has-access) [200 "UNKNOWN_ROOM"]
:else (do-upload session image (lookup-room room-key)))))
;; N.B. -- Upload responses aren't JSON-evaluated
@@ -987,8 +978,9 @@
;; Admin stuff (should be own route?)
(GET "/debug" (debug-page session flash))
(POST "/debug" (debug-commmand! session params))
- (GET "/mute-status" (mute-status session))
+ (GET "/mutes" (show-mutes session))
(POST "/mute" (mute! session params))
+ (POST "/cancel-mute" (handle-cancel-mute! session params))
;; Footer pages
(GET "/about_us" (serve-template "about_us" session))