Skip to content

Commit

Permalink
fix(federation): Don't remove federation rooms while waiting for acce…
Browse files Browse the repository at this point in the history
…pt/reject

Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Oct 11, 2023
1 parent c5bad1d commit e86fac3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
7 changes: 7 additions & 0 deletions lib/BackgroundJob/RemoveEmptyRooms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
) {
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 0 additions & 6 deletions lib/Federation/FederationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down
7 changes: 0 additions & 7 deletions lib/Model/InvitationMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public function __construct(IDBConnection $db) {
}

/**
* @throws DBException
* @throws MultipleObjectsReturnedException
* @throws DoesNotExistException
*/
public function getInvitationById(int $id): Invitation {
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();

Expand Down

0 comments on commit e86fac3

Please sign in to comment.