🐛 Forward email when adding user to Nitrate organization

This commit is contained in:
Juanfran 2026-04-15 09:58:12 +02:00
parent 431056404c
commit f5591ed22e
5 changed files with 31 additions and 25 deletions

View File

@ -250,9 +250,11 @@
schema:team params)))
(defn- add-profile-to-org-api
[cfg {:keys [profile-id org-id team-id] :as params}]
[cfg {:keys [profile-id org-id team-id email] :as params}]
(let [baseuri (cf/get :nitrate-backend-uri)
params (assoc params :request-params {:user-id profile-id :team-id team-id})]
request-params (cond-> {:user-id profile-id :team-id team-id}
(some? email) (assoc :email email))
params (assoc params :request-params request-params)]
(request-to-nitrate cfg :post
(str baseuri
"/api/organizations/"

View File

@ -542,26 +542,29 @@
(defn initialize-user-in-nitrate-org
"If needed, create a default team for the user on the organization,
and notify Nitrate that an user has been added to an org."
[cfg profile-id org-id]
(assert (db/connection-map? cfg)
"expected cfg with valid connection")
(when (contains? cf/flags :nitrate)
(db/tx-run!
cfg
(fn [{:keys [::db/conn] :as tx-cfg}]
(let [org-id org-id
default-team (create-default-org-team (assoc tx-cfg ::db/conn conn) profile-id org-id)
default-team-id (:id default-team)
result (nitrate/call tx-cfg :add-profile-to-org {:profile-id profile-id
:team-id default-team-id
:org-id org-id})]
(when (not (:is-member result))
(ex/raise :type :internal
:code :failed-add-profile-org-nitrate
:context {:profile-id profile-id
:org-id org-id
:default-team-id default-team-id}))
default-team-id)))))
([cfg profile-id org-id]
(initialize-user-in-nitrate-org cfg profile-id org-id nil))
([cfg profile-id org-id email]
(assert (db/connection-map? cfg)
"expected cfg with valid connection")
(when (contains? cf/flags :nitrate)
(db/tx-run!
cfg
(fn [{:keys [::db/conn] :as tx-cfg}]
(let [org-id org-id
default-team (create-default-org-team (assoc tx-cfg ::db/conn conn) profile-id org-id)
default-team-id (:id default-team)
result (nitrate/call tx-cfg :add-profile-to-org (cond-> {:profile-id profile-id
:team-id default-team-id
:org-id org-id}
(some? email) (assoc :email email)))]
(when (not (:is-member result))
(ex/raise :type :internal
:code :failed-add-profile-org-nitrate
:context {:profile-id profile-id
:org-id org-id
:default-team-id default-team-id}))
default-team-id))))))
(defn add-profile-to-team!
([cfg params]

View File

@ -137,7 +137,7 @@
(if organization
;; Insert the invited member to the org
(when (contains? cf/flags :nitrate)
(teams/initialize-user-in-nitrate-org cfg (:id member) (:id organization)))
(teams/initialize-user-in-nitrate-org cfg (:id member) (:id organization) email))
;; Insert the invited member to the team
(teams/add-profile-to-team! cfg params {::db/on-conflict-do-nothing? true}))

View File

@ -111,7 +111,7 @@
accepted-team-id (if org-id
;; Insert the invited member to the org
(when (contains? cf/flags :nitrate)
(teams/initialize-user-in-nitrate-org cfg id-member org-id))
(teams/initialize-user-in-nitrate-org cfg id-member org-id member-email))
;; Insert the invited member to the team
(do (teams/add-profile-to-team! cfg params {::db/on-conflict-do-nothing? true})
team-id))]

View File

@ -57,7 +57,8 @@
(let [href (dm/str "/control-center/org/"
(u/percent-encode organization-slug)
"/"
(u/percent-encode (str organization-id)))]
(u/percent-encode (str organization-id))
"/people/")]
(st/emit! (rt/nav-raw :href href)))
(st/emit! (rt/nav-raw :href "/control-center/")))))