1313use OCA \AppAPI \AppInfo \Application ;
1414use OCA \AppAPI \Db \TaskProcessing \TaskProcessingProvider ;
1515use OCA \AppAPI \Db \TaskProcessing \TaskProcessingProviderMapper ;
16- use OCA \AppAPI \PublicFunctions ;
1716use OCA \AppAPI \Service \AppAPIService ;
17+ use OCA \AppAPI \Service \ExAppService ;
1818use OCP \AppFramework \Bootstrap \IRegistrationContext ;
1919use OCP \AppFramework \Db \DoesNotExistException ;
2020use OCP \AppFramework \Db \MultipleObjectsReturnedException ;
2424use OCP \IServerContainer ;
2525use OCP \TaskProcessing \EShapeType ;
2626use OCP \TaskProcessing \IProvider ;
27- use OCP \TaskProcessing \ITriggerableProvider ;
2827use OCP \TaskProcessing \ITaskType ;
28+ use OCP \TaskProcessing \ITriggerableProvider ;
2929use OCP \TaskProcessing \ShapeDescriptor ;
3030use OCP \TaskProcessing \ShapeEnumValue ;
3131use 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