summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--py-fake-service/app/adapter/mail.py4
-rw-r--r--py-fake-service/app/adapter/mail_service.py3
-rw-r--r--py-fake-service/app/adapter/mailset.py7
-rw-r--r--py-fake-service/app/pixelated_user_agent.py6
4 files changed, 16 insertions, 4 deletions
diff --git a/py-fake-service/app/adapter/mail.py b/py-fake-service/app/adapter/mail.py
index 242501c8..8116129d 100644
--- a/py-fake-service/app/adapter/mail.py
+++ b/py-fake-service/app/adapter/mail.py
@@ -10,11 +10,12 @@ class Mail:
mail = Mail()
mail.header = mail_json['header']
mail.header['date'] = datetime.now().isoformat()
- mail.ident = mail_json['ident'] or 0
+ mail.ident = mail_json.get('ident', 0)
mail.body = mail_json['body']
mail.tags = mail_json['tags']
mail.security_casing = {}
mail.status = []
+ mail.draft_reply_for = mail_json.get('draft_reply_for', 0)
return mail
@@ -26,6 +27,7 @@ class Mail:
self.tags = self._get_tags(mbox_mail)
self.security_casing = {}
self.status = self._get_status()
+ self.draft_reply_for = -1
def _get_status(self):
status = []
diff --git a/py-fake-service/app/adapter/mail_service.py b/py-fake-service/app/adapter/mail_service.py
index 815d3dc4..7c2570f9 100644
--- a/py-fake-service/app/adapter/mail_service.py
+++ b/py-fake-service/app/adapter/mail_service.py
@@ -78,5 +78,6 @@ class MailService:
self.mailset.update(mail)
return mail.ident
-
+ def draft_reply_for(self, mail_id):
+ return self.mailset.find(draft_reply_for=mail_id)
diff --git a/py-fake-service/app/adapter/mailset.py b/py-fake-service/app/adapter/mailset.py
index b59959a7..0b55bdc2 100644
--- a/py-fake-service/app/adapter/mailset.py
+++ b/py-fake-service/app/adapter/mailset.py
@@ -39,4 +39,9 @@ class MailSet:
self.ident += 1
return mail
-
+ def find(self, draft_reply_for):
+ match = [mail for mail in self.mails.values() if mail.draft_reply_for ==draft_reply_for]
+ if len(match) == 0:
+ return None
+ else:
+ return match[0]
diff --git a/py-fake-service/app/pixelated_user_agent.py b/py-fake-service/app/pixelated_user_agent.py
index 2abdb5a1..bae95dee 100644
--- a/py-fake-service/app/pixelated_user_agent.py
+++ b/py-fake-service/app/pixelated_user_agent.py
@@ -99,7 +99,11 @@ def contacts():
@app.route('/draft_reply_for/<int:mail_id>')
def draft_reply_for(mail_id):
- return respond_json(None)
+ mail = mail_service.draft_reply_for(mail_id)
+ if mail:
+ return respond_json(mail.__dict__)
+ else:
+ return respond_json(None)
@app.route('/control/mailset/<mailset>/load', methods=['POST'])