email-mirror-postfix: Handle 8-bit messages correctly.

Since JSON can’t represent bytes, we encode them with base64.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-06-05 14:35:52 -07:00
committed by Tim Abbott
parent bff3dcadc8
commit a803e68528
7 changed files with 36 additions and 37 deletions

View File

@@ -421,8 +421,7 @@ def validate_to_address(rcpt_to: str) -> None:
else:
decode_stream_email_address(rcpt_to)
def mirror_email_message(data: Dict[str, str]) -> Dict[str, str]:
rcpt_to = data['recipient']
def mirror_email_message(rcpt_to: str, msg_base64: str) -> Dict[str, str]:
try:
validate_to_address(rcpt_to)
except ZulipEmailForwardError as e:
@@ -434,8 +433,8 @@ def mirror_email_message(data: Dict[str, str]) -> Dict[str, str]:
queue_json_publish(
"email_mirror",
{
"message": data['msg_text'],
"rcpt_to": rcpt_to,
"msg_base64": msg_base64,
},
)
return {"status": "success"}