mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 21:11:38 +02:00
✨ Add created-by to invitations, and an event related
This commit is contained in:
parent
e1e13bcfb1
commit
cbc92e9f1e
4 changed files with 16 additions and 4 deletions
|
@ -424,7 +424,10 @@
|
||||||
:fn (mg/resource "app/migrations/sql/0133-mod-file-table.sql")}
|
:fn (mg/resource "app/migrations/sql/0133-mod-file-table.sql")}
|
||||||
|
|
||||||
{:name "0134-mod-file-change-table"
|
{:name "0134-mod-file-change-table"
|
||||||
:fn (mg/resource "app/migrations/sql/0134-mod-file-change-table.sql")}])
|
:fn (mg/resource "app/migrations/sql/0134-mod-file-change-table.sql")}
|
||||||
|
|
||||||
|
{:name "0135-mod-team-invitation-table.sql"
|
||||||
|
:fn (mg/resource "app/migrations/sql/0135-mod-team-invitation-table.sql")}])
|
||||||
|
|
||||||
(defn apply-migrations!
|
(defn apply-migrations!
|
||||||
[pool name migrations]
|
[pool name migrations]
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE team_invitation
|
||||||
|
ADD COLUMN created_by uuid NULL REFERENCES profile(id) ON DELETE SET NULL;
|
|
@ -759,8 +759,8 @@
|
||||||
;; --- Mutation: Create Team Invitation
|
;; --- Mutation: Create Team Invitation
|
||||||
|
|
||||||
(def sql:upsert-team-invitation
|
(def sql:upsert-team-invitation
|
||||||
"insert into team_invitation(id, team_id, email_to, role, valid_until)
|
"insert into team_invitation(id, team_id, email_to, role, valid_until, created_by)
|
||||||
values (?, ?, ?, ?, ?)
|
values (?, ?, ?, ?, ?, ?)
|
||||||
on conflict(team_id, email_to) do
|
on conflict(team_id, email_to) do
|
||||||
update set role = ?, valid_until = ?, updated_at = now()
|
update set role = ?, valid_until = ?, updated_at = now()
|
||||||
returning *")
|
returning *")
|
||||||
|
@ -853,6 +853,7 @@
|
||||||
invitation (db/exec-one! conn [sql:upsert-team-invitation id
|
invitation (db/exec-one! conn [sql:upsert-team-invitation id
|
||||||
(:id team) (str/lower email)
|
(:id team) (str/lower email)
|
||||||
(name role) expire
|
(name role) expire
|
||||||
|
(:id profile)
|
||||||
(name role) expire])
|
(name role) expire])
|
||||||
updated? (not= id (:id invitation))
|
updated? (not= id (:id invitation))
|
||||||
profile-id (:id profile)
|
profile-id (:id profile)
|
||||||
|
|
|
@ -169,10 +169,16 @@
|
||||||
:invitation-id (:id invitation)}
|
:invitation-id (:id invitation)}
|
||||||
event (-> (audit/event-from-rpc-params params)
|
event (-> (audit/event-from-rpc-params params)
|
||||||
(assoc ::audit/name "accept-team-invitation")
|
(assoc ::audit/name "accept-team-invitation")
|
||||||
(assoc ::audit/props props))]
|
(assoc ::audit/props props))
|
||||||
|
ev-invitation-from (-> (audit/event-from-rpc-params params)
|
||||||
|
(assoc ::audit/profile-id (:created-by invitation))
|
||||||
|
(assoc ::audit/name "accept-team-invitation-from")
|
||||||
|
(assoc ::audit/props (assoc props :profile-id (:id profile)
|
||||||
|
:email (:email profile))))]
|
||||||
|
|
||||||
(accept-invitation cfg claims invitation profile)
|
(accept-invitation cfg claims invitation profile)
|
||||||
(audit/submit! cfg event)
|
(audit/submit! cfg event)
|
||||||
|
(audit/submit! cfg ev-invitation-from)
|
||||||
(assoc claims :state :created))
|
(assoc claims :state :created))
|
||||||
|
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue