Virtual user gitea-bots
This commit is contained in:
16
models/bots/teabot.go
Normal file
16
models/bots/teabot.go
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package bots
|
||||
|
||||
import user_model "code.gitea.io/gitea/models/user"
|
||||
|
||||
// NewBotUser creates and returns a fake user for running the build.
|
||||
func NewBotUser() *user_model.User {
|
||||
return &user_model.User{
|
||||
ID: -2,
|
||||
Name: "gitea-bots",
|
||||
LowerName: "gitea-bots",
|
||||
}
|
||||
}
|
||||
@@ -577,6 +577,13 @@ func (u *User) IsGhost() bool {
|
||||
return u.ID == -1 && u.Name == "Ghost"
|
||||
}
|
||||
|
||||
func (u *User) IsBots() bool {
|
||||
if u == nil {
|
||||
return false
|
||||
}
|
||||
return u.ID == -2 && u.Name == "gitea-bots"
|
||||
}
|
||||
|
||||
var (
|
||||
reservedUsernames = []string{
|
||||
".",
|
||||
|
||||
Reference in New Issue
Block a user