review: remove old_solution

This commit is contained in:
Lhc_fl 2024-09-10 14:33:26 +08:00
parent d10c7c3f1f
commit ca19bb71fa
No known key found for this signature in database
GPG Key ID: DB9FFA0D3F210F60
1 changed files with 3 additions and 5 deletions

View File

@ -51,14 +51,12 @@ after_initialize do
topic ||= post.topic topic ||= post.topic
DistributedMutex.synchronize("discourse_solved_toggle_answer_#{topic.id}") do DistributedMutex.synchronize("discourse_solved_toggle_answer_#{topic.id}") do
old_solution = topic.solution if topic.solution.present?
if old_solution.present?
UserAction.where( UserAction.where(
action_type: UserAction::SOLVED, action_type: UserAction::SOLVED,
target_post_id: old_solution.answer_post_id, target_post_id: topic.solution.answer_post_id,
).destroy_all ).destroy_all
old_solution.destroy! topic.solution.destroy!
end end
solution = DiscourseSolved::Solution.create(topic:, post:, accepter_user_id: acting_user.id) solution = DiscourseSolved::Solution.create(topic:, post:, accepter_user_id: acting_user.id)