mirror of https://github.com/zulip/zulip.git
actions: Improve format for delete events.
There were several problems with the old format: * The sender was not necessarily the sender; it was the person who did the deletion (which could be an organization administrator) * It didn't include the ID of the sender, just the email address. * It didn't include the recipient ID, instead having a semi-malformed recipient_type_id under the weird name recipient_user_ids. Since nothing was relying on the old behavior, we can just fix the event structure.
This commit is contained in:
parent
a6abafa54b
commit
4f2c9f46bd
|
@ -4379,14 +4379,15 @@ def do_delete_messages(user_profile: UserProfile, messages: Iterable[Message]) -
|
|||
|
||||
event = {
|
||||
'type': 'delete_message',
|
||||
'sender': user_profile.email,
|
||||
'sender': message.sender.email,
|
||||
'sender_id': message.sender_id,
|
||||
'message_id': message.id,
|
||||
'message_type': message_type, } # type: Dict[str, Any]
|
||||
if message_type == "stream":
|
||||
event['stream_id'] = message.recipient.type_id
|
||||
event['topic'] = message.topic_name()
|
||||
else:
|
||||
event['recipient_user_ids'] = message.recipient.type_id
|
||||
event['recipient_id'] = message.recipient_id
|
||||
|
||||
# TODO: Each part of the following should be changed to bulk
|
||||
# queries, since right now if you delete 1000 messages, you'll
|
||||
|
|
|
@ -2464,6 +2464,7 @@ class EventsRegisterTest(ZulipTestCase):
|
|||
('type', equals('delete_message')),
|
||||
('message_id', check_int),
|
||||
('sender', check_string),
|
||||
('sender_id', check_int),
|
||||
('message_type', equals("stream")),
|
||||
('stream_id', check_int),
|
||||
('topic', check_string),
|
||||
|
@ -2482,8 +2483,9 @@ class EventsRegisterTest(ZulipTestCase):
|
|||
('type', equals('delete_message')),
|
||||
('message_id', check_int),
|
||||
('sender', check_string),
|
||||
('sender_id', check_int),
|
||||
('message_type', equals("private")),
|
||||
('recipient_user_ids', check_int),
|
||||
('recipient_id', check_int),
|
||||
])
|
||||
msg_id = self.send_personal_message(
|
||||
self.example_email("cordelia"),
|
||||
|
|
Loading…
Reference in New Issue