diff options
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/adapter/pixelated_mail.py | 4 | ||||
-rw-r--r-- | service/pixelated/user_agent.py | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py index 44ebd08c..9014cb4d 100644 --- a/service/pixelated/adapter/pixelated_mail.py +++ b/service/pixelated/adapter/pixelated_mail.py @@ -50,9 +50,9 @@ class InputMail: @staticmethod def from_dict(mail_dict): input_mail = InputMail() - input_mail.headers = {key.capitalize(): value for key, value in mail_dict['header'].items()} + input_mail.headers = {key.capitalize(): value for key, value in mail_dict.get('header', {}).items()} input_mail.headers['Date'] = pixelated.support.date.iso_now() - input_mail.body = mail_dict['body'] + input_mail.body = mail_dict.get('body', '') input_mail.tags = set(mail_dict.get('tags', [])) input_mail.status = set(mail_dict.get('status', [])) return input_mail diff --git a/service/pixelated/user_agent.py b/service/pixelated/user_agent.py index e6533ea6..0ec5c745 100644 --- a/service/pixelated/user_agent.py +++ b/service/pixelated/user_agent.py @@ -63,7 +63,7 @@ def send_mail(): if 'saveDraft' in DISABLED_FEATURES: mail_service.send(_mail) else: - if request.json['ident']: + if request.json.get('ident'): mail_service.send_draft(_mail) else: _mail = mail_service.create_draft(_mail) @@ -73,7 +73,8 @@ def send_mail(): @app.route('/mails', methods=['PUT']) def update_draft(): _mail = InputMail.from_dict(request.json) - ident = mail_service.update_draft(request.json['ident'], _mail).ident + new_revision = mail_service.update_draft(request.json['ident'], _mail) + ident = new_revision.ident return respond_json({'ident': ident}) |