2018-07-16 12:31:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-16 09:06:14 -04:00
|
|
|
module Emails
|
2017-06-19 08:51:46 -04:00
|
|
|
class CreateService < ::Emails::BaseService
|
2017-10-01 11:07:26 -04:00
|
|
|
def execute(extra_params = {})
|
2019-02-06 07:41:17 -05:00
|
|
|
skip_confirmation = params.delete(:skip_confirmation)
|
2018-09-09 17:04:11 -04:00
|
|
|
|
2019-02-06 07:41:17 -05:00
|
|
|
user.emails.create(params.merge(extra_params)).tap do |email|
|
|
|
|
email&.confirm if skip_confirmation && current_user.admin?
|
|
|
|
end
|
2017-06-16 09:06:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
Emails::CreateService.prepend_if_ee('EE::Emails::CreateService')
|