mirror of
https://github.com/penpot/penpot.git
synced 2026-05-06 08:38:40 +00:00
✨ Add nitrate method for notify user when is added to organization (#8531)
This commit is contained in:
parent
40c9466718
commit
b3a6468697
@ -8,6 +8,7 @@
|
||||
"Internal Nitrate HTTP RPC API. Provides authenticated access to
|
||||
organization management and token validation endpoints."
|
||||
(:require
|
||||
[app.common.features :as cfeat]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.types.profile :refer [schema:profile, schema:basic-profile]]
|
||||
[app.common.types.team :refer [schema:team]]
|
||||
@ -18,8 +19,11 @@
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.rpc.commands.files :as files]
|
||||
[app.rpc.commands.profile :as profile]
|
||||
[app.rpc.commands.teams :as teams]
|
||||
[app.rpc.doc :as doc]
|
||||
[app.util.services :as sv]))
|
||||
[app.rpc.quotes :as quotes]
|
||||
[app.util.services :as sv]
|
||||
[clojure.set :as set]))
|
||||
|
||||
;; ---- API: authenticate
|
||||
|
||||
@ -77,7 +81,8 @@
|
||||
(def ^:private schema:notify-team-change
|
||||
[:map
|
||||
[:id ::sm/uuid]
|
||||
[:organization-id ::sm/text]])
|
||||
[:organization-id ::sm/uuid]
|
||||
[:organization-name ::sm/text]])
|
||||
|
||||
(sv/defmethod ::notify-team-change
|
||||
"Notify to Penpot a team change from nitrate"
|
||||
@ -95,6 +100,33 @@
|
||||
:organization-id organization-id
|
||||
:organization-name organization-name})))
|
||||
|
||||
;; ---- API: notify-user-added-to-organization
|
||||
|
||||
(def ^:private schema:notify-user-added-to-organization
|
||||
[:map
|
||||
[:profile-id ::sm/uuid]
|
||||
[:organization-id ::sm/uuid]
|
||||
[:role ::sm/text]])
|
||||
|
||||
(sv/defmethod ::notify-user-added-to-organization
|
||||
"Notify to Penpot that an user has joined an org from nitrate"
|
||||
{::doc/added "2.14"
|
||||
::sm/params schema:notify-user-added-to-organization
|
||||
::rpc/auth false}
|
||||
[cfg {:keys [profile-id]}]
|
||||
(quotes/check! cfg {::quotes/id ::quotes/teams-per-profile
|
||||
::quotes/profile-id profile-id})
|
||||
|
||||
(let [features (-> (cfeat/get-enabled-features cf/flags)
|
||||
(set/difference cfeat/frontend-only-features)
|
||||
(set/difference cfeat/no-team-inheritable-features))
|
||||
;; TODO Choose a better name and manage a default-in-org setting
|
||||
params {:profile-id profile-id
|
||||
:features features
|
||||
:name "NitrateDefault"}
|
||||
team (db/tx-run! cfg teams/create-team params)]
|
||||
(select-keys team [:id])))
|
||||
|
||||
|
||||
;; ---- API: get-managed-profiles
|
||||
|
||||
@ -126,3 +158,4 @@
|
||||
[cfg {:keys [::rpc/profile-id]}]
|
||||
(let [current-user-id (-> (profile/get-profile cfg profile-id) :id)]
|
||||
(db/exec! cfg [sql:get-managed-profiles current-user-id current-user-id])))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user