From 1f52229775ac654aaf4e1807b38a4bc1527a1434 Mon Sep 17 00:00:00 2001 From: sostler Date: Thu, 27 May 2010 19:01:01 -0400 Subject: Fixed disappearing messages bug --- src/site.clj | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/site.clj b/src/site.clj index 18fe495..2197dd5 100644 --- a/src/site.clj +++ b/src/site.clj @@ -584,24 +584,25 @@ FROM users u ((first (do-select [qry user-id room-id content is-image])) :message_id)))) +(defn build-msg [nick content msg-id] + (struct message-struct nick content (new Date) msg-id)) + (defn msg [session params] (let [user-id (session :user_id) mute ((poll *active-mutes*) user-id) nick (session :nick) room-key (params :room) room (lookup-room room-key) - content (.trim (params :content)) - now (new Date)] + content (.trim (params :content))] (cond (not room) (resp-error "BAD_ROOM") (not nick) (resp-error "NOT_LOGGED_IN") 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)] + (let [msg-id (msg-db user-id (room :room_id) content)] (dosync - (if (not (contains? (ensure (room :users)) nick)) - (login-user (user-struct-from-session session) room)) - (add-message msg room)) + (if (not (contains? (ensure (room :users)) nick)) + (login-user (user-struct-from-session session) room)) + (add-message (build-msg nick content msg-id) room)) (resp-success msg-id))))) (defn validated-msg [session params] -- cgit v1.2.3-70-g09d2