Skip to content

Commit c31ac25

Browse files
Fix: Send local webdav url instead of the remote
We are currently mixing up the local and remote webdav urls when sending a share that uses token exchange, so that needs to be fixed. Signed-off-by: Micke Nordin <kano@sunet.se> Co-authored-by: Mahdi Baghbani <mahdi-baghbani@azadehafzar.io>
1 parent a194441 commit c31ac25

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎lib/private/Federation/CloudFederationFactory.php‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use OCP\Federation\ICloudFederationNotification;
1212
use OCP\Federation\ICloudFederationShare;
1313
use OCP\Federation\ICloudIdManager;
14+
use OCP\IURLGenerator;
1415
use OCP\OCM\Exceptions\OCMProviderException;
1516
use OCP\OCM\IOCMDiscoveryService;
1617
use Psr\Log\LoggerInterface;
@@ -19,6 +20,7 @@ class CloudFederationFactory implements ICloudFederationFactory {
1920
public function __construct(
2021
private IOCMDiscoveryService $ocmDiscoveryService,
2122
private ICloudIdManager $cloudIdManager,
23+
private IURLGenerator $urlGenerator,
2224
private LoggerInterface $logger,
2325
) {
2426
}
@@ -72,6 +74,13 @@ public function getCloudFederationShare($shareWith, $name, $description, $provid
7274
]);
7375
}
7476

77+
$webDavUri = '';
78+
if ($useExchangeToken) {
79+
$webDavUri = $this->urlGenerator->getAbsoluteURL(
80+
$this->ocmDiscoveryService->getLocalOCMProvider(false)->extractProtocolEntry('file', 'webdav'),
81+
);
82+
}
83+
7584
return new CloudFederationShare(
7685
$shareWith,
7786
$name,
@@ -85,7 +94,7 @@ public function getCloudFederationShare($shareWith, $name, $description, $provid
8594
$resourceType,
8695
$sharedSecret,
8796
$useExchangeToken,
88-
$remoteDomain
97+
$webDavUri
8998
);
9099
}
91100

‎lib/private/Federation/CloudFederationShare.php‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class CloudFederationShare implements ICloudFederationShare {
4242
* @param string $resourceType ('file', 'calendar',...)
4343
* @param string $sharedSecret
4444
* @param bool $useExchangeToken whether to use exchange-token protocol (new way) or sharedSecret (old way)
45-
* @param string|null $remoteDomain remote domain for constructing webdav URI
45+
* @param string $webdavUri
4646
*/
4747
public function __construct($shareWith = '',
4848
$name = '',
@@ -56,7 +56,7 @@ public function __construct($shareWith = '',
5656
$resourceType = '',
5757
$sharedSecret = '',
5858
$useExchangeToken = false,
59-
$remoteDomain = null,
59+
$webdavUri = '',
6060
) {
6161
$this->setShareWith($shareWith);
6262
$this->setResourceName($name);
@@ -68,7 +68,6 @@ public function __construct($shareWith = '',
6868
$this->setSharedByDisplayName($sharedByDisplayName);
6969

7070
if ($useExchangeToken) {
71-
$webdavUri = $remoteDomain ? 'https://' . $remoteDomain . '/public.php/webdav/' : '';
7271
$this->setProtocol([
7372
'name' => 'webdav',
7473
'webdav' => [

0 commit comments

Comments
 (0)