diff --git a/lib/Federation/BackendNotifier.php b/lib/Federation/BackendNotifier.php index db891f07c92..809d55c2271 100644 --- a/lib/Federation/BackendNotifier.php +++ b/lib/Federation/BackendNotifier.php @@ -81,6 +81,9 @@ public function sendRemoteShare( $roomOwner = $this->userManager->get($roomOwnerAttendee->getActorId()); $remote = $this->prepareRemoteUrl($invitedCloudId->getRemote()); + if (str_starts_with($remote, 'https://')) { + $remote = substr($remote, 8); + } $shareWithCloudId = $invitedCloudId->getUser() . '@' . $remote; $share = $this->cloudFederationFactory->getCloudFederationShare( diff --git a/lib/Federation/FederationManager.php b/lib/Federation/FederationManager.php index 272f6f79b73..685dcfacea1 100644 --- a/lib/Federation/FederationManager.php +++ b/lib/Federation/FederationManager.php @@ -10,10 +10,12 @@ use OCA\Talk\AppInfo\Application; use OCA\Talk\Exceptions\CannotReachRemoteException; +use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\Exceptions\UnauthorizedException; use OCA\Talk\Manager; use OCA\Talk\Model\Attendee; +use OCA\Talk\Model\AttendeeMapper; use OCA\Talk\Model\Invitation; use OCA\Talk\Model\InvitationMapper; use OCA\Talk\Participant; @@ -21,8 +23,6 @@ use OCA\Talk\Service\ParticipantService; use OCA\Talk\Service\RoomService; use OCP\AppFramework\Db\DoesNotExistException; -use OCP\AppFramework\Http; -use OCP\Federation\Exceptions\ProviderCouldNotAddShareException; use OCP\Federation\ICloudId; use OCP\Federation\ICloudIdManager; use OCP\IUser; @@ -53,6 +53,7 @@ public function __construct( private ParticipantService $participantService, private RoomService $roomService, private InvitationMapper $invitationMapper, + private AttendeeMapper $attendeeMapper, private BackendNotifier $backendNotifier, private IManager $notificationManager, private ICloudIdManager $cloudIdManager, @@ -108,6 +109,18 @@ public function addRemoteRoom( $invitation->setRemoteAttendeeId($remoteAttendeeId); $invitation->setInviterCloudId($inviterCloudId); $invitation->setInviterDisplayName($inviterDisplayName); + + if ($invitation->getState() === Invitation::STATE_ACCEPTED) { + try { + $participant = $this->participantService->getParticipantByActor($room, Attendee::ACTOR_USERS, $user->getUID()); + $attendee = $participant->getAttendee(); + $attendee->setAccessToken($sharedSecret); + $attendee->setRemoteId((string)$remoteAttendeeId); + $this->attendeeMapper->update($attendee); + } catch (ParticipantNotFoundException) { + $invitation->setState(Invitation::STATE_PENDING); + } + } $this->invitationMapper->update($invitation); return $invitation; diff --git a/tests/php/Federation/FederationTest.php b/tests/php/Federation/FederationTest.php index 94c465503e2..1724014347a 100644 --- a/tests/php/Federation/FederationTest.php +++ b/tests/php/Federation/FederationTest.php @@ -145,7 +145,7 @@ public function testSendRemoteShareWithOwner(): void { $providerId = '3'; $token = 'abcdefghijklmno'; - $shareWith = 'test@https://remote.test.local'; + $shareWith = 'test@remote.test.local'; $name = 'abcdefgh'; $owner = 'Owner\'s name'; $ownerId = 'owner';