@@ -36,61 +36,35 @@ func (r *indexerNotifier) NotifyAdoptRepository(ctx context.Context, doer, u *us
3636func (r * indexerNotifier ) NotifyCreateIssueComment (ctx context.Context , doer * user_model.User , repo * repo_model.Repository ,
3737 issue * issues_model.Issue , comment * issues_model.Comment , mentions []* user_model.User ,
3838) {
39- if comment .Type == issues_model .CommentTypeComment {
40- if issue .Comments == nil {
41- if err := issue .LoadDiscussComments (ctx ); err != nil {
42- log .Error ("LoadDiscussComments failed: %v" , err )
43- return
44- }
45- } else {
46- issue .Comments = append (issue .Comments , comment )
47- }
48-
49- issue_indexer .UpdateIssueIndexer (issue .ID )
50- }
39+ issue_indexer .UpdateIssueIndexer (issue .ID )
5140}
5241
5342func (r * indexerNotifier ) NotifyNewIssue (ctx context.Context , issue * issues_model.Issue , mentions []* user_model.User ) {
5443 issue_indexer .UpdateIssueIndexer (issue .ID )
5544}
5645
5746func (r * indexerNotifier ) NotifyNewPullRequest (ctx context.Context , pr * issues_model.PullRequest , mentions []* user_model.User ) {
47+ if err := pr .LoadIssue (ctx ); err != nil {
48+ log .Error ("LoadIssue: %v" , err )
49+ return
50+ }
5851 issue_indexer .UpdateIssueIndexer (pr .Issue .ID )
5952}
6053
6154func (r * indexerNotifier ) NotifyUpdateComment (ctx context.Context , doer * user_model.User , c * issues_model.Comment , oldContent string ) {
62- // Whatever the comment type is, just update the issue indexer.
63- // So that the issue indexer will be updated when Status/Assignee/Label and so on changed.
55+ if err := c .LoadIssue (ctx ); err != nil {
56+ log .Error ("LoadIssue: %v" , err )
57+ return
58+ }
6459 issue_indexer .UpdateIssueIndexer (c .Issue .ID )
6560}
6661
6762func (r * indexerNotifier ) NotifyDeleteComment (ctx context.Context , doer * user_model.User , comment * issues_model.Comment ) {
68- if comment .Type == issues_model .CommentTypeComment {
69- if err := comment .LoadIssue (ctx ); err != nil {
70- log .Error ("LoadIssue: %v" , err )
71- return
72- }
73-
74- var found bool
75- if comment .Issue .Comments != nil {
76- for i := 0 ; i < len (comment .Issue .Comments ); i ++ {
77- if comment .Issue .Comments [i ].ID == comment .ID {
78- comment .Issue .Comments = append (comment .Issue .Comments [:i ], comment .Issue .Comments [i + 1 :]... )
79- found = true
80- break
81- }
82- }
83- }
84-
85- if ! found {
86- if err := comment .Issue .LoadDiscussComments (ctx ); err != nil {
87- log .Error ("LoadDiscussComments failed: %v" , err )
88- return
89- }
90- }
91- // reload comments to delete the old comment
92- issue_indexer .UpdateIssueIndexer (comment .Issue .ID )
63+ if err := comment .LoadIssue (ctx ); err != nil {
64+ log .Error ("LoadIssue: %v" , err )
65+ return
9366 }
67+ issue_indexer .UpdateIssueIndexer (comment .Issue .ID )
9468}
9569
9670func (r * indexerNotifier ) NotifyDeleteRepository (ctx context.Context , doer * user_model.User , repo * repo_model.Repository ) {
0 commit comments