From 369c3e44c02dc67111bd723518adf84647770518 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 29 Jul 2019 12:39:09 +0200 Subject: [PATCH] Make the API work with timestamps Signed-off-by: Joas Schilling --- docs/conversation.md | 2 +- docs/webinary.md | 2 +- lib/Controller/RoomController.php | 4 ++-- lib/Controller/WebinaryController.php | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/conversation.md b/docs/conversation.md index 29162fb11..c9c18ab8b 100644 --- a/docs/conversation.md +++ b/docs/conversation.md @@ -63,7 +63,7 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1` `isFavorite` | bool | Flag if the conversation is favorited by the user `notificationLevel` | int | The notification level for the user (one of `Participant::NOTIFY_*` (1-3)) `lobbyState` | int | Webinary lobby restriction (0-1), if the participant is a moderator they can always join the conversation (only available with `webinary-lobby` capability) - `lobbyTimer` | string | Datetime when the lobby will be automatically disabled ([Format: `Y-m-d\TH:i:sP`](https://www.php.net/manual/en/class.datetimeinterface.php#datetime.constants.atom)) (only available with `webinary-lobby` capability) + `lobbyTimer` | int | Timestamp when the lobby will be automatically disabled (only available with `webinary-lobby` capability) `unreadMessages` | int | Number of unread chat messages in the conversation (only available with `chat-v2` capability) `unreadMention` | bool | Flag if the user was mentioned since their last visit `lastReadMessage` | int | ID of the last read message in a room (only available with `chat-read-marker` capability) diff --git a/docs/webinary.md b/docs/webinary.md index bed6b8568..7f611da75 100644 --- a/docs/webinary.md +++ b/docs/webinary.md @@ -18,7 +18,7 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1` field | type | Description ------|------|------------ `state` | int | New state for the conversation - `timer` | string | Datetime when the lobby state is reset to all participants ([Format: `Y-m-d\TH:i:sP`](https://www.php.net/manual/en/class.datetimeinterface.php#datetime.constants.atom)) + `timer` | int/null | Timestamp when the lobby state is reset to all participants * Response: - Header: diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index bb0de64e8..82a393d58 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -204,9 +204,9 @@ class RoomController extends AEnvironmentAwareController { $lobbyTimer = $room->getLobbyTimer(); if ($lobbyTimer instanceof \DateTimeInterface) { - $lobbyTimer = $lobbyTimer->format(\DateTime::ATOM); + $lobbyTimer = $lobbyTimer->getTimestamp(); } else { - $lobbyTimer = ''; + $lobbyTimer = 0; } $roomData = array_merge($roomData, [ diff --git a/lib/Controller/WebinaryController.php b/lib/Controller/WebinaryController.php index a0f04187c..176e30529 100644 --- a/lib/Controller/WebinaryController.php +++ b/lib/Controller/WebinaryController.php @@ -46,14 +46,14 @@ class WebinaryController extends AEnvironmentAwareController { * @RequireModeratorParticipant * * @param int $state - * @param string $timer + * @param int|null $timer * @return DataResponse */ - public function setLobby(int $state, ?string $timer = null): DataResponse { + public function setLobby(int $state, ?int $timer = null): DataResponse { $timerDateTime = null; - if (trim((string) $timer) !== '') { + if ($timer !== null && $timer > 0) { try { - $timerDateTime = $this->timeFactory->getDateTime($timer); + $timerDateTime = $this->timeFactory->getDateTime('@' . $timer); $timerDateTime->setTimezone(new \DateTimeZone('UTC')); } catch (\Exception $e) { return new DataResponse([], Http::STATUS_BAD_REQUEST);