Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

v1.7.0-beta fixes (#1086)

Dave Earley0708adbd6e77
diff --git a/backend/app/Http/Actions/Organizers/Webhooks/DeleteOrganizerWebhookAction.php b/backend/app/Http/Actions/Organizers/Webhooks/DeleteOrganizerWebhookAction.php
index cd157307f..b6ca306d9 100644
--- a/backend/app/Http/Actions/Organizers/Webhooks/DeleteOrganizerWebhookAction.php
+++ b/backend/app/Http/Actions/Organizers/Webhooks/DeleteOrganizerWebhookAction.php
@@ -21,6 +21,7 @@ class DeleteOrganizerWebhookAction extends BaseAction
$this->deleteWebhookHandler->handle(
webhookId: $webhookId,
+ accountId: $this->getAuthenticatedAccountId(),
eventId: null,
organizerId: $organizerId,
);
diff --git a/backend/app/Http/Actions/Organizers/Webhooks/GetOrganizerWebhookAction.php b/backend/app/Http/Actions/Organizers/Webhooks/GetOrganizerWebhookAction.php
index cb7ea4ad2..7d3e25cf2 100644
--- a/backend/app/Http/Actions/Organizers/Webhooks/GetOrganizerWebhookAction.php
+++ b/backend/app/Http/Actions/Organizers/Webhooks/GetOrganizerWebhookAction.php
@@ -22,8 +22,9 @@ class GetOrganizerWebhookAction extends BaseAction
$webhook = $this->getWebhookHandler->handle(
webhookId: $webhookId,
+ accountId: $this->getAuthenticatedAccountId(),
eventId: null,
- organizerId: $organizerId
+ organizerId: $organizerId,
);
return $this->resourceResponse(
diff --git a/backend/app/Http/Actions/Organizers/Webhooks/GetOrganizerWebhookLogsAction.php b/backend/app/Http/Actions/Organizers/Webhooks/GetOrganizerWebhookLogsAction.php
index 720728f6b..66016aa75 100644
--- a/backend/app/Http/Actions/Organizers/Webhooks/GetOrganizerWebhookLogsAction.php
+++ b/backend/app/Http/Actions/Organizers/Webhooks/GetOrganizerWebhookLogsAction.php
@@ -23,6 +23,7 @@ class GetOrganizerWebhookLogsAction extends BaseAction
$webhookLogs = $this->getWebhookLogsHandler->handle(
webhookId: $webhookId,
+ accountId: $this->getAuthenticatedAccountId(),
eventId: null,
organizerId: $organizerId,
);
diff --git a/backend/app/Http/Actions/Webhooks/DeleteWebhookAction.php b/backend/app/Http/Actions/Webhooks/DeleteWebhookAction.php
index b807d4719..d7c125c6f 100644
--- a/backend/app/Http/Actions/Webhooks/DeleteWebhookAction.php
+++ b/backend/app/Http/Actions/Webhooks/DeleteWebhookAction.php
@@ -21,6 +21,7 @@ class DeleteWebhookAction extends BaseAction
$this->deleteWebhookHandler->handle(
webhookId: $webhookId,
+ accountId: $this->getAuthenticatedAccountId(),
eventId: $eventId,
);
diff --git a/backend/app/Http/Actions/Webhooks/GetWebhookAction.php b/backend/app/Http/Actions/Webhooks/GetWebhookAction.php
index 6c78fd981..a57bfb734 100644
--- a/backend/app/Http/Actions/Webhooks/GetWebhookAction.php
+++ b/backend/app/Http/Actions/Webhooks/GetWebhookAction.php
@@ -21,8 +21,9 @@ class GetWebhookAction extends BaseAction
$this->isActionAuthorized($eventId, EventDomainObject::class);
$webhook = $this->getWebhookHandler->handle(
+ webhookId: $webhookId,
+ accountId: $this->getAuthenticatedAccountId(),
eventId: $eventId,
- webhookId: $webhookId
);
return $this->resourceResponse(
diff --git a/backend/app/Http/Actions/Webhooks/GetWebhookLogsAction.php b/backend/app/Http/Actions/Webhooks/GetWebhookLogsAction.php
index e4e67f154..db20650f4 100644
--- a/backend/app/Http/Actions/Webhooks/GetWebhookLogsAction.php
+++ b/backend/app/Http/Actions/Webhooks/GetWebhookLogsAction.php
@@ -22,8 +22,9 @@ class GetWebhookLogsAction extends BaseAction
$this->isActionAuthorized($eventId, EventDomainObject::class);
$webhookLogs = $this->getWebhookLogsHandler->handle(
- eventId: $eventId,
webhookId: $webhookId,
+ accountId: $this->getAuthenticatedAccountId(),
+ eventId: $eventId,
);
$webhookLogs = $webhookLogs->sortBy(function (WebhookLogDomainObject $webhookLog) {
diff --git a/backend/app/Http/Request/Message/SendMessageRequest.php b/backend/app/Http/Request/Message/SendMessageRequest.php
index c91475abb..5b12e009c 100644
--- a/backend/app/Http/Request/Message/SendMessageRequest.php
+++ b/backend/app/Http/Request/Message/SendMessageRequest.php
@@ -25,7 +25,7 @@ class SendMessageRequest extends FormRequest
'required_if:message_type,' . MessageTypeEnum::ORDER_OWNERS_WITH_PRODUCT->name,
new In([OrderStatus::COMPLETED->name, OrderStatus::AWAITING_OFFLINE_PAYMENT->name]),
],
- 'scheduled_at' => 'nullable|date|after:now',
+ 'scheduled_at' => 'nullable|date',
];
}
diff --git a/backend/app/Listeners/Waitlist/ProcessWaitlistOnCapacityAvailableListener.php b/backend/app/Listeners/Waitlist/ProcessWaitlistOnCapacityAvailableListener.php
index 009c1f5f7..6ee180963 100644
--- a/backend/app/Listeners/Waitlist/ProcessWaitlistOnCapacityAvailableListener.php
+++ b/backend/app/Listeners/Waitlist/ProcessWaitlistOnCapacityAvailableListener.php
@@ -10,8 +10,9 @@ use HiEvents\Repository\Eloquent\Value\Relationship;
use HiEvents\Repository\Interfaces\EventRepositoryInterface;
use HiEvents\Services\Domain\Product\AvailableProductQuantitiesFetchService;
use HiEvents\Services\Domain\Waitlist\ProcessWaitlistService;
+use Illuminate\Contracts\Queue\ShouldQueue;
-class ProcessWaitlistOnCapacityAvailableListener
+class ProcessWaitlistOnCapacityAvailableListener implements ShouldQueue
{
public function __construct(
private readonly EventRepositoryInterface $eventRepository,
diff --git a/backend/app/Listeners/Waitlist/ResolveWaitlistEntryOnOrderCompletedListener.php b/backend/app/Listeners/Waitlist/ResolveWaitlistEntryOnOrderCompletedListener.php
index 9c582143b..4dcf45554 100644
--- a/backend/app/Listeners/Waitlist/ResolveWaitlistEntryOnOrderCompletedListener.php
+++ b/backend/app/Listeners/Waitlist/ResolveWaitlistEntryOnOrderCompletedListener.php
@@ -11,12 +11,14 @@ use HiEvents\DomainObjects\Enums\CapacityChangeDirection;
use HiEvents\Events\CapacityChangedEvent;
use HiEvents\Repository\Interfaces\ProductPriceRepositoryInterface;
use HiEvents\Repository\Interfaces\WaitlistEntryRepositoryInterface;
+use Illuminate\Database\DatabaseManager;
class ResolveWaitlistEntryOnOrderCompletedListener
{
public function __construct(
private readonly WaitlistEntryRepositoryInterface $waitlistEntryRepository,
private readonly ProductPriceRepositoryInterface $productPriceRepository,
+ private readonly DatabaseManager $databaseManager,
)
{
}
@@ -37,33 +39,43 @@ class ResolveWaitlistEntryOnOrderCompletedListener
private function resolveByOrderId(int $orderId): void
{
- $entries = $this->waitlistEntryRepository->findWhere([
- 'order_id' => $orderId,
- ['status', 'in', [WaitlistEntryStatus::OFFERED->name]],
- ]);
+ $this->databaseManager->transaction(function () use ($orderId) {
+ $entries = $this->waitlistEntryRepository->findWhere([
+ 'order_id' => $orderId,
+ ['status', 'in', [WaitlistEntryStatus::OFFERED->name]],
+ ]);
- foreach ($entries as $entry) {
- $this->markAsPurchased($entry);
- }
+ foreach ($entries as $entry) {
+ $this->markAsPurchased($entry);
+ }
+ });
}
private function revertOfferedEntriesByOrderId(int $orderId): void
{
- $entries = $this->waitlistEntryRepository->findWhere([
- 'order_id' => $orderId,
- ['status', 'in', [WaitlistEntryStatus::OFFERED->name]],
- ]);
+ $capacityEvents = [];
+
+ $this->databaseManager->transaction(function () use ($orderId, &$capacityEvents) {
+ $entries = $this->waitlistEntryRepository->findWhere([
+ 'order_id' => $orderId,
+ ['status', 'in', [WaitlistEntryStatus::OFFERED->name]],
+ ]);
+
+ foreach ($entries as $entry) {
+ $this->revertToWaiting($entry);
- foreach ($entries as $entry) {
- $this->revertToWaiting($entry);
+ $productPrice = $this->productPriceRepository->findById($entry->getProductPriceId());
+ $capacityEvents[] = new CapacityChangedEvent(
+ eventId: $entry->getEventId(),
+ direction: CapacityChangeDirection::INCREASED,
+ productId: $productPrice->getProductId(),
+ productPriceId: $entry->getProductPriceId(),
+ );
+ }
+ });
- $productPrice = $this->productPriceRepository->findById($entry->getProductPriceId());
- event(new CapacityChangedEvent(
- eventId: $entry->getEventId(),
- direction: CapacityChangeDirection::INCREASED,
- productId: $productPrice->getProductId(),
- productPriceId: $entry->getProductPriceId(),
- ));
+ foreach ($capacityEvents as $capacityEvent) {
+ event($capacityEvent);
}
}
@@ -74,7 +86,10 @@ class ResolveWaitlistEntryOnOrderCompletedListener
'status' => WaitlistEntryStatus::PURCHASED->name,
'purchased_at' => Carbon::now()->toDateTimeString(),
],
- where: ['id' => $entry->getId()],
+ where: [
+ 'id' => $entry->getId(),
+ 'status' => WaitlistEntryStatus::OFFERED->name,
+ ],
);
}
@@ -88,7 +103,10 @@ class ResolveWaitlistEntryOnOrderCompletedListener
'offer_expires_at' => null,
'offer_token' => null,
],
- where: ['id' => $entry->getId()],
+ where: [
+ 'id' => $entry->getId(),
+ 'status' => WaitlistEntryStatus::OFFERED->name,
+ ],
);
}
}
diff --git a/backend/app/Services/Application/Handlers/Message/SendMessageHandler.php b/backend/app/Services/Application/Handlers/Message/SendMessageHandler.php
index a6621eda6..9f1b7b987 100644
--- a/backend/app/Services/Application/Handlers/Message/SendMessageHandler.php
+++ b/backend/app/Services/Application/Handlers/Message/SendMessageHandler.php
@@ -22,6 +22,7 @@ use HiEvents\Services\Domain\Message\MessagingEligibilityService;
use HiEvents\Services\Infrastructure\HtmlPurifier\HtmlPurifierService;
use Illuminate\Config\Repository;
use Illuminate\Support\Collection;
+use Illuminate\Validation\ValidationException;
class SendMessageHandler
{
@@ -84,6 +85,12 @@ class SendMessageHandler
? DateHelper::convertToUTC($messageData->scheduled_at, $event->getTimezone())
: null;
+ if ($scheduledAtUtc !== null && Carbon::parse($scheduledAtUtc)->isPast()) {
+ throw ValidationException::withMessages([
+ 'scheduled_at' => [__('The scheduled time must be in the future.')],
+ ]);
+ }
+
if ($eligibilityFailure !== null) {
$status = MessageStatus::PENDING_REVIEW;
} elseif ($isScheduled) {
diff --git a/backend/app/Services/Application/Handlers/Webhook/DeleteWebhookHandler.php b/backend/app/Services/Application/Handlers/Webhook/DeleteWebhookHandler.php
index 6a8edb909..c65da1c67 100644
--- a/backend/app/Services/Application/Handlers/Webhook/DeleteWebhookHandler.php
+++ b/backend/app/Services/Application/Handlers/Webhook/DeleteWebhookHandler.php
@@ -17,10 +17,10 @@ class DeleteWebhookHandler
{
}
- public function handle(int $webhookId, ?int $eventId = null, ?int $organizerId = null): void
+ public function handle(int $webhookId, int $accountId, ?int $eventId = null, ?int $organizerId = null): void
{
- $this->databaseManager->transaction(function () use ($eventId, $webhookId, $organizerId) {
- $where = ['id' => $webhookId];
+ $this->databaseManager->transaction(function () use ($eventId, $webhookId, $organizerId, $accountId) {
+ $where = ['id' => $webhookId, 'account_id' => $accountId];
if ($eventId !== null) {
$where['event_id'] = $eventId;
}
diff --git a/backend/app/Services/Application/Handlers/Webhook/EditWebhookHandler.php b/backend/app/Services/Application/Handlers/Webhook/EditWebhookHandler.php
index 9d76c441e..18fb57eca 100644
--- a/backend/app/Services/Application/Handlers/Webhook/EditWebhookHandler.php
+++ b/backend/app/Services/Application/Handlers/Webhook/EditWebhookHandler.php
@@ -20,7 +20,7 @@ class EditWebhookHandler
public function handle(EditWebhookDTO $dto): WebhookDomainObject
{
return $this->databaseManager->transaction(function () use ($dto) {
- $where = ['id' => $dto->webhookId];
+ $where = ['id' => $dto->webhookId, 'account_id' => $dto->accountId];
if ($dto->eventId !== null) {
$where['event_id'] = $dto->eventId;
}
diff --git a/backend/app/Services/Application/Handlers/Webhook/GetWebhookHandler.php b/backend/app/Services/Application/Handlers/Webhook/GetWebhookHandler.php
index 2d63ff111..b2bb2ebc4 100644
--- a/backend/app/Services/Application/Handlers/Webhook/GetWebhookHandler.php
+++ b/backend/app/Services/Application/Handlers/Webhook/GetWebhookHandler.php
@@ -13,9 +13,9 @@ class GetWebhookHandler
{
}
- public function handle(int $webhookId, ?int $eventId = null, ?int $organizerId = null): WebhookDomainObject
+ public function handle(int $webhookId, int $accountId, ?int $eventId = null, ?int $organizerId = null): WebhookDomainObject
{
- $where = ['id' => $webhookId];
+ $where = ['id' => $webhookId, 'account_id' => $accountId];
if ($eventId !== null) {
$where['event_id'] = $eventId;
}
diff --git a/backend/app/Services/Application/Handlers/Webhook/GetWebhookLogsHandler.php b/backend/app/Services/Application/Handlers/Webhook/GetWebhookLogsHandler.php
index 80cd5a319..8d0737f96 100644
--- a/backend/app/Services/Application/Handlers/Webhook/GetWebhookLogsHandler.php
+++ b/backend/app/Services/Application/Handlers/Webhook/GetWebhookLogsHandler.php
@@ -16,9 +16,9 @@ class GetWebhookLogsHandler
{
}
- public function handle(int $webhookId, ?int $eventId = null, ?int $organizerId = null): LengthAwarePaginator
+ public function handle(int $webhookId, int $accountId, ?int $eventId = null, ?int $organizerId = null): LengthAwarePaginator
{
- $where = ['id' => $webhookId];
+ $where = ['id' => $webhookId, 'account_id' => $accountId];
if ($eventId !== null) {
$where['event_id'] = $eventId;
}
diff --git a/backend/app/Services/Domain/Product/ProductQuantityUpdateService.php b/backend/app/Services/Domain/Product/ProductQuantityUpdateService.php
index 58b1b0cba..44fe678a2 100644
--- a/backend/app/Services/Domain/Product/ProductQuantityUpdateService.php
+++ b/backend/app/Services/Domain/Product/ProductQuantityUpdateService.php
@@ -52,7 +52,7 @@ class ProductQuantityUpdateService
});
$this->productPriceRepository->updateWhere([
- 'quantity_sold' => DB::raw('quantity_sold - ' . $adjustment),
+ 'quantity_sold' => DB::raw('GREATEST(0, quantity_sold - ' . $adjustment . ')'),
], [
'id' => $priceId,
]);
@@ -97,7 +97,7 @@ class ProductQuantityUpdateService
private function decreaseCapacityAssignmentUsedCapacity(int $capacityAssignmentId, int $adjustment = 1): void
{
$this->capacityAssignmentRepository->updateWhere([
- CapacityAssignmentDomainObjectAbstract::USED_CAPACITY => DB::raw(CapacityAssignmentDomainObjectAbstract::USED_CAPACITY . ' - ' . $adjustment),
+ CapacityAssignmentDomainObjectAbstract::USED_CAPACITY => DB::raw('GREATEST(0, ' . CapacityAssignmentDomainObjectAbstract::USED_CAPACITY . ' - ' . $adjustment . ')'),
], [
'id' => $capacityAssignmentId,
]);