mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 07:11:32 -05:00
✨ Remove spec usage o teams rpc ns
This commit is contained in:
parent
046ef7eb6e
commit
ae90d59b43
1 changed files with 57 additions and 59 deletions
|
@ -12,7 +12,6 @@
|
||||||
[app.common.features :as cfeat]
|
[app.common.features :as cfeat]
|
||||||
[app.common.logging :as l]
|
[app.common.logging :as l]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.common.spec :as us]
|
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
|
@ -32,16 +31,10 @@
|
||||||
[app.util.services :as sv]
|
[app.util.services :as sv]
|
||||||
[app.util.time :as dt]
|
[app.util.time :as dt]
|
||||||
[app.worker :as wrk]
|
[app.worker :as wrk]
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
;; --- Helpers & Specs
|
;; --- Helpers & Specs
|
||||||
|
|
||||||
(s/def ::id ::us/uuid)
|
|
||||||
(s/def ::name ::us/string)
|
|
||||||
(s/def ::file-id ::us/uuid)
|
|
||||||
(s/def ::team-id ::us/uuid)
|
|
||||||
|
|
||||||
(def ^:private sql:team-permissions
|
(def ^:private sql:team-permissions
|
||||||
"select tpr.is_owner,
|
"select tpr.is_owner,
|
||||||
tpr.is_admin,
|
tpr.is_admin,
|
||||||
|
@ -351,7 +344,7 @@
|
||||||
|
|
||||||
(def ^:private schema:create-team
|
(def ^:private schema:create-team
|
||||||
[:map {:title "create-team"}
|
[:map {:title "create-team"}
|
||||||
[:name :string]
|
[:name [:string {:max 250}]]
|
||||||
[:features {:optional true} ::cfeat/features]
|
[:features {:optional true} ::cfeat/features]
|
||||||
[:id {:optional true} ::sm/uuid]])
|
[:id {:optional true} ::sm/uuid]])
|
||||||
|
|
||||||
|
@ -438,12 +431,14 @@
|
||||||
|
|
||||||
;; --- Mutation: Update Team
|
;; --- Mutation: Update Team
|
||||||
|
|
||||||
(s/def ::update-team
|
(def ^:private schema:update-team
|
||||||
(s/keys :req [::rpc/profile-id]
|
[:map {:title "update-team"}
|
||||||
:req-un [::name ::id]))
|
[:name [:string {:max 250}]]
|
||||||
|
[:id ::sm/uuid]])
|
||||||
|
|
||||||
(sv/defmethod ::update-team
|
(sv/defmethod ::update-team
|
||||||
{::doc/added "1.17"}
|
{::doc/added "1.17"
|
||||||
|
::sm/params schema:update-team}
|
||||||
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id id name] :as params}]
|
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id id name] :as params}]
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(check-edition-permissions! conn profile-id id)
|
(check-edition-permissions! conn profile-id id)
|
||||||
|
@ -503,14 +498,14 @@
|
||||||
|
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
(s/def ::reassign-to ::us/uuid)
|
(def ^:private schema:leave-team
|
||||||
(s/def ::leave-team
|
[:map {:title "leave-team"}
|
||||||
(s/keys :req [::rpc/profile-id]
|
[:id ::sm/uuid]
|
||||||
:req-un [::id]
|
[:reassign-to {:optional true} ::sm/uuid]])
|
||||||
:opt-un [::reassign-to]))
|
|
||||||
|
|
||||||
(sv/defmethod ::leave-team
|
(sv/defmethod ::leave-team
|
||||||
{::doc/added "1.17"}
|
{::doc/added "1.17"
|
||||||
|
::sm/params schema:leave-team}
|
||||||
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id] :as params}]
|
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id] :as params}]
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(leave-team conn (assoc params :profile-id profile-id))))
|
(leave-team conn (assoc params :profile-id profile-id))))
|
||||||
|
@ -539,12 +534,13 @@
|
||||||
:id team-id})
|
:id team-id})
|
||||||
team))
|
team))
|
||||||
|
|
||||||
(s/def ::delete-team
|
(def ^:private schema:delete-team
|
||||||
(s/keys :req [::rpc/profile-id]
|
[:map {:title "delete-team"}
|
||||||
:req-un [::id]))
|
[:id ::sm/uuid]])
|
||||||
|
|
||||||
(sv/defmethod ::delete-team
|
(sv/defmethod ::delete-team
|
||||||
{::doc/added "1.17"}
|
{::doc/added "1.17"
|
||||||
|
::sm/params schema:delete-team}
|
||||||
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id id] :as params}]
|
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id id] :as params}]
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(let [perms (get-permissions conn profile-id id)]
|
(let [perms (get-permissions conn profile-id id)]
|
||||||
|
@ -557,10 +553,6 @@
|
||||||
|
|
||||||
;; --- Mutation: Team Update Role
|
;; --- Mutation: Team Update Role
|
||||||
|
|
||||||
(s/def ::team-id ::us/uuid)
|
|
||||||
(s/def ::member-id ::us/uuid)
|
|
||||||
(s/def ::role #{:owner :admin :editor})
|
|
||||||
|
|
||||||
;; Temporarily disabled viewer role
|
;; Temporarily disabled viewer role
|
||||||
;; https://tree.taiga.io/project/penpot/issue/1083
|
;; https://tree.taiga.io/project/penpot/issue/1083
|
||||||
(def valid-roles
|
(def valid-roles
|
||||||
|
@ -624,25 +616,29 @@
|
||||||
:profile-id member-id})
|
:profile-id member-id})
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
(s/def ::update-team-member-role
|
(def ^:private schema:update-team-member-role
|
||||||
(s/keys :req [::rpc/profile-id]
|
[:map {:title "update-team-member-role"}
|
||||||
:req-un [::team-id ::member-id ::role]))
|
[:team-id ::sm/uuid]
|
||||||
|
[:member-id ::sm/uuid]
|
||||||
|
[:role schema:role]])
|
||||||
|
|
||||||
(sv/defmethod ::update-team-member-role
|
(sv/defmethod ::update-team-member-role
|
||||||
{::doc/added "1.17"}
|
{::doc/added "1.17"
|
||||||
|
::sm/params schema:update-team-member-role}
|
||||||
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id] :as params}]
|
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id] :as params}]
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(update-team-member-role conn (assoc params :profile-id profile-id))))
|
(update-team-member-role conn (assoc params :profile-id profile-id))))
|
||||||
|
|
||||||
|
|
||||||
;; --- Mutation: Delete Team Member
|
;; --- Mutation: Delete Team Member
|
||||||
|
|
||||||
(s/def ::delete-team-member
|
(def ^:private schema:delete-team-member
|
||||||
(s/keys :req [::rpc/profile-id]
|
[:map {:title "delete-team-member"}
|
||||||
:req-un [::team-id ::member-id]))
|
[:team-id ::sm/uuid]
|
||||||
|
[:member-id ::sm/uuid]])
|
||||||
|
|
||||||
(sv/defmethod ::delete-team-member
|
(sv/defmethod ::delete-team-member
|
||||||
{::doc/added "1.17"}
|
{::doc/added "1.17"
|
||||||
|
::sm/params schema:delete-team-member}
|
||||||
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id team-id member-id] :as params}]
|
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id team-id member-id] :as params}]
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(let [perms (get-permissions conn profile-id team-id)]
|
(let [perms (get-permissions conn profile-id team-id)]
|
||||||
|
@ -665,13 +661,14 @@
|
||||||
(declare upload-photo)
|
(declare upload-photo)
|
||||||
(declare ^:private update-team-photo)
|
(declare ^:private update-team-photo)
|
||||||
|
|
||||||
(s/def ::file ::media/upload)
|
(def ^:private schema:update-team-photo
|
||||||
(s/def ::update-team-photo
|
[:map {:title "update-team-photo"}
|
||||||
(s/keys :req [::rpc/profile-id]
|
[:team-id ::sm/uuid]
|
||||||
:req-un [::team-id ::file]))
|
[:file ::media/upload]])
|
||||||
|
|
||||||
(sv/defmethod ::update-team-photo
|
(sv/defmethod ::update-team-photo
|
||||||
{::doc/added "1.17"}
|
{::doc/added "1.17"
|
||||||
|
::sm/params schema:update-team-photo}
|
||||||
[cfg {:keys [::rpc/profile-id file] :as params}]
|
[cfg {:keys [::rpc/profile-id file] :as params}]
|
||||||
;; Validate incoming mime type
|
;; Validate incoming mime type
|
||||||
(media/validate-media-type! file #{"image/jpeg" "image/png" "image/webp"})
|
(media/validate-media-type! file #{"image/jpeg" "image/png" "image/webp"})
|
||||||
|
@ -809,7 +806,7 @@
|
||||||
(def ^:private schema:create-team-invitations
|
(def ^:private schema:create-team-invitations
|
||||||
[:map {:title "create-team-invitations"}
|
[:map {:title "create-team-invitations"}
|
||||||
[:team-id ::sm/uuid]
|
[:team-id ::sm/uuid]
|
||||||
[:role [::sm/one-of #{:owner :admin :editor}]]
|
[:role schema:role]
|
||||||
[:emails ::sm/set-of-emails]])
|
[:emails ::sm/set-of-emails]])
|
||||||
|
|
||||||
(sv/defmethod ::create-team-invitations
|
(sv/defmethod ::create-team-invitations
|
||||||
|
@ -866,12 +863,6 @@
|
||||||
|
|
||||||
;; --- Mutation: Create Team & Invite Members
|
;; --- Mutation: Create Team & Invite Members
|
||||||
|
|
||||||
(s/def ::emails ::us/set-of-valid-emails)
|
|
||||||
(s/def ::create-team-with-invitations
|
|
||||||
(s/merge ::create-team
|
|
||||||
(s/keys :req-un [::emails ::role])))
|
|
||||||
|
|
||||||
|
|
||||||
(def ^:private schema:create-team-with-invitations
|
(def ^:private schema:create-team-with-invitations
|
||||||
[:map {:title "create-team-with-invitations"}
|
[:map {:title "create-team-with-invitations"}
|
||||||
[:name :string]
|
[:name :string]
|
||||||
|
@ -930,12 +921,14 @@
|
||||||
|
|
||||||
;; --- Query: get-team-invitation-token
|
;; --- Query: get-team-invitation-token
|
||||||
|
|
||||||
(s/def ::get-team-invitation-token
|
(def ^:private schema:get-team-invitation-token
|
||||||
(s/keys :req [::rpc/profile-id]
|
[:map {:title "get-team-invitation-token"}
|
||||||
:req-un [::team-id ::email]))
|
[:team-id ::sm/uuid]
|
||||||
|
[:email ::sm/email]])
|
||||||
|
|
||||||
(sv/defmethod ::get-team-invitation-token
|
(sv/defmethod ::get-team-invitation-token
|
||||||
{::doc/added "1.17"}
|
{::doc/added "1.17"
|
||||||
|
::sm/params schema:get-team-invitation-token}
|
||||||
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id team-id email] :as params}]
|
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id team-id email] :as params}]
|
||||||
(check-read-permissions! pool profile-id team-id)
|
(check-read-permissions! pool profile-id team-id)
|
||||||
(let [email (profile/clean-email email)
|
(let [email (profile/clean-email email)
|
||||||
|
@ -956,12 +949,15 @@
|
||||||
|
|
||||||
;; --- Mutation: Update invitation role
|
;; --- Mutation: Update invitation role
|
||||||
|
|
||||||
(s/def ::update-team-invitation-role
|
(def ^:private schema:update-team-invitation-role
|
||||||
(s/keys :req [::rpc/profile-id]
|
[:map {:title "update-team-invitation-role"}
|
||||||
:req-un [::team-id ::email ::role]))
|
[:team-id ::sm/uuid]
|
||||||
|
[:email ::sm/email]
|
||||||
|
[:role schema:role]])
|
||||||
|
|
||||||
(sv/defmethod ::update-team-invitation-role
|
(sv/defmethod ::update-team-invitation-role
|
||||||
{::doc/added "1.17"}
|
{::doc/added "1.17"
|
||||||
|
::sm/params schema:update-team-invitation-role}
|
||||||
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id team-id email role] :as params}]
|
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id team-id email role] :as params}]
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(let [perms (get-permissions conn profile-id team-id)]
|
(let [perms (get-permissions conn profile-id team-id)]
|
||||||
|
@ -977,12 +973,14 @@
|
||||||
|
|
||||||
;; --- Mutation: Delete invitation
|
;; --- Mutation: Delete invitation
|
||||||
|
|
||||||
(s/def ::delete-team-invitation
|
(def ^:private schema:delete-team-invition
|
||||||
(s/keys :req [::rpc/profile-id]
|
[:map {:title "delete-team-invitation"}
|
||||||
:req-un [::team-id ::email]))
|
[:team-id ::sm/uuid]
|
||||||
|
[:email ::sm/email]])
|
||||||
|
|
||||||
(sv/defmethod ::delete-team-invitation
|
(sv/defmethod ::delete-team-invitation
|
||||||
{::doc/added "1.17"}
|
{::doc/added "1.17"
|
||||||
|
::sm/params schema:delete-team-invition}
|
||||||
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id team-id email] :as params}]
|
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id team-id email] :as params}]
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(let [perms (get-permissions conn profile-id team-id)]
|
(let [perms (get-permissions conn profile-id team-id)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue