Sha256: c7a3053d3ada8a66c8cfa9507387180c51dce4456a6bbaa7785fd1caa8742246

Contents?: true

Size: 763 Bytes

Versions: 5

Compression:

Stored size: 763 Bytes

Contents

# frozen-string_literal: true

module Decidim
  module Comments
    class UserMentionedEvent < Decidim::Events::SimpleEvent
      include Decidim::Events::AuthorEvent

      delegate :author, to: :comment

      def i18n_scope
        "decidim.events.comments.user_mentioned"
      end

      def resource_path
        resource_locator.path(url_params)
      end

      def resource_url
        resource_locator.url(url_params)
      end

      private

      def comment
        @comment ||= Decidim::Comments::Comment.find(extra[:comment_id])
      end

      def comment_type
        comment.depth.zero? ? :comment : :reply
      end

      def url_params
        comment_type == :comment ? {} : { anchor: "comment_#{comment.id}" }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-comments-0.10.1 app/events/decidim/comments/user_mentioned_event.rb
decidim-comments-0.10.0 app/events/decidim/comments/user_mentioned_event.rb
decidim-comments-0.9.3 app/events/decidim/comments/user_mentioned_event.rb
decidim-comments-0.9.2 app/events/decidim/comments/user_mentioned_event.rb
decidim-comments-0.9.1 app/events/decidim/comments/user_mentioned_event.rb