mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-21 12:44:49 -05:00
Fix reaction of issues (#21185)
Fix #20860.
`CommentID` in `FindReactionsOptions` should be -1 to search reactions
with zero comment id.
8351172b6e/models/issues/reaction.go (L108-L121)
Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
43c10def68
commit
34f736ca04
1 changed files with 15 additions and 4 deletions
|
@ -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,7 +260,13 @@ 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
|
||||
}
|
||||
|
||||
|
@ -266,6 +276,7 @@ func DeleteIssueReaction(doerID, issueID int64, content string) error {
|
|||
Type: content,
|
||||
DoerID: doerID,
|
||||
IssueID: issueID,
|
||||
CommentID: -1,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue