-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Text processing assistant integration
Signed-off-by: Julius Härtl <[email protected]>
- Loading branch information
1 parent
1a2e575
commit 017b657
Showing
8 changed files
with
477 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace OCA\Text\Listeners; | ||
|
||
use OCA\Text\AppInfo\Application; | ||
use OCA\TPAssistant\Event\BeforeAssistantNotificationEvent; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\IURLGenerator; | ||
|
||
/** @template-implements IEventListener<BeforeAssistantNotificationEvent|Event> */ | ||
class BeforeAssistantNotificationListener implements \OCP\EventDispatcher\IEventListener { | ||
|
||
public function __construct( | ||
private IURLGenerator $urlGenerator, | ||
) { | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function handle(Event $event): void { | ||
if (!$event instanceof BeforeAssistantNotificationEvent) { | ||
return; | ||
} | ||
|
||
$task = $event->getTask(); | ||
if ($task->getAppId() !== Application::APP_NAME || $task->getUserId() === null) { | ||
return; | ||
} | ||
$fileId = (int)str_replace('text-file:', '', $task->getIdentifier()); | ||
$fileLink = $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $fileId]); | ||
$event->setWantsNotification(true); | ||
$event->setNotificationTarget($fileLink); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.