mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-14 09:20:49 +00:00
more cleanup
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user