fix: merge conflicts

Signed-off-by: Luka Trovic <luka@nextcloud.com>
This commit is contained in:
Luka Trovic
2022-12-20 21:41:47 +01:00
parent 21c4955001
commit be27d3ed01
5 changed files with 6 additions and 34 deletions

View File

@@ -53,8 +53,7 @@ class Capabilities implements ICapability {
'canCreateBoards' => $this->permissionService->canCreate(), 'canCreateBoards' => $this->permissionService->canCreate(),
'apiVersions' => [ 'apiVersions' => [
'1.0', '1.0',
'1.1', '1.1'
'1.2'
] ]
] ]
]; ];

View File

@@ -27,16 +27,13 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest; use OCP\IRequest;
use OCA\Deck\Service\AttachmentService; use OCA\Deck\Service\AttachmentService;
use OCA\Deck\Db\AttachmentMapper;
class AttachmentApiController extends ApiController { class AttachmentApiController extends ApiController {
private $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); parent::__construct($appName, $request);
$this->attachmentService = $attachmentService; $this->attachmentService = $attachmentService;
$this->attachmentMapper = $attachmentMapper;
} }
/** /**
@@ -52,13 +49,6 @@ class AttachmentApiController extends ApiController {
return $attachment->getType() === 'deck_file'; return $attachment->getType() === 'deck_file';
}); });
} }
if ($apiVersion === '1.2') {
foreach ($attachment as &$attachment) {
$this->attachmentMapper->mapOwner($attachment);
}
}
return new DataResponse($attachment, HTTP::STATUS_OK); return new DataResponse($attachment, HTTP::STATUS_OK);
} }

View File

@@ -26,31 +26,22 @@ namespace OCA\Deck\Controller;
use OCA\Deck\Service\AttachmentService; use OCA\Deck\Service\AttachmentService;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\IRequest; use OCP\IRequest;
use OCA\Deck\Db\AttachmentMapper;
class AttachmentController extends Controller { class AttachmentController extends Controller {
/** @var AttachmentService */ /** @var AttachmentService */
private $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); parent::__construct($appName, $request);
$this->attachmentService = $attachmentService; $this->attachmentService = $attachmentService;
$this->attachmentMapper = $attachmentMapper;
} }
/** /**
* @NoAdminRequired * @NoAdminRequired
*/ */
public function getAll($cardId) { public function getAll($cardId) {
$attachments = $this->attachmentService->findAll($cardId, true); return $this->attachmentService->findAll($cardId, true);
foreach ($attachments as &$attachment) {
$this->attachmentMapper->mapOwner($attachment);
}
return $attachments;
} }
/** /**

View File

@@ -156,14 +156,4 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
} }
return $this->cardMapper->findBoardId($attachment->getCardId()); 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;
});
}
} }

View File

@@ -60,6 +60,7 @@ class AttachmentService {
private $activityManager; private $activityManager;
/** @var ChangeHelper */ /** @var ChangeHelper */
private $changeHelper; private $changeHelper;
/** @var IUserManager */
private IUserManager $userManager; private IUserManager $userManager;
/** @var AttachmentServiceValidator */ /** @var AttachmentServiceValidator */
private AttachmentServiceValidator $attachmentServiceValidator; private AttachmentServiceValidator $attachmentServiceValidator;
@@ -71,6 +72,7 @@ class AttachmentService {
ChangeHelper $changeHelper, ChangeHelper $changeHelper,
PermissionService $permissionService, PermissionService $permissionService,
Application $application, Application $application,
ICacheFactory $cacheFactory,
AttachmentCacheHelper $attachmentCacheHelper, AttachmentCacheHelper $attachmentCacheHelper,
$userId, $userId,
IL10N $l10n, IL10N $l10n,