mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Migrate `scheduled_message.py` to typed_endpoint. Perform Json parsing in the endpoint itself instead of in `recipient_parsing.py`.
		
			
				
	
	
		
			18 lines
		
	
	
		
			541 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			541 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from django.utils.translation import gettext as _
 | 
						|
 | 
						|
from zerver.lib.exceptions import JsonableError
 | 
						|
 | 
						|
 | 
						|
def extract_stream_id(req_to: int | list[int]) -> int:
 | 
						|
    # Recipient should only be a single stream ID.
 | 
						|
    if isinstance(req_to, list):
 | 
						|
        raise JsonableError(_("Invalid data type for channel ID"))
 | 
						|
    return req_to
 | 
						|
 | 
						|
 | 
						|
def extract_direct_message_recipient_ids(req_to: int | list[int]) -> list[int]:
 | 
						|
    if not isinstance(req_to, list):
 | 
						|
        raise JsonableError(_("Invalid data type for recipients"))
 | 
						|
 | 
						|
    return list(set(req_to))
 |