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
38 changes: 6 additions & 32 deletions lib/Service/OpenProjectAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IGroupManager;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUserManager;
Expand All @@ -44,13 +43,11 @@
use GuzzleHttp\Exception\ServerException;
use GuzzleHttp\Exception\ConnectException;
use OCP\AppFramework\Http;
use OCP\Files\IMimeTypeLoader;
use OC_Util;
use OC\Authentication\Events\AppPasswordCreatedEvent;
use OC\Authentication\Token\IProvider;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Security\ISecureRandom;

use OCP\Server;
use OCA\OpenProject\AppInfo\Application;
use Safe\Exceptions\JsonException;

Expand Down Expand Up @@ -115,15 +112,6 @@ class OpenProjectAPIService {
*/
private ISubAdmin $subAdminManager;

/**
* @var IDBConnection
*/
private $dbConnection;

/**
* @var IMimeTypeLoader
*/
private $mimeTypeLoader;
/**
* Service to make requests to OpenProject v3 (JSON) API
*/
Expand All @@ -145,12 +133,10 @@ public function __construct(
IUserManager $userManager,
IGroupManager $groupManager,
IAppManager $appManager,
IDBConnection $dbConnection,
IProvider $tokenProvider,
ISecureRandom $random,
IEventDispatcher $eventDispatcher,
ISubAdmin $subAdminManager,
IMimeTypeLoader $mimeTypeLoader
ISubAdmin $subAdminManager
) {
$this->appName = $appName;
$this->avatarManager = $avatarManager;
Expand All @@ -164,9 +150,7 @@ public function __construct(
$this->userManager = $userManager;
$this->groupManager = $groupManager;
$this->appManager = $appManager;
$this->dbConnection = $dbConnection;
$this->subAdminManager = $subAdminManager;
$this->mimeTypeLoader = $mimeTypeLoader;
$this->tokenProvider = $tokenProvider;
$this->random = $random;
$this->eventDispatcher = $eventDispatcher;
Expand Down Expand Up @@ -1031,13 +1015,8 @@ public function getProjectFolderSetupInformation(): array {
* @throws NoUserException
*/
public function createGroupfolder(): void {
if (version_compare(OC_Util::getVersionString(), '27') >= 0) {
// @phpstan-ignore-next-line - make phpstan not complain if groupfolders app does not exist
$groupfoldersFolderManager = new FolderManager($this->dbConnection, $this->groupManager, $this->mimeTypeLoader, $this->logger);
} else {
// @phpstan-ignore-next-line - make phpstan not complain if groupfolders app does not exist
$groupfoldersFolderManager = new FolderManager($this->dbConnection);
}
// @phpstan-ignore-next-line - make phpstan not complain if groupfolders app does not exist
$groupfoldersFolderManager = Server::get(FolderManager::class);
// @phpstan-ignore-next-line - make phpstan not complain if groupfolders app does not exist
$folderId = $groupfoldersFolderManager->createFolder(
Application::OPEN_PROJECT_ENTITIES_NAME
Expand All @@ -1064,13 +1043,8 @@ public function createGroupfolder(): void {

// @phpstan-ignore-next-line - make phpstan not complain if groupfolders app does not exist
public function getGroupFolderManager(): FolderManager {
if (version_compare(OC_Util::getVersionString(), '27') >= 0) {
// @phpstan-ignore-next-line - make phpstan not complain if groupfolders app does not exist
$groupfoldersFolderManager = new FolderManager($this->dbConnection, $this->groupManager, $this->mimeTypeLoader, $this->logger);
} else {
// @phpstan-ignore-next-line - make phpstan not complain if groupfolders app does not exist
$groupfoldersFolderManager = new FolderManager($this->dbConnection);
}
// @phpstan-ignore-next-line - make phpstan not complain if groupfolders app does not exist
$groupfoldersFolderManager = Server::get(FolderManager::class);
return $groupfoldersFolderManager;
}

Expand Down
12 changes: 2 additions & 10 deletions tests/lib/Service/OpenProjectAPIServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use OCA\OpenProject\Exception\OpenprojectErrorException;
use OCA\OpenProject\Exception\OpenprojectResponseException;
use OCP\App\IAppManager;
use OCP\Files\IMimeTypeLoader;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
Expand All @@ -32,7 +31,6 @@
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IL10N;
Expand Down Expand Up @@ -462,12 +460,10 @@ private function getOpenProjectAPIService(
$this->createMock(IUserManager::class),
$this->createMock(IGroupManager::class),
$this->createMock(IAppManager::class),
$this->createMock(IDBConnection::class),
$this->createMock(IProvider::class),
$this->createMock(ISecureRandom::class),
$this->createMock(IEventDispatcher::class),
$this->createMock(ISubAdmin::class),
$this->createMock(IMimeTypeLoader::class)
$this->createMock(ISubAdmin::class)
);
}

Expand Down Expand Up @@ -539,12 +535,10 @@ private function getServiceMock(
$userManagerMock,
$groupManagerMock,
$appManagerMock,
$this->createMock(IDBConnection::class),
$tokenProviderMock,
$iSecureRandomMock,
$this->createMock(IEventDispatcher::class),
$subAdminManagerMock,
$this->createMock(IMimeTypeLoader::class)
])
->onlyMethods($onlyMethods)
->getMock();
Expand Down Expand Up @@ -1663,12 +1657,10 @@ public function testRequestException(
$this->createMock(IUserManager::class),
$this->createMock(IGroupManager::class),
$this->createMock(IAppManager::class),
$this->createMock(IDBConnection::class),
$this->createMock(IProvider::class),
$this->createMock(ISecureRandom::class),
$this->createMock(IEventDispatcher::class),
$this->createMock(ISubAdmin::class),
$this->createMock(IMimeTypeLoader::class)
$this->createMock(ISubAdmin::class)
);

$response = $service->request('', '', []);
Expand Down