From 3a110bd647cc4dbd06fb77277345004151b44849 Mon Sep 17 00:00:00 2001 From: Hashir Sarwar Date: Sun, 26 Apr 2020 16:30:57 +0500 Subject: [PATCH] actions: Remove redundant 'url_embed_preview_enabled' check. We add URLs to the `links_for_embed set`, only when the `url_embed_preview_enabled` flag is turned on. So, it is sufficient to check if `links_for_embed` is not empty. --- zerver/lib/actions.py | 3 +-- zerver/views/messages.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 41e297fdf4..7e600146ca 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -16,7 +16,6 @@ from analytics.lib.counts import COUNT_STATS, do_increment_logging_stat, \ from zerver.lib.bugdown import ( version as bugdown_version, - url_embed_preview_enabled, ) from zerver.lib.addressee import Addressee from zerver.lib.bot_config import ( @@ -1499,7 +1498,7 @@ def do_send_messages(messages_maybe_none: Sequence[Optional[MutableMapping[str, event['sender_queue_id'] = message['sender_queue_id'] send_event(message['realm'], event, users) - if url_embed_preview_enabled(message['message']) and links_for_embed: + if links_for_embed: event_data = { 'message_id': message['message'].id, 'message_content': message['message'].content, diff --git a/zerver/views/messages.py b/zerver/views/messages.py index 7023d68a47..b4a89df6f8 100644 --- a/zerver/views/messages.py +++ b/zerver/views/messages.py @@ -1608,7 +1608,7 @@ def update_message_backend(request: HttpRequest, user_profile: UserMessage, # Include the number of messages changed in the logs request._log_data['extra'] = "[%s]" % (number_changed,) - if links_for_embed and bugdown.url_embed_preview_enabled(message): + if links_for_embed: event_data = { 'message_id': message.id, 'message_content': message.content,