mirror of
https://github.com/discourse/discourse.git
synced 2025-02-28 07:20:55 +08:00

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.
13 lines
387 B
Ruby
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
|