aboutsummaryrefslogtreecommitdiffstats
path: root/core/Controller
diff options
context:
space:
mode:
authorJulien Veyssier <julien-nc@posteo.net>2024-07-17 12:35:13 +0200
committerJulien Veyssier <julien-nc@posteo.net>2024-07-22 11:34:29 +0200
commitfffc7847693080318b759bfa0c0a683325b536b5 (patch)
treeba32ce212a605100dddaffb3a93d4b8690b7ac50 /core/Controller
parentfadef0c7ba8e6e6c52a54c0e0c5c27949b165183 (diff)
downloadnextcloud-server-fffc7847693080318b759bfa0c0a683325b536b5.tar.gz
nextcloud-server-fffc7847693080318b759bfa0c0a683325b536b5.zip
feat(taskprocessing): add support for webhooks (http or AppAPI) in the task processing API
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'core/Controller')
-rw-r--r--core/Controller/TaskProcessingApiController.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/Controller/TaskProcessingApiController.php b/core/Controller/TaskProcessingApiController.php
index d9bcbd5da45..6e2a039606f 100644
--- a/core/Controller/TaskProcessingApiController.php
+++ b/core/Controller/TaskProcessingApiController.php
@@ -97,7 +97,8 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
* @param string $type Type of the task
* @param string $appId ID of the app that will execute the task
* @param string $customId An arbitrary identifier for the task
- *
+ * @param string|null $webhookUri URI to be requested when the task finishes
+ * @param string|null $webhookMethod Method used for the webhook request (HTTP:GET, HTTP:POST, HTTP:PUT, HTTP:DELETE or AppAPI:APP_ID:GET, AppAPI:APP_ID:POST...)
* @return DataResponse<Http::STATUS_OK, array{task: CoreTaskProcessingTask}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_BAD_REQUEST|Http::STATUS_PRECONDITION_FAILED|Http::STATUS_UNAUTHORIZED, array{message: string}, array{}>
*
* 200: Task scheduled successfully
@@ -109,8 +110,13 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
#[UserRateLimit(limit: 20, period: 120)]
#[AnonRateLimit(limit: 5, period: 120)]
#[ApiRoute(verb: 'POST', url: '/schedule', root: '/taskprocessing')]
- public function schedule(array $input, string $type, string $appId, string $customId = ''): DataResponse {
+ public function schedule(
+ array $input, string $type, string $appId, string $customId = '',
+ ?string $webhookUri = null, ?string $webhookMethod = null
+ ): DataResponse {
$task = new Task($type, $input, $appId, $this->userId, $customId);
+ $task->setWebhookUri($webhookUri);
+ $task->setWebhookMethod($webhookMethod);
try {
$this->taskProcessingManager->scheduleTask($task);