Sha256: c9ea0c2c9a368389ea0f9e2b59e2a4edc0bd632750be2768170ed345e3f95d1c

Contents?: true

Size: 1020 Bytes

Versions: 8

Compression:

Stored size: 1020 Bytes

Contents

module Locomotive

  class SendPonyEmailJob < ActiveJob::Base

    queue_as :default

    def perform(options)
      _options = prepare_options(options)

      Pony.mail(_options)
    end

    protected

    def prepare_options(options)
      _options = options.deep_symbolize_keys

      _options[:via] = _options[:via].to_sym if _options[:via]
      _options[:via_options] ||= {}

      _options[:via_options][:authentication] = _options.dig(:via_options, :authentication).presence&.to_sym
      _options[:via_options][:user_name]      = _options.dig(:via_options, :user_name).presence
      _options[:via_options][:password]       = _options.dig(:via_options, :password).presence

      # if attachments, decode them because they were enccoding in base64
      if attachments = _options.delete(:attachments)
        _options[:attachments] = {}
        attachments.each do |name, content|
          _options[:attachments][name.to_s] = Base64.decode64(content)
        end
      end

      _options
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/jobs/locomotive/send_pony_email_job.rb
locomotivecms-4.2.0.alpha1 app/jobs/locomotive/send_pony_email_job.rb
locomotivecms-4.1.1 app/jobs/locomotive/send_pony_email_job.rb
locomotivecms-4.1.0 app/jobs/locomotive/send_pony_email_job.rb
locomotivecms-4.1.0.rc1 app/jobs/locomotive/send_pony_email_job.rb
locomotivecms-4.0.3 app/jobs/locomotive/send_pony_email_job.rb
locomotivecms-4.0.2 app/jobs/locomotive/send_pony_email_job.rb
locomotivecms-4.0.1 app/jobs/locomotive/send_pony_email_job.rb