2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

BUGFIXES: properly deal with bookmarks and deleted posts

BUGFIX: removing a bookmark from the activity feed was busted for deleted posts
BUGFIX: delete associated user actions when deleting a post
This commit is contained in:
Régis Hanol 2014-06-04 17:41:11 +02:00
parent 72abb6e274
commit 0df666277d
12 changed files with 69 additions and 47 deletions

View file

@ -63,6 +63,7 @@ class PostDestroyer
Topic.reset_highest(@post.topic_id)
end
trash_post_actions
trash_user_actions
@post.update_flagged_posts_count
remove_associated_replies
remove_associated_notifications
@ -138,6 +139,19 @@ class PostDestroyer
Post.with_deleted.where(id: @post.id).update_all(Hash[*f.flatten])
end
def trash_user_actions
UserAction.where(target_post_id: @post.id).each do |ua|
row = {
action_type: ua.action_type,
user_id: ua.user_id,
acting_user_id: ua.acting_user_id,
target_topic_id: ua.target_topic_id,
target_post_id: ua.target_post_id
}
UserAction.remove_action!(row)
end
end
def remove_associated_replies
post_ids = PostReply.where(reply_id: @post.id).pluck(:post_id)