diff options
author | Jason Song <i@wolfogre.com> | 2022-09-17 19:54:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-17 19:54:03 +0800 |
commit | 34f736ca04e5cf329d5ba8c562c2ccad3b33d2a6 (patch) | |
tree | d6383af15675073c19f25223c9b67d84600dcb82 | |
parent | 43c10def6849f0e1ea50a52115360e6be50ad1ab (diff) | |
download | gitea-34f736ca04e5cf329d5ba8c562c2ccad3b33d2a6.tar.gz gitea-34f736ca04e5cf329d5ba8c562c2ccad3b33d2a6.zip |
Fix reaction of issues (#21185)
Fix #20860.
`CommentID` in `FindReactionsOptions` should be -1 to search reactions
with zero comment id.
https://github.com/go-gitea/gitea/blob/8351172b6e5221290dc5b2c81e159e2eec0b43c8/models/issues/reaction.go#L108-L121
Co-authored-by: Lauris BH <lauris@nix.lv>
-rw-r--r-- | models/issues/reaction.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/models/issues/reaction.go b/models/issues/reaction.go index 87d6ff4310..e7295c8af8 100644 --- a/models/issues/reaction.go +++ b/models/issues/reaction.go @@ -181,6 +181,10 @@ func createReaction(ctx context.Context, opts *ReactionOptions) (*Reaction, erro Reaction: opts.Type, UserID: opts.DoerID, } + if findOpts.CommentID == 0 { + // explicit search of Issue Reactions where CommentID = 0 + findOpts.CommentID = -1 + } existingR, _, err := FindReactions(ctx, findOpts) if err != nil { @@ -256,16 +260,23 @@ func DeleteReaction(ctx context.Context, opts *ReactionOptions) error { CommentID: opts.CommentID, } - _, err := db.GetEngine(ctx).Where("original_author_id = 0").Delete(reaction) + sess := db.GetEngine(ctx).Where("original_author_id = 0") + if opts.CommentID == -1 { + reaction.CommentID = 0 + sess.MustCols("comment_id") + } + + _, err := sess.Delete(reaction) return err } // DeleteIssueReaction deletes a reaction on issue. func DeleteIssueReaction(doerID, issueID int64, content string) error { return DeleteReaction(db.DefaultContext, &ReactionOptions{ - Type: content, - DoerID: doerID, - IssueID: issueID, + Type: content, + DoerID: doerID, + IssueID: issueID, + CommentID: -1, }) } |