I’m looking to contribute to GitHub - discourse/discourse-assign: Plugin for assigning users to a topic and I’d like to add the feature to unassign a user when a topic is marked with a solution. I setup a webhook with webhook.site to watch for a test topic marked with a solution but the response a different object with different headers than a topic that is, say, closed.
In the example below, what should the topic status be to look for when a topic has a solution?
on(:topic_status_updated) do |topic, status, enabled|
if SiteSetting.unassign_on_close && (status == "closed" || status == "autoclosed") && enabled &&
Assignment.exists?(topic_id: topic.id, active: true)
assigner = ::Assigner.new(topic, Discourse.system_user)
assigner.unassign(silent: true, deactivate: true)
topic
.posts
.joins(:assignment)
.find_each do |post|
assigner = ::Assigner.new(post, Discourse.system_user)
assigner.unassign(silent: true, deactivate: true)
end
MessageBus.publish("/topic/#{topic.id}", reload_topic: true, refresh_stream: true)
end
end