        (map first)
        (map db->thread)))
 
-(defn get-thread [thread-id]
+(defn get-thread
+  [thread-id]
   (-> (d/q '[:find (pull ?thread [:thread/id
                                   {:thread/tag [:tag/id]}
                                   {:message/_thread [:message/id

            (d/db *conn*))
       (map (comp db->message first))))

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

       (map (comp db->user first))
       set))

(defn- db->thread
  [thread]
  {:id (thread :thread/id)
   :messages (map (fn [msg]
                    {:id (msg :message/id)
