Add 1.1 api version to handle other attachment types properly

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2021-01-04 15:27:48 +01:00
parent 8ab7019693
commit 199cccf86b
10 changed files with 232 additions and 142 deletions

View File

@@ -52,8 +52,13 @@ class AttachmentController extends Controller {
* @return \OCP\AppFramework\Http\Response
* @throws \OCA\Deck\NotFoundException
*/
public function display($attachmentId) {
return $this->attachmentService->display($attachmentId);
public function display($cardId, $attachmentId) {
if (strpos($attachmentId, ':') === false) {
$type = 'deck_file';
} else {
[$type, $attachmentId] = explode(':', $attachmentId);
}
return $this->attachmentService->display($cardId, $attachmentId, $type);
}
/**
@@ -70,21 +75,36 @@ class AttachmentController extends Controller {
/**
* @NoAdminRequired
*/
public function update($attachmentId) {
return $this->attachmentService->update($attachmentId, $this->request->getParam('data'));
public function update($cardId, $attachmentId) {
if (strpos($attachmentId, ':') === false) {
$type = 'deck_file';
} else {
[$type, $attachmentId] = explode(':', $attachmentId);
}
return $this->attachmentService->update($cardId, $attachmentId, $this->request->getParam('data'), $type);
}
/**
* @NoAdminRequired
*/
public function delete($attachmentId) {
return $this->attachmentService->delete($attachmentId);
public function delete($cardId, $attachmentId) {
if (strpos($attachmentId, ':') === false) {
$type = 'deck_file';
} else {
[$type, $attachmentId] = explode(':', $attachmentId);
}
return $this->attachmentService->delete($cardId, $attachmentId, $type);
}
/**
* @NoAdminRequired
*/
public function restore($attachmentId) {
return $this->attachmentService->restore($attachmentId);
public function restore($cardId, $attachmentId) {
if (strpos($attachmentId, ':') === false) {
$type = 'deck_file';
} else {
[$type, $attachmentId] = explode(':', $attachmentId);
}
return $this->attachmentService->restore($cardId, $attachmentId, $type);
}
}