Skip to content

Commit

Permalink
Merge pull request #2515 from traPtitech/fix/hotfix-delete-unread
Browse files Browse the repository at this point in the history
凍結時にunreadの削除がデカすぎてサーバーが落ちる問題を一時的に修正
  • Loading branch information
pikachu0310 authored Sep 30, 2024
2 parents b409457 + 476ac58 commit 8b99591
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions repository/gorm/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ func (r *userRepository) UpdateUser(id uuid.UUID, args repository.UpdateUserArgs
}

var (
u model.User
activate bool
deactivate bool
changed bool
count int
u model.User
activate bool
//deactivate bool
changed bool
count int
)
err := r.db.Transaction(func(tx *gorm.DB) error {
if err := tx.Preload("Profile").First(&u, model.User{ID: id}).Error; err != nil {
Expand All @@ -243,7 +243,7 @@ func (r *userRepository) UpdateUser(id uuid.UUID, args repository.UpdateUserArgs
case model.UserAccountStatusActive.Int():
activate = true
case model.UserAccountStatusDeactivated.Int():
deactivate = true
//deactivate = true
}
}
if args.IconFileID.Valid {
Expand Down Expand Up @@ -290,11 +290,11 @@ func (r *userRepository) UpdateUser(id uuid.UUID, args repository.UpdateUserArgs
count += len(changes)
}
// 凍結の際は未読を削除
if deactivate {
if err := tx.Delete(&model.Unread{}, "user_id = ?", id).Error; err != nil {
return err
}
}
// if deactivate {
// if err := tx.Delete(&model.Unread{}, "user_id = ?", id).Error; err != nil {
// return err
// }
// }
return nil
})
if err != nil {
Expand Down

0 comments on commit 8b99591

Please sign in to comment.