|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2020 Julius Härtl <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @author Julius Härtl <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU AGPL version 3 or any later version |
|
8
|
|
|
* |
|
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
11
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
12
|
|
|
* License, or (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU Affero General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace OCA\Deck\Controller; |
|
25
|
|
|
|
|
26
|
|
|
use OCA\Deck\Service\CommentService; |
|
27
|
|
|
use OCA\Deck\StatusException; |
|
28
|
|
|
use OCP\AppFramework\ApiController; |
|
29
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
30
|
|
|
|
|
31
|
|
|
use OCP\IRequest; |
|
32
|
|
|
|
|
33
|
|
|
class CommentsApiController extends ApiController { |
|
34
|
|
|
|
|
35
|
|
|
/** @var CommentService */ |
|
36
|
|
|
private $commentService; |
|
37
|
|
|
|
|
38
|
|
|
public function __construct( |
|
39
|
|
|
$appName, IRequest $request, $corsMethods = 'PUT, POST, GET, DELETE, PATCH', $corsAllowedHeaders = 'Authorization, Content-Type, Accept', $corsMaxAge = 1728000, |
|
40
|
|
|
CommentService $commentService |
|
41
|
|
|
) { |
|
42
|
|
|
parent::__construct($appName, $request, $corsMethods, $corsAllowedHeaders, $corsMaxAge); |
|
43
|
|
|
$this->commentService = $commentService; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @NoAdminRequired |
|
48
|
|
|
* @NoCSRFRequired |
|
49
|
|
|
* @throws StatusException |
|
50
|
|
|
*/ |
|
51
|
|
|
public function list(string $cardId, int $limit = 20, int $offset = 0): DataResponse { |
|
52
|
|
|
return $this->commentService->list($cardId, $limit, $offset); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @NoAdminRequired |
|
57
|
|
|
* @NoCSRFRequired |
|
58
|
|
|
* @throws StatusException |
|
59
|
|
|
*/ |
|
60
|
|
|
public function create(string $cardId, string $message, string $parentId = '0'): DataResponse { |
|
61
|
|
|
return $this->commentService->create($cardId, $message, $parentId); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @NoAdminRequired |
|
66
|
|
|
* @NoCSRFRequired |
|
67
|
|
|
* @throws StatusException |
|
68
|
|
|
*/ |
|
69
|
|
|
public function update(string $cardId, string $commentId, string $message): DataResponse { |
|
70
|
|
|
return $this->commentService->update($cardId, $commentId, $message); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @NoAdminRequired |
|
75
|
|
|
* @NoCSRFRequired |
|
76
|
|
|
* @throws StatusException |
|
77
|
|
|
*/ |
|
78
|
|
|
public function delete(string $cardId, string $commentId): DataResponse { |
|
79
|
|
|
return $this->commentService->delete($cardId, $commentId); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|