mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
FIX: Message for bulk closing topics silently (#27400)
We were using `autoclose` as the topic status update
when silently closing topics using the bulk
actions (introduced in 0464ddcd9b
).
However, this resulted in a message like this showing in
the topic as a small moderator post:
> This topic was automatically closed after X days.
This is not accurate, the topic was bulk closed by someone.
Instead, we can use `closed` as the status, and a more accurate
> Closed on DATE
message is used. `TopicStatusUpdater` needed an additional
option to keep the same "fake read" behaviour as autoclose
so we can keep the same functionality for silently closing
topics in bulk actions.
This commit is contained in:
parent
eb6a12b920
commit
10b9a32abb
|
@ -87,7 +87,9 @@ export default class BulkTopicActions extends Component {
|
||||||
const options = {};
|
const options = {};
|
||||||
|
|
||||||
if (this.isSilent) {
|
if (this.isSilent) {
|
||||||
operation = { type: "silent_close" };
|
const newType =
|
||||||
|
operation.type === "close" ? "silent_close" : operation.type;
|
||||||
|
operation.type = newType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isCloseAction && this.closeNote) {
|
if (this.isCloseAction && this.closeNote) {
|
||||||
|
|
|
@ -13,7 +13,11 @@ TopicStatusUpdater =
|
||||||
if updated
|
if updated
|
||||||
highest_post_number = topic.highest_post_number
|
highest_post_number = topic.highest_post_number
|
||||||
create_moderator_post_for(status, opts)
|
create_moderator_post_for(status, opts)
|
||||||
update_read_state_for(status, highest_post_number)
|
update_read_state_for(
|
||||||
|
status,
|
||||||
|
highest_post_number,
|
||||||
|
silent_tracking: opts[:silent_tracking],
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -90,8 +94,8 @@ TopicStatusUpdater =
|
||||||
topic.reload
|
topic.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_read_state_for(status, old_highest_read)
|
def update_read_state_for(status, old_highest_read, silent_tracking: false)
|
||||||
if status.autoclosed? && status.enabled?
|
if (status.autoclosed? && status.enabled?) || (status.closed? && silent_tracking)
|
||||||
# let's pretend all the people that read up to the autoclose message
|
# let's pretend all the people that read up to the autoclose message
|
||||||
# actually read the topic
|
# actually read the topic
|
||||||
PostTiming.pretend_read(topic.id, old_highest_read, topic.highest_post_number)
|
PostTiming.pretend_read(topic.id, old_highest_read, topic.highest_post_number)
|
||||||
|
|
|
@ -174,7 +174,12 @@ class TopicsBulkAction
|
||||||
def silent_close
|
def silent_close
|
||||||
topics.each do |t|
|
topics.each do |t|
|
||||||
if guardian.can_moderate?(t)
|
if guardian.can_moderate?(t)
|
||||||
t.update_status("autoclosed", true, @user, { message: @operation[:message] })
|
t.update_status(
|
||||||
|
"closed",
|
||||||
|
true,
|
||||||
|
@user,
|
||||||
|
{ message: @operation[:message], silent_tracking: true },
|
||||||
|
)
|
||||||
@changed_ids << t.id
|
@changed_ids << t.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user