aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_comment.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-03-31 17:20:39 +0800
committerGitHub <noreply@github.com>2022-03-31 17:20:39 +0800
commitd4f84f1c937e24e71aa5f05c58d440cde741450f (patch)
tree18571ad08fabe6d1090ea4d2674beab3b1c00a6e /models/issue_comment.go
parent43332a483f7838df66e0209eb9c15d4aba3d5874 (diff)
downloadgitea-d4f84f1c937e24e71aa5f05c58d440cde741450f.tar.gz
gitea-d4f84f1c937e24e71aa5f05c58d440cde741450f.zip
Move reaction to models/issues/ (#19264)
* Move reaction to models/issues/ * Fix test * move the function * improve code * Update models/issues/reaction.go Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'models/issue_comment.go')
-rw-r--r--models/issue_comment.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go
index 7fb013ae92..332ae7bdc5 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -244,7 +244,7 @@ type Comment struct {
CommitSHA string `xorm:"VARCHAR(40)"`
Attachments []*repo_model.Attachment `xorm:"-"`
- Reactions ReactionList `xorm:"-"`
+ Reactions issues.ReactionList `xorm:"-"`
// For view issue page.
ShowRole RoleDescriptor `xorm:"-"`
@@ -631,11 +631,11 @@ func (c *Comment) LoadTime() error {
return err
}
-func (c *Comment) loadReactions(e db.Engine, repo *repo_model.Repository) (err error) {
+func (c *Comment) loadReactions(ctx context.Context, repo *repo_model.Repository) (err error) {
if c.Reactions != nil {
return nil
}
- c.Reactions, _, err = findReactions(e, FindReactionsOptions{
+ c.Reactions, _, err = issues.FindReactions(ctx, issues.FindReactionsOptions{
IssueID: c.IssueID,
CommentID: c.ID,
})
@@ -643,7 +643,7 @@ func (c *Comment) loadReactions(e db.Engine, repo *repo_model.Repository) (err e
return err
}
// Load reaction user data
- if _, err := c.Reactions.loadUsers(e, repo); err != nil {
+ if _, err := c.Reactions.LoadUsers(ctx, repo); err != nil {
return err
}
return nil
@@ -651,7 +651,7 @@ func (c *Comment) loadReactions(e db.Engine, repo *repo_model.Repository) (err e
// LoadReactions loads comment reactions
func (c *Comment) LoadReactions(repo *repo_model.Repository) error {
- return c.loadReactions(db.GetEngine(db.DefaultContext), repo)
+ return c.loadReactions(db.DefaultContext, repo)
}
func (c *Comment) loadReview(e db.Engine) (err error) {
@@ -1146,14 +1146,15 @@ func DeleteComment(comment *Comment) error {
}
defer committer.Close()
- if err := deleteComment(db.GetEngine(ctx), comment); err != nil {
+ if err := deleteComment(ctx, comment); err != nil {
return err
}
return committer.Commit()
}
-func deleteComment(e db.Engine, comment *Comment) error {
+func deleteComment(ctx context.Context, comment *Comment) error {
+ e := db.GetEngine(ctx)
if _, err := e.ID(comment.ID).NoAutoCondition().Delete(comment); err != nil {
return err
}
@@ -1177,7 +1178,7 @@ func deleteComment(e db.Engine, comment *Comment) error {
return err
}
- return deleteReaction(e, &ReactionOptions{Comment: comment})
+ return issues.DeleteReaction(ctx, &issues.ReactionOptions{CommentID: comment.ID})
}
// CodeComments represents comments on code by using this structure: FILENAME -> LINE (+ == proposed; - == previous) -> COMMENTS