mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-23 18:42:26 +00:00
(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 commitc9a905f588) (cherry picked from commitc9930563b2) (cherry picked from commit8e8fbf4950) (cherry picked from commitd3b8e54778) (cherry picked from commitee63800789)
64 lines
1.5 KiB
Go
64 lines
1.5 KiB
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package user
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"code.gitea.io/gitea/modules/structs"
|
|
)
|
|
|
|
// NewGhostUser creates and returns a fake user for someone has deleted their account.
|
|
func NewGhostUser() *User {
|
|
return &User{
|
|
ID: -1,
|
|
Name: "Ghost",
|
|
LowerName: "ghost",
|
|
}
|
|
}
|
|
|
|
// IsGhost check if user is fake user for a deleted account
|
|
func (u *User) IsGhost() bool {
|
|
if u == nil {
|
|
return false
|
|
}
|
|
return u.ID == -1 && u.Name == "Ghost"
|
|
}
|
|
|
|
// NewReplaceUser creates and returns a fake user for external user
|
|
func NewReplaceUser(name string) *User {
|
|
return &User{
|
|
ID: -1,
|
|
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
|
|
}
|