Skip to content

Commit

Permalink
Fix the system message when the timer was reached
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jul 24, 2019
1 parent 42d097f commit af0751f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ public function parseMessage(Message $chatMessage): void {
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) {
Expand Down
4 changes: 3 additions & 1 deletion lib/Chat/SystemMessage/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ public static function register(EventDispatcherInterface $dispatcher): void {
/** @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());
Expand Down
7 changes: 5 additions & 2 deletions lib/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function getLobbyTimer(): ?\DateTime {

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

Expand Down Expand Up @@ -527,9 +527,10 @@ public function setReadOnly(int $newState): bool {
* 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)) {
return false;
Expand All @@ -547,6 +548,7 @@ public function setLobby(int $newState, ?\DateTime $dateTime): bool {
'newState' => $newState,
'oldState' => $oldState,
'lobbyTimer' => $dateTime,
'timerReached' => $timerReached,
]));

$query = $this->db->getQueryBuilder();
Expand All @@ -562,6 +564,7 @@ public function setLobby(int $newState, ?\DateTime $dateTime): bool {
'newState' => $newState,
'oldState' => $oldState,
'lobbyTimer' => $dateTime,
'timerReached' => $timerReached,
]));

return true;
Expand Down

0 comments on commit af0751f

Please sign in to comment.