Skip to content

Commit

Permalink
db: message: Implement get_subject
Browse files Browse the repository at this point in the history
Provide a method to get the subject of a given message.

Signed-off-by: Kieran Bingham <[email protected]>
  • Loading branch information
kbingham committed Oct 19, 2021
1 parent 32b885d commit 2494333
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions alot/db/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, dbman, msg, thread=None):
self._datetime = None
self._filename = msg.get_filename()
self._email = None # will be read upon first use
self._subject = None # will be read upon first use
self._attachments = None # will be read upon first use
self._mime_part = None # will be read upon first use
self._mime_tree = None # will be read upon first use
Expand Down Expand Up @@ -122,6 +123,12 @@ def get_message_id(self):
"""returns messages id (str)"""
return self._id

def get_subject(self):
if not self._subject:
mail = self.get_email()
self._subject = decode_header(mail.get('Subject', ''))
return self._subject

def get_thread_id(self):
"""returns id (str) of the thread this message belongs to"""
return self._thread_id
Expand Down

0 comments on commit 2494333

Please sign in to comment.