Skip to content

Commit 5e0b11c

Browse files
committed
updated webhook code adding params for selectivly enabling/disabling messages go rc/teams
1 parent 48adbb1 commit 5e0b11c

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

web/github.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@
6161

6262

6363
switch ($EventType) {
64+
$useRC = true;
65+
$useTeams = true;
6466
case 'issues':
6567
if ($RepositoryName == 'interserver/mailbaby-api-samples') {
68+
$useTeams = false;
6669
break;
6770
}
6871
$Issue = $Message['issue'];
@@ -78,7 +81,7 @@
7881
}
7982

8083
$Msg['text'] = $ChatMsg;
81-
SendToChat('notifications', $Msg);
84+
SendToChat('notifications', $Msg, $useRC, $useTeams);
8285
break;
8386

8487
case 'pull_request':
@@ -96,7 +99,7 @@
9699
}
97100

98101
$Msg['text'] = $ChatMsg;
99-
SendToChat('notifications', $Msg);
102+
SendToChat('notifications', $Msg, $useRC, $useTeams);
100103
break;
101104

102105
case 'push':
@@ -121,7 +124,7 @@
121124
}
122125

123126
$Msg['text'] = $ChatMsg;
124-
SendToChat('notifications', $Msg);
127+
SendToChat('notifications', $Msg, $useRC, $useTeams);
125128
break;
126129

127130
case 'check_suite':
@@ -136,7 +139,7 @@
136139
. "([details]({$Url}))";
137140

138141
$Msg['text'] = $ChatMsg;
139-
//SendToChat('notifications', $Msg);
142+
//SendToChat('notifications', $Msg, $useRC, $useTeams);
140143
break;
141144

142145
case 'workflow_run':
@@ -151,7 +154,7 @@
151154
. "([view run]({$Url}))";
152155

153156
$Msg['text'] = $ChatMsg;
154-
//SendToChat('notifications', $Msg);
157+
//SendToChat('notifications', $Msg, $useRC, $useTeams);
155158
break;
156159

157160
default:
@@ -160,7 +163,7 @@
160163
. "on [{$RepositoryName}](https://github.com/{$RepositoryName}).";
161164

162165
$Msg['text'] = $ChatMsg;
163-
SendToChat('notifications', $Msg);
166+
SendToChat('notifications', $Msg, $useRC, $useTeams);
164167
break;
165168
}
166169
/*
@@ -197,12 +200,10 @@ function WildMatch(string $string, string $expression) : bool
197200
return preg_match('/^' . $expression . '$/', $string) === 1;
198201
}
199202

200-
function SendToChat(string $Where, array $Payload) : bool
203+
function SendToChat(string $Where, array $Payload, $useRC = true, $useTeams = true) : bool
201204
{
202205
error_log("Sending Payload ".json_encode($Payload)." to {$Where}");
203206
global $chatChannels;
204-
$useRC = true;
205-
$useTeams = true;
206207
if ($useRC === true) {
207208
$Url = $chatChannels['rocketchat'][$Where];
208209
$c = curl_init();

0 commit comments

Comments
 (0)