Support bot user

This commit is contained in:
Lunny Xiao
2022-11-25 17:48:47 +08:00
committed by Jason Song
parent 1ddf3b2d12
commit aa09eb63e1
12 changed files with 120 additions and 84 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ func (run *Run) LoadAttributes(ctx context.Context) error {
}
if run.TriggerUser == nil {
u, err := user_model.GetUserByIDCtx(ctx, run.TriggerUserID)
u, err := user_model.GetPossbileUserByID(ctx, run.TriggerUserID)
if err != nil {
return err
}
-27
View File
@@ -1,27 +0,0 @@
// 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"
"code.gitea.io/gitea/modules/structs"
)
// 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",
IsActive: true,
FullName: "Gitea Bots",
Email: "teabot@gitea.io",
KeepEmailPrivate: true,
LoginName: "gitea-bots",
Type: user_model.UserTypeIndividual,
AllowCreateOrganization: true,
Visibility: structs.VisibleTypePublic,
}
}