diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-05-18 21:04:06 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-05-18 21:04:06 -0400 |
commit | 6d5ffaa848dcbc09538f79cb0cdea08f5306f4a4 (patch) | |
tree | 2b782b7bc4b7f25cfa9021f7250450c7534f86cb /app/Model | |
parent | db95e96f92a15660dc043eb033a0f7737b59a030 (diff) |
Send all Kanboard events to the webhook (breaking change)
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/Comment.php | 4 | ||||
-rw-r--r-- | app/Model/Webhook.php | 23 |
2 files changed, 16 insertions, 11 deletions
diff --git a/app/Model/Comment.php b/app/Model/Comment.php index 844f0c89..3aa9c027 100644 --- a/app/Model/Comment.php +++ b/app/Model/Comment.php @@ -129,7 +129,9 @@ class Comment extends Base ->eq('id', $values['id']) ->update(array('comment' => $values['comment'])); - $this->container['dispatcher']->dispatch(self::EVENT_UPDATE, new CommentEvent($values)); + if ($result) { + $this->container['dispatcher']->dispatch(self::EVENT_UPDATE, new CommentEvent($values)); + } return $result; } diff --git a/app/Model/Webhook.php b/app/Model/Webhook.php index b3603818..8c270fb6 100644 --- a/app/Model/Webhook.php +++ b/app/Model/Webhook.php @@ -14,20 +14,23 @@ class Webhook extends Base * Call the external URL * * @access public - * @param string $url URL to call - * @param array $task Task data + * @param array $values Event payload */ - public function notify($url, array $task) + public function notify(array $values) { + $url = $this->config->get('webhook_url'); $token = $this->config->get('webhook_token'); - if (strpos($url, '?') !== false) { - $url .= '&token='.$token; - } - else { - $url .= '?token='.$token; - } + if (! empty($url)) { - return $this->httpClient->post($url, $task); + if (strpos($url, '?') !== false) { + $url .= '&token='.$token; + } + else { + $url .= '?token='.$token; + } + + return $this->httpClient->post($url, $values); + } } } |