Skip to content

Commit

Permalink
fix(flow_notifications): Improve app loading by checking if notificat…
Browse files Browse the repository at this point in the history
…ions app is not installed and enabled when registering the app

Signed-off-by: Faisal Alghamdi <falghamdi125@gmail.com>
  • Loading branch information
falghamdi125 authored and blizzz committed Nov 11, 2024
1 parent ed3be77 commit 09a8573
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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`
Expand Down
2 changes: 2 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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.
Expand Down
7 changes: 7 additions & 0 deletions lib/Listener/RegisterOperationsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,30 @@

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>
*/
class RegisterOperationsListener implements IEventListener {
public function __construct(
protected readonly Operation $operation
protected IAppManager $appManager,

Check failure on line 43 in lib/Listener/RegisterOperationsListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

ParseError

lib/Listener/RegisterOperationsListener.php:43:3: ParseError: Syntax error, unexpected T_PROTECTED, expecting ')' on line 43 (see https://psalm.dev/173)

Check failure on line 43 in lib/Listener/RegisterOperationsListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

ParseError

lib/Listener/RegisterOperationsListener.php:43:36: ParseError: A trailing comma is not allowed here on line 43 (see https://psalm.dev/173)
private readonly LoggerInterface $logger,

Check failure on line 44 in lib/Listener/RegisterOperationsListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

ParseError

lib/Listener/RegisterOperationsListener.php:44:3: ParseError: Syntax error, unexpected T_PRIVATE, expecting ';' on line 44 (see https://psalm.dev/173)

Check failure on line 44 in lib/Listener/RegisterOperationsListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

ParseError

lib/Listener/RegisterOperationsListener.php:44:43: ParseError: A trailing comma is not allowed here on line 44 (see https://psalm.dev/173)
) {

Check failure on line 45 in lib/Listener/RegisterOperationsListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

ParseError

lib/Listener/RegisterOperationsListener.php:45:2: ParseError: Syntax error, unexpected ')', expecting ';' on line 45 (see https://psalm.dev/173)
}

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);
Expand Down

0 comments on commit 09a8573

Please sign in to comment.