mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 00:10:11 -05:00
🐛 Fix unexpected exception on handling audit log on team invitations
A regression introduced in previous commits of this release
This commit is contained in:
parent
b8a606a35f
commit
c4941bb102
1 changed files with 23 additions and 18 deletions
|
@ -780,6 +780,7 @@
|
||||||
|
|
||||||
(def ^:private schema:create-invitation
|
(def ^:private schema:create-invitation
|
||||||
[:map {:title "params:create-invitation"}
|
[:map {:title "params:create-invitation"}
|
||||||
|
[::rpc/profile-id ::sm/uuid]
|
||||||
[:team
|
[:team
|
||||||
[:map
|
[:map
|
||||||
[:id ::sm/uuid]
|
[:id ::sm/uuid]
|
||||||
|
@ -936,7 +937,7 @@
|
||||||
(map :email))
|
(map :email))
|
||||||
|
|
||||||
(defn- create-team-invitations
|
(defn- create-team-invitations
|
||||||
[{:keys [::db/conn] :as cfg} profile team role emails]
|
[{:keys [::db/conn] :as cfg} {:keys [profile team role emails] :as params}]
|
||||||
(let [join-requests (into #{} xf:map-email
|
(let [join-requests (into #{} xf:map-email
|
||||||
(get-valid-requests-email conn (:id team)))
|
(get-valid-requests-email conn (:id team)))
|
||||||
team-members (into #{} xf:map-email
|
team-members (into #{} xf:map-email
|
||||||
|
@ -950,11 +951,7 @@
|
||||||
;; We don't send invitations to
|
;; We don't send invitations to
|
||||||
;; join-requested members
|
;; join-requested members
|
||||||
(remove join-requests)
|
(remove join-requests)
|
||||||
(map (fn [email]
|
(map (fn [email] (assoc params :email email)))
|
||||||
{:email email
|
|
||||||
:team team
|
|
||||||
:profile profile
|
|
||||||
:role role}))
|
|
||||||
(keep (partial create-invitation cfg)))
|
(keep (partial create-invitation cfg)))
|
||||||
emails)]
|
emails)]
|
||||||
|
|
||||||
|
@ -980,7 +977,7 @@
|
||||||
join the team."
|
join the team."
|
||||||
{::doc/added "1.17"
|
{::doc/added "1.17"
|
||||||
::sm/params schema:create-team-invitations}
|
::sm/params schema:create-team-invitations}
|
||||||
[cfg {:keys [::rpc/profile-id team-id emails role] :as params}]
|
[cfg {:keys [::rpc/profile-id team-id emails] :as params}]
|
||||||
(let [perms (get-permissions cfg profile-id team-id)
|
(let [perms (get-permissions cfg profile-id team-id)
|
||||||
profile (db/get-by-id cfg :profile profile-id)
|
profile (db/get-by-id cfg :profile profile-id)
|
||||||
emails (into #{} (map profile/clean-email) emails)]
|
emails (into #{} (map profile/clean-email) emails)]
|
||||||
|
@ -1006,7 +1003,16 @@
|
||||||
(check-profile-muted cfg profile)
|
(check-profile-muted cfg profile)
|
||||||
|
|
||||||
(let [team (db/get-by-id cfg :team team-id)
|
(let [team (db/get-by-id cfg :team team-id)
|
||||||
invitations (db/tx-run! cfg create-team-invitations profile team role emails)]
|
;; NOTE: Is important pass RPC method params down to the
|
||||||
|
;; `create-team-invitations` because it uses the implicit
|
||||||
|
;; RPC properties from params for fill necessary data on
|
||||||
|
;; emiting an entry to the audit-log
|
||||||
|
invitations (db/tx-run! cfg create-team-invitations
|
||||||
|
(-> params
|
||||||
|
(assoc :profile profile)
|
||||||
|
(assoc :team team)
|
||||||
|
(assoc :emails emails)))]
|
||||||
|
|
||||||
(with-meta {:total (count invitations)
|
(with-meta {:total (count invitations)
|
||||||
:invitations invitations}
|
:invitations invitations}
|
||||||
{::audit/props {:invitations (count invitations)}}))))
|
{::audit/props {:invitations (count invitations)}}))))
|
||||||
|
@ -1057,17 +1063,16 @@
|
||||||
(audit/submit! cfg event))
|
(audit/submit! cfg event))
|
||||||
|
|
||||||
;; Create invitations for all provided emails.
|
;; Create invitations for all provided emails.
|
||||||
(let [profile (db/get-by-id conn :profile profile-id)]
|
(let [profile (db/get-by-id conn :profile profile-id)
|
||||||
(->> emails
|
params (-> params
|
||||||
(map (fn [email]
|
(assoc :team team)
|
||||||
(-> params
|
(assoc :profile profile)
|
||||||
(assoc :team team)
|
(assoc :role role))
|
||||||
(assoc :profile profile)
|
invitations (->> emails
|
||||||
(assoc :email email)
|
(map (fn [email] (assoc params :email email)))
|
||||||
(assoc :role role))))
|
(map (partial create-invitation cfg)))]
|
||||||
(run! (partial create-invitation cfg))))
|
|
||||||
|
|
||||||
(vary-meta team assoc ::audit/props {:invitations (count emails)})))
|
(vary-meta team assoc ::audit/props {:invitations (count invitations)}))))
|
||||||
|
|
||||||
;; --- Query: get-team-invitation-token
|
;; --- Query: get-team-invitation-token
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue