Skip to content

Commit

Permalink
Add a flag for informing if sending the email invite was skipped (#3859)
Browse files Browse the repository at this point in the history
Add a flag for informing if the email invite was sent or not

Signed-off-by: Radoslav Dimitrov <[email protected]>
  • Loading branch information
rdimitrov authored and dmjb committed Jul 12, 2024
1 parent fd569c7 commit 597cd20
Show file tree
Hide file tree
Showing 5 changed files with 964 additions and 941 deletions.
1 change: 1 addition & 0 deletions docs/docs/ref/proto.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions internal/controlplane/handlers_authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ func (s *Server) updateInvite(
}
}

emailSkipped := false
// Publish the event for sending the invitation email
// This will happen only if the role is updated (existingInvites[0].Role != authzRole.String())
// or the role stayed the same, but the last invite update was more than a day ago
Expand All @@ -846,6 +847,9 @@ func (s *Server) updateInvite(
if err != nil {
return nil, status.Errorf(codes.Internal, "error publishing event: %v", err)
}
} else {
zerolog.Ctx(ctx).Info().Msg("skipping sending email, role stayed the same and last update was less than a day ago")
emailSkipped = true
}

// Commit the transaction to persist the changes
Expand All @@ -867,6 +871,7 @@ func (s *Server) updateInvite(
CreatedAt: timestamppb.New(userInvite.CreatedAt),
ExpiresAt: invite.GetExpireIn7Days(userInvite.UpdatedAt),
Expired: invite.IsExpired(userInvite.UpdatedAt),
EmailSkipped: emailSkipped,
},
},
}, nil
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/openapi/minder/v1/minder.swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 597cd20

Please sign in to comment.