Sha256: 59f9c19b55cea408d2c445a6530528f066bf4e8e39d4c7b60d11772b4323564f

Contents?: true

Size: 1.41 KB

Versions: 14

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module Decidim
  module Comments
    # A custom mailer for sending notifications to users when
    # a comment is created.
    class CommentNotificationMailer < Decidim::ApplicationMailer
      helper Decidim::ResourceHelper

      helper_method :commentable_title

      def comment_created(user, comment, commentable)
        with_user(user) do
          @user = user
          @comment = comment
          @commentable = commentable
          @locator = Decidim::ResourceLocatorPresenter.new(@commentable)
          @organization = commentable.organization
          subject = I18n.t("comment_created.subject", scope: "decidim.comments.mailer.comment_notification")
          mail(to: user.email, subject: subject)
        end
      end

      def reply_created(user, reply, comment, commentable)
        with_user(user) do
          @user = user
          @reply = reply
          @comment = comment
          @commentable = commentable
          @locator = Decidim::ResourceLocatorPresenter.new(@commentable)
          @organization = commentable.organization
          subject = I18n.t("reply_created.subject", scope: "decidim.comments.mailer.comment_notification")
          mail(to: user.email, subject: subject)
        end
      end

      private

      def commentable_title
        @commentable.title.is_a?(Hash) ? @commentable.title[I18n.locale.to_s] : @commentable.title
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
decidim-comments-0.5.1 app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-0.5.1 decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-comments-0.5.0 app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-0.5.0 decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-comments-0.4.4 app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-0.4.4 decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-comments-0.4.3 app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-comments-0.4.2 app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-comments-0.4.1 app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-0.4.3 decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-0.4.2 decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-0.4.1 decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-comments-0.4.0 app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-0.4.0 decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb