uid = $userId; } /** * @NoAdminRequired * @param string $name * * @return JsonResponse */ #[TrapError] public function create(string $name, int $order, int $actionId, ?int $tagId = null, ?int $mailboxId = null): JsonResponse { if ($this->uid === null) { return JsonResponse::error('User not found', Http::STATUS_UNAUTHORIZED); } try { $action = $this->quickActionsService->find($actionId, $this->uid); if ($action === null) { return JsonResponse::fail('Action not found', Http::STATUS_BAD_REQUEST); } $accountId = $action->getAccountId(); $account = $this->accountService->findById($accountId); } catch (DoesNotExistException $e) { return JsonResponse::fail('Account not found', Http::STATUS_BAD_REQUEST); } if ($account->getUserId() !== $this->uid) { return JsonResponse::fail('Account not found', Http::STATUS_BAD_REQUEST); } $actionStep = $this->quickActionsService->createActionStep($name, $order, $actionId, $tagId, $mailboxId); return JsonResponse::success($actionStep, Http::STATUS_CREATED); } /** * @NoAdminRequired * @param int $id * @param string $name * * @return JsonResponse */ #[TrapError] public function update(int $id, string $name, int $order, ?int $tagId, ?int $mailboxId): JsonResponse { if ($this->uid === null) { return JsonResponse::error('User not found', Http::STATUS_UNAUTHORIZED); } $actionStep = $this->quickActionsService->findActionStep($id, $this->uid); $actionStep = $this->quickActionsService->updateActionStep($actionStep, $name, $order, $tagId, $mailboxId); return JsonResponse::success($actionStep, Http::STATUS_OK); } /** * @NoAdminRequired * * @return JsonResponse */ public function destroy(int $id): JsonResponse { if ($this->uid === null) { return JsonResponse::error('User not found', Http::STATUS_UNAUTHORIZED); } try { $this->quickActionsService->deleteActionStep($id, $this->uid); return JsonResponse::success(); } catch (DoesNotExistException $e) { return JsonResponse::fail('Action step not found', Http::STATUS_NOT_FOUND); } } }