Sha256: bce3c1495615d66adca02beae9ddd86f3a73f60a0dfeef9cf1ffad81a2a64d1e

Contents?: true

Size: 1.21 KB

Versions: 57

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require "mustache"

module Decidim
  class WelcomeNotificationEvent < Decidim::Events::BaseEvent
    include Decidim::Events::EmailEvent
    include Decidim::Events::NotificationEvent
    include TranslationsHelper

    delegate :organization, to: :user, prefix: false
    delegate :url_helpers, to: "Decidim::Core::Engine.routes"

    def subject
      interpolate(organization.welcome_notification_subject.symbolize_keys[I18n.locale])
    end

    def body
      interpolate(organization.welcome_notification_body.symbolize_keys[I18n.locale])
    end

    def email_subject
      subject
    end

    def email_greeting; end

    def email_intro
      body
    end

    def email_outro; end

    def notification_title
      ("<p><strong>#{subject}</strong></p>" + body).html_safe
    end

    def resource_path
      nil
    end

    def resource_title
      nil
    end

    private

    def interpolate(template)
      Mustache.render(
        template.to_s,
        organization: organization.name,
        name: user.name,
        help_url: url_helpers.pages_url(host: organization.host),
        badges_url: url_helpers.gamification_badges_url(host: organization.host)
      ).html_safe
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
decidim-core-0.26.10 app/events/decidim/welcome_notification_event.rb
decidim-core-0.26.9 app/events/decidim/welcome_notification_event.rb
decidim-core-0.28.0 app/events/decidim/welcome_notification_event.rb
decidim-core-0.27.5 app/events/decidim/welcome_notification_event.rb
decidim-core-0.28.0.rc5 app/events/decidim/welcome_notification_event.rb
decidim-core-0.28.0.rc4 app/events/decidim/welcome_notification_event.rb
decidim-core-0.26.8 app/events/decidim/welcome_notification_event.rb
decidim-core-0.27.4 app/events/decidim/welcome_notification_event.rb
decidim-core-0.27.3 app/events/decidim/welcome_notification_event.rb
decidim-core-0.26.7 app/events/decidim/welcome_notification_event.rb
decidim-core-0.26.5 app/events/decidim/welcome_notification_event.rb
decidim-core-0.27.2 app/events/decidim/welcome_notification_event.rb
decidim-core-0.27.1 app/events/decidim/welcome_notification_event.rb
decidim-core-0.26.4 app/events/decidim/welcome_notification_event.rb
decidim-core-0.27.0 app/events/decidim/welcome_notification_event.rb
decidim-core-0.26.3 app/events/decidim/welcome_notification_event.rb
decidim-core-0.27.0.rc2 app/events/decidim/welcome_notification_event.rb
decidim-core-0.27.0.rc1 app/events/decidim/welcome_notification_event.rb
decidim-core-0.26.2 app/events/decidim/welcome_notification_event.rb
decidim-core-0.26.1 app/events/decidim/welcome_notification_event.rb