Skip to content

Commit 12ac3d9

Browse files
committed
fix(exceptions): Catch AlreadyProcessedException as well now
Signed-off-by: Joas Schilling <[email protected]>
1 parent 4bb3a73 commit 12ac3d9

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

lib/Controller/EndpointController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
use OCP\IUser;
4040
use OCP\IUserSession;
4141
use OCP\L10N\IFactory;
42+
use OCP\Notification\AlreadyProcessedException;
4243
use OCP\Notification\IAction;
4344
use OCP\Notification\IManager;
45+
use OCP\Notification\IncompleteParsedNotificationException;
4446
use OCP\Notification\INotification;
4547
use OCP\UserStatus\IManager as IUserStatusManager;
4648
use OCP\UserStatus\IUserStatus;
@@ -116,7 +118,8 @@ public function listNotifications(string $apiVersion): DataResponse {
116118
/** @var INotification $notification */
117119
try {
118120
$notification = $this->manager->prepare($notification, $language);
119-
} catch (\InvalidArgumentException) {
121+
} catch (AlreadyProcessedException|IncompleteParsedNotificationException|\InvalidArgumentException) {
122+
// FIXME remove \InvalidArgumentException in Nextcloud 39
120123
// The app was disabled, skip the notification
121124
continue;
122125
}
@@ -170,7 +173,8 @@ public function getNotification(string $apiVersion, int $id): DataResponse {
170173

171174
try {
172175
$notification = $this->manager->prepare($notification, $language);
173-
} catch (\InvalidArgumentException $e) {
176+
} catch (AlreadyProcessedException|IncompleteParsedNotificationException|\InvalidArgumentException) {
177+
// FIXME remove \InvalidArgumentException in Nextcloud 39
174178
// The app was disabled
175179
return new DataResponse(null, Http::STATUS_NOT_FOUND);
176180
}

lib/MailNotifications.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
use OCP\L10N\IFactory;
3939
use OCP\Mail\IMailer;
4040
use OCP\Mail\IMessage;
41+
use OCP\Notification\AlreadyProcessedException;
4142
use OCP\Notification\IAction;
4243
use OCP\Notification\IManager;
44+
use OCP\Notification\IncompleteParsedNotificationException;
4345
use OCP\Notification\INotification;
4446
use OCP\Util;
4547
use Psr\Log\LoggerInterface;
@@ -200,7 +202,8 @@ protected function sendEmailToUser(Settings $settings, array $notifications, str
200202
/** @var INotification $preparedNotification */
201203
try {
202204
$preparedNotification = $this->manager->prepare($notification, $language);
203-
} catch (\InvalidArgumentException $e) {
205+
} catch (AlreadyProcessedException|IncompleteParsedNotificationException|\InvalidArgumentException) {
206+
// FIXME remove \InvalidArgumentException in Nextcloud 39
204207
// The app was disabled, skip the notification
205208
continue;
206209
} catch (\Exception $e) {

lib/Push.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
use OCP\IDBConnection;
4444
use OCP\IUser;
4545
use OCP\L10N\IFactory;
46+
use OCP\Notification\AlreadyProcessedException;
4647
use OCP\Notification\IManager as INotificationManager;
48+
use OCP\Notification\IncompleteParsedNotificationException;
4749
use OCP\Notification\INotification;
4850
use OCP\UserStatus\IManager as IUserStatusManager;
4951
use OCP\UserStatus\IUserStatus;
@@ -310,7 +312,8 @@ public function pushToDevice(int $id, INotification $notification, ?OutputInterf
310312
try {
311313
$this->notificationManager->setPreparingPushNotification(true);
312314
$notification = $this->notificationManager->prepare($notification, $language);
313-
} catch (\InvalidArgumentException $e) {
315+
} catch (AlreadyProcessedException|IncompleteParsedNotificationException|\InvalidArgumentException) {
316+
// FIXME remove \InvalidArgumentException in Nextcloud 39
314317
return;
315318
} finally {
316319
$this->notificationManager->setPreparingPushNotification(false);

0 commit comments

Comments
 (0)