Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,25 @@
['name' => 'board_ocs#index', 'url' => '/api/v{apiVersion}/boards', 'verb' => 'GET'],
['name' => 'board_ocs#read', 'url' => '/api/v{apiVersion}/board/{boardId}', 'verb' => 'GET'],
['name' => 'stack_ocs#index', 'url' => '/api/v{apiVersion}/stacks/{boardId}', 'verb' => 'GET'],
['name' => 'stack_ocs#getArchived', 'url' => '/api/v{apiVersion}/stacks/{boardId}/archived', 'verb' => 'GET'],
['name' => 'board_ocs#create', 'url' => '/api/v{apiVersion}/boards', 'verb' => 'POST'],
['name' => 'board_ocs#createForTeam', 'url' => '/api/v{apiVersion}/boards/team', 'verb' => 'POST'],
['name' => 'board_ocs#update', 'url' => '/api/v{apiVersion}/boards/{boardId}', 'verb' => 'PUT'],
['name' => 'board_ocs#addAcl', 'url' => '/api/v{apiVersion}/boards/{boardId}/acl', 'verb' => 'POST'],
['name' => 'board_ocs#leave', 'url' => '/api/v{apiVersion}/boards/{boardId}/leave', 'verb' => 'POST'],

['name' => 'card_ocs#create', 'url' => '/api/v{apiVersion}/cards', 'verb' => 'POST'],
['name' => 'card_ocs#update', 'url' => '/api/v{apiVersion}/cards/{cardId}', 'verb' => 'PUT'],
['name' => 'card_ocs#delete', 'url' => '/api/v{apiVersion}/cards/{cardId}', 'verb' => 'DELETE'],
['name' => 'card_ocs#assignLabel', 'url' => '/api/v{apiVersion}/cards/{cardId}/label/{labelId}', 'verb' => 'POST'],
['name' => 'card_ocs#assignUser', 'url' => '/api/v{apiVersion}/cards/{cardId}/assign', 'verb' => 'POST'],
['name' => 'card_ocs#unAssignUser', 'url' => '/api/v{apiVersion}/cards/{cardId}/unassign', 'verb' => 'PUT'],
['name' => 'card_ocs#removeLabel', 'url' => '/api/v{apiVersion}/cards/{cardId}/label/{labelId}', 'verb' => 'DELETE'],
['name' => 'card_ocs#reorder', 'url' => '/api/v{apiVersion}/cards/{cardId}/reorder', 'verb' => 'PUT'],
['name' => 'card_ocs#archive', 'url' => '/api/v{apiVersion}/cards/{cardId}/archive', 'verb' => 'PUT'],
['name' => 'card_ocs#unarchive', 'url' => '/api/v{apiVersion}/cards/{cardId}/unarchive', 'verb' => 'PUT'],
['name' => 'card_ocs#done', 'url' => '/api/v{apiVersion}/cards/{cardId}/done', 'verb' => 'PUT'],
['name' => 'card_ocs#undone', 'url' => '/api/v{apiVersion}/cards/{cardId}/undone', 'verb' => 'PUT'],
['name' => 'card_ocs#assignDependentCard', 'url' => '/api/v{apiVersion}/cards/{cardId}/dependentCards/{dependentCardId}', 'verb' => 'POST'],
['name' => 'card_ocs#removeDependentCard', 'url' => '/api/v{apiVersion}/cards/{cardId}/dependentCards/{dependentCardId}', 'verb' => 'DELETE'],

Expand All @@ -161,6 +169,8 @@

['name' => 'attachment_ocs#getAll', 'url' => '/api/v{apiVersion}/cards/{cardId}/attachments', 'verb' => 'GET'],
['name' => 'attachment_ocs#create', 'url' => '/api/v{apiVersion}/cards/{cardId}/attachment', 'verb' => 'POST'],
['name' => 'attachment_ocs#createRemote', 'url' => '/api/v{apiVersion}/cards/{cardId}/remote-attachment', 'verb' => 'POST'],
['name' => 'attachment_ocs#shareRemote', 'url' => '/api/v{apiVersion}/cards/{cardId}/share-attachment', 'verb' => 'POST'],
['name' => 'attachment_ocs#update', 'url' => '/api/v{apiVersion}/cards/{cardId}/attachments/{attachmentId}', 'verb' => 'PUT'],
['name' => 'attachment_ocs#delete', 'url' => '/api/v{apiVersion}/cards/{cardId}/attachments/{type}:{attachmentId}', 'verb' => 'DELETE'],
['name' => 'attachment_ocs#restore', 'url' => '/api/v{apiVersion}/cards/{cardId}/attachments/{attachmentId}/restore', 'verb' => 'PUT'],
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/boardFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ describe('Board title editing', function() {
cy.login(user)
cy.visit(`/apps/deck/board/${board.id}`)

cy.intercept({ method: 'PUT', url: `**/apps/deck/boards/${board.id}` }).as('updateBoard')
cy.intercept({ method: 'PUT', url: `**/apps/deck/api/v1.0/boards/${board.id}` }).as('updateBoard')

cy.get(`.app-navigation__list .app-navigation-entry:contains("${originalTitle}")`)
.parent()
Expand Down Expand Up @@ -221,7 +221,7 @@ describe('Board title editing', function() {
cy.login(user)
cy.visit(`/apps/deck/board/${boardA.id}`)

cy.intercept({ method: 'PUT', url: `**/apps/deck/boards/${boardB.id}` }).as('updateBoardOther')
cy.intercept({ method: 'PUT', url: `**/apps/deck/api/v1.0/boards/${boardB.id}` }).as('updateBoardOther')

cy.get('.board-title h2').should('contain', boardATitle)

Expand Down
38 changes: 35 additions & 3 deletions lib/Controller/AttachmentOcsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@

namespace OCA\Deck\Controller;

use OCA\Deck\BadRequestException;
use OCA\Deck\NotImplementedException;
use OCA\Deck\Service\AttachmentService;
use OCA\Deck\Service\BoardService;
use OCA\Deck\Service\ExternalBoardService;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
Expand All @@ -23,6 +26,7 @@ public function __construct(
IRequest $request,
private AttachmentService $attachmentService,
private BoardService $boardService,
private ExternalBoardService $externalBoardService,
) {
parent::__construct($appName, $request);
}
Expand All @@ -37,19 +41,43 @@ private function ensureLocalBoard(?int $boardId): void {
}

#[NoAdminRequired]
#[PublicPage]
public function getAll(int $cardId, ?int $boardId = null): DataResponse {
$this->ensureLocalBoard($boardId);
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->getAttachmentsFromRemote($board, $cardId));
}
$attachment = $this->attachmentService->findAll($cardId, true);
return new DataResponse($attachment);
}

#[NoAdminRequired]
public function create(int $cardId, string $type, string $data = '', ?int $boardId = null): DataResponse {
$this->ensureLocalBoard($boardId);
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->createAttachmentForRemote($board, $cardId));
}
$attachment = $this->attachmentService->create($cardId, $type, $data);
return new DataResponse($attachment);
}

#[NoAdminRequired]
#[PublicPage]
public function createRemote(int $cardId, string $token): DataResponse {
$this->attachmentService->acceptRemoteAttachment($cardId, $token);
return new DataResponse([]);
}

#[NoAdminRequired]
public function shareRemote(int $cardId, int $boardId, string $path): DataResponse {
$board = $this->boardService->find($boardId, false);
if (!$board->getExternalId()) {
throw new BadRequestException('board is not federated');
}
$token = $this->externalBoardService->shareAttachmentForRemote($board, $cardId, $path);
return new DataResponse(['token' => $token]);
}

#[NoAdminRequired]
public function update(int $cardId, int $attachmentId, string $data, string $type = 'file', ?int $boardId = null): DataResponse {
$this->ensureLocalBoard($boardId);
Expand All @@ -58,8 +86,12 @@ public function update(int $cardId, int $attachmentId, string $data, string $typ
}

#[NoAdminRequired]
#[PublicPage]
public function delete(int $cardId, int $attachmentId, string $type = 'file', ?int $boardId = null): DataResponse {
$this->ensureLocalBoard($boardId);
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->deleteAttachmentOnRemote($board, $cardId, $attachmentId, $type));
}
$attachment = $this->attachmentService->delete($cardId, $attachmentId, $type);
return new DataResponse($attachment);
}
Expand Down
7 changes: 6 additions & 1 deletion lib/Controller/BoardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ public function deleteUndo(int $boardId): Board {

#[NoAdminRequired]
public function leave(int $boardId) {
return $this->boardService->leave($boardId);
$localBoard = $this->boardService->find($boardId, true, true);
$result = $this->boardService->leave($boardId);
if ($localBoard->getExternalId() !== null) {
$this->externalBoardService->leaveBoardOnRemote($localBoard);
}
return $result;
}

#[NoAdminRequired]
Expand Down
18 changes: 18 additions & 0 deletions lib/Controller/BoardOcsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ public function createForTeam(string $title, string $teamId, ?string $color = nu
return new DataResponse($this->boardService->createForTeam($title, $this->userId, $color, $teamId));
}

#[NoAdminRequired]
#[PublicPage]
public function update(int $boardId, string $title, string $color, bool $archived): DataResponse {
$updatedBoard = $this->boardService->update($boardId, $title, $color, $archived);

if ($updatedBoard->getExternalId()) {
return $this->externalBoardService->updateBoardOnRemote($updatedBoard, $title, $color, $archived);
}

return new DataResponse($updatedBoard);
}

#[NoAdminRequired]
public function addAcl(int $boardId, int $type, string $participant, bool $permissionEdit, bool $permissionShare, bool $permissionManage, ?string $remote = null): DataResponse {
return new DataResponse($this->boardService->addAcl($boardId, $type, $participant, $permissionEdit, $permissionShare, $permissionManage));
Expand All @@ -66,4 +78,10 @@ public function addAcl(int $boardId, int $type, string $participant, bool $permi
public function updateAcl(int $id, bool $permissionEdit, bool $permissionShare, bool $permissionManage): DataResponse {
return new DataResponse($this->boardService->updateAcl($id, $permissionEdit, $permissionShare, $permissionManage));
}

#[NoAdminRequired]
#[PublicPage]
public function leave(int $boardId): DataResponse {
return new DataResponse($this->boardService->leave($boardId));
}
}
66 changes: 64 additions & 2 deletions lib/Controller/CardOcsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function removeLabel(?int $boardId, int $cardId, int $labelId): DataRespo

#[NoAdminRequired]
#[PublicPage]
public function update(int $id, string $title, int $stackId, string $type, int $order, string $description, $duedate, $deletedAt, ?int $boardId, array|string|null $owner = null, $archived = null, $startdate = null): DataResponse {
public function update(int $id, string $title, int $stackId, string $type, int $order, string $description, $duedate, $deletedAt, int $boardId, array|string|null $owner = null, $archived = null, $startdate = null): DataResponse {
$done = array_key_exists('done', $this->request->getParams())
? new OptionalNullableValue($this->request->getParam('done', null))
: null;
Expand Down Expand Up @@ -150,7 +150,9 @@ public function update(int $id, string $title, int $stackId, string $type, int $
$duedate,
$deletedAt,
$archived,
$done
$done,
$startdate,
$color,
));
}
}
Expand All @@ -171,6 +173,18 @@ public function update(int $id, string $title, int $stackId, string $type, int $
));
}

#[NoAdminRequired]
#[PublicPage]
public function delete(int $cardId, ?int $boardId = null): DataResponse {
if ($boardId) {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->deleteCardOnRemote($board, $cardId));
}
}
return new DataResponse($this->cardService->delete($cardId));
}

#[NoAdminRequired]
#[PublicPage]
public function reorder(int $cardId, int $stackId, int $order, ?int $boardId): DataResponse {
Expand All @@ -183,6 +197,30 @@ public function reorder(int $cardId, int $stackId, int $order, ?int $boardId): D
return new DataResponse($this->cardService->reorder($cardId, $stackId, $order));
}

#[NoAdminRequired]
#[PublicPage]
public function archive(int $cardId, int $boardId): DataResponse {
if ($boardId) {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->archiveCardOnRemote($board, $cardId));
}
}
return new DataResponse($this->cardService->archive($cardId));
}

#[NoAdminRequired]
#[PublicPage]
public function unarchive(int $cardId, int $boardId): DataResponse {
if ($boardId) {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->unarchiveCardOnRemote($board, $cardId));
}
}
return new DataResponse($this->cardService->unarchive($cardId));
}

#[NoAdminRequired]
#[PublicPage]
public function assignDependentCard(int $cardId, int $dependentCardId, ?int $boardId = null): DataResponse {
Expand All @@ -206,4 +244,28 @@ public function removeDependentCard(int $cardId, int $dependentCardId, ?int $boa
}
return new DataResponse($this->cardService->removeDependentCard($cardId, $dependentCardId));
}

#[NoAdminRequired]
#[PublicPage]
public function done(int $cardId, ?int $boardId): DataResponse {
if ($boardId) {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->setDoneCardOnRemote($board, $cardId));
}
}
return new DataResponse($this->cardService->done($cardId));
}

#[NoAdminRequired]
#[PublicPage]
public function undone(int $cardId, ?int $boardId): DataResponse {
if ($boardId) {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->setUndoneCardOnRemote($board, $cardId));
}
}
return new DataResponse($this->cardService->undone($cardId));
}
}
43 changes: 39 additions & 4 deletions lib/Controller/CommentsApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@

namespace OCA\Deck\Controller;

use OCA\Deck\Service\BoardService;
use OCA\Deck\Service\CommentService;
use OCA\Deck\Service\ExternalBoardService;
use OCA\Deck\StatusException;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
Expand All @@ -22,6 +25,9 @@ public function __construct(
string $appName,
IRequest $request,
private CommentService $commentService,
private BoardService $boardService,
private ExternalBoardService $externalBoardService,
private ?string $userId,
string $corsMethods = 'PUT, POST, GET, DELETE, PATCH',
string $corsAllowedHeaders = 'Authorization, Content-Type, Accept',
int $corsMaxAge = 1728000,
Expand All @@ -33,31 +39,60 @@ public function __construct(
* @throws StatusException
*/
#[NoAdminRequired]
public function list(int $cardId, int $limit = 20, int $offset = 0): DataResponse {
#[PublicPage]
public function list(int $cardId, int $limit = 20, int $offset = 0, ?int $boardId = null): DataResponse {
if ($boardId) {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->getCardCommentsFromRemote($board, $cardId, $limit, $offset));
}
}
return $this->commentService->list($cardId, $limit, $offset);
}

/**
* @throws StatusException
*/
#[NoAdminRequired]
public function create(int $cardId, string $message, int $parentId = 0): DataResponse {
#[PublicPage]
public function create(int $cardId, string $message, int $parentId = 0, ?int $boardId = null): DataResponse {
if ($boardId) {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->createCardCommentOnRemote($board, $cardId, $message, $parentId));
}
}

return $this->commentService->create($cardId, $message, $parentId);
}

/**
* @throws StatusException
*/
#[NoAdminRequired]
public function update(int $cardId, int $commentId, string $message): DataResponse {
#[PublicPage]
public function update(int $cardId, int $commentId, string $message, ?int $boardId = null): DataResponse {
if ($boardId) {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->updateCardCommentOnRemote($board, $cardId, $commentId, $message));
}
}
return $this->commentService->update($cardId, $commentId, $message);
}

/**
* @throws StatusException
*/
#[NoAdminRequired]
public function delete(int $cardId, int $commentId): DataResponse {
#[PublicPage]
public function delete(int $cardId, int $commentId, ?int $boardId = null): DataResponse {
if ($boardId) {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
return new DataResponse($this->externalBoardService->deleteCardCommentOnRemote($board, $cardId, $commentId));
}
}
return $this->commentService->delete($cardId, $commentId);
}
}
14 changes: 13 additions & 1 deletion lib/Controller/StackOcsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function create(string $title, int $boardId, int $order = 0):DataResponse
} else {
$stack = $this->stackService->create($title, $boardId, $order);
return new DataResponse($stack);
};
}
}

#[NoAdminRequired]
Expand Down Expand Up @@ -91,4 +91,16 @@ public function reorder(int $stackId, int $order, ?int $boardId):DataResponse {
return new DataResponse($stacks);
}

#[NoAdminRequired]
#[PublicPage]
public function getArchived(int $boardId): DataResponse {
$board = $this->boardService->find($boardId, false);
if ($board->getExternalId()) {
$stacks = $this->externalBoardService->getArchivedStacksFromRemote($board);
return new DataResponse($stacks);
}
$stacks = $this->stackService->findAllArchived($boardId);
return new DataResponse($stacks);
}

}
Loading
Loading