def test_old_event_format_processed_correctly(self) -> None: """ do_delete_messages used to send events with users in dict format {"id": <int>}. We have a block in process_notification to deal with that old format, that should be deleted in a later release. This test is meant to ensure correctness of that block. """ realm = get_realm("zulip") cordelia = self.example_user('cordelia') hamlet = self.example_user('hamlet') message_id = self.send_personal_message(cordelia.delivery_email, hamlet.delivery_email) message = Message.objects.get(id=message_id) event = { 'type': 'delete_message', 'sender': message.sender.email, 'sender_id': message.sender_id, 'message_id': message.id, 'message_type': "private", 'recipient_id': message.recipient_id } move_messages_to_archive([message_id]) # We only send the event to see no exception is thrown - as it would be if the block # in process_notification to handle this old format of "users to notify" wasn't correct. send_event(realm, event, [{"id": cordelia.id}, {"id": hamlet.id}])
def send_stream_creation_event(stream: Stream, user_ids: List[int]) -> None: event = dict(type="stream", op="create", streams=[stream.to_dict()]) send_event(stream.realm, event, user_ids)