FIX: Can't recover a post when its user has been deleted.

https://meta.discourse.org/t/moving-posts-to-new-topic/58436
This commit is contained in:
Guo Xiang Tan
2017-03-06 13:17:57 +08:00
parent b2cfad5f47
commit a28704bcee
3 changed files with 56 additions and 6 deletions

View File

@@ -149,7 +149,11 @@ module PostGuardian
# Recovery Method
def can_recover_post?(post)
is_staff? || (is_my_own?(post) && post.user_deleted && !post.deleted_at)
if is_staff?
post.deleted_at && post.user
else
is_my_own?(post) && post.user_deleted && !post.deleted_at
end
end
def can_delete_post_action?(post_action)

View File

@@ -52,7 +52,7 @@ module TopicGuardian
# Recovery Method
def can_recover_topic?(topic)
is_staff?
topic && topic.deleted_at && topic.user && is_staff?
end
def can_delete_topic?(topic)