Move to OCS routes for new comments api
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -122,11 +122,14 @@ return [
|
|||||||
['name' => 'attachment_api#delete', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/attachments/{attachmentId}', 'verb' => 'DELETE'],
|
['name' => 'attachment_api#delete', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/attachments/{attachmentId}', 'verb' => 'DELETE'],
|
||||||
['name' => 'attachment_api#restore', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/attachments/{attachmentId}/restore', 'verb' => 'PUT'],
|
['name' => 'attachment_api#restore', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/attachments/{attachmentId}/restore', 'verb' => 'PUT'],
|
||||||
|
|
||||||
['name' => 'comments_api#list', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/comments', 'verb' => 'GET'],
|
|
||||||
['name' => 'comments_api#create', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/comments', 'verb' => 'POST'],
|
|
||||||
['name' => 'comments_api#update', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/comments/{commentId}', 'verb' => 'PUT'],
|
|
||||||
['name' => 'comments_api#delete', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}/cards/{cardId}/comments/{commentId}', 'verb' => 'DELETE'],
|
|
||||||
|
|
||||||
['name' => 'board_api#preflighted_cors', 'url' => '/api/v1.0/{path}','verb' => 'OPTIONS', 'requirements' => ['path' => '.+']],
|
['name' => 'board_api#preflighted_cors', 'url' => '/api/v1.0/{path}','verb' => 'OPTIONS', 'requirements' => ['path' => '.+']],
|
||||||
|
],
|
||||||
|
'ocs' => [
|
||||||
|
['name' => 'comments_api#list', 'url' => '/api/v1.0/cards/{cardId}/comments', 'verb' => 'GET'],
|
||||||
|
['name' => 'comments_api#create', 'url' => '/api/v1.0/cards/{cardId}/comments', 'verb' => 'POST'],
|
||||||
|
['name' => 'comments_api#update', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'PUT'],
|
||||||
|
['name' => 'comments_api#delete', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'DELETE'],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -23,14 +23,17 @@
|
|||||||
|
|
||||||
namespace OCA\Deck\Controller;
|
namespace OCA\Deck\Controller;
|
||||||
|
|
||||||
|
use OCA\Deck\BadRequestException;
|
||||||
use OCA\Deck\Service\CommentService;
|
use OCA\Deck\Service\CommentService;
|
||||||
use OCA\Deck\StatusException;
|
use OCA\Deck\StatusException;
|
||||||
use OCP\AppFramework\ApiController;
|
use OCP\AppFramework\ApiController;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
|
|
||||||
|
use OCP\AppFramework\OCS\OCSException;
|
||||||
|
use OCP\AppFramework\OCSController;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
|
||||||
class CommentsApiController extends ApiController {
|
class CommentsApiController extends OCSController {
|
||||||
|
|
||||||
/** @var CommentService */
|
/** @var CommentService */
|
||||||
private $commentService;
|
private $commentService;
|
||||||
@@ -45,7 +48,6 @@ class CommentsApiController extends ApiController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
|
||||||
* @throws StatusException
|
* @throws StatusException
|
||||||
*/
|
*/
|
||||||
public function list(string $cardId, int $limit = 20, int $offset = 0): DataResponse {
|
public function list(string $cardId, int $limit = 20, int $offset = 0): DataResponse {
|
||||||
@@ -54,7 +56,6 @@ class CommentsApiController extends ApiController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
|
||||||
* @throws StatusException
|
* @throws StatusException
|
||||||
*/
|
*/
|
||||||
public function create(string $cardId, string $message, string $parentId = '0'): DataResponse {
|
public function create(string $cardId, string $message, string $parentId = '0'): DataResponse {
|
||||||
@@ -63,7 +64,6 @@ class CommentsApiController extends ApiController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
|
||||||
* @throws StatusException
|
* @throws StatusException
|
||||||
*/
|
*/
|
||||||
public function update(string $cardId, string $commentId, string $message): DataResponse {
|
public function update(string $cardId, string $commentId, string $message): DataResponse {
|
||||||
@@ -72,7 +72,6 @@ class CommentsApiController extends ApiController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
|
||||||
* @throws StatusException
|
* @throws StatusException
|
||||||
*/
|
*/
|
||||||
public function delete(string $cardId, string $commentId): DataResponse {
|
public function delete(string $cardId, string $commentId): DataResponse {
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ use OCA\Deck\StatusException;
|
|||||||
use OCP\AppFramework\Db\DoesNotExistException;
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
use OCP\AppFramework\Middleware;
|
use OCP\AppFramework\Middleware;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
use OCP\AppFramework\OCS\OCSException;
|
||||||
|
use OCP\AppFramework\OCSController;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
use OCP\Util;
|
use OCP\Util;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
@@ -65,6 +67,11 @@ class ExceptionMiddleware extends Middleware {
|
|||||||
if ($this->config->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) {
|
if ($this->config->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) {
|
||||||
$this->logger->logException($exception);
|
$this->logger->logException($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($controller instanceof OCSController) {
|
||||||
|
$exception = new OCSException($exception->getMessage(), $exception->getStatus(), $exception);
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
return new JSONResponse([
|
return new JSONResponse([
|
||||||
'status' => $exception->getStatus(),
|
'status' => $exception->getStatus(),
|
||||||
'message' => $exception->getMessage()
|
'message' => $exception->getMessage()
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ class CommentService {
|
|||||||
'actorId' => $comment->getActorId(),
|
'actorId' => $comment->getActorId(),
|
||||||
'actorType' => $comment->getActorType(),
|
'actorType' => $comment->getActorType(),
|
||||||
'actorDisplayName' => $actorDisplayName,
|
'actorDisplayName' => $actorDisplayName,
|
||||||
|
'creationDateTime' => $comment->getCreationDateTime()->format(\DateTime::ATOM),
|
||||||
'mentions' => array_map(function($mention) {
|
'mentions' => array_map(function($mention) {
|
||||||
try {
|
try {
|
||||||
$displayName = $this->commentsManager->resolveDisplayName($mention['type'], $mention['id']);
|
$displayName = $this->commentsManager->resolveDisplayName($mention['type'], $mention['id']);
|
||||||
|
|||||||
Reference in New Issue
Block a user