Skip to content

Commit 63b251c

Browse files
committed
fix: Fix cyclic dependency
1 parent 01b67f2 commit 63b251c

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

lib/Controller/TaskProcessingController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
use OCA\AppAPI\AppInfo\Application;
1313
use OCA\AppAPI\Attribute\AppAPIAuth;
14+
use OCA\AppAPI\Service\AppAPIService;
15+
use OCA\AppAPI\Service\ExAppService;
1416
use OCA\AppAPI\Service\ProvidersAI\TaskProcessingService;
1517
use OCP\AppFramework\Http;
1618
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
@@ -26,10 +28,14 @@ class TaskProcessingController extends OCSController {
2628
public function __construct(
2729
IRequest $request,
2830
private readonly TaskProcessingService $taskProcessingService,
31+
private readonly AppAPIService $appAPIService,
32+
private readonly ExAppService $exAppService,
2933
) {
3034
parent::__construct(Application::APP_ID, $request);
3135

3236
$this->request = $request;
37+
$this->taskProcessingService->setAppAPIService($this->appAPIService);
38+
$this->taskProcessingService->setExAppService($this->exAppService);
3339
}
3440

3541
#[NoCSRFRequired]

lib/Service/AppAPIService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function __construct(
5252
private readonly HarpService $harpService,
5353
) {
5454
$this->client = $clientService->newClient();
55+
$this->exAppService->setAppAPIService($this);
5556
}
5657

5758
/**

lib/Service/ExAppService.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
class ExAppService {
3838
private ?ICache $cache = null;
39+
private AppAPIService $appAPIService;
3940

4041
public function __construct(
4142
private readonly LoggerInterface $logger,
@@ -66,6 +67,7 @@ public function __construct(
6667
$this->cache = $cacheFactory->createDistributed(Application::APP_ID . '/service');
6768
}
6869
}
70+
$this->taskProcessingService->setExAppService($this);
6971
}
7072

7173
public function getExApp(string $appId): ?ExApp {
@@ -446,4 +448,9 @@ private function unregisterExAppWebhooks(string $appId): void {
446448
$this->logger->debug(sprintf('Error while unregistering ExApp %s webhooks: %s', $appId, $e->getMessage()));
447449
}
448450
}
451+
452+
public function setAppAPIService(AppAPIService $appAPIService): void {
453+
$this->appAPIService = $appAPIService;
454+
$this->taskProcessingService->setAppAPIService($this->appAPIService);
455+
}
449456
}

lib/Service/ProvidersAI/TaskProcessingService.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
use OCA\AppAPI\AppInfo\Application;
1414
use OCA\AppAPI\Db\TaskProcessing\TaskProcessingProvider;
1515
use OCA\AppAPI\Db\TaskProcessing\TaskProcessingProviderMapper;
16-
use OCA\AppAPI\PublicFunctions;
1716
use OCA\AppAPI\Service\AppAPIService;
17+
use OCA\AppAPI\Service\ExAppService;
1818
use OCP\AppFramework\Bootstrap\IRegistrationContext;
1919
use OCP\AppFramework\Db\DoesNotExistException;
2020
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
@@ -24,8 +24,8 @@
2424
use OCP\IServerContainer;
2525
use OCP\TaskProcessing\EShapeType;
2626
use OCP\TaskProcessing\IProvider;
27-
use OCP\TaskProcessing\ITriggerableProvider;
2827
use OCP\TaskProcessing\ITaskType;
28+
use OCP\TaskProcessing\ITriggerableProvider;
2929
use OCP\TaskProcessing\ShapeDescriptor;
3030
use OCP\TaskProcessing\ShapeEnumValue;
3131
use Psr\Log\LoggerInterface;
@@ -34,17 +34,27 @@ class TaskProcessingService {
3434
private ?ICache $cache = null;
3535
private ?array $registeredProviders = null;
3636

37+
private AppAPIService $appAPIService;
38+
private ExAppService $exAppService;
39+
3740
public function __construct(
3841
ICacheFactory $cacheFactory,
3942
private readonly TaskProcessingProviderMapper $mapper,
4043
private readonly LoggerInterface $logger,
41-
private readonly PublicFunctions $service,
4244
) {
4345
if ($cacheFactory->isAvailable()) {
4446
$this->cache = $cacheFactory->createDistributed(Application::APP_ID . '/ex_task_processing_providers');
4547
}
4648
}
4749

50+
public function setAppAPIService(AppAPIService $appAPIService): void {
51+
$this->appAPIService = $appAPIService;
52+
}
53+
54+
public function setExAppService(ExAppService $exAppService): void {
55+
$this->exAppService = $exAppService;
56+
}
57+
4858
/**
4959
* Get list of registered TaskProcessing providers (only for enabled ExApps)
5060
*
@@ -267,11 +277,12 @@ public function getAnonymousExAppProvider(
267277
array $provider,
268278
string $appId,
269279
): IProvider {
270-
return new class($provider, $appId, $this->service) implements IProvider, ITriggerableProvider {
280+
return new class($provider, $appId, $this->exAppService, $this->appAPIService) implements IProvider, ITriggerableProvider {
271281
public function __construct(
272282
private readonly array $provider,
273283
private readonly string $appId,
274-
private readonly PublicFunctions $service,
284+
private readonly ExAppService $exAppService,
285+
private readonly AppAPiService $appAPIService
275286
) {
276287
}
277288

@@ -288,7 +299,11 @@ public function getTaskTypeId(): string {
288299
}
289300

290301
public function trigger(): void {
291-
$this->service->exAppRequest($this->appId, '/trigger', params: ['providerId' => $this->provider['id']]);
302+
$exApp = $this->exAppService->getExApp($this->appId);
303+
if ($exApp === null) {
304+
return;
305+
}
306+
$this->appAPIService->requestToExApp($exApp, '/trigger', params: ['providerId' => $this->provider['id']]);
292307
}
293308

294309
public function getExpectedRuntime(): int {

0 commit comments

Comments
 (0)