summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
authorLisa Junger <ljunger@thoughtworks.com>2014-11-19 10:44:08 +0100
committerAlexandre Pretto Nunes <anunes@thoughtworks.com>2014-12-03 15:48:49 -0200
commitf273d2abeefa0d77d306bcfab3135195afbc31c3 (patch)
treedb0864f7e413f3c51756ecf9f32cdf235c1f4a90 /service/pixelated
parent6c5e6a65ed543193f676f601741fb597dc48e5dd (diff)
added functionality for reply all to service.
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/adapter/mail.py10
-rw-r--r--service/pixelated/adapter/mail_service.py4
-rw-r--r--service/pixelated/config/app_factory.py31
-rw-r--r--service/pixelated/controllers/mails_controller.py4
4 files changed, 47 insertions, 2 deletions
diff --git a/service/pixelated/adapter/mail.py b/service/pixelated/adapter/mail.py
index 949daa9e..6beac4c2 100644
--- a/service/pixelated/adapter/mail.py
+++ b/service/pixelated/adapter/mail.py
@@ -329,3 +329,13 @@ class PixelatedMail(Mail):
'mailbox': self.mailbox_name.lower(),
'attachments': self.parts['attachments'] if self.parts else []
}
+
+ def to_reply_template(self):
+ template = self.as_dict()
+ recipients = template['header']['to'][0]
+ for recipient in recipients:
+ if recipient == InputMail.FROM_EMAIL_ADDRESS:
+ recipients.remove(recipient)
+ template['header']['to'][0] = recipients
+ template['header']['subject'] = 'Re: %s' % template['header']['subject']
+ return template
diff --git a/service/pixelated/adapter/mail_service.py b/service/pixelated/adapter/mail_service.py
index 6c093b6d..722b9a29 100644
--- a/service/pixelated/adapter/mail_service.py
+++ b/service/pixelated/adapter/mail_service.py
@@ -83,3 +83,7 @@ class MailService:
def drafts(self):
raise NotImplementedError()
+
+ def reply_all_template(self, mail_id):
+ mail = self.mail(mail_id)
+ return mail.to_reply_template()
diff --git a/service/pixelated/config/app_factory.py b/service/pixelated/config/app_factory.py
index ede19e60..2021556d 100644
--- a/service/pixelated/config/app_factory.py
+++ b/service/pixelated/config/app_factory.py
@@ -62,13 +62,40 @@ def update_info_sync_and_index_partial(sync_info_controller, search_engine, mail
return wrapper
+def _setup_routes(app, home_controller, mails_controller, tags_controller, features_controller, sync_info_controller,
+ attachments_controller):
+ # mails
+ app.route('/mails', methods=['GET'])(mails_controller.mails)
+ app.route('/mail/<mail_id>/read', methods=['POST'])(mails_controller.mark_mail_as_read)
+ app.route('/mail/<mail_id>/unread', methods=['POST'])(mails_controller.mark_mail_as_unread)
+ app.route('/mails/unread', methods=['POST'])(mails_controller.mark_many_mail_unread)
+ app.route('/mails/read', methods=['POST'])(mails_controller.mark_many_mail_read)
+ app.route('/mail/<mail_id>', methods=['GET'])(mails_controller.mail)
+ app.route('/mail/<mail_id>/reply_all_template', methods=['GET'])(mails_controller.reply_all_template)
+ app.route('/mail/<mail_id>', methods=['DELETE'])(mails_controller.delete_mail)
+ app.route('/mails', methods=['DELETE'])(mails_controller.delete_mails)
+ app.route('/mails', methods=['POST'])(mails_controller.send_mail)
+ app.route('/mail/<mail_id>/tags', methods=['POST'])(mails_controller.mail_tags)
+ app.route('/mails', methods=['PUT'])(mails_controller.update_draft)
+ # tags
+ app.route('/tags', methods=['GET'])(tags_controller.tags)
+ # features
+ app.route('/features', methods=['GET'])(features_controller.features)
+ # sync info
+ app.route('/sync_info', methods=['GET'])(sync_info_controller.sync_info)
+ # attachments
+ app.route('/attachment/<attachment_id>', methods=['GET'])(attachments_controller.attachment)
+ # static
+ app.route('/', methods=['GET'], branch=True)(home_controller.home)
+
+
def init_leap_session(app):
try:
leap_session = LeapSession.open(app.config['LEAP_USERNAME'],
app.config['LEAP_PASSWORD'],
app.config['LEAP_SERVER_NAME'])
- except ConnectionError:
- print("Can't connect to the requested provider")
+ except ConnectionError, error:
+ print("Can't connect to the requested provider", error)
sys.exit(1)
except LeapAuthException, e:
print("Couldn't authenticate with the credentials provided %s" % e.message)
diff --git a/service/pixelated/controllers/mails_controller.py b/service/pixelated/controllers/mails_controller.py
index 3a2e0d3b..d84018dc 100644
--- a/service/pixelated/controllers/mails_controller.py
+++ b/service/pixelated/controllers/mails_controller.py
@@ -123,6 +123,10 @@ class MailsController:
self._search_engine.index_mail(self._mail_service.mail(ident))
return respond_json({'ident': ident}, request)
+ def reply_all_template(self, request, mail_id):
+ mail = self._mail_service.reply_all_template(mail_id)
+ return respond_json(mail, request)
+
def _format_exception(self, exception):
exception_info = map(str, list(exception.args))
return '\n'.join(exception_info)