mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 12:43:54 -06:00
adda53c462
See PR for details
31 lines
794 B
Ruby
31 lines
794 B
Ruby
# frozen_string_literal: true
|
|
|
|
module SuggestedTopicsMixin
|
|
def self.included(klass)
|
|
klass.attributes :related_messages
|
|
klass.attributes :suggested_topics
|
|
end
|
|
|
|
def include_related_messages?
|
|
return false if @options[:exclude_suggested_and_related]
|
|
object.next_page.nil? && object.related_messages&.topics
|
|
end
|
|
|
|
def include_suggested_topics?
|
|
return false if @options[:exclude_suggested_and_related]
|
|
object.next_page.nil? && object.suggested_topics&.topics
|
|
end
|
|
|
|
def related_messages
|
|
object.related_messages.topics.map do |t|
|
|
SuggestedTopicSerializer.new(t, scope: scope, root: false)
|
|
end
|
|
end
|
|
|
|
def suggested_topics
|
|
object.suggested_topics.topics.map do |t|
|
|
SuggestedTopicSerializer.new(t, scope: scope, root: false)
|
|
end
|
|
end
|
|
end
|