From 6eef477d546b8ac3a2a800d1f2840d44eef6b40e Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 13 Feb 2026 12:08:39 +0000 Subject: [PATCH] more cleanup --- synapse/appservice/__init__.py | 8 +++++++- synapse/media/url_previewer.py | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/synapse/appservice/__init__.py b/synapse/appservice/__init__.py index e7d2a3a50f..72477598e7 100644 --- a/synapse/appservice/__init__.py +++ b/synapse/appservice/__init__.py @@ -149,7 +149,7 @@ class ApplicationService: # users: [ {regex: "[A-z]+.*", exclusive: true}, ...], # aliases: [ {regex: "[A-z]+.*", exclusive: true}, ...], # rooms: [ {regex: "[A-z]+.*", exclusive: true}, ...], - # uk_half-shot_msc4417_preview_urls: [ {regex: "[A-z]+.*", exclusive: true}, ...], + # uk.half-shot.msc4417.preview_urls: [ {regex: "[A-z]+.*", exclusive: true}, ...], # } if namespaces is None: namespaces = {} @@ -371,6 +371,9 @@ class ApplicationService: return bool(self._matches_regex(ApplicationService.NS_ROOMS, room_id)) def is_preview_url_in_namespace(self, url: str) -> bool: + """ + Determines whether a given url should be previewed by this service. + """ return bool(self._matches_regex(ApplicationService.NS_PREVIEW_URLS, url)) def is_exclusive_user(self, user_id: str) -> bool: @@ -380,6 +383,9 @@ class ApplicationService: ) def is_exclusive_preview_url(self, url: str) -> bool: + """ + Determines whether a given url should be *exclusively* previewed by this service. + """ return self._is_exclusive(ApplicationService.NS_PREVIEW_URLS, url) def is_interested_in_protocol(self, protocol: str) -> bool: diff --git a/synapse/media/url_previewer.py b/synapse/media/url_previewer.py index 7c3cce13fd..adefefe744 100644 --- a/synapse/media/url_previewer.py +++ b/synapse/media/url_previewer.py @@ -232,8 +232,9 @@ class UrlPreviewer: return json_encoder.encode(as_og_data.result).encode("utf8") if as_og_data.exclusive: - # This is NOT the same as the Bad Gateway error we usually return for - # failed requests. Maybe this is wrong. + # XXX: _do_preview typically returns a 500 for any failed + # requests but in this case we know the appservice requested + # exclusivity over this URL pattern, so we can say it's a 404. raise SynapseError( 404, "Not able to preview URL",