summaryrefslogtreecommitdiff
path: root/src/rooms.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/rooms.clj')
-rw-r--r--src/rooms.clj17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/rooms.clj b/src/rooms.clj
index e919557..3367ea9 100644
--- a/src/rooms.clj
+++ b/src/rooms.clj
@@ -2,10 +2,11 @@
(:import java.util.Date)
(:use clojure.contrib.str-utils
clojure.contrib.def
+ config
utils
user))
-(defstruct message-struct :nick :content :created_on :msg_id)
+(defstruct message-struct :nick :content :created_on :msg_id :recips)
(def *run-flusher* true)
(def *flusher-sleep* (seconds 4))
@@ -98,21 +99,12 @@
; Note: To ensure that the msg's timestamp is consistent
; with other msg creations, build-msg must be used
; within a dosync.
-(defn build-msg [nick content msg-id]
- (struct message-struct nick content (new Date) msg-id))
-
-(def message-count-limit 200)
+(defn build-msg [nick content msg-id recips]
+ (struct message-struct nick content (new Date) msg-id recips))
(defn add-message [msg room]
(insert-and-truncate! (room :messages) msg message-count-limit))
-(defn insert-message-into-db! [user-id room-id content is-image]
- (:message_id
- (first
- (do-select ["INSERT INTO messages (user_id, room_id, content, is_image)
- VALUES (?, ?, ?, ?) RETURNING message_id"
- user-id room-id content is-image]))))
-
(defn create-and-add-room! [key]
(do-select ["INSERT INTO rooms (key, name, description)
VALUES (?, ?, ?) RETURNING room_id"
@@ -123,7 +115,6 @@
(build-room-map-from-db room-db))
room-db)))
-; TODO: cache
(defn get-or-create-room! [key]
(:room_id
(or (first (do-select ["SELECT room_id FROM rooms WHERE lower(key) = ?"