Skip to content

Commit f7d2b8f

Browse files
committed
fix(flow_notifications): Improve app loading by checking if notifications app is not installed and enabled when registering the app
Signed-off-by: Faisal Alghamdi <[email protected]>
1 parent 7f66a73 commit f7d2b8f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/Listener/RegisterOperationsListener.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,33 @@
2727

2828
use OCA\FlowNotifications\AppInfo\Application;
2929
use OCA\FlowNotifications\Flow\Operation;
30+
use OCP\App\IAppManager;
3031
use OCP\EventDispatcher\Event;
3132
use OCP\EventDispatcher\IEventListener;
3233
use OCP\Util;
3334
use OCP\WorkflowEngine\Events\RegisterOperationsEvent;
35+
use Psr\Log\LoggerInterface;
3436

3537
/**
3638
* @template-implements IEventListener<Event|RegisterOperationsEvent>
3739
*/
3840
class RegisterOperationsListener implements IEventListener {
3941
public function __construct(
4042
protected readonly Operation $operation,
43+
protected IAppManager $appManager,
44+
private readonly LoggerInterface $logger,
4145
) {
4246
}
4347

4448
public function handle(Event $event): void {
4549
if (!$event instanceof RegisterOperationsEvent) {
4650
return;
51+
} elseif (!$this->appManager->isInstalled('notifications') ||
52+
!$this->appManager->isEnabledForUser('notifications')) {
53+
$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']);
54+
return;
4755
}
48-
56+
4957
$event->registerOperation($this->operation);
5058
Util::addScript(Application::APP_ID, 'flow_notifications-main');
5159
}

0 commit comments

Comments
 (0)