From 752ebe6d3709b543cde758726ec72683894956f0 Mon Sep 17 00:00:00 2001 From: Patrick Maia Date: Mon, 15 Sep 2014 12:13:52 -0300 Subject: adding feature toggle for drafts --- service/pixelated/user_agent.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'service/pixelated') diff --git a/service/pixelated/user_agent.py b/service/pixelated/user_agent.py index 952af297..19c5c3f5 100644 --- a/service/pixelated/user_agent.py +++ b/service/pixelated/user_agent.py @@ -49,24 +49,23 @@ def respond_json(entity): response = json.dumps(entity) return Response(response=response, mimetype="application/json") +DISABLED_FEATURES = ['saveDraft', 'draftReply', 'signatureStatus', 'encryptionStatus', 'contacts'] @app.route('/disabled_features') def disabled_features(): - return respond_json([ - 'draftReply', - 'signatureStatus', - 'encryptionStatus', - 'contacts' - ]) + return respond_json(DISABLED_FEATURES) @app.route('/mails', methods=['POST']) def send_mail(): _mail = PixelatedMail.from_dict(request.json) - if _mail.ident: - mail_service.send_draft(_mail) + if 'saveDrafts' in DISABLED_FEATURES: + mail_service.send(_mail) else: - _mail = mail_service.create_draft(_mail) + if _mail.ident: + mail_service.send_draft(_mail) + else: + _mail = mail_service.create_draft(_mail) return respond_json(_mail.as_dict()) -- cgit v1.2.3