|
|
@ -181,6 +181,10 @@ func createReaction(ctx context.Context, opts *ReactionOptions) (*Reaction, erro |
|
|
|
Reaction: opts.Type, |
|
|
|
Reaction: opts.Type, |
|
|
|
UserID: opts.DoerID, |
|
|
|
UserID: opts.DoerID, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if findOpts.CommentID == 0 { |
|
|
|
|
|
|
|
// explicit search of Issue Reactions where CommentID = 0
|
|
|
|
|
|
|
|
findOpts.CommentID = -1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
existingR, _, err := FindReactions(ctx, findOpts) |
|
|
|
existingR, _, err := FindReactions(ctx, findOpts) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -256,16 +260,23 @@ func DeleteReaction(ctx context.Context, opts *ReactionOptions) error { |
|
|
|
CommentID: opts.CommentID, |
|
|
|
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 |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// DeleteIssueReaction deletes a reaction on issue.
|
|
|
|
// DeleteIssueReaction deletes a reaction on issue.
|
|
|
|
func DeleteIssueReaction(doerID, issueID int64, content string) error { |
|
|
|
func DeleteIssueReaction(doerID, issueID int64, content string) error { |
|
|
|
return DeleteReaction(db.DefaultContext, &ReactionOptions{ |
|
|
|
return DeleteReaction(db.DefaultContext, &ReactionOptions{ |
|
|
|
Type: content, |
|
|
|
Type: content, |
|
|
|
DoerID: doerID, |
|
|
|
DoerID: doerID, |
|
|
|
IssueID: issueID, |
|
|
|
IssueID: issueID, |
|
|
|
|
|
|
|
CommentID: -1, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|