Skip to content

Commit

Permalink
fix(federation): Also reset information for the attendee
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Sep 30, 2024
1 parent 3161484 commit 04febb2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/Federation/BackendNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
17 changes: 15 additions & 2 deletions lib/Federation/FederationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

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;
use OCA\Talk\Room;
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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Federation/FederationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function testSendRemoteShareWithOwner(): void {

$providerId = '3';
$token = 'abcdefghijklmno';
$shareWith = 'test@https://remote.test.local';
$shareWith = '[email protected]';
$name = 'abcdefgh';
$owner = 'Owner\'s name';
$ownerId = 'owner';
Expand Down

0 comments on commit 04febb2

Please sign in to comment.