Browse Source

feat(events): Emitted typed events for room modifications

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/10731/head
Joas Schilling 2 years ago
parent
commit
9a75ba089f
No known key found for this signature in database GPG Key ID: 74434EFE0D2E2205
  1. 42
      lib/Events/ACallEndedForEveryoneEvent.php
  2. 51
      lib/Events/ALobbyModifiedEvent.php
  3. 76
      lib/Events/ARoomModifiedEvent.php
  4. 27
      lib/Events/BeforeCallEndedForEveryoneEvent.php
  5. 27
      lib/Events/BeforeLobbyModifiedEvent.php
  6. 2
      lib/Events/BeforeRoomModifiedEvent.php
  7. 57
      lib/Events/CallEndedForEveryoneEvent.php
  8. 27
      lib/Events/LobbyModifiedEvent.php
  9. 2
      lib/Events/RoomModifiedEvent.php
  10. 6
      lib/Service/ParticipantService.php
  11. 75
      lib/Service/RoomService.php

42
lib/Events/ACallEndedForEveryoneEvent.php

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
abstract class ACallEndedForEveryoneEvent extends ARoomModifiedEvent {
public function __construct(
Room $room,
?Participant $actor = null,
) {
parent::__construct(
$room,
self::PROPERTY_IN_CALL,
Participant::FLAG_DISCONNECTED,
null,
$actor
);
}
}

51
lib/Events/ALobbyModifiedEvent.php

@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Room;
abstract class ALobbyModifiedEvent extends ARoomModifiedEvent {
public function __construct(
Room $room,
string|int $newValue,
string|int|null $oldValue,
protected ?\DateTime $lobbyTimer,
protected bool $timerReached,
) {
parent::__construct(
$room,
self::PROPERTY_LOBBY,
$newValue,
$oldValue,
);
}
public function getLobbyTimer(): ?\DateTime {
return $this->lobbyTimer;
}
public function isTimerReached(): bool {
return $this->timerReached;
}
}

76
lib/Events/ARoomModifiedEvent.php

@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
abstract class ARoomModifiedEvent extends RoomEvent {
public const PROPERTY_AVATAR = 'avatar';
public const PROPERTY_BREAKOUT_ROOM_MODE = 'breakoutRoomMode';
public const PROPERTY_BREAKOUT_ROOM_STATUS = 'breakoutRoomStatus';
public const PROPERTY_CALL_PERMISSIONS = 'callPermissions';
public const PROPERTY_CALL_RECORDING = 'callRecording';
public const PROPERTY_DEFAULT_PERMISSIONS = 'defaultPermissions';
public const PROPERTY_DESCRIPTION = 'description';
public const PROPERTY_IN_CALL = 'inCall';
public const PROPERTY_LISTABLE = 'listable';
public const PROPERTY_LOBBY = 'lobby';
public const PROPERTY_MESSAGE_EXPIRATION = 'messageExpiration';
public const PROPERTY_NAME = 'name';
public const PROPERTY_PASSWORD = 'password';
public const PROPERTY_READ_ONLY = 'readOnly';
public const PROPERTY_RECORDING_CONSENT = 'recordingConsent';
public const PROPERTY_SIP_ENABLED = 'sipEnabled';
public const PROPERTY_TYPE = 'type';
/**
* @param self::PROPERTY_* $property
*/
public function __construct(
Room $room,
protected string $property,
protected string|int $newValue,
protected string|int|null $oldValue = null,
protected ?Participant $actor = null,
) {
parent::__construct($room);
}
public function getProperty(): string {
return $this->property;
}
public function getNewValue(): string|int {
return $this->newValue;
}
public function getOldValue(): string|int|null {
return $this->oldValue;
}
public function getActor(): ?Participant {
return $this->actor;
}
}

27
lib/Events/BeforeCallEndedForEveryoneEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeCallEndedForEveryoneEvent extends ACallEndedForEveryoneEvent {
}

27
lib/Events/BeforeLobbyModifiedEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class BeforeLobbyModifiedEvent extends ALobbyModifiedEvent {
}

2
lib/Events/BeforeRoomModifiedEvent.php

@ -23,5 +23,5 @@ declare(strict_types=1);
namespace OCA\Talk\Events;
class BeforeRoomModifiedEvent extends ModifyRoomEvent {
class BeforeRoomModifiedEvent extends ARoomModifiedEvent {
}

57
lib/Events/CallEndedForEveryoneEvent.php

@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
use OCA\Talk\Participant;
use OCA\Talk\Room;
class CallEndedForEveryoneEvent extends ACallEndedForEveryoneEvent {
public function __construct(
Room $room,
?Participant $actor = null,
/** @var string[] */
protected array $sessionIds = [],
/** @var string[] */
protected array $userIds = [],
) {
parent::__construct(
$room,
$actor
);
}
/**
* @return string[]
*/
public function getSessionIds(): array {
return $this->sessionIds;
}
/**
* @return string[]
*/
public function getUserIds(): array {
return $this->userIds;
}
}

27
lib/Events/LobbyModifiedEvent.php

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Events;
class LobbyModifiedEvent extends ALobbyModifiedEvent {
}

2
lib/Events/RoomModifiedEvent.php

@ -23,5 +23,5 @@ declare(strict_types=1);
namespace OCA\Talk\Events;
class RoomModifiedEvent extends ModifyRoomEvent {
class RoomModifiedEvent extends ARoomModifiedEvent {
}

6
lib/Service/ParticipantService.php

@ -31,7 +31,9 @@ use OCA\Talk\Config;
use OCA\Talk\Events\AddParticipantsEvent;
use OCA\Talk\Events\AttendeesAddedEvent;
use OCA\Talk\Events\AttendeesRemovedEvent;
use OCA\Talk\Events\BeforeCallEndedForEveryoneEvent;
use OCA\Talk\Events\BeforeFederatedUserJoinedRoomEvent;
use OCA\Talk\Events\CallEndedForEveryoneEvent;
use OCA\Talk\Events\ChatEvent;
use OCA\Talk\Events\DuplicatedParticipantEvent;
use OCA\Talk\Events\EndCallForEveryoneEvent;
@ -1047,6 +1049,8 @@ class ParticipantService {
}
public function endCallForEveryone(Room $room, Participant $moderator): void {
$event = new BeforeCallEndedForEveryoneEvent($room, $moderator);
$this->dispatcher->dispatchTyped($event);
$event = new EndCallForEveryoneEvent($room, $moderator);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_END_CALL_FOR_EVERYONE, $event);
@ -1069,6 +1073,8 @@ class ParticipantService {
$event->setUserIds($changedUserIds);
$this->dispatcher->dispatch(Room::EVENT_AFTER_END_CALL_FOR_EVERYONE, $event);
$event = new CallEndedForEveryoneEvent($room, $moderator, $changedSessionIds, $changedUserIds);
$this->dispatcher->dispatchTyped($event);
}
public function changeInCall(Room $room, Participant $participant, int $flags, bool $endCallForEveryone = false, bool $silent = false): bool {

75
lib/Service/RoomService.php

@ -25,8 +25,11 @@ namespace OCA\Talk\Service;
use InvalidArgumentException;
use OCA\Talk\Config;
use OCA\Talk\Events\ARoomModifiedEvent;
use OCA\Talk\Events\BeforeLobbyModifiedEvent;
use OCA\Talk\Events\BeforeRoomDeletedEvent;
use OCA\Talk\Events\BeforeRoomModifiedEvent;
use OCA\Talk\Events\LobbyModifiedEvent;
use OCA\Talk\Events\ModifyLobbyEvent;
use OCA\Talk\Events\ModifyRoomEvent;
use OCA\Talk\Events\RoomDeletedEvent;
@ -185,8 +188,10 @@ class RoomService {
}
if ($level === 'default') {
$property = ARoomModifiedEvent::PROPERTY_DEFAULT_PERMISSIONS;
$oldPermissions = $room->getDefaultPermissions();
} elseif ($level === 'call') {
$property = ARoomModifiedEvent::PROPERTY_CALL_PERMISSIONS;
$oldPermissions = $room->getCallPermissions();
} else {
return false;
@ -209,6 +214,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, $property, $newPermissions, $oldPermissions);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, $level . 'Permissions', $newPermissions, $oldPermissions);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_PERMISSIONS_SET, $event);
@ -231,6 +238,8 @@ class RoomService {
}
$this->dispatcher->dispatch(Room::EVENT_AFTER_PERMISSIONS_SET, $event);
$event = new RoomModifiedEvent($room, $property, $newPermissions, $oldPermissions);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -258,6 +267,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_SIP_ENABLED, $newSipEnabled, $oldSipEnabled);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'sipEnabled', $newSipEnabled, $oldSipEnabled);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SIP_ENABLED_SET, $event);
@ -270,6 +281,8 @@ class RoomService {
$room->setSIPEnabled($newSipEnabled);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SIP_ENABLED_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_SIP_ENABLED, $newSipEnabled, $oldSipEnabled);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -301,7 +314,7 @@ class RoomService {
throw new InvalidArgumentException('breakout-room');
}
$event = new BeforeRoomModifiedEvent($room, 'recordingConsent', $recordingConsent, $oldRecordingConsent);
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_RECORDING_CONSENT, $recordingConsent, $oldRecordingConsent);
$this->dispatcher->dispatchTyped($event);
$now = $this->timeFactory->getDateTime();
@ -316,7 +329,7 @@ class RoomService {
$room->setRecordingConsent($recordingConsent);
$room->setLastActivity($now);
$event = new RoomModifiedEvent($room, 'recordingConsent', $recordingConsent, $oldRecordingConsent);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_RECORDING_CONSENT, $recordingConsent, $oldRecordingConsent);
$this->dispatcher->dispatchTyped($event);
// Update the recording consent for all rooms
@ -339,6 +352,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_NAME, $newName, $oldName);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'name', $newName, $oldName);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_NAME_SET, $event);
@ -351,6 +366,8 @@ class RoomService {
$room->setName($newName);
$this->dispatcher->dispatch(Room::EVENT_AFTER_NAME_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_NAME, $newName, $oldName);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -381,9 +398,11 @@ class RoomService {
return false;
}
$event = new ModifyLobbyEvent($room, 'lobby', $newState, $oldState, $dateTime, $timerReached);
$legacyEvent = new ModifyLobbyEvent($room, 'lobby', $newState, $oldState, $dateTime, $timerReached);
if ($dispatchEvents) {
$this->dispatcher->dispatch(Room::EVENT_BEFORE_LOBBY_STATE_SET, $event);
$event = new BeforeLobbyModifiedEvent($room, $newState, $oldState, $dateTime, $timerReached);
$this->dispatcher->dispatchTyped($event);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_LOBBY_STATE_SET, $legacyEvent);
}
$update = $this->db->getQueryBuilder();
@ -397,7 +416,9 @@ class RoomService {
$room->setLobbyTimer($dateTime);
if ($dispatchEvents) {
$this->dispatcher->dispatch(Room::EVENT_AFTER_LOBBY_STATE_SET, $event);
$this->dispatcher->dispatch(Room::EVENT_AFTER_LOBBY_STATE_SET, $legacyEvent);
$event = new LobbyModifiedEvent($room, $newState, $oldState, $dateTime, $timerReached);
$this->dispatcher->dispatchTyped($event);
}
return true;
@ -408,6 +429,9 @@ class RoomService {
return false;
}
$oldAvatar = $room->getAvatar();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_AVATAR, $avatar, $oldAvatar);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'avatar', $avatar, $room->getAvatar());
$this->dispatcher->dispatch(Room::EVENT_BEFORE_AVATAR_SET, $event);
@ -420,6 +444,8 @@ class RoomService {
$room->setAvatar($avatar);
$this->dispatcher->dispatch(Room::EVENT_AFTER_AVATAR_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_AVATAR, $avatar, $oldAvatar);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -442,6 +468,8 @@ class RoomService {
}
$oldStatus = $room->getCallRecording();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_CALL_RECORDING, $status, $oldStatus, $participant);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'callRecording', $status, $oldStatus, $participant);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_CALL_RECORDING, $event);
@ -454,6 +482,8 @@ class RoomService {
$room->setCallRecording($status);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SET_CALL_RECORDING, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_CALL_RECORDING, $status, $oldStatus, $participant);
$this->dispatcher->dispatchTyped($event);
}
/**
@ -497,6 +527,8 @@ class RoomService {
$oldType = $room->getType();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_TYPE, $newType, $oldType);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'type', $newType, $oldType);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_TYPE_SET, $event);
@ -518,6 +550,8 @@ class RoomService {
}
$this->dispatcher->dispatch(Room::EVENT_AFTER_TYPE_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_TYPE, $newType, $oldType);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -547,6 +581,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_READ_ONLY, $newState, $oldState);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'readOnly', $newState, $oldState);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_READONLY_SET, $event);
@ -559,6 +595,8 @@ class RoomService {
$room->setReadOnly($newState);
$this->dispatcher->dispatch(Room::EVENT_AFTER_READONLY_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_READ_ONLY, $newState, $oldState);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -592,6 +630,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_LISTABLE, $newState, $oldState);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'listable', $newState, $oldState);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_LISTABLE_SET, $event);
@ -604,6 +644,8 @@ class RoomService {
$room->setListable($newState);
$this->dispatcher->dispatch(Room::EVENT_AFTER_LISTABLE_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_LISTABLE, $newState, $oldState);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -643,6 +685,8 @@ class RoomService {
return false;
}
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_DESCRIPTION, $description, $oldDescription);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'description', $description, $oldDescription);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_DESCRIPTION_SET, $event);
@ -655,6 +699,8 @@ class RoomService {
$room->setDescription($description);
$this->dispatcher->dispatch(Room::EVENT_AFTER_DESCRIPTION_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_DESCRIPTION, $description, $oldDescription);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -680,6 +726,8 @@ class RoomService {
$hash = $password !== '' ? $this->hasher->hash($password) : '';
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_PASSWORD, $password);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'password', $password);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_PASSWORD_SET, $event);
@ -692,6 +740,8 @@ class RoomService {
$room->setPassword($hash);
$this->dispatcher->dispatch(Room::EVENT_AFTER_PASSWORD_SET, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_PASSWORD, $password);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -721,6 +771,9 @@ class RoomService {
throw new \InvalidArgumentException('room');
}
$oldExpiration = $room->getMessageExpiration();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_MESSAGE_EXPIRATION, $seconds, $oldExpiration);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'messageExpiration', $seconds);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_MESSAGE_EXPIRATION, $event);
@ -733,6 +786,8 @@ class RoomService {
$room->setMessageExpiration($seconds);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SET_MESSAGE_EXPIRATION, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_MESSAGE_EXPIRATION, $seconds, $oldExpiration);
$this->dispatcher->dispatchTyped($event);
}
public function setBreakoutRoomMode(Room $room, int $mode): bool {
@ -745,6 +800,9 @@ class RoomService {
return false;
}
$oldMode = $room->getBreakoutRoomMode();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_BREAKOUT_ROOM_MODE, $mode, $oldMode);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'breakoutRoomMode', $mode);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_BREAKOUT_ROOM_MODE, $event);
@ -757,6 +815,8 @@ class RoomService {
$room->setBreakoutRoomMode($mode);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SET_BREAKOUT_ROOM_MODE, $event);
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_BREAKOUT_ROOM_MODE, $mode, $oldMode);
$this->dispatcher->dispatchTyped($event);
return true;
}
@ -771,6 +831,9 @@ class RoomService {
return false;
}
$oldStatus = $room->getBreakoutRoomStatus();
$event = new BeforeRoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_BREAKOUT_ROOM_STATUS, $status, $oldStatus);
$this->dispatcher->dispatchTyped($event);
$event = new ModifyRoomEvent($room, 'breakoutRoomStatus', $status);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_BREAKOUT_ROOM_STATUS, $event);
@ -783,6 +846,8 @@ class RoomService {
$room->setBreakoutRoomStatus($status);
$this->dispatcher->dispatch(Room::EVENT_AFTER_SET_BREAKOUT_ROOM_STATUS, $event);
$oldStatus = $room->getBreakoutRoomStatus();
$event = new RoomModifiedEvent($room, ARoomModifiedEvent::PROPERTY_BREAKOUT_ROOM_STATUS, $status, $oldStatus);
return true;
}

Loading…
Cancel
Save