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
@@ -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
+8 -5
View File
@@ -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
+1 -1
View File
@@ -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()
+8 -5
View File
@@ -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
+1 -1
View File
@@ -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
}