Skip to content

Commit 34921ea

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 34921ea

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
@@ -31,21 +31,29 @@
3131
use OCP\EventDispatcher\IEventListener;
3232
use OCP\Util;
3333
use OCP\WorkflowEngine\Events\RegisterOperationsEvent;
34+
use OCP\App\IAppManager;
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
4144
) {
4245
}
4346

4447
public function handle(Event $event): void {
4548
if (!$event instanceof RegisterOperationsEvent) {
4649
return;
50+
} else if(!$this->appManager->isInstalled('notifications') ||
51+
!$this->appManager->isEnabledForUser('notifications')) {
52+
$logger = \OC::$server->get(LoggerInterface::class);
53+
$logger->error('Failed to register `flow_notifications` app. This could happen due to the app `notifications` 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)