mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	internal_send_private_message: Fix edge case of message to system bot.
I don't think this is used anywhere outside of tests, but we should have this logic correct. If this function is used to send a message from a user to a cross-realm bot, the message.realm should be the realm of the user. In the normal case, where a user send a message to a cross-realm bot through the API is already handled correctly, this bug is unrelated.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							a674de5cf8
						
					
				
				
					commit
					78a325ac58
				
			@@ -85,6 +85,7 @@ from zerver.models import (
 | 
			
		||||
    get_stream_by_id_in_realm,
 | 
			
		||||
    get_system_bot,
 | 
			
		||||
    get_user_by_delivery_email,
 | 
			
		||||
    is_cross_realm_bot_email,
 | 
			
		||||
    query_for_ids,
 | 
			
		||||
)
 | 
			
		||||
from zerver.tornado.django_api import send_event
 | 
			
		||||
@@ -1602,7 +1603,10 @@ def internal_prep_private_message(
 | 
			
		||||
    See _internal_prep_message for details of how this works.
 | 
			
		||||
    """
 | 
			
		||||
    addressee = Addressee.for_user_profile(recipient_user)
 | 
			
		||||
    if not is_cross_realm_bot_email(recipient_user.delivery_email):
 | 
			
		||||
        realm = recipient_user.realm
 | 
			
		||||
    else:
 | 
			
		||||
        realm = sender.realm
 | 
			
		||||
 | 
			
		||||
    return _internal_prep_message(
 | 
			
		||||
        realm=realm,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user