mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 19:06:09 +00:00
Handle more types of data in extract_recipients.
We now allow the list of recipients to be sent as a comma-delimited string with optional JSON encoding. (imported from commit e928b037bbd258348eb5b2ecca486d0bb77f593e)
This commit is contained in:
@@ -536,13 +536,21 @@ def already_sent_mirrored_message_id(message):
|
||||
return messages[0].id
|
||||
return None
|
||||
|
||||
def extract_recipients(raw_recipients):
|
||||
def extract_recipients(s):
|
||||
# We try to accept multiple incoming formats for recipients.
|
||||
# See test_extract_recipients() for examples of what we allow.
|
||||
try:
|
||||
recipients = json_to_list(raw_recipients)
|
||||
data = ujson.loads(s)
|
||||
except ValueError:
|
||||
recipients = [raw_recipients]
|
||||
data = s
|
||||
|
||||
if isinstance(data, basestring):
|
||||
data = data.split(',')
|
||||
|
||||
if not isinstance(data, list):
|
||||
raise ValueError("Invalid data type for recipients")
|
||||
|
||||
recipients = data
|
||||
|
||||
# Strip recipients, and then remove any duplicates and any that
|
||||
# are the empty string after being stripped.
|
||||
|
||||
Reference in New Issue
Block a user