summaryrefslogtreecommitdiff
path: root/app/Controller/Webhook.php
blob: 6e172aeb5d038db05aab71f1728f4c62568b2598 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

namespace Kanboard\Controller;

/**
 * Webhook controller
 *
 * @package  controller
 * @author   Frederic Guillot
 */
class Webhook extends BaseController
{
    /**
     * Webhook to create a task
     *
     * @access public
     */
    public function task()
    {
        $this->checkWebhookToken();

        $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->taskCreation->create($values)) {
            return $this->response->text('OK');
        }

        return $this->response->text('FAILED');
    }
}