Sha256: c2bb378eeb5727a746e382f981af2d8f34245675f5789125b7e314d070abc198

Contents?: true

Size: 927 Bytes

Versions: 34

Compression:

Stored size: 927 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  # A module to be included in the mailers that allows
  # to define the assets host based on an organization host
  module MultitenantAssetHost
    extend ActiveSupport::Concern

    included do
      before_action :set_asset_host

      # set_asset_host allows to redefine the host asset if not specified in application configuration
      # We use a lambda because this code is executed when the application is started
      # and does not allow us to modify it afterwards.
      # Leave action_mailer asset_host empty to use it.
      def set_asset_host
        return if Rails.application.config.action_mailer.asset_host.present?

        self.asset_host = ->(_mail) { "#{protocol}://#{@organization.host}" }
      end

      private

      def protocol
        return "https" if Decidim.force_ssl

        "http"
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
decidim-core-0.26.10 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.26.9 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.26.8 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.26.7 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.26.5 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.26.4 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.26.3 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.26.2 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.26.1 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.26.0 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.26.0.rc2 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.26.0.rc1 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.25.2 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.25.1 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.25.0 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.25.0.rc4 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.25.0.rc3 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.25.0.rc2 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.25.0.rc1 app/mailers/concerns/decidim/multitenant_asset_host.rb
decidim-core-0.24.3 app/mailers/concerns/decidim/multitenant_asset_host.rb