Skip to content

Commit

Permalink
don't try to update rep for the nil user
Browse files Browse the repository at this point in the history
  • Loading branch information
cellio committed Aug 23, 2024
1 parent 000fd1b commit 3cee414
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/models/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,12 @@ def modify_author_reputation
sc = saved_changes
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))
else
user.update(reputation: user.reputation + Vote.total_rep_change(votes))
if user
if deleted
user.update(reputation: user.reputation - Vote.total_rep_change(votes))
else
user.update(reputation: user.reputation + Vote.total_rep_change(votes))
end
end
end
end
Expand Down

0 comments on commit 3cee414

Please sign in to comment.