diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 6a2d653456c19..a9b0f147c57b0 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -2223,6 +2223,11 @@ + + + + + diff --git a/lib/private/Notification/Manager.php b/lib/private/Notification/Manager.php index ac287e970483c..b75e52deacb59 100644 --- a/lib/private/Notification/Manager.php +++ b/lib/private/Notification/Manager.php @@ -74,7 +74,15 @@ public function __construct( * @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 @@ public function defer(): bool { $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 @@ public function defer(): bool { * @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 @@ public function prepare(INotification $notification, string $languageCode): INot * @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 @@ public function markProcessed(INotification $notification): void { * @return int */ public function getCount(INotification $notification): int { - $apps = $this->getApps(); + $apps = array_reverse($this->getApps()); $count = 0; foreach ($apps as $app) {