From 5646e11e7465fe7ce1a993df37c5f7d9316ea67f Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Mon, 5 Feb 2024 20:53:33 +0100
Subject: [PATCH] no screenshot without url

---
 app/models/communication/website/with_screenshot.rb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/app/models/communication/website/with_screenshot.rb b/app/models/communication/website/with_screenshot.rb
index 014b85c0f..46869832f 100644
--- a/app/models/communication/website/with_screenshot.rb
+++ b/app/models/communication/website/with_screenshot.rb
@@ -6,8 +6,10 @@ module Communication::Website::WithScreenshot
   end
   
   def screenshot!
+    return if url.blank?
     screenshot_url = Screenshot.capture(url)
     downloaded_image = URI.open(screenshot_url)
-    self.screenshot.attach(io: downloaded_image  , filename: "screenshot.png")
+    self.screenshot.attach  io: downloaded_image, 
+                            filename: "screenshot.png"
   end
 end
\ No newline at end of file
-- 
GitLab