diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /lib/gitlab/quick_actions | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'lib/gitlab/quick_actions')
-rw-r--r-- | lib/gitlab/quick_actions/issue_actions.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/gitlab/quick_actions/issue_actions.rb b/lib/gitlab/quick_actions/issue_actions.rb index c162ee545c6..012e495502f 100644 --- a/lib/gitlab/quick_actions/issue_actions.rb +++ b/lib/gitlab/quick_actions/issue_actions.rb @@ -235,6 +235,35 @@ module Gitlab @execution_message[:remove_zoom] = result.message end + desc _('Add email participant(s)') + explanation _('Adds email participant(s)') + params 'email1@example.com email2@example.com (up to 6 emails)' + types Issue + condition do + Feature.enabled?(:issue_email_participants, parent) && + current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target) + end + command :invite_email do |emails = ""| + MAX_NUMBER_OF_EMAILS = 6 + + existing_emails = quick_action_target.email_participants_emails_downcase + emails_to_add = emails.split(' ').index_by { |email| [email.downcase, email] }.except(*existing_emails).each_value.first(MAX_NUMBER_OF_EMAILS) + added_emails = [] + + emails_to_add.each do |email| + new_participant = quick_action_target.issue_email_participants.create(email: email) + added_emails << email if new_participant.persisted? + end + + if added_emails.any? + message = _("added %{emails}") % { emails: added_emails.to_sentence } + SystemNoteService.add_email_participants(quick_action_target, quick_action_target.project, current_user, message) + @execution_message[:invite_email] = message.upcase_first << "." + else + @execution_message[:invite_email] = _("No email participants were added. Either none were provided, or they already exist.") + end + end + private def zoom_link_service |