mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 11:33:51 +00:00
thumbnails: Extract user_uploads_or_external as a function.
This is a prepartory commit for the upcoming changes. It was meaningful to extract this one out because this function is essentially a condition check on whether a given url is one of the user_uploads or an external one. Based on its value we decide whether a url must be thumbnailed or not and thus this function will also be used in an upcoming commit patching lib/thumbnail.py to do the same check before thumbnail url generation.
This commit is contained in:
committed by
Tim Abbott
parent
9a411a5765
commit
5d68bd92ad
@@ -18,6 +18,9 @@ from zerver.lib.camo import get_camo_url
|
||||
def is_thumbor_enabled() -> bool:
|
||||
return settings.THUMBOR_URL != ''
|
||||
|
||||
def user_uploads_or_external(url: str) -> bool:
|
||||
return url.startswith('http') or url.lstrip('/').startswith('user_uploads/')
|
||||
|
||||
def get_source_type(url: str) -> str:
|
||||
if not (url.startswith('/user_uploads/') or url.startswith('/user_avatars/')):
|
||||
return THUMBOR_EXTERNAL_TYPE
|
||||
|
||||
Reference in New Issue
Block a user