Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@

namespace OCA\Files_Sharing\Controller;

use OCA\Files_Sharing\BackgroundJob\ExternalShareScanJob;
use OCA\Files_Sharing\External\Manager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\JSONResponse;
use OCP\BackgroundJob\IJobList;
use OCP\IRequest;

/**
Expand All @@ -26,7 +24,6 @@ public function __construct(
string $appName,
IRequest $request,
private readonly Manager $externalManager,
private IJobList $jobList,
) {
parent::__construct($appName, $request);
}
Expand All @@ -47,7 +44,6 @@ public function create(string $id): JSONResponse {
$externalShare = $this->externalManager->getShare($id);
if ($externalShare !== false) {
$this->externalManager->acceptShare($externalShare);
$this->jobList->add(ExternalShareScanJob::class, [$externalShare->getUser(), $externalShare->getMountpoint()]);
}
return new JSONResponse();
}
Expand Down
4 changes: 4 additions & 0 deletions apps/files_sharing/lib/External/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

use OC\Files\Filesystem;
use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent;
use OCA\Files_Sharing\BackgroundJob\ExternalShareScanJob;
use OCA\Files_Sharing\Helper;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\BackgroundJob\IJobList;
use OCP\DB\Exception;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
Expand Down Expand Up @@ -58,6 +60,7 @@ public function __construct(
private ICertificateManager $certificateManager,
private ExternalShareMapper $externalShareMapper,
private IConfig $config,
private readonly IJobList $jobList,
) {
$this->user = $userSession->getUser();
}
Expand Down Expand Up @@ -249,6 +252,7 @@ public function acceptShare(ExternalShare $externalShare, ?IUser $user = null):
$externalShare->setMountpoint($mountPoint);
$this->externalShareMapper->update($externalShare);
$userShareAccepted = true;
$this->jobList->add(ExternalShareScanJob::class, [$externalShare->getUser(), $externalShare->getMountpoint()]);
}
} else {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use OCA\Files_Sharing\External\ExternalShare;
use OCA\Files_Sharing\External\Manager;
use OCP\AppFramework\Http\JSONResponse;
use OCP\BackgroundJob\IJobList;
use OCP\IRequest;
use PHPUnit\Framework\MockObject\MockObject;

Expand All @@ -24,21 +23,18 @@
class ExternalShareControllerTest extends \Test\TestCase {
private IRequest&MockObject $request;
private Manager&MockObject $externalManager;
private IJobList&MockObject $jobList;

protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
$this->externalManager = $this->createMock(Manager::class);
$this->jobList = $this->createMock(IJobList::class);
}

public function getExternalShareController(): ExternalSharesController {
return new ExternalSharesController(
'files_sharing',
$this->request,
$this->externalManager,
$this->jobList,
);
}

Expand All @@ -62,9 +58,6 @@ public function testCreate(): void {
->expects($this->once())
->method('acceptShare')
->with($share);
$this->jobList
->expects($this->once())
->method('add');

$this->assertEquals(new JSONResponse(), $this->getExternalShareController()->create('4'));
}
Expand Down
4 changes: 4 additions & 0 deletions apps/files_sharing/tests/External/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use OCA\Files_Sharing\External\Manager;
use OCA\Files_Sharing\External\MountProvider;
use OCA\Files_Sharing\Tests\TestCase;
use OCP\BackgroundJob\IJobList;
use OCP\Contacts\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
Expand Down Expand Up @@ -77,6 +78,7 @@ class ManagerTest extends TestCase {
private IOCMDiscoveryService&MockObject $ocmDiscoveryService;
private ExternalShareMapper $externalShareMapper;
private IConfig $config;
private IJobList&MockObject $jobList;

protected function setUp(): void {
parent::setUp();
Expand All @@ -93,6 +95,7 @@ protected function setUp(): void {
$this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class);
$this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class);
$this->config = $this->createMock(IConfig::class);
$this->jobList = $this->createMock(IJobList::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
Expand Down Expand Up @@ -182,6 +185,7 @@ private function createManagerForUser(IUser $user): Manager&MockObject {
$this->certificateManager,
$this->externalShareMapper,
$this->config,
$this->jobList,
]
)->onlyMethods(['tryOCMEndPoint'])->getMock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OCA\Files_Sharing\External\ExternalShareMapper;
use OCA\Files_Sharing\External\Manager;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\BackgroundJob\IJobList;
use OCP\DB\Exception;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
Expand Down Expand Up @@ -64,6 +65,7 @@ protected function setUp(): void {
$this->createMock(ICertificateManager::class),
$this->externalShareMapper,
$this->createMock(IConfig::class),
$this->createMock(IJobList::class),
);
}

Expand Down
Loading