FIX: Don't error out on deleted users #149
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the problem?
The
GuardianExtension#poster_group_allow_translate?
method restricts and determines whether a post can be translated based on the poster's group membership. There are reports that this errors out when deleting spammers.The problem is that when a spammer is deleted, their post
user_id
is nullified, and because the above method doesn't account for this case, we try to call#in_any_groups?
onnil
, which errors out.This PR fixes that by explicitly accounting for the case of a post with a
nil
user ID.We have to make a decision here, since we're losing the history of which groups the poster was in, whether the post should be translatable or not. I'm defaulting to
false
here. It should be a minor thing as deleting a spam user should hide or delete their post as well.