Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
changes to allow nextcloud notifications via unified push. requires r…
…elated changes in nextcloud app. linted. Signed-off-by: Gavin Element <[email protected]>
  • Loading branch information
gavine99 committed Sep 5, 2024
commit b50b2cc0a8d150e763af490f04b2d9ba7c8367e9
34 changes: 16 additions & 18 deletions lib/private/Notification/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OC\Notification;

use OC\AppFramework\Bootstrap\Coordinator;
use OCP\App\IAppManager;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IUserManager;
Expand All @@ -23,11 +24,10 @@
use OCP\Notification\INotifier;
use OCP\Notification\UnknownNotificationException;
use OCP\RichObjectStrings\IValidator;
use OCP\Server;
use OCP\Support\Subscription\IRegistry;
use Psr\Container\ContainerExceptionInterface;
use Psr\Log\LoggerInterface;
use OCP\Server;
use OCP\App\IAppManager;

class Manager implements IManager {
/** @var ICache */
Expand Down Expand Up @@ -74,18 +74,18 @@ public function __construct(
* @since 17.0.0
*/
public function registerApp(string $appClass): void {
// ensure Nextcloud Notification app is always added at the front of the array so it gets processed first
// for new notifications and last for marking processed or sending deletes.
// this is because it sets the unique id and adds the notification to the data store that other apps might need
// access to in order to be compatible
$appManager = Server::get(IAppManager::class);
if (($appManager !== null) &&
($appManager->isInstalled("notifications") === true) &&
($appClass === "OCA\Notifications\App")) {
array_unshift($this->appClasses, $appClass);
}
else
$this->appClasses[] = $appClass;
// ensure Nextcloud Notification app is always added at the front of the array so it gets processed first
// for new notifications and last for marking processed or sending deletes.
// this is because it sets the unique id and adds the notification to the data store that other apps might need
// access to in order to be compatible
$appManager = Server::get(IAppManager::class);
if (($appManager !== null) &&
($appManager->isInstalled('notifications') === true) &&
($appClass === 'OCA\Notifications\App')) {
array_unshift($this->appClasses, $appClass);
} else {
$this->appClasses[] = $appClass;
}
}

/**
Expand Down Expand Up @@ -319,8 +319,7 @@ public function notify(INotification $notification): void {
}
}

public function notifyDelete(string $user, ?int $id, ?INotification $notification): void
{
public function notifyDelete(string $user, ?int $id, ?INotification $notification): void {
if ($notification && !$notification->isValid()) {
throw new IncompleteNotificationException('The given notification is invalid');
}
Expand All @@ -337,8 +336,7 @@ public function notifyDelete(string $user, ?int $id, ?INotification $notificatio
$this->logger->debug(get_class($app) . '::notify() threw \InvalidArgumentException which is deprecated. Throw \OCP\Notification\IncompleteNotificationException when the notification is incomplete for your app and otherwise handle all \InvalidArgumentException yourself.');
}
}

}
}


/**
Expand Down
4 changes: 2 additions & 2 deletions lib/public/Notification/IApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ interface IApp {
public function notify(INotification $notification): void;

/**
* @param string $user user
* @param ?int $id id as used by notification app
* @param string $user user
* @param ?int $id id as used by notification app
* @param INotification $notification
* @throws IncompleteNotificationException When the notification does not have all required fields set
* @since 9.0.0
Expand Down