From a2fa1515cd45e6d95143cc4465890970416f78ec Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 11 Mar 2024 23:11:25 +0100 Subject: [PATCH] fix(reactions): add reactions to task comments --- pkg/models/task_comments.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/models/task_comments.go b/pkg/models/task_comments.go index 6c219a86a..bf547d5af 100644 --- a/pkg/models/task_comments.go +++ b/pkg/models/task_comments.go @@ -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.