mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-20 23:49:23 +00:00
8985e17343
(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
)
71 lines
1.6 KiB
Go
71 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
|
|
}
|