diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php index 8f0808dd2fc..2bc6333e003 100644 --- a/lib/Controller/PollController.php +++ b/lib/Controller/PollController.php @@ -104,7 +104,7 @@ public function createPoll(string $question, array $options, int $resultMode, in ); } catch (PollPropertyException $e) { $this->logger->error('Error creating poll', ['exception' => $e]); - return new DataResponse(['error' => PollPropertyException::REASON_POLL], Http::STATUS_BAD_REQUEST); + return new DataResponse(['error' => $e->getReason()], Http::STATUS_BAD_REQUEST); } if ($draft) { @@ -145,7 +145,7 @@ public function createPoll(string $question, array $options, int $resultMode, in * @param 0|1 $resultMode Mode how the results will be shown * @psalm-param Poll::MODE_* $resultMode Mode how the results will be shown * @param int $maxVotes Number of maximum votes per voter - * @return DataResponse|DataResponse|DataResponse + * @return DataResponse|DataResponse * * 200: Draft modified successfully * 400: Modifying poll is not possible @@ -173,7 +173,7 @@ public function updateDraftPoll(int $pollId, string $question, array $options, i try { $poll = $this->pollService->getPoll($this->room->getId(), $pollId); } catch (DoesNotExistException $e) { - return new DataResponse(['error' => $e->getMessage()], Http::STATUS_NOT_FOUND); + return new DataResponse(['error' => PollPropertyException::REASON_POLL], Http::STATUS_NOT_FOUND); } if (!$poll->isDraft()) { @@ -200,7 +200,7 @@ public function updateDraftPoll(int $pollId, string $question, array $options, i $this->pollService->updatePoll($this->participant, $poll); } catch (WrongPermissionsException $e) { $this->logger->error('Error modifying poll', ['exception' => $e]); - return new DataResponse(['error' => 'poll'], Http::STATUS_FORBIDDEN); + return new DataResponse(['error' => PollPropertyException::REASON_POLL], Http::STATUS_FORBIDDEN); } return new DataResponse($poll->renderAsDraft()); @@ -346,7 +346,7 @@ public function votePoll(int $pollId, array $optionIds = []): DataResponse { * * @param int $pollId ID of the poll * @psalm-param non-negative-int $pollId - * @return DataResponse|DataResponse|DataResponse + * @return DataResponse|DataResponse|DataResponse * * 200: Poll closed successfully * 202: Poll draft was deleted successfully diff --git a/lib/Service/PollService.php b/lib/Service/PollService.php index 90bc5ea1dc5..00e653f9a2c 100644 --- a/lib/Service/PollService.php +++ b/lib/Service/PollService.php @@ -86,9 +86,6 @@ public function updatePoll(Participant $participant, Poll $poll): void { } /** - * @param Participant $participant - * @param Poll $poll - * @return void * @throws WrongPermissionsException */ public function closePoll(Participant $participant, Poll $poll): void { diff --git a/openapi-full.json b/openapi-full.json index fcc1f62d43f..e11a9a2f960 100644 --- a/openapi-full.json +++ b/openapi-full.json @@ -9695,6 +9695,7 @@ "enum": [ "draft", "options", + "poll", "question", "room" ] @@ -9739,6 +9740,7 @@ "enum": [ "draft", "options", + "poll", "question", "room" ] @@ -9779,7 +9781,14 @@ ], "properties": { "error": { - "type": "string" + "type": "string", + "enum": [ + "draft", + "options", + "poll", + "question", + "room" + ] } } } @@ -10397,33 +10406,18 @@ "$ref": "#/components/schemas/OCSMeta" }, "data": { - "anyOf": [ - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string", - "enum": [ - "poll" - ] - } - } - }, - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string" - } - } + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string", + "enum": [ + "poll" + ] } - ] + } } } } @@ -10453,33 +10447,18 @@ "$ref": "#/components/schemas/OCSMeta" }, "data": { - "anyOf": [ - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string", - "enum": [ - "poll" - ] - } - } - }, - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string" - } - } + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string", + "enum": [ + "poll" + ] } - ] + } } } } @@ -10509,33 +10488,18 @@ "$ref": "#/components/schemas/OCSMeta" }, "data": { - "anyOf": [ - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string", - "enum": [ - "poll" - ] - } - } - }, - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string" - } - } + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string", + "enum": [ + "poll" + ] } - ] + } } } } diff --git a/openapi.json b/openapi.json index 3a56f184da1..1a57392a383 100644 --- a/openapi.json +++ b/openapi.json @@ -9582,6 +9582,7 @@ "enum": [ "draft", "options", + "poll", "question", "room" ] @@ -9626,6 +9627,7 @@ "enum": [ "draft", "options", + "poll", "question", "room" ] @@ -9666,7 +9668,14 @@ ], "properties": { "error": { - "type": "string" + "type": "string", + "enum": [ + "draft", + "options", + "poll", + "question", + "room" + ] } } } @@ -10284,33 +10293,18 @@ "$ref": "#/components/schemas/OCSMeta" }, "data": { - "anyOf": [ - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string", - "enum": [ - "poll" - ] - } - } - }, - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string" - } - } + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string", + "enum": [ + "poll" + ] } - ] + } } } } @@ -10340,33 +10334,18 @@ "$ref": "#/components/schemas/OCSMeta" }, "data": { - "anyOf": [ - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string", - "enum": [ - "poll" - ] - } - } - }, - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string" - } - } + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string", + "enum": [ + "poll" + ] } - ] + } } } } @@ -10396,33 +10375,18 @@ "$ref": "#/components/schemas/OCSMeta" }, "data": { - "anyOf": [ - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string", - "enum": [ - "poll" - ] - } - } - }, - { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string" - } - } + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string", + "enum": [ + "poll" + ] } - ] + } } } } diff --git a/src/types/openapi/openapi-full.ts b/src/types/openapi/openapi-full.ts index 2dcb4a88f83..67c9c1c424f 100644 --- a/src/types/openapi/openapi-full.ts +++ b/src/types/openapi/openapi-full.ts @@ -5588,7 +5588,7 @@ export interface operations { meta: components["schemas"]["OCSMeta"]; data: { /** @enum {string} */ - error: "draft" | "options" | "question" | "room"; + error: "draft" | "options" | "poll" | "question" | "room"; }; }; }; @@ -5605,7 +5605,7 @@ export interface operations { meta: components["schemas"]["OCSMeta"]; data: { /** @enum {string} */ - error: "draft" | "options" | "question" | "room"; + error: "draft" | "options" | "poll" | "question" | "room"; }; }; }; @@ -5621,7 +5621,8 @@ export interface operations { ocs: { meta: components["schemas"]["OCSMeta"]; data: { - error: string; + /** @enum {string} */ + error: "draft" | "options" | "poll" | "question" | "room"; }; }; }; @@ -5869,8 +5870,6 @@ export interface operations { data: { /** @enum {string} */ error: "poll"; - } | { - error: string; }; }; }; @@ -5888,8 +5887,6 @@ export interface operations { data: { /** @enum {string} */ error: "poll"; - } | { - error: string; }; }; }; @@ -5907,8 +5904,6 @@ export interface operations { data: { /** @enum {string} */ error: "poll"; - } | { - error: string; }; }; }; diff --git a/src/types/openapi/openapi.ts b/src/types/openapi/openapi.ts index 9725ae87325..7ee43fba1da 100644 --- a/src/types/openapi/openapi.ts +++ b/src/types/openapi/openapi.ts @@ -5069,7 +5069,7 @@ export interface operations { meta: components["schemas"]["OCSMeta"]; data: { /** @enum {string} */ - error: "draft" | "options" | "question" | "room"; + error: "draft" | "options" | "poll" | "question" | "room"; }; }; }; @@ -5086,7 +5086,7 @@ export interface operations { meta: components["schemas"]["OCSMeta"]; data: { /** @enum {string} */ - error: "draft" | "options" | "question" | "room"; + error: "draft" | "options" | "poll" | "question" | "room"; }; }; }; @@ -5102,7 +5102,8 @@ export interface operations { ocs: { meta: components["schemas"]["OCSMeta"]; data: { - error: string; + /** @enum {string} */ + error: "draft" | "options" | "poll" | "question" | "room"; }; }; }; @@ -5350,8 +5351,6 @@ export interface operations { data: { /** @enum {string} */ error: "poll"; - } | { - error: string; }; }; }; @@ -5369,8 +5368,6 @@ export interface operations { data: { /** @enum {string} */ error: "poll"; - } | { - error: string; }; }; }; @@ -5388,8 +5385,6 @@ export interface operations { data: { /** @enum {string} */ error: "poll"; - } | { - error: string; }; }; };