Sha256: 97ca96b5efbb5d749d4ef5e0a812b57856e448b05a984299fe5a065bca54eb3f

Contents?: true

Size: 590 Bytes

Versions: 2

Compression:

Stored size: 590 Bytes

Contents

module Mailkick
  class Processor
    attr_reader :message

    def initialize(message)
      @message = message
    end

    def process
      email = message.to.first
      user = Mailkick.user_method.call(email) if Mailkick.user_method

      verifier = ActiveSupport::MessageVerifier.new(Mailkick.secret_token)
      token = verifier.generate([email, user.try(:id), user.try(:class).try(:name)])

      parts = message.parts.any? ? message.parts : [message]
      parts.each do |part|
        part.body.raw_source.gsub!(/%7B%7BMAILKICK_TOKEN%7D%7D/, token)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mailkick-0.0.2 lib/mailkick/processor.rb
mailkick-0.0.1 lib/mailkick/processor.rb