Browse Source

feat(events): Add type events for remaining room events

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/10731/head
Joas Schilling 2 years ago
parent
commit
c4fc290ec9
No known key found for this signature in database GPG Key ID: 74434EFE0D2E2205
  1. 1
      lib/Controller/RoomController.php
  2. 27
      lib/Events/BeforeGuestsCleanedUpEvent.php
  3. 3
      lib/Events/CreateRoomTokenEvent.php
  4. 27
      lib/Events/GuestsCleanedUpEvent.php
  5. 27
      lib/Events/RoomCreatedEvent.php
  6. 3
      lib/Events/RoomEvent.php
  7. 3
      lib/Events/UserEvent.php
  8. 4
      lib/Manager.php
  9. 5
      lib/Room.php
  10. 6
      lib/Service/ParticipantService.php

1
lib/Controller/RoomController.php

@ -91,6 +91,7 @@ use Psr\Log\LoggerInterface;
* @psalm-import-type TalkRoom from ResponseDefinitions
*/
class RoomController extends AEnvironmentAwareController {
/** @deprecated */
public const EVENT_BEFORE_ROOMS_GET = self::class . '::preGetRooms';
protected array $commonReadMessages = [];

27
lib/Events/BeforeGuestsCleanedUpEvent.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 BeforeGuestsCleanedUpEvent extends RoomEvent {
}

3
lib/Events/CreateRoomTokenEvent.php

@ -25,6 +25,9 @@ namespace OCA\Talk\Events;
use OCP\EventDispatcher\Event;
/**
* @deprecated
*/
class CreateRoomTokenEvent extends Event {
protected string $token;

27
lib/Events/GuestsCleanedUpEvent.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 GuestsCleanedUpEvent extends RoomEvent {
}

27
lib/Events/RoomCreatedEvent.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 RoomCreatedEvent extends RoomEvent {
}

3
lib/Events/RoomEvent.php

@ -26,6 +26,9 @@ namespace OCA\Talk\Events;
use OCA\Talk\Room;
use OCP\EventDispatcher\Event;
/**
* @deprecated
*/
class RoomEvent extends Event {

3
lib/Events/UserEvent.php

@ -25,6 +25,9 @@ namespace OCA\Talk\Events;
use OCP\EventDispatcher\Event;
/**
* @deprecated
*/
class UserEvent extends Event {

4
lib/Manager.php

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace OCA\Talk;
use OCA\Talk\Chat\CommentsManager;
use OCA\Talk\Events\RoomCreatedEvent;
use OCA\Talk\Events\RoomEvent;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
@ -53,6 +54,7 @@ use OCP\Security\ISecureRandom;
use OCP\Server;
class Manager {
/** @deprecated */
public const EVENT_TOKEN_GENERATE = self::class . '::generateNewToken';
protected ICommentsManager $commentsManager;
@ -1063,6 +1065,8 @@ class Manager {
$event = new RoomEvent($room);
$this->dispatcher->dispatch(Room::EVENT_AFTER_ROOM_CREATE, $event);
$event = new RoomCreatedEvent($room);
$this->dispatcher->dispatchTyped($event);
return $room;
}

5
lib/Room.php

@ -103,8 +103,11 @@ class Room {
public const PARTICIPANT_REMOVED_ALL = 'remove_all';
public const PARTICIPANT_LEFT = 'leave';
/** @deprecated */
public const EVENT_AFTER_ROOM_CREATE = self::class . '::createdRoom';
/** @deprecated */
public const EVENT_BEFORE_ROOM_DELETE = self::class . '::preDeleteRoom';
/** @deprecated */
public const EVENT_AFTER_ROOM_DELETE = self::class . '::postDeleteRoom';
/** @deprecated */
public const EVENT_BEFORE_NAME_SET = self::class . '::preSetName';
@ -163,7 +166,9 @@ class Room {
public const EVENT_BEFORE_GUEST_CONNECT = self::class . '::preJoinRoomGuest';
public const EVENT_AFTER_GUEST_CONNECT = self::class . '::postJoinRoomGuest';
public const EVENT_PASSWORD_VERIFY = self::class . '::verifyPassword';
/** @deprecated */
public const EVENT_BEFORE_GUESTS_CLEAN = self::class . '::preCleanGuests';
/** @deprecated */
public const EVENT_AFTER_GUESTS_CLEAN = self::class . '::postCleanGuests';
public const EVENT_BEFORE_SESSION_JOIN_CALL = self::class . '::preSessionJoinCall';
public const EVENT_AFTER_SESSION_JOIN_CALL = self::class . '::postSessionJoinCall';

6
lib/Service/ParticipantService.php

@ -33,11 +33,13 @@ use OCA\Talk\Events\AttendeesAddedEvent;
use OCA\Talk\Events\AttendeesRemovedEvent;
use OCA\Talk\Events\BeforeCallEndedForEveryoneEvent;
use OCA\Talk\Events\BeforeFederatedUserJoinedRoomEvent;
use OCA\Talk\Events\BeforeGuestsCleanedUpEvent;
use OCA\Talk\Events\CallEndedForEveryoneEvent;
use OCA\Talk\Events\ChatEvent;
use OCA\Talk\Events\DuplicatedParticipantEvent;
use OCA\Talk\Events\EndCallForEveryoneEvent;
use OCA\Talk\Events\FederatedUserJoinedRoomEvent;
use OCA\Talk\Events\GuestsCleanedUpEvent;
use OCA\Talk\Events\JoinRoomGuestEvent;
use OCA\Talk\Events\JoinRoomUserEvent;
use OCA\Talk\Events\ModifyEveryoneEvent;
@ -985,6 +987,8 @@ class ParticipantService {
}
public function cleanGuestParticipants(Room $room): void {
$event = new BeforeGuestsCleanedUpEvent($room);
$this->dispatcher->dispatchTyped($event);
$event = new RoomEvent($room);
$this->dispatcher->dispatch(Room::EVENT_BEFORE_GUESTS_CLEAN, $event);
@ -1046,6 +1050,8 @@ class ParticipantService {
$this->dispatcher->dispatchTyped($attendeeEvent);
$this->dispatcher->dispatch(Room::EVENT_AFTER_GUESTS_CLEAN, $event);
$event = new GuestsCleanedUpEvent($room);
$this->dispatcher->dispatchTyped($event);
}
public function endCallForEveryone(Room $room, Participant $moderator): void {

Loading…
Cancel
Save