From 976868cf01081998672940725323ddf5603a6f6c Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sun, 19 Feb 2017 15:23:42 -0800 Subject: [PATCH] message_edit: Store which user edited a given message. This is important for, in the future, being able to display who edited the topic of a message if that wasn't the person who originally sent the message. --- zerver/lib/actions.py | 7 ++++++- zerver/tests/test_events.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 7cfd53dea0..997c2b5057 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -2689,9 +2689,14 @@ def do_update_embedded_data(user_profile, message, content, rendered_content): def do_update_message(user_profile, message, subject, propagate_mode, content, rendered_content): # type: (UserProfile, Message, Optional[Text], str, Optional[Text], Optional[Text]) -> int event = {'type': 'update_message', + # TODO: We probably want to remove the 'sender' field + # after confirming it isn't used by any consumers. 'sender': user_profile.email, + 'user_id': user_profile.id, 'message_id': message.id} # type: Dict[str, Any] - edit_history_event = {} # type: Dict[str, Any] + edit_history_event = { + 'user_id': user_profile.id, + } # type: Dict[str, Any] changed_messages = [message] # Set first_rendered_content to be the oldest version of the diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 4366880532..cc44fe566f 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -367,6 +367,7 @@ class EventsRegisterTest(ZulipTestCase): ('stream_id', check_int), ('subject', check_string), ('subject_links', check_list(None)), + ('user_id', check_int), # There is also a timestamp field in the event, but we ignore it, as # it's kind of an unwanted but harmless side effect of calling log_event. ])