mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 08:16:00 +08:00
FEATURE: Topic slow mode. (#10904)
Adds a new slow mode for topics that are heating up. Users will have to wait for a period of time before being able to post again. We store this interval inside the topics table and track the last time a user posted using the last_posted_at datetime in the TopicUser relation.
This commit is contained in:
@ -40,7 +40,8 @@ class TopicViewSerializer < ApplicationSerializer
|
||||
:pinned_globally,
|
||||
:pinned_at,
|
||||
:pinned_until,
|
||||
:image_url
|
||||
:image_url,
|
||||
:slow_mode_seconds
|
||||
)
|
||||
|
||||
attributes(
|
||||
@ -72,7 +73,8 @@ class TopicViewSerializer < ApplicationSerializer
|
||||
:queued_posts_count,
|
||||
:show_read_indicator,
|
||||
:requested_group_name,
|
||||
:thumbnails
|
||||
:thumbnails,
|
||||
:user_last_posted_at
|
||||
)
|
||||
|
||||
has_one :details, serializer: TopicViewDetailsSerializer, root: false, embed: :objects
|
||||
@ -280,4 +282,12 @@ class TopicViewSerializer < ApplicationSerializer
|
||||
extra_sizes = ThemeModifierHelper.new(request: scope.request).topic_thumbnail_sizes
|
||||
object.topic.thumbnail_info(enqueue_if_missing: true, extra_sizes: extra_sizes)
|
||||
end
|
||||
|
||||
def user_last_posted_at
|
||||
object.topic_user.last_posted_at
|
||||
end
|
||||
|
||||
def include_user_last_posted_at?
|
||||
object.topic.slow_mode_seconds.to_i > 0
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user