Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4e0269e

Browse files
GiteaBotlunny
andauthored
Reload issue when sending webhook to make num comments is right. (#35243) (#35248)
Backport#35243 by@lunnyFix#35229Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
1 parent04114c6 commit4e0269e

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

‎services/actions/notifier.go‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,6 @@ func (n *actionsNotifier) CreateIssueComment(ctx context.Context, doer *user_mod
260260
func (n*actionsNotifier)UpdateComment(ctx context.Context,doer*user_model.User,c*issues_model.Comment,oldContentstring) {
261261
ctx=withMethod(ctx,"UpdateComment")
262262

263-
iferr:=c.LoadIssue(ctx);err!=nil {
264-
log.Error("LoadIssue: %v",err)
265-
return
266-
}
267-
268263
ifc.Issue.IsPull {
269264
notifyIssueCommentChange(ctx,doer,c,oldContent,webhook_module.HookEventPullRequestComment,api.HookIssueCommentEdited)
270265
return
@@ -275,11 +270,6 @@ func (n *actionsNotifier) UpdateComment(ctx context.Context, doer *user_model.Us
275270
func (n*actionsNotifier)DeleteComment(ctx context.Context,doer*user_model.User,comment*issues_model.Comment) {
276271
ctx=withMethod(ctx,"DeleteComment")
277272

278-
iferr:=comment.LoadIssue(ctx);err!=nil {
279-
log.Error("LoadIssue: %v",err)
280-
return
281-
}
282-
283273
ifcomment.Issue.IsPull {
284274
notifyIssueCommentChange(ctx,doer,comment,"",webhook_module.HookEventPullRequestComment,api.HookIssueCommentDeleted)
285275
return
@@ -288,6 +278,7 @@ func (n *actionsNotifier) DeleteComment(ctx context.Context, doer *user_model.Us
288278
}
289279

290280
funcnotifyIssueCommentChange(ctx context.Context,doer*user_model.User,comment*issues_model.Comment,oldContentstring,event webhook_module.HookEventType,action api.HookIssueCommentAction) {
281+
comment.Issue=nil// force issue to be loaded
291282
iferr:=comment.LoadIssue(ctx);err!=nil {
292283
log.Error("LoadIssue: %v",err)
293284
return

‎services/issue/comments.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ func CreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_m
8080
returnnil,err
8181
}
8282

83+
// reload issue to ensure it has the latest data, especially the number of comments
84+
issue,err=issues_model.GetIssueByID(ctx,issue.ID)
85+
iferr!=nil {
86+
returnnil,err
87+
}
88+
8389
notify_service.CreateIssueComment(ctx,doer,repo,issue,comment,mentions)
8490

8591
returncomment,nil

‎services/webhook/notifier.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ func (m *webhookNotifier) DeleteComment(ctx context.Context, doer *user_model.Us
445445
log.Error("LoadPoster: %v",err)
446446
return
447447
}
448+
comment.Issue=nil// reload issue to ensure it has the latest data, especially the number of comments
448449
iferr=comment.LoadIssue(ctx);err!=nil {
449450
log.Error("LoadIssue: %v",err)
450451
return

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp