mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-24 06:15:42 +03:00
e003d403cc
(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 commit2668d92220
) (cherry picked from commitf60fe5c8ea
) (cherry picked from commit1167fd8352
) (cherry picked from commit92a49af7ca
) (cherry picked from commitee95014448
)
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
|
|
}
|