Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tornado: Fix ID lists leaked to the events API.
Tim Abbott99a54ba67ef9
diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.pyindex 96e684811ce..c3b6efcac1d 100644--- a/zerver/lib/event_schema.py+++ b/zerver/lib/event_schema.py@@ -5,7 +5,7 @@ It will contain schemas (aka validators) for Zulip events.Right now it's only intended to be used by test code."""-from typing import Any, Dict, Sequence, Set, Tuple, Union+from typing import Any, Callable, Dict, List, Sequence, Set, Tuple, Unionfrom zerver.lib.topic import ORIG_TOPIC, TOPIC_LINKS, TOPIC_NAMEfrom zerver.lib.validator import (@@ -693,20 +693,13 @@ update_message_required_fields = [("message_id", check_int),]-update_message_content_fields = [+update_message_content_fields: List[Tuple[str, Callable[[str, object], object]]] = [("content", check_string),("is_me_message", check_bool),- ("mention_user_ids", check_list(check_int)),("orig_content", check_string),("orig_rendered_content", check_string),- ("presence_idle_user_ids", check_list(check_int)),("prev_rendered_content_version", check_int),- ("prior_mention_user_ids", check_list(check_int)),- ("push_notify_user_ids", check_list(check_int)),("rendered_content", check_string),- ("stream_email_user_ids", check_list(check_int)),- ("stream_push_user_ids", check_list(check_int)),- ("wildcard_mention_user_ids", check_list(check_int)),]update_message_topic_fields = [diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.pyindex a8809967757..d972d34ff83 100644--- a/zerver/tornado/event_queue.py+++ b/zerver/tornado/event_queue.py@@ -1007,15 +1007,18 @@ def process_deletion_event(event: Mapping[str, Any], users: Iterable[int]) -> Nodel compatibility_event['message_ids']client.add_event(compatibility_event)-def process_message_update_event(event_template: Mapping[str, Any],+def process_message_update_event(orig_event: Mapping[str, Any],users: Iterable[Mapping[str, Any]]) -> None:- prior_mention_user_ids = set(event_template.get('prior_mention_user_ids', []))- mention_user_ids = set(event_template.get('mention_user_ids', []))- presence_idle_user_ids = set(event_template.get('presence_idle_user_ids', []))- stream_push_user_ids = set(event_template.get('stream_push_user_ids', []))- stream_email_user_ids = set(event_template.get('stream_email_user_ids', []))- wildcard_mention_user_ids = set(event_template.get('wildcard_mention_user_ids', []))- push_notify_user_ids = set(event_template.get('push_notify_user_ids', []))+ # Extract the parameters passed via the event object that don't+ # belong in the actual events.+ event_template = dict(orig_event)+ prior_mention_user_ids = set(event_template.pop('prior_mention_user_ids', []))+ mention_user_ids = set(event_template.pop('mention_user_ids', []))+ presence_idle_user_ids = set(event_template.pop('presence_idle_user_ids', []))+ stream_push_user_ids = set(event_template.pop('stream_push_user_ids', []))+ stream_email_user_ids = set(event_template.pop('stream_email_user_ids', []))+ wildcard_mention_user_ids = set(event_template.pop('wildcard_mention_user_ids', []))+ push_notify_user_ids = set(event_template.pop('push_notify_user_ids', []))stream_name = event_template.get('stream_name')message_id = event_template['message_id']