Return the newly created notification for handling

This commit is contained in:
2025-08-11 14:30:07 +02:00
parent 658c9fecf6
commit e75254f930

View File

@ -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); $this->openNotificationsPanel($browser);
try { try {
@ -135,8 +135,7 @@ class InstagramNotificationHandlingJob extends InstagramAbstractJob implements S
if ($repostId) { if ($repostId) {
$notification->instagram_repost_id = $repostId; $notification->instagram_repost_id = $repostId;
} }
} } catch (\Exception $e) {
catch (\Exception $e) {
Log::error("Failed to get post ID from notification : " . $e->getMessage()); Log::error("Failed to get post ID from notification : " . $e->getMessage());
} }
$notification->message = $DOMnotificationText->getText(); $notification->message = $DOMnotificationText->getText();
@ -146,16 +145,17 @@ class InstagramNotificationHandlingJob extends InstagramAbstractJob implements S
$notification->save(); $notification->save();
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error("Failed to save notification : " . $e->getMessage()); 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); dump("Notification saved : " . $notification);
$notifications[] = $notification; $notifications[] = $notification;
} }
return $notifications;
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error("Failed to get notifications : " . $e->getMessage()); Log::error("Failed to get notifications : " . $e->getMessage());
$browser->screenshot(JobDebugScreenshot::getFileName($this->jobId)); $browser->screenshot(JobDebugScreenshot::getFileName($this->jobId));
AllNotification::send(new JobDebugNotification($this->jobId, "Failed to open notifications panel: " . $e->getMessage())); AllNotification::send(new JobDebugNotification($this->jobId, "Failed to open notifications panel: " . $e->getMessage()));
return; return null;
} }
} }