diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2017-09-06 10:52:45 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2017-09-06 14:30:13 -0700 |
commit | d4ea14c7f58e2a7c1981f15aec513517d9268918 (patch) | |
tree | 39a3a3eb3bce20bb40dcf4b69abfa092b865463e /alot/db/message.py | |
parent | ed48c4550427bbcf6d2e64258c4724091c29fa01 (diff) |
db/message: Don't set sender to ''
If the message doesn't have a sender, try to come up with one. If the
message has the draft tag we known that the user is the sender, just use
the default account as the from if we can't find one another way. If it
doesn't have the draft tag just set the sending to 'Unknown'.
Diffstat (limited to 'alot/db/message.py')
-rw-r--r-- | alot/db/message.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/alot/db/message.py b/alot/db/message.py index 9d7437eb..72d87f12 100644 --- a/alot/db/message.py +++ b/alot/db/message.py @@ -45,14 +45,22 @@ class Message(object): except ValueError: self._datetime = None self._filename = msg.get_filename() - try: - self._from = decode_header(msg.get_header('From')) - except NullPointerError: - self._from = '' self._email = None # will be read upon first use self._attachments = None # will be read upon first use self._tags = set(msg.get_tags()) + try: + sender = decode_header(msg.get_header('From')) + except NullPointerError: + sender = None + if sender: + self._from = sender + elif 'draft' in self._tags: + acc = settings.get_accounts()[0] + self._from = '"{}" <{}>'.format(acc.realname, unicode(acc.address)) + else: + self._from = '"Unknown" <>' + def __str__(self): """prettyprint the message""" aname, aaddress = self.get_author() |