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 <github@xymail.tk>
This commit is contained in:
gavine99 2025-03-30 16:05:09 +11:00 committed by Joas Schilling
parent b03ffab5f0
commit ed6d76ec8d
No known key found for this signature in database
GPG key ID: F72FA5B49FFA96B0
2 changed files with 18 additions and 5 deletions

View file

@ -2223,6 +2223,11 @@
<code><![CDATA[mixed]]></code>
</LessSpecificImplementedReturnType>
</file>
<file src="lib/private/Notification/Manager.php">
<UndefinedClass>
<code><![CDATA[\OCA\Notifications\App]]></code>
</UndefinedClass>
</file>
<file src="lib/private/Preview/BackgroundCleanupJob.php">
<InvalidReturnStatement>
<code><![CDATA[[]]]></code>

View file

@ -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) {