Sha256: 9085da8afc4639ee6cb5e5a49e8e963b2baeaa2591540dcc812a6bded5a8ba1c

Contents?: true

Size: 1.17 KB

Versions: 21

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Decidim
  module Messaging
    # A custom mailer for sending notifications to users when they receive
    # private messages
    class ConversationMailer < Decidim::ApplicationMailer
      def new_conversation(originator, user, conversation)
        notification_mail(
          from: originator,
          to: user,
          conversation: conversation,
          action: "new_conversation"
        )
      end

      def new_message(sender, user, conversation)
        notification_mail(
          from: sender,
          to: user,
          conversation: conversation,
          action: "new_message"
        )
      end

      private

      def notification_mail(from:, to:, conversation:, action:)
        with_user(to) do
          @organization = to.organization
          @conversation = conversation
          @sender = from.name
          @recipient = to.name
          @host = @organization.host

          subject = I18n.t(
            "conversation_mailer.#{action}.subject",
            scope: "decidim.messaging",
            sender: @sender
          )

          mail(to: to.email, subject: subject)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
decidim-core-0.15.2 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.15.1 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.15.0 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.14.4 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.14.3 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.14.2 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.14.1 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.13.1 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.12.2 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.13.0 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.12.1 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.13.0.pre1 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.12.0 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.11.2 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.12.0.pre app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.11.1 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.11.0.pre1 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.9.3 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.9.2 app/mailers/decidim/messaging/conversation_mailer.rb
decidim-core-0.9.1 app/mailers/decidim/messaging/conversation_mailer.rb