Browse Source
feat(events): Migrate session join and leave to typed events
feat(events): Migrate session join and leave to typed events
Signed-off-by: Joas Schilling <coding@schilljs.com>pull/10731/head
No known key found for this signature in database
GPG Key ID: 74434EFE0D2E2205
15 changed files with 397 additions and 15 deletions
-
29docs/events.md
-
58lib/Events/ABeforeJoinedRoomEvent.php
-
45lib/Events/ASessionLeftRoomEvent.php
-
29lib/Events/BeforeGuestJoinedRoomEvent.php
-
27lib/Events/BeforeSessionLeftRoomEvent.php
-
46lib/Events/BeforeUserJoinedRoomEvent.php
-
3lib/Events/DuplicatedParticipantEvent.php
-
40lib/Events/GuestJoinedRoomEvent.php
-
3lib/Events/JoinRoomGuestEvent.php
-
3lib/Events/JoinRoomUserEvent.php
-
3lib/Events/ParticipantEvent.php
-
27lib/Events/SessionLeftRoomEvent.php
-
46lib/Events/UserJoinedRoomEvent.php
-
6lib/Room.php
-
47lib/Service/ParticipantService.php
@ -0,0 +1,58 @@ |
|||
<?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\Room; |
|||
|
|||
abstract class ABeforeJoinedRoomEvent extends RoomEvent { |
|||
protected bool $cancelJoin = false; |
|||
|
|||
public function __construct( |
|||
Room $room, |
|||
protected string $password, |
|||
protected bool $passedPasswordProtection, |
|||
) { |
|||
parent::__construct($room); |
|||
} |
|||
|
|||
public function setCancelJoin(bool $cancelJoin): void { |
|||
$this->cancelJoin = $cancelJoin; |
|||
} |
|||
|
|||
public function getCancelJoin(): bool { |
|||
return $this->cancelJoin; |
|||
} |
|||
|
|||
public function getPassword(): string { |
|||
return $this->password; |
|||
} |
|||
|
|||
public function setPassedPasswordProtection(bool $passedPasswordProtection): void { |
|||
$this->passedPasswordProtection = $passedPasswordProtection; |
|||
} |
|||
|
|||
public function getPassedPasswordProtection(): bool { |
|||
return $this->passedPasswordProtection; |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
<?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 ASessionLeftRoomEvent extends RoomEvent { |
|||
public function __construct( |
|||
Room $room, |
|||
protected Participant $participant, |
|||
protected bool $rejoining, |
|||
) { |
|||
parent::__construct($room); |
|||
} |
|||
|
|||
public function getParticipant(): Participant { |
|||
return $this->participant; |
|||
} |
|||
|
|||
public function isRejoining(): bool { |
|||
return $this->rejoining; |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
<?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\Room; |
|||
|
|||
class BeforeGuestJoinedRoomEvent extends ABeforeJoinedRoomEvent { |
|||
} |
|||
@ -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 BeforeSessionLeftRoomEvent extends ASessionLeftRoomEvent { |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
<?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\Room; |
|||
use OCP\IUser; |
|||
|
|||
class BeforeUserJoinedRoomEvent extends ABeforeJoinedRoomEvent { |
|||
public function __construct( |
|||
Room $room, |
|||
protected IUser $user, |
|||
string $password, |
|||
bool $passedPasswordProtection, |
|||
) { |
|||
parent::__construct($room, $password, $passedPasswordProtection); |
|||
} |
|||
|
|||
public function getUser(): IUser { |
|||
return $this->user; |
|||
} |
|||
|
|||
public function getPassword(): string { |
|||
return $this->password; |
|||
} |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
<?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 GuestJoinedRoomEvent extends RoomEvent { |
|||
public function __construct( |
|||
Room $room, |
|||
protected Participant $participant, |
|||
) { |
|||
parent::__construct($room); |
|||
} |
|||
|
|||
public function getParticipant(): Participant { |
|||
return $this->participant; |
|||
} |
|||
} |
|||
@ -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 SessionLeftRoomEvent extends ASessionLeftRoomEvent { |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
<?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; |
|||
use OCP\IUser; |
|||
|
|||
class UserJoinedRoomEvent extends RoomEvent { |
|||
public function __construct( |
|||
Room $room, |
|||
protected IUser $user, |
|||
protected Participant $participant, |
|||
) { |
|||
parent::__construct($room); |
|||
} |
|||
|
|||
public function getUser(): IUser { |
|||
return $this->user; |
|||
} |
|||
|
|||
public function getParticipant(): Participant { |
|||
return $this->participant; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue