fix(reactions): add reactions to task comments
This commit is contained in:
parent
69b9086bef
commit
a2fa1515cd
|
@ -37,6 +37,8 @@ type TaskComment struct {
|
|||
Author *user.User `xorm:"-" json:"author"`
|
||||
TaskID int64 `xorm:"not null" json:"-" param:"task"`
|
||||
|
||||
Reactions ReactionMap `xorm:"-" json:"reactions"`
|
||||
|
||||
Created time.Time `xorm:"created" json:"created"`
|
||||
Updated time.Time `xorm:"updated" json:"updated"`
|
||||
|
||||
|
@ -263,8 +265,10 @@ func (tc *TaskComment) ReadAll(s *xorm.Session, auth web.Auth, search string, pa
|
|||
}
|
||||
|
||||
var authorIDs []int64
|
||||
var commentIDs []int64
|
||||
for _, comment := range comments {
|
||||
authorIDs = append(authorIDs, comment.AuthorID)
|
||||
commentIDs = append(commentIDs, comment.ID)
|
||||
}
|
||||
|
||||
authors, err := getUsersOrLinkSharesFromIDs(s, authorIDs)
|
||||
|
@ -272,8 +276,17 @@ func (tc *TaskComment) ReadAll(s *xorm.Session, auth web.Auth, search string, pa
|
|||
return
|
||||
}
|
||||
|
||||
reactions, err := getReactionsForEntityIDs(s, ReactionKindTask, commentIDs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, comment := range comments {
|
||||
comment.Author = authors[comment.AuthorID]
|
||||
r, has := reactions[comment.ID]
|
||||
if has {
|
||||
comment.Reactions = r
|
||||
}
|
||||
}
|
||||
|
||||
numberOfTotalItems, err = s.
|
||||
|
|
Loading…
Reference in New Issue