-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dispatch event to let the scheduling app request a notification and s…
…et its target Signed-off-by: Julien Veyssier <[email protected]>
- Loading branch information
Showing
6 changed files
with
111 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\TPAssistant\Event; | ||
|
||
use OCP\EventDispatcher\Event; | ||
use OCP\TextProcessing\Task; | ||
|
||
/** | ||
* Event to let apps that scheduled a task via the assistant | ||
* decide if they want a notification or not. | ||
* If they want one, they can specify the notification target link | ||
*/ | ||
class BeforeAssistantNotificationEvent extends Event { | ||
|
||
private bool $wantsNotification = false; | ||
private ?string $notificationTarget = null; | ||
|
||
public function __construct( | ||
private Task $task, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Get the task that was successful and for which a notification can be produced | ||
* | ||
* @return Task | ||
*/ | ||
public function getTask(): Task { | ||
return $this->task; | ||
} | ||
|
||
/** | ||
* Does the app that scheduled the task want a notification? | ||
* | ||
* @return bool | ||
*/ | ||
public function getWantsNotification(): bool { | ||
return $this->wantsNotification; | ||
} | ||
|
||
/** | ||
* @param bool $wantsNotification true means a notification will be produced for this task | ||
* @return void | ||
*/ | ||
public function setWantsNotification(bool $wantsNotification): void { | ||
$this->wantsNotification = $wantsNotification; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getNotificationTarget(): ?string { | ||
return $this->notificationTarget; | ||
} | ||
|
||
/** | ||
* @param string|null $notificationTarget URL that will be used as target for the notification and its main action, | ||
* null means the assistant will take care of rendering the result (in a modal or by setting a dedicated NC page showing the result) | ||
* @return void | ||
*/ | ||
public function setNotificationTarget(?string $notificationTarget): void { | ||
$this->notificationTarget = $notificationTarget; | ||
} | ||
} |
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
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