From e86fac30d4c19be47e8d40ec671aaefd706dec05 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 11 Oct 2023 07:02:42 +0200 Subject: [PATCH] fix(federation): Don't remove federation rooms while waiting for accept/reject Signed-off-by: Joas Schilling --- lib/BackgroundJob/RemoveEmptyRooms.php | 7 +++++++ lib/Federation/FederationManager.php | 6 ------ lib/Model/InvitationMapper.php | 7 ------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/BackgroundJob/RemoveEmptyRooms.php b/lib/BackgroundJob/RemoveEmptyRooms.php index 0c590b62ecd..09e0646aa98 100644 --- a/lib/BackgroundJob/RemoveEmptyRooms.php +++ b/lib/BackgroundJob/RemoveEmptyRooms.php @@ -23,6 +23,7 @@ namespace OCA\Talk\BackgroundJob; +use OCA\Talk\Federation\FederationManager; use OCA\Talk\Manager; use OCA\Talk\Room; use OCA\Talk\Service\ParticipantService; @@ -47,6 +48,7 @@ public function __construct( protected Manager $manager, protected RoomService $roomService, protected ParticipantService $participantService, + protected FederationManager $federationManager, protected LoggerInterface $logger, protected IUserMountCache $userMountCache, ) { @@ -89,6 +91,11 @@ private function deleteIfIsEmpty(Room $room): bool { return false; } + if ($room->getRemoteServer() && $room->getRemoteToken() + && $this->federationManager->getNumberOfInvitations($room) !== 0) { + return false; + } + $this->doDeleteRoom($room); return true; } diff --git a/lib/Federation/FederationManager.php b/lib/Federation/FederationManager.php index 55acd2f5a99..8575b507440 100644 --- a/lib/Federation/FederationManager.php +++ b/lib/Federation/FederationManager.php @@ -136,9 +136,7 @@ public function acceptRemoteRoomShare(IUser $user, int $shareId): void { } /** - * @throws DBException * @throws UnauthorizedException - * @throws MultipleObjectsReturnedException * @throws DoesNotExistException */ public function rejectRemoteRoomShare(IUser $user, int $shareId): void { @@ -157,15 +155,11 @@ public function rejectRemoteRoomShare(IUser $user, int $shareId): void { /** * @param IUser $user * @return Invitation[] - * @throws DBException */ public function getRemoteRoomShares(IUser $user): array { return $this->invitationMapper->getInvitationsForUser($user); } - /** - * @throws DBException - */ public function getNumberOfInvitations(Room $room): int { return $this->invitationMapper->countInvitationsForRoom($room); } diff --git a/lib/Model/InvitationMapper.php b/lib/Model/InvitationMapper.php index 1d99bdf167b..8152f0a3099 100644 --- a/lib/Model/InvitationMapper.php +++ b/lib/Model/InvitationMapper.php @@ -50,8 +50,6 @@ public function __construct(IDBConnection $db) { } /** - * @throws DBException - * @throws MultipleObjectsReturnedException * @throws DoesNotExistException */ public function getInvitationById(int $id): Invitation { @@ -67,7 +65,6 @@ public function getInvitationById(int $id): Invitation { /** * @param Room $room * @return Invitation[] - * @throws DBException */ public function getInvitationsForRoom(Room $room): array { $qb = $this->db->getQueryBuilder(); @@ -82,7 +79,6 @@ public function getInvitationsForRoom(Room $room): array { /** * @param IUser $user * @return Invitation[] - * @throws DBException */ public function getInvitationsForUser(IUser $user): array { $qb = $this->db->getQueryBuilder(); @@ -94,9 +90,6 @@ public function getInvitationsForUser(IUser $user): array { return $this->findEntities($qb); } - /** - * @throws DBException - */ public function countInvitationsForRoom(Room $room): int { $qb = $this->db->getQueryBuilder();