@@ -53,8 +53,7 @@ class Capabilities implements ICapability {
|
||||
'canCreateBoards' => $this->permissionService->canCreate(),
|
||||
'apiVersions' => [
|
||||
'1.0',
|
||||
'1.1',
|
||||
'1.2'
|
||||
'1.1'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
@@ -27,16 +27,13 @@ use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\IRequest;
|
||||
use OCA\Deck\Service\AttachmentService;
|
||||
use OCA\Deck\Db\AttachmentMapper;
|
||||
|
||||
class AttachmentApiController extends ApiController {
|
||||
private $attachmentService;
|
||||
private $attachmentMapper;
|
||||
|
||||
public function __construct($appName, IRequest $request, AttachmentService $attachmentService, AttachmentMapper $attachmentMapper) {
|
||||
public function __construct($appName, IRequest $request, AttachmentService $attachmentService) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->attachmentService = $attachmentService;
|
||||
$this->attachmentMapper = $attachmentMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,13 +49,6 @@ class AttachmentApiController extends ApiController {
|
||||
return $attachment->getType() === 'deck_file';
|
||||
});
|
||||
}
|
||||
|
||||
if ($apiVersion === '1.2') {
|
||||
foreach ($attachment as &$attachment) {
|
||||
$this->attachmentMapper->mapOwner($attachment);
|
||||
}
|
||||
}
|
||||
|
||||
return new DataResponse($attachment, HTTP::STATUS_OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,31 +26,22 @@ namespace OCA\Deck\Controller;
|
||||
use OCA\Deck\Service\AttachmentService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\IRequest;
|
||||
use OCA\Deck\Db\AttachmentMapper;
|
||||
|
||||
class AttachmentController extends Controller {
|
||||
|
||||
/** @var AttachmentService */
|
||||
private $attachmentService;
|
||||
private $attachmentMapper;
|
||||
|
||||
public function __construct($appName, IRequest $request, AttachmentService $attachmentService, AttachmentMapper $attachmentMapper) {
|
||||
public function __construct($appName, IRequest $request, AttachmentService $attachmentService) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->attachmentService = $attachmentService;
|
||||
$this->attachmentMapper = $attachmentMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getAll($cardId) {
|
||||
$attachments = $this->attachmentService->findAll($cardId, true);
|
||||
|
||||
foreach ($attachments as &$attachment) {
|
||||
$this->attachmentMapper->mapOwner($attachment);
|
||||
}
|
||||
|
||||
return $attachments;
|
||||
return $this->attachmentService->findAll($cardId, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -156,14 +156,4 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
|
||||
}
|
||||
return $this->cardMapper->findBoardId($attachment->getCardId());
|
||||
}
|
||||
|
||||
public function mapOwner(Attachment &$attachment) {
|
||||
$attachment->resolveRelation('createdBy', function ($userId) {
|
||||
$user = $this->userManager->get($userId);
|
||||
if ($user !== null) {
|
||||
return new User($user);
|
||||
}
|
||||
return $user;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ class AttachmentService {
|
||||
private $activityManager;
|
||||
/** @var ChangeHelper */
|
||||
private $changeHelper;
|
||||
/** @var IUserManager */
|
||||
private IUserManager $userManager;
|
||||
/** @var AttachmentServiceValidator */
|
||||
private AttachmentServiceValidator $attachmentServiceValidator;
|
||||
@@ -71,6 +72,7 @@ class AttachmentService {
|
||||
ChangeHelper $changeHelper,
|
||||
PermissionService $permissionService,
|
||||
Application $application,
|
||||
ICacheFactory $cacheFactory,
|
||||
AttachmentCacheHelper $attachmentCacheHelper,
|
||||
$userId,
|
||||
IL10N $l10n,
|
||||
|
||||
Reference in New Issue
Block a user