Skip to content

Commit 89c633e

Browse files
committed
feat(Assignments): Send notifications for assignment failure
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 162cb34 commit 89c633e

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎lib/AppInfo/Application.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function register(IRegistrationContext $context): void {
9292
$context->registerEventListener(TaskSuccessfulEvent::class, TaskSuccessfulListener::class);
9393
$context->registerEventListener(TaskFailedEvent::class, TaskFailedListener::class);
9494
$context->registerEventListener(TaskSuccessfulEvent::class, ChattyLLMTaskListener::class);
95+
$context->registerEventListener(TaskFailedEvent::class, ChattyLLMTaskListener::class);
9596
$context->registerEventListener(TaskSuccessfulEvent::class, FileActionTaskSuccessfulListener::class);
9697
$context->registerEventListener(TaskSuccessfulEvent::class, NewFileMenuTaskSuccessfulListener::class);
9798
$context->registerEventListener(TaskFailedEvent::class, FileActionTaskFailedListener::class);

‎lib/Listener/ChattyLLMTaskListener.php‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use OCA\Assistant\Service\TaskProcessingService;
1818
use OCP\EventDispatcher\Event;
1919
use OCP\EventDispatcher\IEventListener;
20+
use OCP\TaskProcessing\Events\TaskFailedEvent;
2021
use OCP\TaskProcessing\Events\TaskSuccessfulEvent;
2122
use OCP\TaskProcessing\Task;
2223
use Psr\Log\LoggerInterface;
@@ -36,6 +37,21 @@ public function __construct(
3637
}
3738

3839
public function handle(Event $event): void {
40+
if ($event instanceof TaskFailedEvent) {
41+
$task = $event->getTask();
42+
$customId = $task->getCustomId();
43+
if (preg_match('/^chatty-llm:(\d+)/', $customId, $matches)) {
44+
$sessionId = (int)$matches[1];
45+
$session = $this->sessionMapper->getUserSession($task->getUserId(), $sessionId);
46+
$assignmentId = $session->getAssignmentId();
47+
if ($assignmentId !== null) {
48+
$this->notificationService->sendAssignmentNotification(
49+
$task->getUserId(), $task, $session
50+
);
51+
}
52+
}
53+
return;
54+
}
3955
if (!($event instanceof TaskSuccessfulEvent)) {
4056
return;
4157
}

0 commit comments

Comments
 (0)