summaryrefslogtreecommitdiff
path: root/app/Model/Webhook.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model/Webhook.php')
-rw-r--r--app/Model/Webhook.php89
1 files changed, 4 insertions, 85 deletions
diff --git a/app/Model/Webhook.php b/app/Model/Webhook.php
index 14d50684..7edffa6e 100644
--- a/app/Model/Webhook.php
+++ b/app/Model/Webhook.php
@@ -2,8 +2,6 @@
namespace Model;
-use Event\WebhookListener;
-
/**
* Webhook model
*
@@ -34,87 +32,6 @@ class Webhook extends Base
const HTTP_USER_AGENT = 'Kanboard Webhook';
/**
- * URL to call for task creation
- *
- * @access private
- * @var string
- */
- private $url_task_creation = '';
-
- /**
- * URL to call for task modification
- *
- * @access private
- * @var string
- */
- private $url_task_modification = '';
-
- /**
- * Webook token
- *
- * @access private
- * @var string
- */
- private $token = '';
-
- /**
- * Attach events
- *
- * @access public
- */
- public function attachEvents()
- {
- $this->url_task_creation = $this->config->get('webhook_url_task_creation');
- $this->url_task_modification = $this->config->get('webhook_url_task_modification');
- $this->token = $this->config->get('webhook_token');
-
- if ($this->url_task_creation) {
- $this->attachCreateEvents();
- }
-
- if ($this->url_task_modification) {
- $this->attachUpdateEvents();
- }
- }
-
- /**
- * Attach events for task modification
- *
- * @access public
- */
- public function attachUpdateEvents()
- {
- $events = array(
- Task::EVENT_UPDATE,
- Task::EVENT_CLOSE,
- Task::EVENT_OPEN,
- Task::EVENT_MOVE_COLUMN,
- Task::EVENT_MOVE_POSITION,
- Task::EVENT_ASSIGNEE_CHANGE,
- );
-
- $listener = new WebhookListener($this->container);
- $listener->setUrl($this->url_task_modification);
-
- foreach ($events as $event_name) {
- $this->event->attach($event_name, $listener);
- }
- }
-
- /**
- * Attach events for task creation
- *
- * @access public
- */
- public function attachCreateEvents()
- {
- $listener = new WebhookListener($this->container);
- $listener->setUrl($this->url_task_creation);
-
- $this->event->attach(Task::EVENT_CREATE, $listener);
- }
-
- /**
* Call the external URL
*
* @access public
@@ -123,6 +40,8 @@ class Webhook extends Base
*/
public function notify($url, array $task)
{
+ $token = $this->config->get('webhook_token');
+
$headers = array(
'Connection: close',
'User-Agent: '.self::HTTP_USER_AGENT,
@@ -140,10 +59,10 @@ class Webhook extends Base
));
if (strpos($url, '?') !== false) {
- $url .= '&token='.$this->token;
+ $url .= '&token='.$token;
}
else {
- $url .= '?token='.$this->token;
+ $url .= '?token='.$token;
}
@file_get_contents($url, false, $context);