DeleteInactivated deletes all inactivated users. NOTE: We do not take context.Context here because this operation in practice could much longer than the general request timeout (e.g. one minute).
()
| 559 | // NOTE: We do not take context.Context here because this operation in practice |
| 560 | // could much longer than the general request timeout (e.g. one minute). |
| 561 | func (s *UsersStore) DeleteInactivated() error { |
| 562 | var userIDs []int64 |
| 563 | err := s.db.Model(&User{}).Where("is_active = ?", false).Pluck("id", &userIDs).Error |
| 564 | if err != nil { |
| 565 | return errors.Wrap(err, "get inactivated user IDs") |
| 566 | } |
| 567 | |
| 568 | for _, userID := range userIDs { |
| 569 | err = s.DeleteByID(context.Background(), userID, true) |
| 570 | if err != nil { |
| 571 | // Skip users that may had set to inactivated by admins. |
| 572 | if IsErrUserOwnRepos(err) || IsErrUserHasOrgs(err) { |
| 573 | continue |
| 574 | } |
| 575 | return errors.Wrapf(err, "delete user with ID %d", userID) |
| 576 | } |
| 577 | } |
| 578 | err = newPublicKeysStore(s.db).RewriteAuthorizedKeys() |
| 579 | if err != nil { |
| 580 | return errors.Wrap(err, `rewrite "authorized_keys" file`) |
| 581 | } |
| 582 | return nil |
| 583 | } |
| 584 | |
| 585 | func (*UsersStore) recountFollows(tx *gorm.DB, userID, followID int64) error { |
| 586 | /* |