MCPcopy Create free account
hub / github.com/gogs/gogs / DeleteInactivated

Method DeleteInactivated

internal/database/users.go:561–583  ·  view source on GitHub ↗

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).

()

Source from the content-addressed store, hash-verified

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).
561func (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
585func (*UsersStore) recountFollows(tx *gorm.DB, userID, followID int64) error {
586 /*

Callers 3

usersDeleteInactivatedFunction · 0.80
admin.goFile · 0.80
OperationFunction · 0.80

Calls 6

DeleteByIDMethod · 0.95
IsErrUserOwnReposFunction · 0.85
IsErrUserHasOrgsFunction · 0.85
newPublicKeysStoreFunction · 0.85
WhereMethod · 0.80
RewriteAuthorizedKeysMethod · 0.80

Tested by 1

usersDeleteInactivatedFunction · 0.64