diff --git a/backend/src/app/rpc/commands/teams_invitations.clj b/backend/src/app/rpc/commands/teams_invitations.clj index 729205c4c9..7051c2b594 100644 --- a/backend/src/app/rpc/commands/teams_invitations.clj +++ b/backend/src/app/rpc/commands/teams_invitations.clj @@ -235,9 +235,8 @@ :organization-name (:name organization) :member-email (:email-to invitation) :member-id (:id member) - :role role} - organization - (assoc :user-who-send-invitation (str profile-id)) + :role role + :user-who-send-invitation (str profile-id)} (not organization) (assoc :team-belongs-to-organization (boolean team-organization-id) diff --git a/backend/src/app/rpc/commands/verify_token.clj b/backend/src/app/rpc/commands/verify_token.clj index 8db7afcd8b..d46c7a8057 100644 --- a/backend/src/app/rpc/commands/verify_token.clj +++ b/backend/src/app/rpc/commands/verify_token.clj @@ -308,7 +308,9 @@ (assoc :name "accept-organization-invitation") (assoc :props (-> props - (assoc :organization-id organization-id-on-add) + (assoc :organization-id organization-id-on-add + :user-id (:id profile) + :user-who-send-invitation (:created-by invitation)) (audit/clean-props)))))) (cond-> (assoc claims :state :created) @@ -325,6 +327,8 @@ (assoc :organization-id organization-id-on-add :organization-member-add-source organization-add-source :belongs-to-team-on-add (boolean team-id) + :user-id (:id profile) + :user-who-send-invitation (:created-by invitation) :organization-member-count-before organization-member-count-before) (audit/clean-props))})))))) diff --git a/backend/test/backend_tests/rpc_team_test.clj b/backend/test/backend_tests/rpc_team_test.clj index 3d755d8231..b087eb6819 100644 --- a/backend/test/backend_tests/rpc_team_test.clj +++ b/backend/test/backend_tests/rpc_team_test.clj @@ -154,10 +154,14 @@ (get-in % [:props :member-email]))) events))] (doseq [event [create-organization update-organization]] + (t/is (= (str (:id owner)) + (get-in event [:props :user-who-send-invitation]))) (t/is (true? (get-in event [:props :team-belongs-to-organization]))) (t/is (true? (get-in event [:props :adds-invitee-to-organization]))) (t/is (true? (get-in event [:props :invitee-already-organization-member])))) + (t/is (= (str (:id owner)) + (get-in create-plain [:props :user-who-send-invitation]))) (t/is (false? (get-in create-plain [:props :team-belongs-to-organization]))) (t/is (false? (get-in create-plain [:props :adds-invitee-to-organization]))) (t/is (false? (get-in create-plain [:props :invitee-already-organization-member]))))))) @@ -521,6 +525,9 @@ (let [event (organization-event)] (t/is (= organization-id (get-in event [:props :organization-id]))) + (t/is (= (:id invitee) (get-in event [:props :user-id]))) + (t/is (= (:id inviter) + (get-in event [:props :user-who-send-invitation]))) (t/is (not (contains? (:props event) :organization-member-add-source))) (t/is (not (contains? (:props event) :belongs-to-team-on-add))) (t/is (not (contains? (:props event) :organization-member-count-before))) @@ -530,6 +537,10 @@ (:origin @frontend-event))) (t/is (= organization-id (get-in @frontend-event [:props :organization-id]))) + (t/is (= (:id invitee) + (get-in @frontend-event [:props :user-id]))) + (t/is (= (:id inviter) + (get-in @frontend-event [:props :user-who-send-invitation]))) (t/is (= "direct-organization-invitation" (get-in @frontend-event [:props :organization-member-add-source]))) (t/is (false? (get-in @frontend-event [:props :belongs-to-team-on-add]))) @@ -570,6 +581,9 @@ (t/is (some #(= "accept-team-invitation-from" (:name %)) events)) (t/is (= (:id team) (get-in event [:props :team-id]))) (t/is (= organization-id (get-in event [:props :organization-id]))) + (t/is (= (:id invitee) (get-in event [:props :user-id]))) + (t/is (= (:id inviter) + (get-in event [:props :user-who-send-invitation]))) (t/is (not (contains? (:props event) :organization-member-add-source))) (t/is (not (contains? (:props event) :belongs-to-team-on-add))) (t/is (not (contains? (:props event) :organization-member-count-before))) @@ -578,6 +592,10 @@ (t/is (= (:id team) (get-in @frontend-event [:props :team-id]))) (t/is (= organization-id (get-in @frontend-event [:props :organization-id]))) + (t/is (= (:id invitee) + (get-in @frontend-event [:props :user-id]))) + (t/is (= (:id inviter) + (get-in @frontend-event [:props :user-who-send-invitation]))) (t/is (= "team-invitation" (get-in @frontend-event [:props :organization-member-add-source]))) (t/is (true? (get-in @frontend-event [:props :belongs-to-team-on-add])))