diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-08-18 17:39:46 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-08-18 17:39:46 +0200 |
commit | 573113dfb99e4d6eb6086b53dee1afcb845c18a9 (patch) | |
tree | 2aac5cde2d91273db4f93af61905da34e28d0fa3 /src | |
parent | 202ef602aa8672c74619cd2db47dc3e1bab747a6 (diff) |
Add table posts.
Diffstat (limited to 'src')
-rw-r--r-- | src/mulk/benki/lazychat.clj | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mulk/benki/lazychat.clj b/src/mulk/benki/lazychat.clj index 2b0db68..75b0b16 100644 --- a/src/mulk/benki/lazychat.clj +++ b/src/mulk/benki/lazychat.clj @@ -48,11 +48,11 @@ (with-dbt (when id ;; FIXME: Is this assertion sufficient? Is it too strict? - (assert (query1 "SELECT 't' WHERE currval('lazychat_messages_id_seq') >= ?" id))) + (assert (query1 "SELECT 't' WHERE currval('posts_id_seq') >= ?" id))) (let [id (or id - (:id (query1 "SELECT nextval('lazychat_messages_id_seq')::INTEGER AS id")))] + (:id (query1 "SELECT nextval('posts_id_seq')::INTEGER AS id")))] (sql/with-query-results ids - ["INSERT INTO lazychat_messages(id, author, content, format) + ["INSERT INTO lazychat_messages(id, owner, content, format) VALUES (?, ?, ?, ?) RETURNING id" id user content format] @@ -84,7 +84,7 @@ {:content content, :visibility visibility, :format format, :targets targets, :referees referees, :id id, - :author user, :date (java.util.Date.)}) + :owner user, :date (java.util.Date.)}) {:type ::lafargue-message})))))) (defn create-lazychat-message! [msg] @@ -108,7 +108,7 @@ :referees []}))) (defn select-message [id] - (let [message (query1 "SELECT author, content, format, visibility, date + (let [message (query1 "SELECT owner, content, format, visibility, date FROM lazychat_messages WHERE id = ?" id) @@ -145,9 +145,9 @@ (defmacro with-messages-visible-by-user [[messages user] & body] `(sql/with-query-results ~messages - ["SELECT m.id, m.author, m.date, m.content, m.format, u.first_name, u.last_name + ["SELECT m.id, m.owner, m.date, m.content, m.format, u.first_name, u.last_name FROM lazychat_messages m - JOIN users u ON (author = u.id) + JOIN users u ON (owner = u.id) JOIN user_visible_lazychat_messages uvlm ON (uvlm.message = m.id) WHERE uvlm.user IS NOT DISTINCT FROM ? ORDER BY m.date DESC" @@ -262,7 +262,7 @@ (defpage [:post "/lafargue/messages/genid"] {id :id} (with-auth (response/json - (with-dbt (query1 "SELECT NEXTVAL('lazychat_messages_id_seq')"))))) + (with-dbt (query1 "SELECT NEXTVAL('posts_id_seq')"))))) (defn init-lazychat! [] (receive-all lafargue-events push-message-to-xmpp) |