Sha256: c82f934d1bf5cf95ee5a9cdf16c780766eee2ec4bc2aff047512c2cf215d00dc

Contents?: true

Size: 934 Bytes

Versions: 3

Compression:

Stored size: 934 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class NewsletterMailer < ApplicationMailer
    helper Decidim::SanitizeHelper
    include Decidim::NewslettersHelper

    add_template_helper Decidim::TranslationsHelper

    def newsletter(user, newsletter)
      return if user.email.blank?

      @organization = user.organization
      @newsletter = newsletter
      @user = user

      @custom_url_for_mail_root = custom_url_for_mail_root(@organization, @newsletter.id) if Decidim.config.track_newsletter_links
      @encrypted_token = Decidim::NewsletterEncryptor.sent_at_encrypted(@user.id, @newsletter.sent_at)
      with_user(user) do
        @subject = parse_interpolations(@newsletter.subject[I18n.locale.to_s], user, @newsletter.id)
        @body = parse_interpolations(@newsletter.body[I18n.locale.to_s], user, @newsletter.id)

        mail(to: "#{user.name} <#{user.email}>", subject: @subject)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-core-0.15.2 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.15.1 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.15.0 app/mailers/decidim/newsletter_mailer.rb