From 22a9e5ec0cfe1ff8018eb9ff8f5d9db83ec1e017 Mon Sep 17 00:00:00 2001 From: lvessiller <lvessiller@open-dsi.fr> Date: Mon, 16 Aug 2021 16:42:56 +0200 Subject: [PATCH] FIX notification and activity labels --- lib/Activity/Provider.php | 4 ++-- lib/BackgroundJob/ArchiveProcess.php | 6 ++++-- lib/BackgroundJob/IndexationProcess.php | 8 +++++--- lib/Notification/Notifier.php | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/Activity/Provider.php b/lib/Activity/Provider.php index 1d5c2df..787e5be 100644 --- a/lib/Activity/Provider.php +++ b/lib/Activity/Provider.php @@ -38,7 +38,7 @@ class Provider implements IProvider { /** @var string */ protected $lastType = ''; - const SUBJECT_ARCHIVES_PROCESSED = 'job_processed'; + const SUBJECT_ARCHIVES_PROCESSED_ACTIVITY = 'job_processed_activity'; /** * @param IFactory $languageFactory @@ -116,7 +116,7 @@ class Provider implements IProvider { $parameters = $event->getSubjectParameters(); switch ($subject) { - case self::SUBJECT_ARCHIVES_PROCESSED: + case self::SUBJECT_ARCHIVES_PROCESSED_ACTIVITY: return [ 'nb_success' => $parameters[0], 'nb_total' => $parameters[1], diff --git a/lib/BackgroundJob/ArchiveProcess.php b/lib/BackgroundJob/ArchiveProcess.php index c330a0c..f44c6eb 100644 --- a/lib/BackgroundJob/ArchiveProcess.php +++ b/lib/BackgroundJob/ArchiveProcess.php @@ -19,6 +19,8 @@ use Exception; use OCA\Dematpayslip\Db\DematpayslipArchive; use OCA\Dematpayslip\Db\DematpayslipArchiveMapper; use OCA\Dematpayslip\Db\DematpayslipUserMapper; +use OCA\Dematpayslip\Activity\Provider; +use OCA\Dematpayslip\Notification\Notifier; /** @@ -283,7 +285,7 @@ class ArchiveProcess extends TimedJob { ->setType('job_processed') ->setAffectedUser($userId) ->setTimestamp($dateTimeNow->getTimestamp()) - ->setSubject('job_processed', [$nbSuccess, $nbTotal]); + ->setSubject(Provider::SUBJECT_ARCHIVES_PROCESSED_ACTIVITY, [$nbSuccess, $nbTotal]); //->setLink($folderLink) //->setObject('folder', $folder->getId(), $folder->getUuid()); $this->_activityManager->publish($event); @@ -292,7 +294,7 @@ class ArchiveProcess extends TimedJob { $this->_log('Notification add : archives processed'); $notification = $this->_notificationManager->createNotification(); $notification->setApp($this->_appName) - ->setSubject('job_processed', ['nb_success' => $nbSuccess, 'nb_total' => $nbTotal]) + ->setSubject(Notifier::SUBJECT_JOB_PROCESSED_NOTIFY, ['nb_success' => $nbSuccess, 'nb_total' => $nbTotal]) ->setObject('dematpayslip_process', $dateTimeNow->getTimestamp()) ->setUser($userId); //->setIcon($this->_urlGenerator->getAbsoluteURL($this->_urlGenerator->imagePath($this->_appName, 'folder.png'))) diff --git a/lib/BackgroundJob/IndexationProcess.php b/lib/BackgroundJob/IndexationProcess.php index 23870c8..b7c1c2c 100644 --- a/lib/BackgroundJob/IndexationProcess.php +++ b/lib/BackgroundJob/IndexationProcess.php @@ -22,9 +22,11 @@ use OCA\Dematpayslip\Db\DematpayslipArchiveMapper; use OCA\Dematpayslip\Db\DematpayslipProcessMapper; use OCA\Dematpayslip\Db\DematpayslipProcessSkipMapper; use OCA\Dematpayslip\Db\DematpayslipUserMapper; +use OCA\Dematpayslip\Activity\Provider; +use OCA\Dematpayslip\Notification\Notifier; -/** + /** * Clean up all file locks that are expired for the DB file locking provider */ class IndexationProcess extends TimedJob { @@ -296,7 +298,7 @@ class IndexationProcess extends TimedJob { ->setType('job_processed') ->setAffectedUser($userId) ->setTimestamp($dateTimeNow->getTimestamp()) - ->setSubject('job_processed', [$nbSuccess, $nbTotal]); + ->setSubject(Provider::SUBJECT_ARCHIVES_PROCESSED_ACTIVITY, [$nbSuccess, $nbTotal]); //->setLink($folderLink) //->setObject('folder', $folder->getId(), $folder->getUuid()); $this->_activityManager->publish($event); @@ -305,7 +307,7 @@ class IndexationProcess extends TimedJob { $this->_log('Notification add : indexation processed'); $notification = $this->_notificationManager->createNotification(); $notification->setApp($this->_appName) - ->setSubject('job_processed', ['nb_success' => $nbSuccess, 'nb_total' => $nbTotal]) + ->setSubject(Notifier::SUBJECT_JOB_PROCESSED_NOTIFY, ['nb_success' => $nbSuccess, 'nb_total' => $nbTotal]) ->setObject('dematpayslip_process', $dateTimeNow->getTimestamp()) ->setUser($userId); //->setIcon($this->_urlGenerator->getAbsoluteURL($this->_urlGenerator->imagePath($this->_appName, 'folder.png'))) diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index b63258b..bbc8e81 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -43,7 +43,7 @@ class Notifier implements INotifier { /** @var IURLGenerator */ protected $url; - const SUBJECT_ARCHIVES_PROCESSED = 'job_processed'; + const SUBJECT_JOB_PROCESSED_NOTIFY = 'job_processed_notify'; /** * @param IFactory $factory @@ -93,7 +93,7 @@ class Notifier implements INotifier { } switch ($notification->getSubject()) { - case self::SUBJECT_ARCHIVES_PROCESSED: + case self::SUBJECT_JOB_PROCESSED_NOTIFY: $subject = $this->getSubject($notification, $languageCode); if ($subject === '') { // Everything done, mark the notification as processed... -- GitLab