@@ -5,10 +5,6 @@ open Common
5
5
open Github_j
6
6
open Slack_j
7
7
8
- let log = Log. from " slack"
9
-
10
- type channel_hook = string
11
-
12
8
let empty_attachments =
13
9
{
14
10
mrkdwn_in = None ;
@@ -37,7 +33,7 @@ let show_labels = function
37
33
| (labels : label list ) ->
38
34
Some (sprintf " Labels: %s" @@ String. concat ~sep: " , " (List. map ~f: (fun x -> x.name) labels))
39
35
40
- let generate_pull_request_notification notification =
36
+ let generate_pull_request_notification notification channel =
41
37
let { action; number; sender; pull_request; repository } = notification in
42
38
let ({ body; title; html_url; labels; _ } : pull_request ) = pull_request in
43
39
let action, body =
@@ -57,6 +53,7 @@ let generate_pull_request_notification notification =
57
53
action sender.login)
58
54
in
59
55
{
56
+ channel;
60
57
text = None ;
61
58
attachments =
62
59
Some
@@ -73,7 +70,7 @@ let generate_pull_request_notification notification =
73
70
blocks = None ;
74
71
}
75
72
76
- let generate_pr_review_notification notification =
73
+ let generate_pr_review_notification notification channel =
77
74
let { action; sender; pull_request; review; repository } = notification in
78
75
let ({ number; title; html_url; _ } : pull_request ) = pull_request in
79
76
let action_str =
@@ -96,6 +93,7 @@ let generate_pr_review_notification notification =
96
93
action_str number html_url title)
97
94
in
98
95
{
96
+ channel;
99
97
text = None ;
100
98
attachments =
101
99
Some
@@ -112,7 +110,7 @@ let generate_pr_review_notification notification =
112
110
blocks = None ;
113
111
}
114
112
115
- let generate_pr_review_comment_notification notification =
113
+ let generate_pr_review_comment_notification notification channel =
116
114
let { action; pull_request; sender; comment; repository } = notification in
117
115
let ({ number; title; html_url; _ } : pull_request ) = pull_request in
118
116
let action_str =
@@ -134,6 +132,7 @@ let generate_pr_review_comment_notification notification =
134
132
| Some a -> Some (sprintf " New comment by %s in <%s|%s>" sender.login comment.html_url a)
135
133
in
136
134
{
135
+ channel;
137
136
text = None ;
138
137
attachments =
139
138
Some
@@ -151,7 +150,7 @@ let generate_pr_review_comment_notification notification =
151
150
blocks = None ;
152
151
}
153
152
154
- let generate_issue_notification notification =
153
+ let generate_issue_notification notification channel =
155
154
let ({ action; sender; issue; repository } : issue_notification ) = notification in
156
155
let { number; body; title; html_url; labels; _ } = issue in
157
156
let action, body =
@@ -171,6 +170,7 @@ let generate_issue_notification notification =
171
170
sender.login)
172
171
in
173
172
{
173
+ channel;
174
174
text = None ;
175
175
attachments =
176
176
Some
@@ -187,7 +187,7 @@ let generate_issue_notification notification =
187
187
blocks = None ;
188
188
}
189
189
190
- let generate_issue_comment_notification notification =
190
+ let generate_issue_comment_notification notification channel =
191
191
let { action; issue; sender; comment; repository } = notification in
192
192
let { number; title; _ } = issue in
193
193
let action_str =
@@ -205,6 +205,7 @@ let generate_issue_comment_notification notification =
205
205
action_str number issue.html_url title)
206
206
in
207
207
{
208
+ channel;
208
209
text = None ;
209
210
attachments =
210
211
Some
@@ -223,7 +224,7 @@ let generate_issue_comment_notification notification =
223
224
224
225
let git_short_sha_hash hash = String. sub ~pos: 0 ~len: 8 hash
225
226
226
- let generate_push_notification notification =
227
+ let generate_push_notification notification channel =
227
228
let { sender; created; deleted; forced; compare; commits; repository; _ } = notification in
228
229
let commits_branch = Github. commits_branch_of_ref notification.ref in
229
230
let tree_url = String. concat ~sep: " /" [ repository.url; " tree" ; Uri. pct_encode commits_branch ] in
@@ -247,6 +248,7 @@ let generate_push_notification notification =
247
248
sprintf " `<%s|%s>` %s - %s" url (git_short_sha_hash id) title author.name)
248
249
in
249
250
{
251
+ channel;
250
252
text = Some title;
251
253
attachments =
252
254
Some
@@ -262,7 +264,7 @@ let generate_push_notification notification =
262
264
blocks = None ;
263
265
}
264
266
265
- let generate_status_notification (cfg : Config_t.config ) (notification : status_notification ) =
267
+ let generate_status_notification (cfg : Config_t.config ) (notification : status_notification ) channel =
266
268
let { commit; state; description; target_url; context; repository; _ } = notification in
267
269
let ({ commit : inner_commit ; sha; author; html_url; _ } : status_commit ) = commit in
268
270
let ({ message; _ } : inner_commit ) = commit in
@@ -324,9 +326,9 @@ let generate_status_notification (cfg : Config_t.config) (notification : status_
324
326
fields = Some [ { title = None ; value = String. concat ~sep: " \n " @@ List. concat [ commit_info; branches_info ] } ];
325
327
}
326
328
in
327
- { text = None ; attachments = Some [ attachment ]; blocks = None }
329
+ { channel; text = None ; attachments = Some [ attachment ]; blocks = None }
328
330
329
- let generate_commit_comment_notification api_commit notification =
331
+ let generate_commit_comment_notification api_commit notification channel =
330
332
let { commit; _ } = api_commit in
331
333
let { sender; comment; repository; _ } = notification in
332
334
let commit_id =
@@ -355,5 +357,4 @@ let generate_commit_comment_notification api_commit notification =
355
357
text = Some (mrkdwn_of_markdown comment.body);
356
358
}
357
359
in
358
- let notifs = { text = None ; attachments = Some [ attachment ]; blocks = None } in
359
- Lwt. return notifs
360
+ { channel; text = None ; attachments = Some [ attachment ]; blocks = None }
0 commit comments