loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Jason Song
Lauris BH
and committed by
GitHub
34f736ca 43c10def

+15 -4
+15 -4
models/issues/reaction.go
··· 181 181 Reaction: opts.Type, 182 182 UserID: opts.DoerID, 183 183 } 184 + if findOpts.CommentID == 0 { 185 + // explicit search of Issue Reactions where CommentID = 0 186 + findOpts.CommentID = -1 187 + } 184 188 185 189 existingR, _, err := FindReactions(ctx, findOpts) 186 190 if err != nil { ··· 256 260 CommentID: opts.CommentID, 257 261 } 258 262 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) 260 270 return err 261 271 } 262 272 263 273 // DeleteIssueReaction deletes a reaction on issue. 264 274 func DeleteIssueReaction(doerID, issueID int64, content string) error { 265 275 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, 269 280 }) 270 281 } 271 282