@@ -11,9 +11,8 @@ import (
11
11
12
12
"code.gitea.io/gitea/models"
13
13
"code.gitea.io/gitea/modules/git"
14
- "code.gitea.io/gitea/modules/log "
14
+ "code.gitea.io/gitea/modules/notification "
15
15
"code.gitea.io/gitea/modules/setting"
16
- api "code.gitea.io/gitea/modules/structs"
17
16
"code.gitea.io/gitea/services/gitdiff"
18
17
)
19
18
@@ -31,19 +30,8 @@ func CreateIssueComment(doer *models.User, repo *models.Repository, issue *model
31
30
return nil , err
32
31
}
33
32
34
- mode , _ := models .AccessLevel (doer , repo )
35
- if err = models .PrepareWebhooks (repo , models .HookEventIssueComment , & api.IssueCommentPayload {
36
- Action : api .HookIssueCommentCreated ,
37
- Issue : issue .APIFormat (),
38
- Comment : comment .APIFormat (),
39
- Repository : repo .APIFormat (mode ),
40
- Sender : doer .APIFormat (),
41
- IsPull : issue .IsPull ,
42
- }); err != nil {
43
- log .Error ("PrepareWebhooks [comment_id: %d]: %v" , comment .ID , err )
44
- } else {
45
- go models .HookQueue .Add (repo .ID )
46
- }
33
+ notification .NotifyCreateIssueComment (doer , repo , issue , comment )
34
+
47
35
return comment , nil
48
36
}
49
37
@@ -106,35 +94,7 @@ func UpdateComment(c *models.Comment, doer *models.User, oldContent string) erro
106
94
return err
107
95
}
108
96
109
- if err := c .LoadPoster (); err != nil {
110
- return err
111
- }
112
- if err := c .LoadIssue (); err != nil {
113
- return err
114
- }
115
-
116
- if err := c .Issue .LoadAttributes (); err != nil {
117
- return err
118
- }
119
-
120
- mode , _ := models .AccessLevel (doer , c .Issue .Repo )
121
- if err := models .PrepareWebhooks (c .Issue .Repo , models .HookEventIssueComment , & api.IssueCommentPayload {
122
- Action : api .HookIssueCommentEdited ,
123
- Issue : c .Issue .APIFormat (),
124
- Comment : c .APIFormat (),
125
- Changes : & api.ChangesPayload {
126
- Body : & api.ChangesFromPayload {
127
- From : oldContent ,
128
- },
129
- },
130
- Repository : c .Issue .Repo .APIFormat (mode ),
131
- Sender : doer .APIFormat (),
132
- IsPull : c .Issue .IsPull ,
133
- }); err != nil {
134
- log .Error ("PrepareWebhooks [comment_id: %d]: %v" , c .ID , err )
135
- } else {
136
- go models .HookQueue .Add (c .Issue .Repo .ID )
137
- }
97
+ notification .NotifyUpdateComment (doer , c , oldContent )
138
98
139
99
return nil
140
100
}
@@ -145,31 +105,7 @@ func DeleteComment(comment *models.Comment, doer *models.User) error {
145
105
return err
146
106
}
147
107
148
- if err := comment .LoadPoster (); err != nil {
149
- return err
150
- }
151
- if err := comment .LoadIssue (); err != nil {
152
- return err
153
- }
154
-
155
- if err := comment .Issue .LoadAttributes (); err != nil {
156
- return err
157
- }
158
-
159
- mode , _ := models .AccessLevel (doer , comment .Issue .Repo )
160
-
161
- if err := models .PrepareWebhooks (comment .Issue .Repo , models .HookEventIssueComment , & api.IssueCommentPayload {
162
- Action : api .HookIssueCommentDeleted ,
163
- Issue : comment .Issue .APIFormat (),
164
- Comment : comment .APIFormat (),
165
- Repository : comment .Issue .Repo .APIFormat (mode ),
166
- Sender : doer .APIFormat (),
167
- IsPull : comment .Issue .IsPull ,
168
- }); err != nil {
169
- log .Error ("PrepareWebhooks [comment_id: %d]: %v" , comment .ID , err )
170
- } else {
171
- go models .HookQueue .Add (comment .Issue .Repo .ID )
172
- }
108
+ notification .NotifyDeleteComment (doer , comment )
173
109
174
110
return nil
175
111
}
0 commit comments