mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
Support bot user
This commit is contained in:
@@ -351,7 +351,7 @@ func (c *Comment) LoadPoster(ctx context.Context) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
c.Poster, err = user_model.GetUserByIDCtx(ctx, c.PosterID)
|
||||
c.Poster, err = user_model.GetPossbileUserByID(ctx, c.PosterID)
|
||||
if err != nil {
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
c.PosterID = -1
|
||||
|
||||
@@ -49,12 +49,15 @@ func (comments CommentList) LoadPosters(ctx context.Context) error {
|
||||
}
|
||||
|
||||
for _, comment := range comments {
|
||||
if comment.PosterID <= 0 {
|
||||
if comment.PosterID == user_model.BotUserID {
|
||||
comment.Poster = user_model.NewBotUser()
|
||||
} else if comment.PosterID <= 0 {
|
||||
continue
|
||||
}
|
||||
var ok bool
|
||||
if comment.Poster, ok = posterMaps[comment.PosterID]; !ok {
|
||||
comment.Poster = user_model.NewGhostUser()
|
||||
} else {
|
||||
var ok bool
|
||||
if comment.Poster, ok = posterMaps[comment.PosterID]; !ok {
|
||||
comment.Poster = user_model.NewGhostUser()
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -243,7 +243,7 @@ func (issue *Issue) LoadLabels(ctx context.Context) (err error) {
|
||||
// LoadPoster loads poster
|
||||
func (issue *Issue) LoadPoster(ctx context.Context) (err error) {
|
||||
if issue.Poster == nil {
|
||||
issue.Poster, err = user_model.GetUserByIDCtx(ctx, issue.PosterID)
|
||||
issue.Poster, err = user_model.GetPossbileUserByID(ctx, issue.PosterID)
|
||||
if err != nil {
|
||||
issue.PosterID = -1
|
||||
issue.Poster = user_model.NewGhostUser()
|
||||
|
||||
@@ -106,12 +106,15 @@ func (issues IssueList) loadPosters(ctx context.Context) error {
|
||||
}
|
||||
|
||||
for _, issue := range issues {
|
||||
if issue.PosterID <= 0 {
|
||||
if issue.PosterID == user_model.BotUserID {
|
||||
issue.Poster = user_model.NewBotUser()
|
||||
} else if issue.PosterID <= 0 {
|
||||
continue
|
||||
}
|
||||
var ok bool
|
||||
if issue.Poster, ok = posterMaps[issue.PosterID]; !ok {
|
||||
issue.Poster = user_model.NewGhostUser()
|
||||
} else {
|
||||
var ok bool
|
||||
if issue.Poster, ok = posterMaps[issue.PosterID]; !ok {
|
||||
issue.Poster = user_model.NewGhostUser()
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -159,7 +159,7 @@ func (r *Review) LoadReviewer(ctx context.Context) (err error) {
|
||||
if r.ReviewerID == 0 || r.Reviewer != nil {
|
||||
return
|
||||
}
|
||||
r.Reviewer, err = user_model.GetUserByIDCtx(ctx, r.ReviewerID)
|
||||
r.Reviewer, err = user_model.GetPossbileUserByID(ctx, r.ReviewerID)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user