 (defn fetch-users-for-user
   "Get all users visible to given user"
   [user-id]
-  (->> (d/q '[:find (pull ?e [:user/id
-                              :user/nickname
-                              :user/avatar
-                              {:group/_user [:group/id]}])
-              :in $ ?user-id
+  (->> (d/q '[:find (pull ?e pull-pattern)
+              :in $ ?user-id pull-pattern
               :where
               [?u :user/id ?user-id]
               [?g :group/user ?u]
               [?g :group/user ?e]]
-            (d/db *conn*) user-id)
+            (d/db *conn*)
+            user-id
+            user-pull-pattern)
        (map (comp db->user first))
        set))
 

                      :message/content
                      {:message/user [:user/id]}
                      :message/created-at]}])

(defn- db->thread
  [thread]

       set))

(defn get-users-in-group [group-id]
  (->> (d/q '[:find (pull ?u pull-pattern)
              :in $ ?group-id pull-pattern
              :where
              [?g :group/id ?group-id]
              [?g :group/user ?u]]
            (d/db *conn*)
            group-id
            user-pull-pattern)
       (map (comp db->user first))
       set))

