mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Better tracking of topic visibility changes (#26709)
This commit introduces a few changes as a result of customer issues with finding why a topic was relisted. In one case, if a user edited the OP of a topic that was unlisted and hidden because of too many flags, the topic would get relisted by directly changing topic.visible, instead of going via TopicStatusUpdater. To improve tracking we: * Introduce a visibility_reason_id to topic which functions in a similar way to hidden_reason_id on post, this column is set from the various places we change topic visibility * Fix Post#unhide! which was directly modifying topic.visible, instead we use TopicStatusUpdater which sets visibility_reason_id and also makes a small action post * Show the reason topic visibility changed when hovering the unlisted icon in topic status on topic titles
This commit is contained in:
@@ -497,6 +497,18 @@ class TopicsController < ApplicationController
|
||||
Topic.find_by(id: topic_id)
|
||||
end
|
||||
|
||||
status_opts = { until: params[:until].presence }
|
||||
|
||||
if status == "visible"
|
||||
status_opts[:visibility_reason_id] = (
|
||||
if enabled
|
||||
Topic.visibility_reasons[:manually_relisted]
|
||||
else
|
||||
Topic.visibility_reasons[:manually_unlisted]
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
case status
|
||||
when "closed"
|
||||
guardian.ensure_can_close_topic!(@topic)
|
||||
@@ -510,9 +522,7 @@ class TopicsController < ApplicationController
|
||||
guardian.ensure_can_moderate!(@topic)
|
||||
end
|
||||
|
||||
params[:until] === "" ? params[:until] = nil : params[:until]
|
||||
|
||||
@topic.update_status(status, enabled, current_user, until: params[:until])
|
||||
@topic.update_status(status, enabled, current_user, status_opts)
|
||||
|
||||
render json:
|
||||
success_json.merge!(
|
||||
|
||||
Reference in New Issue
Block a user