Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/dav/tests/unit/Connector/Sabre/NodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ public function testDavPermissions(int $permissions, string $type, bool $shared,
->method('getRelativePath')
->with(null)
->willReturn('');
$view
->method('getAbsolutePath')
->with(null)
->willReturn('');

$node = new File($view, $info);
$node = new File($view, $info);
$this->assertEquals($expected, $node->getDavPermissions());
}

Expand Down
55 changes: 0 additions & 55 deletions apps/files/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use OCA\Files\Collaboration\Resources\Listener;
use OCA\Files\Collaboration\Resources\ResourceProvider;
use OCA\Files\ConfigLexicon;
use OCA\Files\Controller\ApiController;
use OCA\Files\Dashboard\FavoriteWidget;
use OCA\Files\DirectEditingCapabilities;
use OCA\Files\Event\LoadSearchPlugins;
Expand All @@ -28,10 +27,6 @@
use OCA\Files\Listener\UserFirstTimeLoggedInListener;
use OCA\Files\Notification\Notifier;
use OCA\Files\Search\FilesSearchProvider;
use OCA\Files\Service\TagService;
use OCA\Files\Service\UserConfig;
use OCA\Files\Service\ViewConfig;
use OCP\Activity\IManager as IActivityManager;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
Expand All @@ -45,19 +40,8 @@
use OCP\Files\Events\Node\NodeCopiedEvent;
use OCP\Files\Events\NodeAddedToFavorite;
use OCP\Files\Events\NodeRemovedFromFavorite;
use OCP\Files\IRootFolder;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IPreview;
use OCP\IRequest;
use OCP\IServerContainer;
use OCP\ITagManager;
use OCP\IUserSession;
use OCP\Share\IManager as IShareManager;
use OCP\User\Events\UserFirstTimeLoggedInEvent;
use OCP\Util;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

class Application extends App implements IBootstrap {
public const APP_ID = 'files';
Expand All @@ -68,45 +52,6 @@ public function __construct(array $urlParams = []) {

#[\Override]
public function register(IRegistrationContext $context): void {
/**
* Controllers
*/
$context->registerService('APIController', function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);

return new ApiController(
$c->get('AppName'),
$c->get(IRequest::class),
$c->get(IUserSession::class),
$c->get(TagService::class),
$c->get(IPreview::class),
$c->get(IShareManager::class),
$c->get(IConfig::class),
$server->getUserFolder(),
$c->get(UserConfig::class),
$c->get(ViewConfig::class),
$c->get(IL10N::class),
$c->get(IRootFolder::class),
$c->get(LoggerInterface::class),
);
});

/**
* Services
*/
$context->registerService(TagService::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);

return new TagService(
$c->get(IUserSession::class),
$c->get(IActivityManager::class),
$c->get(ITagManager::class)->load(self::APP_ID),
$server->getUserFolder(),
);
});

/*
* Register capabilities
*/
Expand Down
7 changes: 6 additions & 1 deletion apps/files/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
* @package OCA\Files\Controller
*/
class ApiController extends Controller {
private ?Folder $userFolder = null;

public function __construct(
string $appName,
IRequest $request,
Expand All @@ -61,14 +63,17 @@ public function __construct(
private IPreview $previewManager,
private IManager $shareManager,
private IConfig $config,
private ?Folder $userFolder,
private UserConfig $userConfig,
private ViewConfig $viewConfig,
private IL10N $l10n,
private IRootFolder $rootFolder,
private LoggerInterface $logger,
) {
parent::__construct($appName, $request);
$user = $this->userSession->getUser();
if ($user) {
$this->userFolder = $this->rootFolder->getUserFolder($user->getUID());
}
}

/**
Expand Down
14 changes: 12 additions & 2 deletions apps/files/lib/Service/TagService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,33 @@
*/
namespace OCA\Files\Service;

use OCA\Files\AppInfo\Application;
use OCP\Activity\IManager;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\ITagManager;
use OCP\ITags;
use OCP\IUserSession;

/**
* Service class to manage tags on files.
*/
class TagService {
private ?Folder $homeFolder = null;
private ?ITags $tagger;

public function __construct(
private IUserSession $userSession,
private IManager $activityManager,
private ?ITags $tagger,
private ?Folder $homeFolder,
ITagManager $tagManager,
IRootFolder $rootFolder,
) {
$user = $this->userSession->getUser();
if ($user) {
$this->homeFolder = $rootFolder->getUserFolder($user->getUID());
}
$this->tagger = $tagManager->load(Application::APP_ID);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion apps/files/tests/Controller/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ protected function setUp(): void {
$this->viewConfig = $this->createMock(ViewConfig::class);
$this->l10n = $this->createMock(IL10N::class);
$this->rootFolder = $this->createMock(IRootFolder::class);
$this->rootFolder->expects($this->any())
->method('getUserFolder')
->willReturn($this->userFolder);
$this->logger = $this->createMock(LoggerInterface::class);

$this->apiController = new ApiController(
Expand All @@ -87,7 +90,6 @@ protected function setUp(): void {
$this->preview,
$this->shareManager,
$this->config,
$this->userFolder,
$this->userConfig,
$this->viewConfig,
$this->l10n,
Expand Down
13 changes: 11 additions & 2 deletions apps/files/tests/Service/TagServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ protected function setUp(): void {
\OC_User::setUserId($this->user);
\OC_Util::setupFS($this->user);
$user = $this->createMock(IUser::class);
$user->expects($this->any())
->method('getUID')
->willReturn($this->user);
$this->userSession = $this->createMock(IUserSession::class);
$this->userSession->expects($this->any())
->method('getUser')
Expand All @@ -61,8 +64,8 @@ protected function getTagService(array $methods = []): TagService&MockObject {
->setConstructorArgs([
$this->userSession,
$this->activityManager,
$this->tagger,
$this->root,
Server::get(ITagManager::class),
Server::get(IRootFolder::class),
])
->onlyMethods($methods)
->getMock();
Expand Down Expand Up @@ -91,16 +94,22 @@ public function testUpdateFileTags(): void {
// set tags
$this->tagService->updateFileTags('subdir/test.txt', [$tag1, $tag2]);

// Sync to reload tags
$this->tagger->addMultiple([], sync:true);
$this->assertEquals([$fileId], $this->tagger->getIdsForTag($tag1));
$this->assertEquals([$fileId], $this->tagger->getIdsForTag($tag2));

// remove tag
$this->tagService->updateFileTags('subdir/test.txt', [$tag2]);
// Sync to reload tags
$this->tagger->addMultiple([], sync:true);
$this->assertEquals([], $this->tagger->getIdsForTag($tag1));
$this->assertEquals([$fileId], $this->tagger->getIdsForTag($tag2));

// clear tags
$this->tagService->updateFileTags('subdir/test.txt', []);
// Sync to reload tags
$this->tagger->addMultiple([], sync:true);
$this->assertEquals([], $this->tagger->getIdsForTag($tag1));
$this->assertEquals([], $this->tagger->getIdsForTag($tag2));

Expand Down
28 changes: 1 addition & 27 deletions apps/files_versions/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
*/
namespace OCA\Files_Versions\AppInfo;

use OC\KnownUser\KnownUserService;
use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCA\DAV\Connector\Sabre\Principal;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar;
Expand All @@ -22,7 +20,6 @@
use OCA\Files_Versions\Listener\VersionStorageMoveListener;
use OCA\Files_Versions\Versions\IVersionManager;
use OCA\Files_Versions\Versions\VersionManager;
use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
Expand All @@ -39,14 +36,6 @@
use OCP\Files\Events\Node\NodeRenamedEvent;
use OCP\Files\Events\Node\NodeTouchedEvent;
use OCP\Files\Events\Node\NodeWrittenEvent;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IServerContainer;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Server;
use OCP\Share\IManager as IShareManager;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

Expand All @@ -67,22 +56,7 @@ public function register(IRegistrationContext $context): void {
/**
* Register $principalBackend for the DAV collection
*/
$context->registerService('principalBackend', function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);
return new Principal(
$server->get(IUserManager::class),
$server->get(IGroupManager::class),
Server::get(IAccountManager::class),
$server->get(IShareManager::class),
$server->get(IUserSession::class),
$server->get(IAppManager::class),
$server->get(ProxyMapper::class),
$server->get(KnownUserService::class),
$server->get(IConfig::class),
$server->get(IFactory::class),
);
});
$context->registerServiceAlias('principalBackend', Principal::class);

$context->registerServiceAlias(IVersionManager::class, VersionManager::class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
'OCA\\Provisioning_API\\Controller\\PreferencesController' => $baseDir . '/../lib/Controller/PreferencesController.php',
'OCA\\Provisioning_API\\Controller\\UsersController' => $baseDir . '/../lib/Controller/UsersController.php',
'OCA\\Provisioning_API\\Controller\\VerificationController' => $baseDir . '/../lib/Controller/VerificationController.php',
'OCA\\Provisioning_API\\FederatedShareProviderFactory' => $baseDir . '/../lib/FederatedShareProviderFactory.php',
'OCA\\Provisioning_API\\Listener\\UserDeletedListener' => $baseDir . '/../lib/Listener/UserDeletedListener.php',
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => $baseDir . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => $baseDir . '/../lib/Middleware/ProvisioningApiMiddleware.php',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class ComposerStaticInitProvisioning_API
'OCA\\Provisioning_API\\Controller\\PreferencesController' => __DIR__ . '/..' . '/../lib/Controller/PreferencesController.php',
'OCA\\Provisioning_API\\Controller\\UsersController' => __DIR__ . '/..' . '/../lib/Controller/UsersController.php',
'OCA\\Provisioning_API\\Controller\\VerificationController' => __DIR__ . '/..' . '/../lib/Controller/VerificationController.php',
'OCA\\Provisioning_API\\FederatedShareProviderFactory' => __DIR__ . '/..' . '/../lib/FederatedShareProviderFactory.php',
'OCA\\Provisioning_API\\Listener\\UserDeletedListener' => __DIR__ . '/..' . '/../lib/Listener/UserDeletedListener.php',
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => __DIR__ . '/..' . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ProvisioningApiMiddleware.php',
Expand Down
24 changes: 0 additions & 24 deletions apps/provisioning_api/lib/FederatedShareProviderFactory.php

This file was deleted.

17 changes: 0 additions & 17 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1409,14 +1409,8 @@
</TypeDoesNotContainType>
</file>
<file src="apps/files/lib/AppInfo/Application.php">
<DeprecatedInterface>
<code><![CDATA[$server]]></code>
<code><![CDATA[$server]]></code>
</DeprecatedInterface>
<DeprecatedMethod>
<code><![CDATA[Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig')]]></code>
<code><![CDATA[getUserFolder]]></code>
<code><![CDATA[getUserFolder]]></code>
</DeprecatedMethod>
</file>
<file src="apps/files/lib/BackgroundJob/ScanFiles.php">
Expand Down Expand Up @@ -2046,9 +2040,6 @@
<DeprecatedClass>
<code><![CDATA[LegacyRollbackListener::class]]></code>
</DeprecatedClass>
<DeprecatedInterface>
<code><![CDATA[$server]]></code>
</DeprecatedInterface>
</file>
<file src="apps/files_versions/lib/BackgroundJob/ExpireVersions.php">
<DeprecatedClass>
Expand Down Expand Up @@ -2296,14 +2287,6 @@
<code><![CDATA[$groupid === null]]></code>
</TypeDoesNotContainNull>
</file>
<file src="apps/provisioning_api/lib/FederatedShareProviderFactory.php">
<DeprecatedInterface>
<code><![CDATA[private]]></code>
</DeprecatedInterface>
<DeprecatedMethod>
<code><![CDATA[query]]></code>
</DeprecatedMethod>
</file>
<file src="apps/provisioning_api/lib/Middleware/ProvisioningApiMiddleware.php">
<DeprecatedMethod>
<code><![CDATA[hasAnnotation]]></code>
Expand Down
Loading
Loading