diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-03-07 21:15:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 21:15:22 +0100 |
commit | 50cad99bcd1a97d6e525f774d64c1725571e6760 (patch) | |
tree | df7af9468440bb24f63837f4129e1a50a5029b20 /lib | |
parent | 4334f544951b2bc658e513e46d4e4e6308d48822 (diff) | |
parent | 7d4bcb4d8555d9dda622c7b9103e3ce3833eb3d6 (diff) |
Merge pull request #11747 from nextcloud/bugfix/noid/allow-to-remove-self
fix(federation): Allow to remove self from a federated conversation
Diffstat (limited to 'lib')
-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 f02451e2d..e725eb663 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); } @@ -1249,6 +1251,7 @@ class RoomController extends AEnvironmentAwareController { * 400: Removing participant is not possible * 404: Participant not found */ + #[FederationSupported] #[NoAdminRequired] #[RequireLoggedInParticipant] public function removeSelfFromRoom(): DataResponse { @@ -1259,6 +1262,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 |