   [invite-id]
   (some-> (d/pull (d/db *conn*)
               [:invite/id
-               {:invite/from [:user/id]}
+               {:invite/from [:user/id :user/email]}
                :invite/to
-               {:invite/group [:group/id]}]
+               {:invite/group [:group/id :group/name]}]
               [:invite/id invite-id])
       db->invitation))
 


(defn- db->invitation [e]
  {:id (:invite/id e)
   :inviter-id (:user/id (:invite/from e))
   :invitee-email (:invite/to e)
   :group-id (:group/id (:invite/group e)) })

(defmacro with-conn
  "Execute the body with *conn* dynamically bound to a new connection."

(defn fetch-invitations-for-user
  [user-id]
  (->> (d/q '[:find (pull ?i [{:invite/group [:group/id :group/name]}
                              {:invite/from [:user/id :user/email]}
                              :invite/id])
              :in $ ?user-id
              :where
              [?u :user/id ?user-id]
              [?u :user/email ?email]
              [?i :invite/to ?email]]
            (d/db *conn*) user-id)
       (map (comp db->invitation first))))

(defn fetch-messages
  "This almost certainly shouldn't be called outside of tests"
