Merge pull request #227 from falghamdi125/falghamdi125-improve-app-loading-by-making-sure-notifications-app-installed
fix(flow_notifications): Improve app loading by checking if notificat…
This commit is contained in:
Коммит
388d27b3ba
|
@ -14,6 +14,8 @@
|
|||
### 🔔 Receive notifications
|
||||
![](screenshots/notification.png)
|
||||
|
||||
💡 To use the `Flow Notifications` app, ensure that the [Notifications](https://github.com/nextcloud/notifications) app is installed and enabled. The `Notifications` app provides the necessary APIs for the `Flow Notifications` app to work correctly.
|
||||
|
||||
## 🏗 Development setup
|
||||
|
||||
1. ☁ Clone this app into the `apps` folder of your Nextcloud: `git clone https://github.com/nextcloud/flow_notifications.git`
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
Users are empowered to configure a "Send a notification" Flow in their personal settings. They can choose between the events being triggered, and other conditions like filetypes, assigned tags, time ranges and more. They can specify an inscription so that when the notification appears they will have context.
|
||||
|
||||
To use the `Flow Notifications` app, ensure that the `Notifications` app is installed and enabled. The `Notifications` app provides the necessary APIs for the `Flow Notifications` app to work correctly.
|
||||
|
||||
![Notification Flow Configuration](https://raw.githubusercontent.com/nextcloud/flow_notifications/master/screenshots/configuration.png)
|
||||
|
||||
When an event happens where all conditions are apply, the user will receive a regular Nextcloud notification.
|
||||
|
|
|
@ -10,10 +10,12 @@ namespace OCA\FlowNotifications\Listener;
|
|||
|
||||
use OCA\FlowNotifications\AppInfo\Application;
|
||||
use OCA\FlowNotifications\Flow\Operation;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\Util;
|
||||
use OCP\WorkflowEngine\Events\RegisterOperationsEvent;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @template-implements IEventListener<Event|RegisterOperationsEvent>
|
||||
|
@ -21,12 +23,17 @@ use OCP\WorkflowEngine\Events\RegisterOperationsEvent;
|
|||
class RegisterOperationsListener implements IEventListener {
|
||||
public function __construct(
|
||||
protected readonly Operation $operation,
|
||||
protected IAppManager $appManager,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
if (!$event instanceof RegisterOperationsEvent) {
|
||||
return;
|
||||
} elseif (!$this->appManager->isEnabledForUser('notifications')) {
|
||||
$this->logger->error('Failed to register `flow_notifications` app. This could happen due to the `notifications` app isn\'t installed or enabled.', ['app' => 'flow_notifications']);
|
||||
return;
|
||||
}
|
||||
|
||||
$event->registerOperation($this->operation);
|
||||
|
|
Загрузка…
Ссылка в новой задаче