Philipp Hörist pushed to branch generate-ogp-previews at gajim / gajim


Commits:
84b87e06 by Philipp Hörist at 2026-02-16T00:04:33+01:00
cfix: Fix cancel logic

- - - - -
208403a5 by Philipp Hörist at 2026-02-16T00:05:15+01:00
new: Improve error messages

- - - - -


1 changed file:

- gajim/gtk/message_url_previews.py


Changes:

=====================================
gajim/gtk/message_url_previews.py
=====================================
@@ -16,6 +16,7 @@
 from nbxmpp.structs import OpenGraphData
 
 from gajim.common import app
+from gajim.common.multiprocess.http import CancelledError
 from gajim.common.multiprocess.url_preview import generate_url_preview
 from gajim.common.regex import URL_REGEX
 from gajim.common.types import ChatContactT
@@ -130,7 +131,7 @@ def _find_urls(self, text: str) -> None:
             self._update_preview(about_url, og_data)
 
     def _request_url_preview(self, about_url: str) -> None:
-        log.info("Requesting url preview for: %s", about_url)
+        log.info("Request preview for: %s", about_url)
 
         event = self._manager.Event()
 
@@ -142,7 +143,7 @@ def _request_url_preview(self, about_url: str) -> None:
                 None,  # TODO add proxy
             )
         except Exception as error:
-            log.warning("unable to generate url preview: %s %s", about_url, 
error)
+            log.warning("Unable to generate preview: %s %s", about_url, error)
             return
 
         future.add_done_callback(
@@ -157,13 +158,20 @@ def _on_request_finished(
         log.info("Request finished for %s", about_url)
         self._requests_in_progress.pop(about_url, None)
 
+        og_data = None
         try:
             og_data = future.result()
+        except CancelledError:
+            log.info("Request was cancelled: %s", about_url)
+            # Don't set value to the request cache so we can query
+            # later again
+
         except Exception as error:
             log.error("Error during request: %s", error)
-            og_data = None
+            self._request_cache[about_url] = None
 
-        self._request_cache[about_url] = og_data
+        else:
+            self._request_cache[about_url] = og_data
 
         if og_data is None:
             log.warning("No opengraph data found for url: %s", about_url)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/858c449af37438428066064d7a56c6ec62c4fdcc...208403a5142e20441c8050b9f1882c15fc25510e

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/858c449af37438428066064d7a56c6ec62c4fdcc...208403a5142e20441c8050b9f1882c15fc25510e
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to