diff options
author | Joas Schilling <coding@schilljs.com> | 2024-03-07 18:55:20 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-03-07 19:10:32 +0100 |
commit | 7d4bcb4d8555d9dda622c7b9103e3ce3833eb3d6 (patch) | |
tree | 70c3971356b15a84839ef9f4b305be91e55782b3 /lib/Controller | |
parent | 56af1c1e72ab587073a6c5b5d8b03cd56266d163 (diff) |
fix(federation): Allow to remove self from a federated conversation
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/FederationController.php | 6 | ||||
-rw-r--r-- | lib/Controller/RoomController.php | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/Controller/FederationController.php b/lib/Controller/FederationController.php index cb1f23940..5cc0ef441 100644 --- a/lib/Controller/FederationController.php +++ b/lib/Controller/FederationController.php @@ -156,7 +156,7 @@ class FederationController extends OCSController { * * 🚧 Draft: Still work in progress * - * @return DataResponse<Http::STATUS_OK, TalkFederationInvite[], array{}> + * @return DataResponse<Http::STATUS_OK, list<TalkFederationInvite>, array{}> * * 200: Get list of received federation invites successfully */ @@ -169,8 +169,8 @@ class FederationController extends OCSController { } $invitations = $this->federationManager->getRemoteRoomShares($user); - /** @var TalkFederationInvite[] $data */ - $data = array_filter(array_map([$this, 'enrichInvite'], $invitations)); + /** @var list<TalkFederationInvite> $data */ + $data = array_values(array_filter(array_map([$this, 'enrichInvite'], $invitations))); return new DataResponse($data); } diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 90e792285..e05b69f33 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -39,6 +39,7 @@ use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\Exceptions\UnauthorizedException; use OCA\Talk\Federation\Authenticator; +use OCA\Talk\Federation\BackendNotifier; use OCA\Talk\GuestManager; use OCA\Talk\Manager; use OCA\Talk\MatterbridgeManager; @@ -125,6 +126,7 @@ class RoomController extends AEnvironmentAwareController { protected LoggerInterface $logger, protected Authenticator $federationAuthenticator, protected Capabilities $capabilities, + protected BackendNotifier $federationBackendNotifier, ) { parent::__construct($appName, $request); } @@ -1246,6 +1248,7 @@ class RoomController extends AEnvironmentAwareController { * 400: Removing participant is not possible * 404: Participant not found */ + #[FederationSupported] #[NoAdminRequired] #[RequireLoggedInParticipant] public function removeSelfFromRoom(): DataResponse { @@ -1256,6 +1259,14 @@ class RoomController extends AEnvironmentAwareController { * @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND, array<empty>, array{}> */ protected function removeSelfFromRoomLogic(Room $room, Participant $participant): DataResponse { + if ($room->getRemoteServer() !== '') { + $this->federationBackendNotifier->sendShareDeclined( + $room->getRemoteServer(), + (int) $participant->getAttendee()->getRemoteId(), + $participant->getAttendee()->getAccessToken(), + ); + } + if ($room->getType() !== Room::TYPE_ONE_TO_ONE && $room->getType() !== Room::TYPE_ONE_TO_ONE_FORMER) { if ($participant->hasModeratorPermissions(false) && $this->participantService->getNumberOfUsers($room) > 1 |