Post#expunge!: fix remove_pool! to remove posts from deleted pools.

Don't silently ignore attempts to remove posts from deleted pools.
Remove the restriction on removing posts from deleted pools instead (ref: #1109).

Fixes failure to remove posts from deleted pools during expungement.
This commit is contained in:
evazion
2017-07-20 21:06:37 -05:00
parent 1b310dcc0b
commit fbee7f6912
3 changed files with 14 additions and 7 deletions

View File

@@ -239,11 +239,10 @@ class Pool < ApplicationRecord
def remove!(post)
return unless contains?(post.id)
return unless CurrentUser.user.can_remove_from_pools?
return if is_deleted?
with_lock do
update_attributes(:post_ids => remove_number_from_string(post.id, post_ids), :post_count => post_count - 1)
post.remove_pool!(self, true)
post.remove_pool!(self)
clear_post_id_array
end
end
@@ -284,7 +283,7 @@ class Pool < ApplicationRecord
removed.each do |post_id|
post = Post.find(post_id)
post.remove_pool!(self, true)
post.remove_pool!(self)
end
normalize_post_ids

View File

@@ -1079,10 +1079,9 @@ class Post < ApplicationRecord
end
end
def remove_pool!(pool, force = false)
def remove_pool!(pool)
return unless belongs_to_pool?(pool)
return unless CurrentUser.user.can_remove_from_pools?
return if pool.is_deleted? && !force
with_lock do
self.pool_string = pool_string.gsub(/(?:\A| )pool:#{pool.id}(?:\Z| )/, " ").strip