summaryrefslogtreecommitdiff
path: root/app/services/emails/create_service.rb
blob: dc06a5caa403b5c5e3ad0b107ad48af9395be3ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
# frozen_string_literal: true

module Emails
  class CreateService < ::Emails::BaseService
    def execute(extra_params = {})
      skip_confirmation = params.delete(:skip_confirmation)

      user.emails.create(params.merge(extra_params)).tap do |email|
        email&.confirm if skip_confirmation && current_user.admin?
      end
    end
  end
end