mailbot doesn't crawl mails which it wrote itself anymore

master
b3yond 2018-01-18 14:23:11 +01:00
parent 331bf6277e
commit 95466c5cc3
1 changed files with 12 additions and 9 deletions

View File

@ -84,14 +84,16 @@ class Mailbot(object):
return msgs return msgs
msg = email.message_from_bytes(data[0][1]) msg = email.message_from_bytes(data[0][1])
# get a comparable date out of the email if not self.config['mail']['user'] + "@" + \
date_tuple = email.utils.parsedate_tz(msg['Date']) self.config["mail"]["mailserver"].partition(".")[2] in msg['From']:
date_tuple = datetime.datetime.fromtimestamp(email.utils.mktime_tz(date_tuple)) # get a comparable date out of the email
date = (date_tuple - datetime.datetime(1970, 1, 1)).total_seconds() date_tuple = email.utils.parsedate_tz(msg['Date'])
if date > self.get_history(self.history_path): date_tuple = datetime.datetime.fromtimestamp(email.utils.mktime_tz(date_tuple))
self.last_mail = date date = (date_tuple - datetime.datetime(1970, 1, 1)).total_seconds()
self.save_last() if date > self.get_history(self.history_path):
msgs.append(self.make_report(msg)) self.last_mail = date
self.save_last()
msgs.append(self.make_report(msg))
return msgs return msgs
def get_history(self, path): def get_history(self, path):
@ -154,7 +156,8 @@ class Mailbot(object):
:param statuses: (list of report.Report objects) :param statuses: (list of report.Report objects)
:return: statuses: (list of report.Report objects) :return: statuses: (list of report.Report objects)
""" """
self.post(statuses) for status in statuses:
self.post(status)
msgs = self.crawl() msgs = self.crawl()