                          :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"
+  "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

                                  [[:db/add [:thread/id thread-id]
                                    :thread/mentioned [:user/id user-id]]
                                   [:db/add [:user/id user-id]
                                    :user/subscribed-thread [:thread/id thread-id]]
                                   [:db/add [:user/id user-id]
                                    :user/open-thread [:thread/id thread-id]]])
                                mentioned-user-ids)
        ; open thread for users already subscribed to thread
        txs-for-tag-subscribers (map
