Skip to content

Commit

Permalink
Make the API work with timestamps
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen authored and danxuliu committed Aug 27, 2019
1 parent 6d03939 commit 83f8033
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/conversation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion docs/webinary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ protected function formatRoom(Room $room, ?Participant $currentParticipant): arr

$lobbyTimer = $room->getLobbyTimer();
if ($lobbyTimer instanceof \DateTimeInterface) {
$lobbyTimer = $lobbyTimer->format(\DateTime::ATOM);
$lobbyTimer = $lobbyTimer->getTimestamp();
} else {
$lobbyTimer = '';
$lobbyTimer = 0;
}

$roomData = array_merge($roomData, [
Expand Down
8 changes: 4 additions & 4 deletions lib/Controller/WebinaryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public function __construct(string $appName,
* @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);
Expand Down

0 comments on commit 83f8033

Please sign in to comment.