mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	messages: Check for empty recipient lists in Addressee.
The check for empty recipient lists (the "message_to" argument) does not belong in check_message. As we implement support for sending messages by user IDs (see #9474), we will be extending much of the existing code in Addressee.legacy_build that validates recipient lists. Therefore, Addressee.legacy_build is a much more apt area to check for empty recipient lists. Also, Addressee.for_private and Addressee.for_user_ids also need to do their own validation, since not everything goes through Addressee.legacy_build. It is okay to simply throw a 500 in these cases because we expect that callers will be doing their own validation for calls that don't go through Addressee.legacy_build(). This commit is a part of our efforts surrounding #9474.
This commit is contained in:
		@@ -2167,10 +2167,6 @@ def check_message(sender: UserProfile, client: Client, addressee: Addressee,
 | 
			
		||||
 | 
			
		||||
    elif addressee.is_private():
 | 
			
		||||
        user_profiles = addressee.user_profiles()
 | 
			
		||||
 | 
			
		||||
        if user_profiles is None or len(user_profiles) == 0:
 | 
			
		||||
            raise JsonableError(_("Message must have recipients"))
 | 
			
		||||
 | 
			
		||||
        mirror_message = client and client.name in ["zephyr_mirror", "irc_mirror",
 | 
			
		||||
                                                    "jabber_mirror", "JabberMirror"]
 | 
			
		||||
        not_forged_mirror_message = mirror_message and not forged
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user