diff --git a/app/Browser/Jobs/InstagramRepost/InstagramNotificationHandlingJob.php b/app/Browser/Jobs/InstagramRepost/InstagramNotificationHandlingJob.php index 32005ea..86fda4a 100644 --- a/app/Browser/Jobs/InstagramRepost/InstagramNotificationHandlingJob.php +++ b/app/Browser/Jobs/InstagramRepost/InstagramNotificationHandlingJob.php @@ -112,7 +112,7 @@ class InstagramNotificationHandlingJob extends InstagramAbstractJob implements S } } - private function saveNotifications(Browser $browser): void + private function saveNotifications(Browser $browser): ?array { $this->openNotificationsPanel($browser); try { @@ -123,7 +123,7 @@ class InstagramNotificationHandlingJob extends InstagramAbstractJob implements S $DOMnotificationText = $DOMnotification->findElement(WebDriverBy::xpath('./div[2]/span')); $notification = new InstagramNotification(); - $notification->username = str_replace( "/", "", $DOMnotificationText->findElement(WebDriverBy::xpath('./a[1]'))->getAttribute('href')); + $notification->username = str_replace("/", "", $DOMnotificationText->findElement(WebDriverBy::xpath('./a[1]'))->getAttribute('href')); $notification->notification_type = NotificationTypeDetector::detectType($DOMnotificationText->getText()); // 05/08/2025 : Instagram removed the link to the post in the notification, the day I'm working on it :() $postId = null; @@ -135,8 +135,7 @@ class InstagramNotificationHandlingJob extends InstagramAbstractJob implements S if ($repostId) { $notification->instagram_repost_id = $repostId; } - } - catch (\Exception $e) { + } catch (\Exception $e) { Log::error("Failed to get post ID from notification : " . $e->getMessage()); } $notification->message = $DOMnotificationText->getText(); @@ -146,16 +145,17 @@ class InstagramNotificationHandlingJob extends InstagramAbstractJob implements S $notification->save(); } catch (\Exception $e) { Log::error("Failed to save notification : " . $e->getMessage()); - continue; // Skip to the next notification + break; // Stop processing further notifications if one fails } dump("Notification saved : " . $notification); $notifications[] = $notification; } + return $notifications; } catch (\Exception $e) { Log::error("Failed to get notifications : " . $e->getMessage()); $browser->screenshot(JobDebugScreenshot::getFileName($this->jobId)); AllNotification::send(new JobDebugNotification($this->jobId, "Failed to open notifications panel: " . $e->getMessage())); - return; + return null; } }