From ed6d76ec8d60c158f7c0597bdfe1527c9e8bd89e Mon Sep 17 00:00:00 2001 From: gavine99 Date: Sun, 30 Mar 2025 16:05:09 +1100 Subject: fix(notifications): Change notification app orders The notification manager always calls notify() of the 'main' notifications app before other notify apps, and calls other functions for other notifications apps before the 'main' notification app Signed-off-by: gavine99 --- lib/private/Notification/Manager.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/private/Notification/Manager.php b/lib/private/Notification/Manager.php index ac287e97048..b75e52deacb 100644 --- a/lib/private/Notification/Manager.php +++ b/lib/private/Notification/Manager.php @@ -74,7 +74,15 @@ class Manager implements IManager { * @since 17.0.0 */ public function registerApp(string $appClass): void { - $this->appClasses[] = $appClass; + // other apps may want to rely on the 'main' notification app so make it deterministic that + // the 'main' notification app adds it's notifications first and removes it's notifications last + if ($appClass === \OCA\Notifications\App::class) { + // add 'main' notifications app to start of internal list of apps + array_unshift($this->appClasses, $appClass); + } else { + // add app to end of internal list of apps + $this->appClasses[] = $appClass; + } } /** @@ -237,7 +245,7 @@ class Manager implements IManager { $alreadyDeferring = $this->deferPushing; $this->deferPushing = true; - $apps = $this->getApps(); + $apps = array_reverse($this->getApps()); foreach ($apps as $app) { if ($app instanceof IDeferrableApp) { @@ -252,7 +260,7 @@ class Manager implements IManager { * @since 20.0.0 */ public function flush(): void { - $apps = $this->getApps(); + $apps = array_reverse($this->getApps()); foreach ($apps as $app) { if (!$app instanceof IDeferrableApp) { @@ -384,7 +392,7 @@ class Manager implements IManager { * @param INotification $notification */ public function markProcessed(INotification $notification): void { - $apps = $this->getApps(); + $apps = array_reverse($this->getApps()); foreach ($apps as $app) { $app->markProcessed($notification); @@ -396,7 +404,7 @@ class Manager implements IManager { * @return int */ public function getCount(INotification $notification): int { - $apps = $this->getApps(); + $apps = array_reverse($this->getApps()); $count = 0; foreach ($apps as $app) { -- cgit v1.2.3