Skip to content

Commit 763906f

Browse files
authored
Merge branch 'main' into fix-tree-mode
2 parents c081436 + 34f736c commit 763906f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

models/issues/reaction.go

+15-4
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ func createReaction(ctx context.Context, opts *ReactionOptions) (*Reaction, erro
181181
Reaction: opts.Type,
182182
UserID: opts.DoerID,
183183
}
184+
if findOpts.CommentID == 0 {
185+
// explicit search of Issue Reactions where CommentID = 0
186+
findOpts.CommentID = -1
187+
}
184188

185189
existingR, _, err := FindReactions(ctx, findOpts)
186190
if err != nil {
@@ -256,16 +260,23 @@ func DeleteReaction(ctx context.Context, opts *ReactionOptions) error {
256260
CommentID: opts.CommentID,
257261
}
258262

259-
_, err := db.GetEngine(ctx).Where("original_author_id = 0").Delete(reaction)
263+
sess := db.GetEngine(ctx).Where("original_author_id = 0")
264+
if opts.CommentID == -1 {
265+
reaction.CommentID = 0
266+
sess.MustCols("comment_id")
267+
}
268+
269+
_, err := sess.Delete(reaction)
260270
return err
261271
}
262272

263273
// DeleteIssueReaction deletes a reaction on issue.
264274
func DeleteIssueReaction(doerID, issueID int64, content string) error {
265275
return DeleteReaction(db.DefaultContext, &ReactionOptions{
266-
Type: content,
267-
DoerID: doerID,
268-
IssueID: issueID,
276+
Type: content,
277+
DoerID: doerID,
278+
IssueID: issueID,
279+
CommentID: -1,
269280
})
270281
}
271282

0 commit comments

Comments
 (0)