2023-10-07 10:22:37 +02:00
|
|
|
from django.utils.translation import gettext as _
|
|
|
|
|
|
|
|
from zerver.lib.exceptions import JsonableError
|
|
|
|
|
|
|
|
|
2024-08-18 14:16:43 +02:00
|
|
|
def extract_stream_id(req_to: int | list[int]) -> int:
|
2023-10-07 10:22:37 +02:00
|
|
|
# Recipient should only be a single stream ID.
|
2024-08-18 14:16:43 +02:00
|
|
|
if isinstance(req_to, list):
|
2024-04-16 15:52:21 +02:00
|
|
|
raise JsonableError(_("Invalid data type for channel ID"))
|
2024-08-18 14:16:43 +02:00
|
|
|
return req_to
|
2023-10-07 10:22:37 +02:00
|
|
|
|
|
|
|
|
2024-08-18 14:16:43 +02:00
|
|
|
def extract_direct_message_recipient_ids(req_to: int | list[int]) -> list[int]:
|
|
|
|
if not isinstance(req_to, list):
|
2023-10-07 10:22:37 +02:00
|
|
|
raise JsonableError(_("Invalid data type for recipients"))
|
|
|
|
|
2024-08-18 14:16:43 +02:00
|
|
|
return list(set(req_to))
|