From 1882d665607a5a8b7532b3513c2002e0f3a684a1 Mon Sep 17 00:00:00 2001 From: kyteinsky Date: Thu, 23 Jul 2026 02:33:25 +0530 Subject: [PATCH] feat(taskprocessing): add option for user-facing error message Signed-off-by: kyteinsky --- nc_py_api/ex_app/providers/task_processing.py | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/nc_py_api/ex_app/providers/task_processing.py b/nc_py_api/ex_app/providers/task_processing.py index 8f5a54eb..c4bd7cea 100644 --- a/nc_py_api/ex_app/providers/task_processing.py +++ b/nc_py_api/ex_app/providers/task_processing.py @@ -186,13 +186,23 @@ def report_result( task_id: int, output: dict[str, typing.Any] | None = None, error_message: str | None = None, + user_facing_error_message: str | None = None, ) -> dict[str, typing.Any]: - """Report result of the task processing to Nextcloud.""" + """Report result of the task processing to Nextcloud. + + :param user_facing_error_message: An error message that will be shown to the user. + Available starting with Nextcloud 33. Added in nc_py_api 0.31.0. + """ with contextlib.suppress(NextcloudException): if r := self._session.ocs( "POST", f"/ocs/v2.php/taskprocessing/tasks_provider/{task_id}/result", - json={"taskId": task_id, "output": output, "errorMessage": error_message}, + json={ + "taskId": task_id, + "output": output, + "errorMessage": error_message, + "userFacingErrorMessage": user_facing_error_message, + }, ): return r return {} @@ -283,13 +293,23 @@ async def report_result( task_id: int, output: dict[str, typing.Any] | None = None, error_message: str | None = None, + user_facing_error_message: str | None = None, ) -> dict[str, typing.Any]: - """Report result of the task processing to Nextcloud.""" + """Report result of the task processing to Nextcloud. + + :param user_facing_error_message: An error message that will be shown to the user. + Available starting with Nextcloud 33. Added in nc_py_api 0.31.0. + """ with contextlib.suppress(NextcloudException): if r := await self._session.ocs( "POST", f"/ocs/v2.php/taskprocessing/tasks_provider/{task_id}/result", - json={"taskId": task_id, "output": output, "errorMessage": error_message}, + json={ + "taskId": task_id, + "output": output, + "errorMessage": error_message, + "userFacingErrorMessage": user_facing_error_message, + }, ): return r return {}