Skip to content

Commit

Permalink
fix(exceptions): Catch AlreadyProcessedException as well now
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Apr 15, 2024
1 parent 4bb3a73 commit 12ac3d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/Controller/EndpointController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
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;
Expand Down Expand Up @@ -116,7 +118,8 @@ public function listNotifications(string $apiVersion): DataResponse {
/** @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;
}
Expand Down Expand Up @@ -170,7 +173,8 @@ public function getNotification(string $apiVersion, int $id): DataResponse {

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);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/MailNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
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;
Expand Down Expand Up @@ -200,7 +202,8 @@ protected function sendEmailToUser(Settings $settings, array $notifications, str
/** @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) {
Expand Down
5 changes: 4 additions & 1 deletion lib/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
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;
Expand Down Expand Up @@ -310,7 +312,8 @@ public function pushToDevice(int $id, INotification $notification, ?OutputInterf
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);
Expand Down

0 comments on commit 12ac3d9

Please sign in to comment.