Commit 0b00d1e8 authored by Sean Madsen's avatar Sean Madsen

Improve webhook listener

- Don't send emails to "donotreply" addresses
- Handle a couple more error situations with specific exceptions
parent dd53ea45
......@@ -32,6 +32,13 @@ class GitHubHookProcessor {
* @param mixed $payload An object given by json_decode()
*/
public function process($event, $payload) {
if (empty($payload)) {
throw new \Exception("No payload data supplied");
}
if (empty($event)) {
throw new \Exception("Unable to determine webhook event type from "
. "request headers");
}
if ($event == 'pull_request') {
$this->getDetailsFromPullRequest($payload);
}
......@@ -104,6 +111,9 @@ class GitHubHookProcessor {
if (!is_array($recipients)) {
$recipients = array($recipients);
}
// remove any email addresses begins with "donotreply@" or "noreply"
$recipients = preg_grep('/^(donot|no)reply@/', $recipients, PREG_GREP_INVERT);
$this->recipients = array_unique(array_merge($this->recipients, $recipients));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment