mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
bugdown: Create a constant for inline preview limit.
This commit is contained in:
@@ -452,6 +452,7 @@ class BacktickPattern(markdown.inlinepatterns.Pattern):
|
|||||||
class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
|
class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
|
||||||
TWITTER_MAX_IMAGE_HEIGHT = 400
|
TWITTER_MAX_IMAGE_HEIGHT = 400
|
||||||
TWITTER_MAX_TO_PREVIEW = 3
|
TWITTER_MAX_TO_PREVIEW = 3
|
||||||
|
INLINE_PREVIEW_LIMIT_PER_MESSAGE = 5
|
||||||
|
|
||||||
def __init__(self, md: markdown.Markdown, bugdown: 'Bugdown') -> None:
|
def __init__(self, md: markdown.Markdown, bugdown: 'Bugdown') -> None:
|
||||||
# Passing in bugdown for access to config to check if realm is zulip.com
|
# Passing in bugdown for access to config to check if realm is zulip.com
|
||||||
@@ -825,8 +826,7 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
|
|||||||
# Get all URLs from the blob
|
# Get all URLs from the blob
|
||||||
found_urls = walk_tree_with_family(root, self.get_url_data)
|
found_urls = walk_tree_with_family(root, self.get_url_data)
|
||||||
|
|
||||||
# If there are more than 5 URLs in the message, don't do inline previews
|
if len(found_urls) == 0 or len(found_urls) > self.INLINE_PREVIEW_LIMIT_PER_MESSAGE:
|
||||||
if len(found_urls) == 0 or len(found_urls) > 5:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
rendered_tweet_count = 0
|
rendered_tweet_count = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user