From bbe474e78c0859a2e5a445c0909f4461c7b1ce36 Mon Sep 17 00:00:00 2001 From: dadada Date: Sat, 30 May 2020 11:43:38 +0200 Subject: [PATCH] fix: encoding --- bin/mailbox2matrix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/mailbox2matrix b/bin/mailbox2matrix index 32aee32..f51b6a2 100755 --- a/bin/mailbox2matrix +++ b/bin/mailbox2matrix @@ -3,13 +3,18 @@ import asyncio import email import pathlib -from os import path, listdir import sys import logging + +from os import path, listdir +from email.header import decode_header, make_header from nio import (AsyncClient, Api, ClientConfig, RoomSendError) from inotify_simple import INotify, flags +def decode(header): + return make_hader(decode_header(header)) + class Client(AsyncClient): def send_message(self, From, Subject): @@ -18,7 +23,7 @@ class Client(AsyncClient): message_type="m.room.message", content={ "msgtype": "m.text", - "body": "From:\t%s\nSubject:\t%s" % (From, Subject) + "body": "From:\t%s\nSubject:\t%s" % (decode(From), decode(Subject)) } )