Skip to content

Commit

Permalink
Merge pull request #1384 from codidact/cellio/fix-500-on-delete
Browse files Browse the repository at this point in the history
don't try to update rep for the nil user
  • Loading branch information
Oaphi committed Aug 25, 2024
2 parents 1dfd966 + 3beb811 commit 71a6eca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ def modify_author_reputation
if sc.include?('deleted') && sc['deleted'][0] != sc['deleted'][1] && created_at >= 60.days.ago
deleted = !!saved_changes['deleted']&.last
if deleted
user.update(reputation: user.reputation - Vote.total_rep_change(votes))
user&.update(reputation: (user&.reputation || 1) - Vote.total_rep_change(votes))
else
user.update(reputation: user.reputation + Vote.total_rep_change(votes))
user&.update(reputation: (user&.reputation || 1) + Vote.total_rep_change(votes))
end
end
end
Expand Down

0 comments on commit 71a6eca

Please sign in to comment.