Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
actions: Move part into zerver.lib.message.
Anders Kaseorgc041b68578fe
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.pyindex 7ecc5fcd252..605c283b7c5 100644--- a/zerver/lib/actions.py+++ b/zerver/lib/actions.py@@ -57,7 +57,6 @@ from zerver.lib.cache import (cache_delete,cache_delete_many,cache_set,- cache_set_many,cache_with_key,delete_user_profile_caches,display_recipient_cache_key,@@ -96,6 +95,7 @@ from zerver.lib.message import (render_markdown,truncate_topic,update_first_visible_message_id,+ update_to_dict_cache,wildcard_mention_allowed,)from zerver.lib.notification_data import UserMessageNotificationsData, get_user_group_mentions_data@@ -5633,23 +5633,6 @@ def update_user_message_flags(um.save(update_fields=["flags"])-def update_to_dict_cache(- changed_messages: List[Message], realm_id: Optional[int] = None-) -> List[int]:- """Updates the message as stored in the to_dict cache (for serving- messages)."""- items_for_remote_cache = {}- message_ids = []- changed_messages_to_dict = MessageDict.to_dict_uncached(changed_messages, realm_id)- for msg_id, msg in changed_messages_to_dict.items():- message_ids.append(msg_id)- key = to_dict_cache_key_id(msg_id)- items_for_remote_cache[key] = (msg,)-- cache_set_many(items_for_remote_cache)- return message_ids--def do_update_embedded_data(user_profile: UserProfile,message: Message,diff --git a/zerver/lib/message.py b/zerver/lib/message.pyindex d87199a36b6..163ed3a3564 100644--- a/zerver/lib/message.py+++ b/zerver/lib/message.py@@ -18,6 +18,7 @@ from analytics.lib.counts import COUNT_STATSfrom analytics.models import RealmCountfrom zerver.lib.avatar import get_avatar_fieldfrom zerver.lib.cache import (+ cache_set_many,cache_with_key,generic_bulk_cached_fetch,to_dict_cache_key,@@ -1609,3 +1610,20 @@ def parse_message_content_delete_limit(raise RequestVariableConversionError("message_content_delete_limit_seconds", value)assert isinstance(value, int)return value+++def update_to_dict_cache(+ changed_messages: List[Message], realm_id: Optional[int] = None+) -> List[int]:+ """Updates the message as stored in the to_dict cache (for serving+ messages)."""+ items_for_remote_cache = {}+ message_ids = []+ changed_messages_to_dict = MessageDict.to_dict_uncached(changed_messages, realm_id)+ for msg_id, msg in changed_messages_to_dict.items():+ message_ids.append(msg_id)+ key = to_dict_cache_key_id(msg_id)+ items_for_remote_cache[key] = (msg,)++ cache_set_many(items_for_remote_cache)+ return message_ids