                        db->group)]
     (when (:public? (group-settings (group :id)))
       group)))
-

         (into #{}))))

(defn threads-with-tag
  "Find threads with a given tag that the user is allowed to see, ordered by most recent message.
  Paginates results, dropping `skip` threads and returning `limit`.
  Returns the threads and a count of how many threads remain."
  [conn user-id tag-id skip limit]

              user-id
              thread-pull-pattern)
         (into ()
               (map (comp
                      #(update-in % [:tag-ids]
                                  (partial into #{} (filter visible-tags)))
                      #(thread-add-last-open-at % user-id)
                      db->thread
                      first))))))

(defn get-thread
  [conn thread-id]
