Merge pull request #39174 from shdehnavi/refactor_lib_private_notification

refactor lib/private/Notification
pull/42563/head
Louis 2024-01-03 15:54:24 +07:00 committed by GitHub
commit a64df1908b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 88 deletions

@ -27,23 +27,17 @@ namespace OC\Notification;
use OCP\Notification\IAction; use OCP\Notification\IAction;
class Action implements IAction { class Action implements IAction {
/** @var string */ protected string $label;
protected $label;
/** @var string */ protected string $labelParsed;
protected $labelParsed;
/** @var string */ protected string $link;
protected $link;
/** @var string */ protected string $requestType;
protected $requestType;
/** @var string */ protected string $icon;
protected $icon;
/** @var bool */ protected bool $primary;
protected $primary;
public function __construct() { public function __construct() {
$this->label = ''; $this->label = '';

@ -43,48 +43,35 @@ use Psr\Container\ContainerExceptionInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class Manager implements IManager { class Manager implements IManager {
/** @var IValidator */
protected $validator;
/** @var IUserManager */
private $userManager;
/** @var ICache */ /** @var ICache */
protected $cache; protected ICache $cache;
/** @var IRegistry */
protected $subscription;
/** @var LoggerInterface */
protected $logger;
/** @var Coordinator */
private $coordinator;
/** @var IApp[] */ /** @var IApp[] */
protected $apps; protected array $apps;
/** @var string[] */ /** @var string[] */
protected $appClasses; protected array $appClasses;
/** @var INotifier[] */ /** @var INotifier[] */
protected $notifiers; protected array $notifiers;
/** @var string[] */ /** @var string[] */
protected $notifierClasses; protected array $notifierClasses;
/** @var bool */ /** @var bool */
protected $preparingPushNotification; protected bool $preparingPushNotification;
/** @var bool */ /** @var bool */
protected $deferPushing; protected bool $deferPushing;
/** @var bool */ /** @var bool */
private $parsedRegistrationContext; private bool $parsedRegistrationContext;
public function __construct(IValidator $validator, public function __construct(
IUserManager $userManager, protected IValidator $validator,
private IUserManager $userManager,
ICacheFactory $cacheFactory, ICacheFactory $cacheFactory,
IRegistry $subscription, protected IRegistry $subscription,
LoggerInterface $logger, protected LoggerInterface $logger,
Coordinator $coordinator) { private Coordinator $coordinator,
$this->validator = $validator; ) {
$this->userManager = $userManager;
$this->cache = $cacheFactory->createDistributed('notifications'); $this->cache = $cacheFactory->createDistributed('notifications');
$this->subscription = $subscription;
$this->logger = $logger;
$this->coordinator = $coordinator;
$this->apps = []; $this->apps = [];
$this->notifiers = []; $this->notifiers = [];
@ -111,7 +98,7 @@ class Manager implements IManager {
* @deprecated 17.0.0 use registerNotifierService instead. * @deprecated 17.0.0 use registerNotifierService instead.
* @since 8.2.0 - Parameter $info was added in 9.0.0 * @since 8.2.0 - Parameter $info was added in 9.0.0
*/ */
public function registerNotifier(\Closure $service, \Closure $info) { public function registerNotifier(\Closure $service, \Closure $info): void {
$infoData = $info(); $infoData = $info();
$exception = new \InvalidArgumentException( $exception = new \InvalidArgumentException(
'Notifier ' . $infoData['name'] . ' (id: ' . $infoData['id'] . ') is not considered because it is using the old way to register.' 'Notifier ' . $infoData['name'] . ' (id: ' . $infoData['id'] . ') is not considered because it is using the old way to register.'

@ -32,74 +32,51 @@ use OCP\RichObjectStrings\InvalidObjectExeption;
use OCP\RichObjectStrings\IValidator; use OCP\RichObjectStrings\IValidator;
class Notification implements INotification { class Notification implements INotification {
/** @var IValidator */ protected string $app;
protected $richValidator;
/** @var string */ protected string $user;
protected $app;
/** @var string */ protected \DateTime $dateTime;
protected $user;
/** @var \DateTime */ protected string $objectType;
protected $dateTime;
/** @var string */ protected string $objectId;
protected $objectType;
/** @var string */ protected string $subject;
protected $objectId;
/** @var string */ protected array $subjectParameters;
protected $subject;
/** @var array */ protected string $subjectParsed;
protected $subjectParameters;
/** @var string */ protected string $subjectRich;
protected $subjectParsed;
/** @var string */ protected array $subjectRichParameters;
protected $subjectRich;
/** @var array */ protected string $message;
protected $subjectRichParameters;
/** @var string */ protected array $messageParameters;
protected $message;
/** @var array */ protected string $messageParsed;
protected $messageParameters;
/** @var string */ protected string $messageRich;
protected $messageParsed;
/** @var string */ protected array $messageRichParameters;
protected $messageRich;
/** @var array */ protected string $link;
protected $messageRichParameters;
/** @var string */ protected string $icon;
protected $link;
/** @var string */ protected array $actions;
protected $icon;
/** @var array */ protected array $actionsParsed;
protected $actions;
/** @var array */ protected bool $hasPrimaryAction;
protected $actionsParsed;
/** @var bool */ protected bool $hasPrimaryParsedAction;
protected $hasPrimaryAction;
/** @var bool */ public function __construct(
protected $hasPrimaryParsedAction; protected IValidator $richValidator,
) {
public function __construct(IValidator $richValidator) {
$this->richValidator = $richValidator;
$this->app = ''; $this->app = '';
$this->user = ''; $this->user = '';
$this->dateTime = new \DateTime(); $this->dateTime = new \DateTime();