                                  :thread/id thread-id
                                  :thread/group [:group/id group-id]}])))
 
-  (let [; for users subscribed to mentioned tags, open and subscribe them to the thread
+  (let [; for users subscribed to mentioned tags, open and subscribe them to
+        ; the thread
         txs-for-tag-mentions (mapcat
                                (fn [tag-id]
                                  (into

                         :db/id #db/id [:entities]}])))

(defn user-search-preferences
  "Find the ids of users that have the a given value for a given key set in their preferences"
  [conn k v]
  (d/q '[:find [?user-id ...]
         :in $ ?k ?v

                  :message/thread [:thread/id thread-id]
                  :message/created-at created-at}
        ; user who created message: show thread, subscribe to thread
        subscribe-data [[:db/add [:user/id user-id]
                         :user/open-thread [:thread/id thread-id]]
                        [:db/add [:user/id user-id]
                         :user/subscribed-thread [:thread/id thread-id]]]
        {:keys [db-after tempids]} @(d/transact conn
                                      (concat [msg-data]
                                              subscribe-data
                                              txs-for-tag-subscribers
                                              txs-for-tag-mentions
                                              txs-for-user-mentions))]
    (->> (d/resolve-tempid db-after tempids (msg-data :db/id))
         (d/pull db-after '[:message/id
                            :message/content
