Fix the system message when the timer was reached

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-07-24 08:48:54 +02:00 коммит произвёл Daniel Calviño Sánchez
Родитель f56ab8fe90
Коммит 1136b70ec2
3 изменённых файлов: 10 добавлений и 3 удалений

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

@ -138,6 +138,8 @@ class SystemMessage {
if ($currentUserIsActor) {
$parsedMessage = $this->l->t('You locked the conversation');
}
} else if ($message === 'lobby_timer_reached') {
$parsedMessage = $this->l->t('The conversation is now open to everyone');
} else if ($message === 'lobby_all_participants') {
$parsedMessage = $this->l->t('{actor} opened the conversation to everyone');
if ($currentUserIsActor) {

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

@ -171,7 +171,9 @@ class Listener {
/** @var self $listener */
$listener = \OC::$server->query(self::class);
if ($arguments['newState'] === Webinary::ALL_PARTICIPANTS) {
if ($arguments['timerReached']) {
$listener->sendSystemMessage($room, 'lobby_timer_reached', $event->getArguments());
} else if ($arguments['newState'] === Webinary::ALL_PARTICIPANTS) {
$listener->sendSystemMessage($room, 'lobby_all_participants', $event->getArguments());
} else if ($arguments['newState'] === Webinary::MODERATORS_ONLY) {
$listener->sendSystemMessage($room, 'lobby_moderators_only', $event->getArguments());

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

@ -165,7 +165,7 @@ class Room {
protected function validateTimer(): void {
if ($this->lobbyTimer !== null && $this->lobbyTimer < $this->timeFactory->getDateTime()) {
$this->setLobby(Webinary::ALL_PARTICIPANTS, null);
$this->setLobby(Webinary::ALL_PARTICIPANTS, null, true);
}
}
@ -527,9 +527,10 @@ class Room {
* Also it's not allowed in one-to-one conversations,
* file conversations and password request conversations.
* @param \DateTime|null $dateTime
* @param bool $timerReached
* @return bool True when the change was valid, false otherwise
*/
public function setLobby(int $newState, ?\DateTime $dateTime): bool {
public function setLobby(int $newState, ?\DateTime $dateTime, bool $timerReached = false): bool {
$oldState = $this->lobbyState;
if (!in_array($this->getType(), [self::GROUP_CALL, self::PUBLIC_CALL], true)) {
@ -548,6 +549,7 @@ class Room {
'newState' => $newState,
'oldState' => $oldState,
'lobbyTimer' => $dateTime,
'timerReached' => $timerReached,
]));
$query = $this->db->getQueryBuilder();
@ -563,6 +565,7 @@ class Room {
'newState' => $newState,
'oldState' => $oldState,
'lobbyTimer' => $dateTime,
'timerReached' => $timerReached,
]));
return true;