mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-21 17:24:10 +00:00
Fix GetInactiveUsers (#32540)
Fix #31480 (cherry picked from commit 9bf821ae6c108379d22ae11d8d5784a4ed7ad647) Conflicts: models/user/user_test.go trivial context conflict
This commit is contained in:
parent
6482429091
commit
32a91add34
3 changed files with 27 additions and 6 deletions
|
@ -50,19 +50,19 @@ const (
|
|||
UserTypeIndividual UserType = iota // Historic reason to make it starts at 0.
|
||||
|
||||
// UserTypeOrganization defines an organization
|
||||
UserTypeOrganization
|
||||
UserTypeOrganization // 1
|
||||
|
||||
// UserTypeUserReserved reserves a (non-existing) user, i.e. to prevent a spam user from re-registering after being deleted, or to reserve the name until the user is actually created later on
|
||||
UserTypeUserReserved
|
||||
UserTypeUserReserved // 2
|
||||
|
||||
// UserTypeOrganizationReserved reserves a (non-existing) organization, to be used in combination with UserTypeUserReserved
|
||||
UserTypeOrganizationReserved
|
||||
UserTypeOrganizationReserved // 3
|
||||
|
||||
// UserTypeBot defines a bot user
|
||||
UserTypeBot
|
||||
UserTypeBot // 4
|
||||
|
||||
// UserTypeRemoteUser defines a remote user for federated users
|
||||
UserTypeRemoteUser
|
||||
UserTypeRemoteUser // 5
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -919,7 +919,13 @@ func UpdateUserCols(ctx context.Context, u *User, cols ...string) error {
|
|||
|
||||
// GetInactiveUsers gets all inactive users
|
||||
func GetInactiveUsers(ctx context.Context, olderThan time.Duration) ([]*User, error) {
|
||||
var cond builder.Cond = builder.Eq{"is_active": false}
|
||||
cond := builder.And(
|
||||
builder.Eq{"is_active": false},
|
||||
builder.Or( // only plain user
|
||||
builder.Eq{"`type`": UserTypeIndividual},
|
||||
builder.Eq{"`type`": UserTypeUserReserved},
|
||||
),
|
||||
)
|
||||
|
||||
if olderThan > 0 {
|
||||
cond = cond.And(builder.Lt{"created_unix": time.Now().Add(-olderThan).Unix()})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue