Sha256: edb835e6c99f3a39b5d67de4d6759d57073528cbcde9405f62b57d798d95e8f9

Contents?: true

Size: 1.47 KB

Versions: 44

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    # A custom mailer for sending notifications to users when
    # they join a meeting.
    class RegistrationMailer < Decidim::ApplicationMailer
      include Decidim::TranslationsHelper
      include ActionView::Helpers::SanitizeHelper

      helper Decidim::ResourceHelper
      helper Decidim::TranslationsHelper

      def confirmation(user, meeting)
        with_user(user) do
          @user = user
          @meeting = meeting
          @organization = @meeting.organization
          @locator = Decidim::ResourceLocatorPresenter.new(@meeting)

          add_calendar_attachment

          subject = I18n.t("confirmation.subject", scope: "decidim.meetings.mailer.registration_mailer")
          mail(to: user.email, subject: subject)
        end
      end

      private

      def add_calendar_attachment
        calendar = Icalendar::Calendar.new
        calendar.event do |event|
          event.dtstart = Icalendar::Values::DateTime.new(@meeting.start_time)
          event.dtend = Icalendar::Values::DateTime.new(@meeting.end_time)
          event.summary = translated_attribute @meeting.title
          event.description = strip_tags(translated_attribute(@meeting.description))
          event.location = @meeting.address
          event.geo = [@meeting.latitude, @meeting.longitude]
          event.url = @locator.url
        end

        attachments["meeting-calendar-info.ics"] = calendar.to_ical
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
decidim-meetings-0.13.1 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.12.2 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.13.0 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.12.1 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.13.0.pre1 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.12.0 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.11.2 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.12.0.pre app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.11.1 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.11.0.pre1 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.10.1 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.10.0 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.9.3 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.9.2 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.9.1 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.9.0 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.8.4 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.8.3 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.8.2 app/mailers/decidim/meetings/registration_mailer.rb
decidim-meetings-0.8.1 app/mailers/decidim/meetings/registration_mailer.rb