        (d/db *conn*)
        thread-id))
 
-(defn create-message! [attrs]
+(defn create-message!
+  [{:keys [thread-id id content user-id created-at]}]
   (let [; show thread for all users subscribed to thread
         add-open-transactions (map (fn [user-id]
                                      [:db/add [:user/id user-id]
-                                      :user/open-thread [:thread/id (attrs :thread-id)]])
-                                   (get-users-subscribed-to-thread (attrs :thread-id)))
+                                      :user/open-thread [:thread/id thread-id]])
+                                   (get-users-subscribed-to-thread thread-id))
         ; upsert thread
         thread-data {:db/id (d/tempid :entities)
-                     :thread/id (attrs :thread-id)}
+                     :thread/id thread-id}
         ; upsert message
         msg-data {:db/id (d/tempid :entities)
-                  :message/id (attrs :id)
-                  :message/content (attrs :content)
-                  :message/user [:user/id (attrs :user-id)]
+                  :message/id id
+                  :message/content content
+                  :message/user [:user/id user-id]
                   :message/thread (:db/id thread-data)
-                  :message/created-at (attrs :created-at)}
+                  :message/created-at created-at}
         ; user who created message: show thread, subscribe to thread
-        subscribe-data {:db/id [:user/id (attrs :user-id)]
+        subscribe-data {:db/id [:user/id user-id]
                         :user/open-thread (thread-data :db/id)
                         :user/subscribed-thread (thread-data :db/id)}
         {:keys [db-after tempids]} @(d/transact *conn* (concat [thread-data

    (->> (d/resolve-tempid db-after tempids new-id)
         (d/entity db-after))))

(defn get-users-subscribed-to-thread [thread-id]
  (d/q '[:find [?user-id ...]
         :in $ ?thread-id
         :where

      first
      db->thread))

(defn get-subscribed-thread-ids-for-user
  [user-id]
  (d/q '[:find [?thread-id ...]
         :in $ ?user-id
         :where
