summaryrefslogtreecommitdiffstats
path: root/lib/Federation/CloudFederationProviderTalk.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-02-14 12:44:27 +0100
committerJoas Schilling <coding@schilljs.com>2024-02-23 14:33:00 +0100
commit74e75417be28f0329ce98667ce4d84bd03e6441c (patch)
tree381bcdaee20bcc6fa3b7a23981c0250d955b910b /lib/Federation/CloudFederationProviderTalk.php
parent848fecf97d0e218c42fa6b31e93d140ab8ad7caa (diff)
feat(federation): Add TalkV1 federation proxy for mentions
Decision is to proxy the requests on the own server, so we can proxy other services (matrix coming to mind) in the future and the clients still have to only talk to their own server, to help with CSP and to reduce the efforts Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Federation/CloudFederationProviderTalk.php')
-rw-r--r--lib/Federation/CloudFederationProviderTalk.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Federation/CloudFederationProviderTalk.php b/lib/Federation/CloudFederationProviderTalk.php
index fc3f6c682..2d68aa1f6 100644
--- a/lib/Federation/CloudFederationProviderTalk.php
+++ b/lib/Federation/CloudFederationProviderTalk.php
@@ -53,6 +53,7 @@ use OCP\Federation\Exceptions\BadRequestException;
use OCP\Federation\Exceptions\ProviderCouldNotAddShareException;
use OCP\Federation\ICloudFederationProvider;
use OCP\Federation\ICloudFederationShare;
+use OCP\Federation\ICloudIdManager;
use OCP\HintException;
use OCP\ISession;
use OCP\IUser;
@@ -65,6 +66,7 @@ use SensitiveParameter;
class CloudFederationProviderTalk implements ICloudFederationProvider {
public function __construct(
+ private ICloudIdManager $cloudIdManager,
private IUserManager $userManager,
private AddressHandler $addressHandler,
private FederationManager $federationManager,
@@ -120,6 +122,12 @@ class CloudFederationProviderTalk implements ICloudFederationProvider {
$remoteId = $share->getProviderId();
$roomToken = $share->getResourceName();
$roomName = $share->getProtocol()['roomName'];
+ if (isset($share->getProtocol()['invitedCloudId'])) {
+ $invitedCloudId = $share->getProtocol()['invitedCloudId'];
+ } else {
+ $this->logger->debug('Received a federation invite without invitedCloudId, falling back to shareWith');
+ $invitedCloudId = $this->cloudIdManager->getCloudId($shareWith, null);
+ }
$roomType = (int) $roomType;
$sharedByDisplayName = $share->getSharedByDisplayName();
$sharedByFederatedId = $share->getSharedBy();
@@ -151,7 +159,7 @@ class CloudFederationProviderTalk implements ICloudFederationProvider {
throw new ProviderCouldNotAddShareException('User does not exist', '', Http::STATUS_BAD_REQUEST);
}
- $invite = $this->federationManager->addRemoteRoom($shareWith, (int) $remoteId, $roomType, $roomName, $roomToken, $remote, $shareSecret, $sharedByFederatedId, $sharedByDisplayName);
+ $invite = $this->federationManager->addRemoteRoom($shareWith, (int) $remoteId, $roomType, $roomName, $roomToken, $remote, $shareSecret, $sharedByFederatedId, $sharedByDisplayName, $invitedCloudId);
$this->notifyAboutNewShare($shareWith, (string) $invite->getId(), $sharedByFederatedId, $sharedByDisplayName, $roomName, $roomToken, $remote);
return (string) $invite->getId();