Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(exceptions): Catch AlreadyProcessedException as well now #1892

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading