2017-04-18 17:28:55 +02:00
|
|
|
from django.http import HttpRequest, HttpResponse
|
|
|
|
|
2024-02-08 20:40:39 +01:00
|
|
|
from zerver.decorator import internal_api_view
|
2017-04-18 17:28:55 +02:00
|
|
|
from zerver.lib.email_mirror import mirror_email_message
|
2021-06-30 18:35:50 +02:00
|
|
|
from zerver.lib.exceptions import JsonableError
|
|
|
|
from zerver.lib.response import json_success
|
2024-07-14 19:39:20 +02:00
|
|
|
from zerver.lib.typed_endpoint import typed_endpoint
|
2017-04-18 17:28:55 +02:00
|
|
|
|
|
|
|
|
2024-02-08 20:40:39 +01:00
|
|
|
@internal_api_view(False)
|
2024-07-14 19:39:20 +02:00
|
|
|
@typed_endpoint
|
2020-06-05 23:35:52 +02:00
|
|
|
def email_mirror_message(
|
2021-02-12 08:19:30 +01:00
|
|
|
request: HttpRequest,
|
2024-07-14 19:39:20 +02:00
|
|
|
*,
|
|
|
|
rcpt_to: str,
|
|
|
|
msg_base64: str,
|
2020-06-05 23:35:52 +02:00
|
|
|
) -> HttpResponse:
|
|
|
|
result = mirror_email_message(rcpt_to, msg_base64)
|
2017-04-18 17:28:55 +02:00
|
|
|
if result["status"] == "error":
|
2021-06-30 18:35:50 +02:00
|
|
|
raise JsonableError(result["msg"])
|
2022-01-31 13:44:02 +01:00
|
|
|
return json_success(request)
|