Make the API work with timestamps

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-07-29 12:39:09 +02:00 коммит произвёл Daniel Calviño Sánchez
Родитель 1136b70ec2
Коммит 369c3e44c0
4 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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:

Просмотреть файл

@ -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, [

Просмотреть файл

@ -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);