diff options
| author | sostler <sbostler@gmail.com> | 2010-01-08 01:02:07 -0500 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2010-01-08 01:02:07 -0500 |
| commit | 1a8b5db6a5efb7258e0116bfcdafb7b719395f52 (patch) | |
| tree | f9f57864d089f1abefcd1918395a492a15e070c3 | |
| parent | 4e837788114e07330be2dfb869efd70e525b2bc4 (diff) | |
Automatic re-login
| -rwxr-xr-x | src/site.clj | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/site.clj b/src/site.clj index 1d27753..f3aa9a1 100755 --- a/src/site.clj +++ b/src/site.clj @@ -141,6 +141,9 @@ (defn maybe-parse-int [s f] (if s (Integer/parseInt s) f)) +(defn maybe-parse-long [s f] + (if s (Long/parseLong s) f)) + (defn count-messages-by-room [room-id image-only] (let [query (str "SELECT COUNT(*) " "FROM messages m, users u " @@ -325,11 +328,13 @@ (defn refresh [session params room] (dosync (let [now (System/currentTimeMillis) - since (Long/parseLong (params :since)) + since (maybe-parse-long (params :since) now) nick (session :nick) users (room :users)] - (if (contains? @users nick) - (alter users assoc-in [nick :last-seen] now)) + (if nick + (if (contains? @users nick) + (alter users assoc-in [nick :last-seen] now) + (alter (room :users) assoc nick (user-struct-from-session session)))) (resp-success (assoc (updates room since) :timestamp now))))) |
