Sha256: c9adfff69540032ab9942e649d50ba6de09d7bf97f794959231df04fa1cd9811

Contents?: true

Size: 1.31 KB

Versions: 29

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

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

    layout "decidim/newsletter_base"

    add_template_helper Decidim::TranslationsHelper

    helper_method :cell

    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
        uninterpolated_subject =
          @newsletter.subject[I18n.locale.to_s].presence || @newsletter.subject[@organization.default_locale]

        @subject = parse_interpolations(uninterpolated_subject, user, @newsletter.id)

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

    private

    def cell
      @cell ||= ::Decidim::ViewModel.cell(
        @newsletter.template.cell,
        @newsletter.template,
        organization: @organization,
        newsletter: @newsletter,
        recipient_user: @user,
        context: {
          controller: self
        }
      )
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
decidim-core-0.26.4 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.26.3 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.26.2 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.26.1 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.26.0 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.26.0.rc2 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.26.0.rc1 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.25.2 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.25.1 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.25.0 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.25.0.rc4 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.25.0.rc3 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.25.0.rc2 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.25.0.rc1 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.24.3 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.23.6 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.24.2 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.23.5 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.24.1 app/mailers/decidim/newsletter_mailer.rb
decidim-core-0.24.0 app/mailers/decidim/newsletter_mailer.rb