mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Topic user bookmarked column is out of sync after post moves (#12612)
When posts are moved from one topic to another, the `topic_user.bookmarked` column for all users in the new and the old topic needs to be resynced, for example because a user bookmarks post 12 in topic 1, then it is moved to topic 2, the topic_user record for topic 1 should no longer be bookmarked. A background job has been added to sync the column for a specified topic, or for no topic at all, which does it for all topics like the migration. Also includes a migration that we have run in the past to fix bad data. ---- This has been addressed in other places in the past: https://github.com/discourse/discourse/pull/10211 https://github.com/discourse/discourse/pull/10188
This commit is contained in:
@@ -494,6 +494,11 @@ class PostMover
|
||||
|
||||
def update_bookmarks
|
||||
Bookmark.where(post_id: post_ids).update_all(topic_id: @destination_topic.id)
|
||||
|
||||
DB.after_commit do
|
||||
Jobs.enqueue(:sync_topic_user_bookmarked, topic_id: @original_topic.id)
|
||||
Jobs.enqueue(:sync_topic_user_bookmarked, topic_id: @destination_topic.id)
|
||||
end
|
||||
end
|
||||
|
||||
def watch_new_topic
|
||||
|
||||
Reference in New Issue
Block a user