mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
Merge pull request #52404 from nextcloud/bugfix/49973/allow-federated-filesharing-without-federation-app
fix(federation): Allow federation file sharing when federation app is…
This commit is contained in:
commit
0c3ebbfed5
3 changed files with 17 additions and 4 deletions
|
|
@ -6,6 +6,7 @@
|
|||
namespace OCA\CloudFederationAPI;
|
||||
|
||||
use OCP\Federation\ICloudFederationProviderManager;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class config
|
||||
|
|
@ -18,6 +19,7 @@ class Config {
|
|||
|
||||
public function __construct(
|
||||
private ICloudFederationProviderManager $cloudFederationProviderManager,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -32,6 +34,7 @@ class Config {
|
|||
$provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType);
|
||||
return $provider->getSupportedShareTypes();
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error('Failed to create federation provider', ['exception' => $e]);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ class RequestHandlerController extends Controller {
|
|||
*/
|
||||
private function getHostFromFederationId(string $entry): string {
|
||||
if (!str_contains($entry, '@')) {
|
||||
throw new IncomingRequestException('entry ' . $entry . ' does not contains @');
|
||||
throw new IncomingRequestException('entry ' . $entry . ' does not contain @');
|
||||
}
|
||||
$rightPart = substr($entry, strrpos($entry, '@') + 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider {
|
|||
private LoggerInterface $logger,
|
||||
private IFilenameValidator $filenameValidator,
|
||||
private readonly IProviderFactory $shareProviderFactory,
|
||||
private TrustedServers $trustedServers,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -156,6 +155,17 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider {
|
|||
// get DisplayName about the owner of the share
|
||||
$ownerDisplayName = $this->getUserDisplayName($ownerFederatedId);
|
||||
|
||||
$trustedServers = null;
|
||||
if ($this->appManager->isEnabledForAnyone('federation')
|
||||
&& class_exists(TrustedServers::class)) {
|
||||
try {
|
||||
$trustedServers = Server::get(TrustedServers::class);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->debug('Failed to create TrustedServers', ['exception' => $e]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($shareType === IShare::TYPE_USER) {
|
||||
$event = $this->activityManager->generateEvent();
|
||||
$event->setApp('files_sharing')
|
||||
|
|
@ -167,7 +177,7 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider {
|
|||
$this->notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name, $ownerDisplayName);
|
||||
|
||||
// If auto-accept is enabled, accept the share
|
||||
if ($this->federatedShareProvider->isFederatedTrustedShareAutoAccept() && $this->trustedServers->isTrustedServer($remote)) {
|
||||
if ($this->federatedShareProvider->isFederatedTrustedShareAutoAccept() && $trustedServers?->isTrustedServer($remote) === true) {
|
||||
$this->externalShareManager->acceptShare($shareId, $shareWith);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -183,7 +193,7 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider {
|
|||
$this->notifyAboutNewShare($user->getUID(), $shareId, $ownerFederatedId, $sharedByFederatedId, $name, $ownerDisplayName);
|
||||
|
||||
// If auto-accept is enabled, accept the share
|
||||
if ($this->federatedShareProvider->isFederatedTrustedShareAutoAccept() && $this->trustedServers->isTrustedServer($remote)) {
|
||||
if ($this->federatedShareProvider->isFederatedTrustedShareAutoAccept() && $trustedServers?->isTrustedServer($remote) === true) {
|
||||
$this->externalShareManager->acceptShare($shareId, $user->getUID());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue