Merge pull request #1892 from nextcloud/techdebt/44770/notification-exceptions

fix(exceptions): Catch AlreadyProcessedException as well now
This commit is contained in:
Joas Schilling 2024-04-15 12:32:58 +02:00 коммит произвёл GitHub
Родитель 3a46933a93 12ac3d9a80
Коммит 560e3e912d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -39,8 +39,10 @@ use OCP\IRequest;
use OCP\IUser;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Notification\AlreadyProcessedException;
use OCP\Notification\IAction;
use OCP\Notification\IManager;
use OCP\Notification\IncompleteParsedNotificationException;
use OCP\Notification\INotification;
use OCP\UserStatus\IManager as IUserStatusManager;
use OCP\UserStatus\IUserStatus;
@ -116,7 +118,8 @@ class EndpointController extends OCSController {
/** @var INotification $notification */
try {
$notification = $this->manager->prepare($notification, $language);
} catch (\InvalidArgumentException) {
} catch (AlreadyProcessedException|IncompleteParsedNotificationException|\InvalidArgumentException) {
// FIXME remove \InvalidArgumentException in Nextcloud 39
// The app was disabled, skip the notification
continue;
}
@ -170,7 +173,8 @@ class EndpointController extends OCSController {
try {
$notification = $this->manager->prepare($notification, $language);
} catch (\InvalidArgumentException $e) {
} catch (AlreadyProcessedException|IncompleteParsedNotificationException|\InvalidArgumentException) {
// FIXME remove \InvalidArgumentException in Nextcloud 39
// The app was disabled
return new DataResponse(null, Http::STATUS_NOT_FOUND);
}

Просмотреть файл

@ -38,8 +38,10 @@ use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
use OCP\Mail\IMessage;
use OCP\Notification\AlreadyProcessedException;
use OCP\Notification\IAction;
use OCP\Notification\IManager;
use OCP\Notification\IncompleteParsedNotificationException;
use OCP\Notification\INotification;
use OCP\Util;
use Psr\Log\LoggerInterface;
@ -200,7 +202,8 @@ class MailNotifications {
/** @var INotification $preparedNotification */
try {
$preparedNotification = $this->manager->prepare($notification, $language);
} catch (\InvalidArgumentException $e) {
} catch (AlreadyProcessedException|IncompleteParsedNotificationException|\InvalidArgumentException) {
// FIXME remove \InvalidArgumentException in Nextcloud 39
// The app was disabled, skip the notification
continue;
} catch (\Exception $e) {

Просмотреть файл

@ -43,7 +43,9 @@ use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUser;
use OCP\L10N\IFactory;
use OCP\Notification\AlreadyProcessedException;
use OCP\Notification\IManager as INotificationManager;
use OCP\Notification\IncompleteParsedNotificationException;
use OCP\Notification\INotification;
use OCP\UserStatus\IManager as IUserStatusManager;
use OCP\UserStatus\IUserStatus;
@ -310,7 +312,8 @@ class Push {
try {
$this->notificationManager->setPreparingPushNotification(true);
$notification = $this->notificationManager->prepare($notification, $language);
} catch (\InvalidArgumentException $e) {
} catch (AlreadyProcessedException|IncompleteParsedNotificationException|\InvalidArgumentException) {
// FIXME remove \InvalidArgumentException in Nextcloud 39
return;
} finally {
$this->notificationManager->setPreparingPushNotification(false);