Skip to content

Commit

Permalink
fixup! fixup! feat(polls): allow editing of draft polls
Browse files Browse the repository at this point in the history
  • Loading branch information
nickvergessen committed Dec 20, 2024
1 parent d90570b commit 810d314
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/Federation/Proxy/TalkV1/Controller/PollController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use OCA\Talk\Room;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use Psr\Log\LoggerInterface;

/**
* @psalm-import-type TalkPoll from ResponseDefinitions
Expand All @@ -27,6 +28,7 @@ class PollController {
public function __construct(
protected ProxyRequest $proxy,
protected UserConverter $userConverter,
protected LoggerInterface $logger,
) {
}

Expand Down Expand Up @@ -132,7 +134,7 @@ public function votePoll(Room $room, Participant $participant, int $pollId, arra


/**
* @return DataResponse<Http::STATUS_OK, TalkPollDraft, array{}>|DataResponse<Http::STATUS_CREATED, TalkPoll, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'draft'|'options'|'question'|'room'}, array{}>
* @return DataResponse<Http::STATUS_OK, TalkPollDraft, array{}>|DataResponse<Http::STATUS_CREATED, TalkPoll, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'draft'|'options'|'poll'|'question'|'room'}, array{}>
* @throws CannotReachRemoteException
*
* 200: Draft created successfully
Expand Down Expand Up @@ -172,7 +174,7 @@ public function createPoll(Room $room, Participant $participant, string $questio
}

/**
* @return DataResponse<Http::STATUS_OK, TalkPollDraft, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'draft'|'options'|'question'|'room'}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array{error: string}, array{}>
* @return DataResponse<Http::STATUS_OK, TalkPollDraft, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array{error: 'draft'|'options'|'poll'|'question'|'room'}, array{}>
* @throws CannotReachRemoteException
*
* 200: Draft created successfully
Expand Down Expand Up @@ -211,7 +213,7 @@ public function updateDraftPoll(int $pollId, Room $room, Participant $participan
}

/**
* @return DataResponse<Http::STATUS_OK, TalkPoll, array{}>|DataResponse<Http::STATUS_ACCEPTED, null, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array{error: 'poll'}|array{error: string}, array{}>
* @return DataResponse<Http::STATUS_OK, TalkPoll, array{}>|DataResponse<Http::STATUS_ACCEPTED, null, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array{error: 'poll'}, array{}>
* @throws CannotReachRemoteException
*
* 200: Poll closed successfully
Expand Down Expand Up @@ -239,7 +241,12 @@ public function closePoll(Room $room, Participant $participant, int $pollId): Da
}
/** @var array{error?: string} $data */
$data = $this->proxy->getOCSData($proxy);
return new DataResponse(['error' => $data['error'] ?? PollPropertyException::REASON_POLL], $statusCode);

if ($data['error'] !== PollPropertyException::REASON_POLL) {
$this->logger->error('Unhandled error in ' . __METHOD__ . ': ' . $data['error']);
}

return new DataResponse(['error' => PollPropertyException::REASON_POLL], $statusCode);
}

/** @var TalkPoll $data */
Expand Down

0 comments on commit 810d314

Please sign in to comment.