This commit is contained in:
Yuri Kuznetsov
2024-05-04 13:37:44 +03:00
parent d2e90f7853
commit da27b68312
15 changed files with 54 additions and 50 deletions
+4 -4
View File
@@ -55,7 +55,7 @@ class Attachment implements EntryPoint
$id = $request->getQueryParam('id');
if (!$id) {
throw new BadRequest();
throw new BadRequest("No id.");
}
$attachment = $this->entityManager
@@ -63,15 +63,15 @@ class Attachment implements EntryPoint
->getById($id);
if (!$attachment) {
throw new NotFound();
throw new NotFound("Attachment not found.");
}
if (!$this->acl->checkEntity($attachment)) {
throw new Forbidden();
throw new Forbidden("No access to attachment.");
}
if (!$this->fileStorageManager->exists($attachment)) {
throw new NotFound();
throw new NotFound("File not found.");
}
$fileType = $attachment->getType();
@@ -54,7 +54,7 @@ class ChangePassword implements EntryPoint
$requestId = $request->getQueryParam('id');
if (!$requestId) {
throw new BadRequest();
throw new BadRequest("No request ID.");
}
$passwordChangeRequest = $this->entityManager
@@ -65,7 +65,7 @@ class ConfirmOptIn implements EntryPoint
$id = $request->getQueryParam('id');
if (!$id) {
throw new BadRequest();
throw new BadRequest("No id.");
}
$result = $this->service->confirmOptIn($id);
+4 -4
View File
@@ -55,22 +55,22 @@ class Download implements EntryPoint
$id = $request->getQueryParam('id');
if (!$id) {
throw new BadRequest();
throw new BadRequest("No id.");
}
/** @var ?AttachmentEntity $attachment */
$attachment = $this->entityManager->getEntityById(AttachmentEntity::ENTITY_TYPE, $id);
if (!$attachment) {
throw new NotFoundSilent();
throw new NotFoundSilent("Attachment not found.");
}
if (!$this->acl->checkEntity($attachment)) {
throw new Forbidden();
throw new Forbidden("No access to attachment.");
}
if ($attachment->isBeingUploaded()) {
throw new Forbidden();
throw new Forbidden("Attachment is being uploaded.");
}
$stream = $this->fileStorageManager->getStream($attachment);
+5 -5
View File
@@ -72,7 +72,7 @@ class Image implements EntryPoint
$size = $request->getQueryParam('size') ?? null;
if (!$id) {
throw new BadRequest();
throw new BadRequest("No id.");
}
$this->show($response, $id, $size);
@@ -90,7 +90,7 @@ class Image implements EntryPoint
$attachment = $this->entityManager->getEntityById(Attachment::ENTITY_TYPE, $id);
if (!$attachment) {
throw new NotFoundSilent();
throw new NotFoundSilent("Attachment not found.");
}
if (!$disableAccessCheck && !$this->acl->checkEntity($attachment)) {
@@ -105,13 +105,13 @@ class Image implements EntryPoint
if ($this->allowedRelatedTypeList) {
if (!in_array($attachment->getRelatedType(), $this->allowedRelatedTypeList)) {
throw new NotFoundSilent();
throw new NotFoundSilent("Not allowed related type.");
}
}
if ($this->allowedFieldList) {
if (!in_array($attachment->getTargetField(), $this->allowedFieldList)) {
throw new NotFoundSilent();
throw new NotFoundSilent("Not allowed field.");
}
}
@@ -175,7 +175,7 @@ class Image implements EntryPoint
$filePath = $this->getAttachmentRepository()->getFilePath($attachment);
if (!$this->fileManager->isFile($filePath)) {
throw new NotFound();
throw new NotFound("File not found.");
}
$fileType = $attachment->getType() ?? '';
+1 -1
View File
@@ -51,7 +51,7 @@ class LogoImage extends Image
}
if (!$id) {
throw new NotFound();
throw new NotFound("No id.");
}
$this->show($response, $id, $size);
+7 -3
View File
@@ -57,15 +57,19 @@ class Pdf implements EntryPoint
$templateId = $request->getQueryParam('templateId');
if (!$entityId || !$entityType || !$templateId) {
throw new BadRequest();
throw new BadRequest("No entityId or entityType or templateId.");
}
$entity = $this->entityManager->getEntityById($entityType, $entityId);
/** @var ?Template $template */
$template = $this->entityManager->getEntityById(Template::ENTITY_TYPE, $templateId);
if (!$entity || !$template) {
throw new NotFound();
if (!$entity) {
throw new NotFound("Record not found.");
}
if (!$template) {
throw new NotFound("Template not found.");
}
$contents = $this->service->generate($entityType, $entityId, $templateId);
@@ -82,7 +82,7 @@ class Call extends Record
$id = $request->getParsedBody()->id ?? null;
if (!$id) {
throw new BadRequest();
throw new BadRequest("No id.");
}
$invitees = $this->fetchInvitees($request);
@@ -108,21 +108,21 @@ class Call extends Record
}
if (!is_array($targets)) {
throw new BadRequest();
throw new BadRequest("No targets.");
}
$invitees = [];
foreach ($targets as $target) {
if (!$target instanceof stdClass) {
throw new BadRequest();
throw new BadRequest("Bad target.");
}
$targetEntityType = $target->entityType ?? null;
$targetId = $target->id ?? null;
if (!is_string($targetEntityType) || !is_string($targetId)) {
throw new BadRequest();
throw new BadRequest("No entityType or id.");
}
$invitees[] = new Invitee($targetEntityType, $targetId);
@@ -179,7 +179,7 @@ class Call extends Record
$data = $request->getParsedBody();
if (empty($data->id) || empty($data->status)) {
throw new BadRequest();
throw new BadRequest("No id or status.");
}
$this->injectableFactory
@@ -199,7 +199,7 @@ class Call extends Record
$id = $request->getRouteParam('id');
if (!$id) {
throw new BadRequest();
throw new BadRequest("No id.");
}
$collection = $this->injectableFactory
@@ -61,7 +61,7 @@ class Meeting extends Record
$id = $request->getParsedBody()->id ?? null;
if (!$id) {
throw new BadRequest();
throw new BadRequest("No id.");
}
$invitees = $this->fetchInvitees($request);
@@ -85,7 +85,7 @@ class Meeting extends Record
$id = $request->getParsedBody()->id ?? null;
if (!$id) {
throw new BadRequest();
throw new BadRequest("No id.");
}
$invitees = $this->fetchInvitees($request);
@@ -111,21 +111,21 @@ class Meeting extends Record
}
if (!is_array($targets)) {
throw new BadRequest();
throw new BadRequest("No targets.");
}
$invitees = [];
foreach ($targets as $target) {
if (!$target instanceof stdClass) {
throw new BadRequest();
throw new BadRequest("Bad target.");
}
$targetEntityType = $target->entityType ?? null;
$targetId = $target->id ?? null;
if (!is_string($targetEntityType) || !is_string($targetId)) {
throw new BadRequest();
throw new BadRequest("No entityType or id.");
}
$invitees[] = new Invitee($targetEntityType, $targetId);
@@ -182,7 +182,7 @@ class Meeting extends Record
$data = $request->getParsedBody();
if (empty($data->id) || empty($data->status)) {
throw new BadRequest();
throw new BadRequest("No id or status.");
}
$this->injectableFactory
@@ -202,7 +202,7 @@ class Meeting extends Record
$id = $request->getRouteParam('id');
if (!$id) {
throw new BadRequest();
throw new BadRequest("No id.");
}
$collection = $this->injectableFactory
@@ -59,16 +59,16 @@ class CampaignTrackOpened implements EntryPoint
$id = $request->getQueryParam('id');
if (!$id || !is_string($id)) {
throw new BadRequest();
throw new BadRequest("No id.");
}
$queueItemId = $id;
/** @var ?EmailQueueItem $queueItem */
$queueItem = $this->entityManager->getEntity(EmailQueueItem::ENTITY_TYPE, $queueItemId);
$queueItem = $this->entityManager->getEntityById(EmailQueueItem::ENTITY_TYPE, $queueItemId);
if (!$queueItem) {
throw new NotFound();
throw new NotFound("Item not found.");
}
$targetType = $queueItem->getTargetType();
@@ -73,14 +73,14 @@ class CampaignUrl implements EntryPoint
$uid = $request->getQueryParam('uid') ?? null;
if (!$trackingUrlId || !is_string($trackingUrlId)) {
throw new BadRequest();
throw new BadRequest("No tracking URL ID.");
}
/** @var ?CampaignTrackingUrl $trackingUrl */
$trackingUrl = $this->entityManager->getEntityById(CampaignTrackingUrl::ENTITY_TYPE, $trackingUrlId);
if (!$trackingUrl) {
throw new NotFoundSilent("Tracking URL '{$trackingUrlId}' not found.");
throw new NotFoundSilent("Tracking URL '$trackingUrlId' not found.");
}
if ($emailAddress && $hash) {
@@ -91,14 +91,14 @@ class CampaignUrl implements EntryPoint
}
else {
if (!$queueItemId || !is_string($queueItemId)) {
throw new BadRequest();
throw new BadRequest("No item ID.");
}
/** @var ?EmailQueueItem $queueItem */
$queueItem = $this->entityManager->getEntityById(EmailQueueItem::ENTITY_TYPE, $queueItemId);
if (!$queueItem) {
throw new NotFoundSilent();
throw new NotFoundSilent("Item not found.");
}
$this->processWithQueueItem($trackingUrl, $queueItem);
@@ -76,11 +76,11 @@ class EventConfirmation implements EntryPoint
$action = $request->getQueryParam('action') ?? null;
if (!$uid) {
throw new BadRequest();
throw new BadRequest("No uid.");
}
if (!in_array($action, [self::ACTION_ACCEPT, self::ACTION_DECLINE, self::ACTION_TENTATIVE])) {
throw new BadRequest();
throw new BadRequest("Bad action.");
}
/** @var ?UniqueId $uniqueId */
@@ -112,11 +112,11 @@ class EventConfirmation implements EntryPoint
$link;
if (!$toProcess) {
throw new Error();
throw new Error("Bad data.");
}
if ($sentDateStart !== null && !is_string($sentDateStart)) {
throw new Error();
throw new Error("No date in data.");
}
$event = $this->entityManager->getEntityById($eventType, $eventId);
@@ -81,7 +81,7 @@ class SubscribeAgain implements EntryPoint
}
if (!$id || !is_string($id)) {
throw new BadRequest();
throw new BadRequest("No id.");
}
$queueItemId = $id;
@@ -90,7 +90,7 @@ class SubscribeAgain implements EntryPoint
$queueItem = $this->entityManager->getEntity(EmailQueueItem::ENTITY_TYPE, $queueItemId);
if (!$queueItem) {
throw new NotFound();
throw new NotFound("No item.");
}
$campaign = null;
@@ -116,7 +116,7 @@ class SubscribeAgain implements EntryPoint
$target = $this->entityManager->getEntityById($targetType, $targetId);
if (!$target) {
throw new NotFound();
throw new NotFound("Record not found.");
}
if ($massEmail->get('optOutEntirely')) {
@@ -84,7 +84,7 @@ class Unsubscribe implements EntryPoint
}
if (!$id) {
throw new BadRequest();
throw new BadRequest("No id.");
}
$queueItemId = $id;
@@ -93,7 +93,7 @@ class Unsubscribe implements EntryPoint
$queueItem = $this->entityManager->getEntityById(EmailQueueItem::ENTITY_TYPE, $queueItemId);
if (!$queueItem) {
throw new NotFound();
throw new NotFound("No item.");
}
$campaign = null;
@@ -56,11 +56,11 @@ class PostFollowers implements Action
$data = $request->getParsedBody();
if (!$entityType || !$id) {
throw new BadRequest();
throw new BadRequest("No entityType or id.");
}
if (!$this->acl->check($entityType)) {
throw new Forbidden();
throw new Forbidden("No access to $entityType.");
}
$ids = $data->ids ?? (isset($data->id) ? [$data->id] : []);