🎉 Add team invitations API

This commit is contained in:
Pablo Alba 2022-02-15 14:18:45 +01:00 committed by Andrey Antukh
parent 09a4cb30ec
commit 1990232adc
6 changed files with 155 additions and 10 deletions

View file

@ -229,3 +229,20 @@
(defn retrieve-team-stats
[conn team-id]
(db/exec-one! conn [sql:team-stats team-id team-id]))
;; --- Query: Team invitations
(s/def ::team-id ::us/uuid)
(s/def ::team-invitations
(s/keys :req-un [::profile-id ::team-id]))
(def sql:team-invitations
"select email_to as email, role, (valid_until < now()) as expired from team_invitation where team_id = ?")
(sv/defmethod ::team-invitations
[{:keys [pool] :as cfg} {:keys [profile-id team-id]}]
(with-open [conn (db/open pool)]
(check-read-permissions! conn profile-id team-id)
(db/exec! conn [sql:team-invitations team-id])))