summaryrefslogtreecommitdiff
path: root/src/site.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/site.clj')
-rw-r--r--src/site.clj28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/site.clj b/src/site.clj
index 234f5da..2b1fa94 100644
--- a/src/site.clj
+++ b/src/site.clj
@@ -642,10 +642,7 @@
now (new Date)]
(cond (not room) (resp-error "BAD_ROOM")
(not nick) (resp-error "NOT_LOGGED_IN")
- mute (resp-error
- (format (str "I'm sorry, you've been muted for %s. "
- "You'll be able to post again on %s EST.")
- (mute :reason) (mute :expiry)))
+ mute (resp-error (format-mute mute))
:else
(let [msg-id (msg-db user-id (room :room_id) content)
msg (struct message-struct nick content now msg-id)]
@@ -866,12 +863,12 @@
(defn image-url-from-file [dir date file]
(str-join "/" [*server-url* dir date (.getName file)]))
-(defn validate-upload [f vip]
+(defn validate-upload-file [f vip]
(or (is-file-too-big? f vip)
(is-image-invalid? f)))
(defn do-upload [session image room]
- (if-let [err (validate-upload (image :tempfile) (is-vip? session))]
+ (if-let [err (validate-upload-file (image :tempfile) (is-vip? session))]
(resp-error err)
(let [filename (format-filename (:filename image) (session :nick))
date (today)
@@ -883,14 +880,21 @@
(dosync
(add-message msg room))
(copy (:tempfile image) dest)
- (resp-success url)))))
+ "OK"))))
(defn upload [session params]
- (let [room-key (params :room)
- nick (session :nick)
- image (params :image)]
- (cond (not nick) [200 "NOT_LOGGED_IN"]
- (not image) [200 "INVALID_REQUEST"]
+ (let [room-key (params :room)
+ nick (session :nick)
+ user-id (session :user_id)
+ mute ((poll *active-mutes*) user-id)
+ image (params :image)]
+ ; --TODO--
+ ; Because ajaxupload.js doesn't feature an error-handler,
+ ; all responses not equal to "OK" signal errors.
+ (println mute (if mute (format-mute mute) nil))
+ (cond (not nick) (resp-success "NOT_LOGGED_IN")
+ (not image) (resp-success "INVALID_REQUEST")
+ mute (resp-success (format-mute mute))
(not (validate-room-access room-key session)) [200 "UNKNOWN_ROOM"]
:else (do-upload session image (lookup-room room-key)))))