mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
fix(federation): Allow federation file sharing when federation app is disabled
The app id might be misleading, the federation app is for syncing addressbooks with trusted servers. It is not always enabled and show not have to be. Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
94538c11c7
commit
4fc5eaeff0
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