mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 09:08:10 +08:00
FEATURE: auto archive group message if topic is closed. (#9046)
Co-Authored-By: Régis Hanol <regis@hanol.fr>
This commit is contained in:
@ -502,6 +502,17 @@ class Topic < ActiveRecord::Base
|
||||
def update_status(status, enabled, user, opts = {})
|
||||
TopicStatusUpdater.new(self, user).update!(status, enabled, opts)
|
||||
DiscourseEvent.trigger(:topic_status_updated, self, status, enabled)
|
||||
|
||||
if enabled && private_message? && status.to_s["closed"]
|
||||
group_ids = user.groups.pluck(:id)
|
||||
if group_ids.present?
|
||||
allowed_group_ids = self.allowed_groups
|
||||
.where('topic_allowed_groups.group_id IN (?)', group_ids).pluck(:id)
|
||||
allowed_group_ids.each do |id|
|
||||
GroupArchivedMessage.archive!(id, self)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Atomically creates the next post number
|
||||
|
Reference in New Issue
Block a user