Skip to content

Limit external participants on a single issue

Marc Saleiko requested to merge ms-limit-issue-email-participants into master

Feature context

Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/299940+

This feature is hidden behind the feature flag 🎏 issue_email_participants.

We want to limit the number of external participants on an issue and learn how it's used in the first place to prevent abuse

What does this MR do and why?

Limit external participants on a single issue

When using the CreateService you cannot add more than the maximum allowed number of issue email participants to a single issue.

Screenshots or screen recordings

🚫 backend only

How to set up and validate locally

  1. Select a project and enable the feature flag for issue_email_participants.
    project = Project.find(7)
    
    Feature.enable(:issue_email_participants, project)
  2. Select an issue that you'd like to use
    issue = project.issues.last
  3. Add an external participant using the service class and see it added the participant
    emails = ['user@example.com']
    ::IssueEmailParticipants::CreateService.new(
      target: issue,
      current_user: project.creator,
      emails: emails
    ).execute
    issue.issue_email_participants
  4. Add another 5 participants to add the maximum number of participants
    emails = Array.new(5) { |i| "user#{i}@example.com" }
    ::IssueEmailParticipants::CreateService.new(
      target: issue,
      current_user: project.creator,
      emails: emails
    ).execute
    issue.issue_email_participants
  5. Try to add another participant. This shouldn't work and the service should return an error ServiceResponse.
    emails = ['not-me@example.com']
    ::IssueEmailParticipants::CreateService.new(
      target: issue,
      current_user: project.creator,
      emails: emails
    ).execute

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Marc Saleiko

Merge request reports