e1bb077d6e
(cherry picked from commit2a25be788b
) (cherry picked from commitb270d5815c
) (cherry picked from commite7382cc71e
) (cherry picked from commit665400ea1e
) (cherry picked from commitf5b2c691f1
) (cherry picked from commit3df97adfef
) (cherry picked from commit494f6eafc1
) (cherry picked from commit822e3d2c83
) (cherry picked from commit7460f12568
) (cherry picked from commitf6cd70881e
) (cherry picked from commitc669ce8173
) (cherry picked from commit1d5a433e02
) (cherry picked from commitc1a4dc150c
) (cherry picked from commitdd1c971c6c
) (cherry picked from commit8d2dcd9b1e
) (cherry picked from commitb6bb8fd275
) (cherry picked from commitd4b71fe96e
) (cherry picked from commite204ec0b23
) (cherry picked from commit8d9f1174bd
) (cherry picked from commite314a7d5ba
) (cherry picked from commit48b3ad5a30
) (cherry picked from commit71ed4b7c69
) (cherry picked from commitd63324ccb6
) (cherry picked from commit9249e893db
) (cherry picked from commit78f156427b
) (cherry picked from commitc3d4a1a602
) (cherry picked from commit83b1855f55
) (cherry picked from commit319815d9b1
) (cherry picked from commitc4fcbfd297
) (cherry picked from commitfb58c85222
) (cherry picked from commit69c24e3e8b
) (cherry picked from commit1e9ec4737a
) (cherry picked from commit70439970c1
) (cherry picked from commit7e6146c1a8
) (cherry picked from commit7adf6d5869
) (cherry picked from commit8985e17343
) (cherry picked from commitfd4dc3ebca
) (cherry picked from commitd31bf1639e
) (cherry picked from commitd2a9b6dea0
) (cherry picked from commit0d9279bc85
) (cherry picked from commit0591a15cee
) (cherry picked from commit3ad88f1146
) (cherry picked from commit5501f5b2e5
) (cherry picked from commit9b9f62f774
) (cherry picked from commitdd2e5f525d
) (cherry picked from commit9b489fd8a5
) (cherry picked from commit60c820562a
) (cherry picked from commit084d732317
)
70 lines
1.6 KiB
Go
70 lines
1.6 KiB
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package user
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"code.gitea.io/gitea/modules/structs"
|
|
)
|
|
|
|
const (
|
|
GhostUserID = -1
|
|
GhostUserName = "Ghost"
|
|
GhostUserLowerName = "ghost"
|
|
)
|
|
|
|
// NewGhostUser creates and returns a fake user for someone has deleted their account.
|
|
func NewGhostUser() *User {
|
|
return &User{
|
|
ID: GhostUserID,
|
|
Name: GhostUserName,
|
|
LowerName: GhostUserLowerName,
|
|
}
|
|
}
|
|
|
|
// IsGhost check if user is fake user for a deleted account
|
|
func (u *User) IsGhost() bool {
|
|
if u == nil {
|
|
return false
|
|
}
|
|
return u.ID == GhostUserID && u.Name == GhostUserName
|
|
}
|
|
|
|
// NewReplaceUser creates and returns a fake user for external user
|
|
func NewReplaceUser(name string) *User {
|
|
return &User{
|
|
ID: 0,
|
|
Name: name,
|
|
LowerName: strings.ToLower(name),
|
|
}
|
|
}
|
|
|
|
const (
|
|
ActionsUserID = -2
|
|
ActionsUserName = "forgejo-actions"
|
|
ActionsFullName = "Forgejo Actions"
|
|
ActionsEmail = "noreply@forgejo.org"
|
|
)
|
|
|
|
// NewActionsUser creates and returns a fake user for running the actions.
|
|
func NewActionsUser() *User {
|
|
return &User{
|
|
ID: ActionsUserID,
|
|
Name: ActionsUserName,
|
|
LowerName: ActionsUserName,
|
|
IsActive: true,
|
|
FullName: ActionsFullName,
|
|
Email: ActionsEmail,
|
|
KeepEmailPrivate: true,
|
|
LoginName: ActionsUserName,
|
|
Type: UserTypeIndividual,
|
|
AllowCreateOrganization: true,
|
|
Visibility: structs.VisibleTypePublic,
|
|
}
|
|
}
|
|
|
|
func (u *User) IsActions() bool {
|
|
return u != nil && u.ID == ActionsUserID
|
|
}
|