From 21c50fb7fa80f004418972aa24e52225187f1ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Mon, 22 Sep 2014 14:34:30 +0200 Subject: [PATCH] Move task webhook to the controller webhook --- app/Controller/Task.php | 34 ---------------------------------- docs/webhooks.markdown | 6 +++--- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/app/Controller/Task.php b/app/Controller/Task.php index eddb61d51..7bb989c6a 100644 --- a/app/Controller/Task.php +++ b/app/Controller/Task.php @@ -12,40 +12,6 @@ use Model\Project as ProjectModel; */ class Task extends Base { - /** - * Webhook to create a task (useful for external software) - * - * @access public - */ - public function add() - { - $token = $this->request->getStringParam('token'); - - if ($this->config->get('webhooks_token') !== $token) { - $this->response->text('Not Authorized', 401); - } - - $defaultProject = $this->project->getFirst(); - - $values = array( - 'title' => $this->request->getStringParam('title'), - 'description' => $this->request->getStringParam('description'), - 'color_id' => $this->request->getStringParam('color_id'), - 'project_id' => $this->request->getIntegerParam('project_id', $defaultProject['id']), - 'owner_id' => $this->request->getIntegerParam('owner_id'), - 'column_id' => $this->request->getIntegerParam('column_id'), - 'category_id' => $this->request->getIntegerParam('category_id'), - ); - - list($valid,) = $this->taskValidator->validateCreation($values); - - if ($valid && $this->task->create($values)) { - $this->response->text('OK'); - } - - $this->response->text('FAILED'); - } - /** * Public access (display a task) * diff --git a/docs/webhooks.markdown b/docs/webhooks.markdown index 1d4617469..3a0801a64 100644 --- a/docs/webhooks.markdown +++ b/docs/webhooks.markdown @@ -13,10 +13,10 @@ Firstly, you have to get the token from the settings page. After that, just call ```bash # Create a task for the default project inside the first column -curl "http://myserver/?controller=task&action=add&token=superSecretToken&title=mySuperTask" +curl "http://myserver/?controller=webhook&action=task&token=superSecretToken&title=mySuperTask" # Create a task to another project inside a specific column with the color red -curl "http://myserver/?controller=task&action=add&token=superSecretToken&title=task123&project_id=3&column_id=7&color_id=red" +curl "http://myserver/?controller=webhook&action=task&token=superSecretToken&title=task123&project_id=3&column_id=7&color_id=red" ``` ### Available responses @@ -27,7 +27,7 @@ curl "http://myserver/?controller=task&action=add&token=superSecretToken&title=t ### Available parameters -Base URL: `http://YOUR_SERVER_HOSTNAME/?controller=task&action=add` +Base URL: `http://YOUR_SERVER_HOSTNAME/?controller=webhook&action=task` - `token`: Token displayed on the settings page (required) - `title`: Task title (required)