🐛 Fix neutral reaction count as negative

This commit is contained in:
LittleSheep 2024-07-26 22:21:31 +08:00
parent 30399be718
commit 2366c3fd42

View File

@ -293,7 +293,7 @@ func ReactPost(user models.Account, reaction models.Reaction) (bool, models.Reac
} }
err = database.C.Save(&reaction).Error err = database.C.Save(&reaction).Error
if err == nil { if err == nil && reaction.Attitude != models.AttitudeNeutral {
_ = ModifyPosterVoteCount(op.Author, reaction.Attitude == models.AttitudePositive, 1) _ = ModifyPosterVoteCount(op.Author, reaction.Attitude == models.AttitudePositive, 1)
if reaction.Attitude == models.AttitudePositive { if reaction.Attitude == models.AttitudePositive {
@ -310,7 +310,7 @@ func ReactPost(user models.Account, reaction models.Reaction) (bool, models.Reac
} }
} else { } else {
err = database.C.Delete(&reaction).Error err = database.C.Delete(&reaction).Error
if err == nil { if err == nil && reaction.Attitude != models.AttitudeNeutral {
_ = ModifyPosterVoteCount(op.Author, reaction.Attitude == models.AttitudePositive, -1) _ = ModifyPosterVoteCount(op.Author, reaction.Attitude == models.AttitudePositive, -1)
if reaction.Attitude == models.AttitudePositive { if reaction.Attitude == models.AttitudePositive {