From 6b4d1113a231b9ddbce9daa421ceb62c66888cbf Mon Sep 17 00:00:00 2001 From: Kush Date: Wed, 30 Oct 2024 09:59:17 +0530 Subject: [PATCH] fix: create org member event when the org is created (#797) OrgMemberCreatedEvent was not getting emitted in some of the situations, it should do now. Signed-off-by: Kush Sharma --- core/organization/service.go | 5 +++++ internal/api/v1beta1/org.go | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/organization/service.go b/core/organization/service.go index 24af40bbd..a81b491e8 100644 --- a/core/organization/service.go +++ b/core/organization/service.go @@ -184,6 +184,11 @@ func (s Service) AddMember(ctx context.Context, orgID, relationName string, prin }); err != nil { return err } + + audit.GetAuditor(ctx, orgID).Log(audit.OrgMemberCreatedEvent, audit.Target{ + ID: principal.ID, + Type: principal.Type, + }) return nil } diff --git a/internal/api/v1beta1/org.go b/internal/api/v1beta1/org.go index 819d62835..2558f5173 100644 --- a/internal/api/v1beta1/org.go +++ b/internal/api/v1beta1/org.go @@ -382,10 +382,6 @@ func (h Handler) AddOrganizationUsers(ctx context.Context, request *frontierv1be } } - for _, userID := range request.GetUserIds() { - audit.GetAuditor(ctx, orgResp.ID).Log(audit.OrgMemberCreatedEvent, audit.UserTarget(userID)) - } - if err := h.orgService.AddUsers(ctx, orgResp.ID, request.GetUserIds()); err != nil { return nil, err }