forgejo/models/user/user_system.go
Loïc Dachary ef25d18d9c
[BRANDING] reserve forgejo-actions username
(cherry picked from commit 2a25be788b)
(cherry picked from commit b270d5815c)
(cherry picked from commit e7382cc71e)
(cherry picked from commit 665400ea1e)
(cherry picked from commit f5b2c691f1)
(cherry picked from commit 3df97adfef)
(cherry picked from commit 494f6eafc1)
(cherry picked from commit 822e3d2c83)
(cherry picked from commit 7460f12568)
(cherry picked from commit f6cd70881e)
(cherry picked from commit c669ce8173)
(cherry picked from commit 1d5a433e02)
(cherry picked from commit c1a4dc150c)
(cherry picked from commit dd1c971c6c)
(cherry picked from commit 8d2dcd9b1e)
(cherry picked from commit b6bb8fd275)
(cherry picked from commit d4b71fe96e)
(cherry picked from commit e204ec0b23)
(cherry picked from commit 8d9f1174bd)
(cherry picked from commit e314a7d5ba)
(cherry picked from commit 48b3ad5a30)
(cherry picked from commit 71ed4b7c69)
(cherry picked from commit d63324ccb6)
(cherry picked from commit 9249e893db)
(cherry picked from commit 78f156427b)
(cherry picked from commit c3d4a1a602)
(cherry picked from commit 83b1855f55)
(cherry picked from commit 319815d9b1)
(cherry picked from commit c4fcbfd297)
(cherry picked from commit fb58c85222)
(cherry picked from commit 69c24e3e8b)
(cherry picked from commit 1e9ec4737a)
(cherry picked from commit 70439970c1)
(cherry picked from commit 7e6146c1a8)
(cherry picked from commit 7adf6d5869)
(cherry picked from commit 8985e17343)
(cherry picked from commit fd4dc3ebca)
(cherry picked from commit d31bf1639e)
(cherry picked from commit d2a9b6dea0)
(cherry picked from commit 0d9279bc85)
(cherry picked from commit 0591a15cee)
(cherry picked from commit 3ad88f1146)
(cherry picked from commit 5501f5b2e5)
(cherry picked from commit 9b9f62f774)
(cherry picked from commit dd2e5f525d)
(cherry picked from commit 9b489fd8a5)
(cherry picked from commit 60c820562a)
(cherry picked from commit 084d732317)
(cherry picked from commit e1bb077d6e)
2024-02-05 16:05:01 +01:00

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
}