Sha256: a29df1a1556f1a4d127c5103ef8e1a306e96b35dcde4ab797619a52becc85083

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 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
          @comment = comment
          @commentable = commentable
          @organization = commentable.organization
          subject = I18n.t("comment_created.subject", scope: "decidim.comments.mailer.comment_notification")
          mail(to: commentable.author.email, subject: subject)
        end
      end

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

      private

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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
decidim-comments-0.0.8.1 app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-0.0.8.1 decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-comments-0.0.7 app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-0.0.7 decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-comments-0.0.6 app/mailers/decidim/comments/comment_notification_mailer.rb
decidim-0.0.6 decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb