discourse/app/serializers/basic_topic_serializer.rb
Natalie Tay 5f00ae2ca9
DEV: Introduce plugin modifiers for post.cooked and topic.fancy_titles (#31261)
Related:
40fd82e2d1

This PR introduces three new plugin modifiers attached to 
- `basic_post_serializer.cooked`
- `basic_topic_serializer.fancy_title`
- `topic_view_serializer.fancy_title`

Implementation note: I had wanted to add them in the `Post` and `Topic`
models themselves, but they do not directly provide access to the
request's scope which is needed for the use case.
2025-02-14 00:19:50 +08:00

13 lines
387 B
Ruby

# frozen_string_literal: true
# The most basic attributes of a topic that we need to create a link for it.
class BasicTopicSerializer < ApplicationSerializer
attributes :id, :title, :fancy_title, :slug, :posts_count
def fancy_title
f = object.fancy_title
modified = DiscoursePluginRegistry.apply_modifier(:topic_serializer_fancy_title, f, self)
modified || f
end
end