mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 09:10:25 +08:00
When clicked, it pops up a modal showing a history of moderation actions taken on the post or topic.
40 lines
1 KiB
Ruby
40 lines
1 KiB
Ruby
class Admin::ModerationHistoryController < Admin::AdminController
|
|
|
|
def index
|
|
history_filter = params[:filter]
|
|
raise Discourse::NotFound unless ['post', 'topic'].include?(history_filter)
|
|
|
|
query = UserHistory.where(
|
|
action: UserHistory.actions.only(
|
|
:delete_user,
|
|
:suspend_user,
|
|
:silence_user,
|
|
:delete_post,
|
|
:delete_topic
|
|
).values
|
|
)
|
|
|
|
case history_filter
|
|
when 'post'
|
|
raise Discourse::NotFound if params[:post_id].blank?
|
|
query = query.where(post_id: params[:post_id])
|
|
when 'topic'
|
|
raise Discourse::NotFound if params[:topic_id].blank?
|
|
query = query.where(
|
|
"topic_id = ? OR post_id IN (?)",
|
|
params[:topic_id],
|
|
Post.with_deleted.where(topic_id: params[:topic_id]).pluck(:id)
|
|
)
|
|
end
|
|
query = query.includes(:acting_user)
|
|
query = query.order(:created_at)
|
|
|
|
render_serialized(
|
|
query,
|
|
UserHistorySerializer,
|
|
root: 'moderation_history',
|
|
rest_serializer: true
|
|
)
|
|
end
|
|
|
|
end
|