debian-mirror-gitlab/app/services/emails/create_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
537 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
module Emails
class CreateService < ::Emails::BaseService
2018-03-17 18:26:18 +05:30
def execute(extra_params = {})
2019-07-07 11:18:12 +05:30
skip_confirmation = params.delete(:skip_confirmation)
2018-12-05 23:21:45 +05:30
2019-07-07 11:18:12 +05:30
user.emails.create(params.merge(extra_params)).tap do |email|
email&.confirm if skip_confirmation && current_user.admin?
2022-06-21 17:19:12 +05:30
notification_service.new_email_address_added(user, email.email) if email.persisted? && !email.user_primary_email?
2019-07-07 11:18:12 +05:30
end
2017-09-10 17:25:29 +05:30
end
end
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
Emails::CreateService.prepend_mod_with('Emails::CreateService')