diff options
author | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-10-20 19:53:27 +0000 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2014-10-22 17:27:24 -0300 |
commit | 61d7ba86167da51d6a8b18aa849760054cf6ed9b (patch) | |
tree | a290ed876855d41640891decb71cd41b306c13bc /service/pixelated/adapter | |
parent | 3baa79696b36bf3ba0db20af58dc5ea6b3a701a3 (diff) |
Card #30 - method to extract email alternatives and attachments
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r-- | service/pixelated/adapter/soledad_querier.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/service/pixelated/adapter/soledad_querier.py b/service/pixelated/adapter/soledad_querier.py index ae518f00..ce75750a 100644 --- a/service/pixelated/adapter/soledad_querier.py +++ b/service/pixelated/adapter/soledad_querier.py @@ -97,6 +97,20 @@ class SoledadQuerier: fdocs_chash = [(result[0], ident) for result, ident in fdocs_chash if result] return self._build_mails_from_fdocs(fdocs_chash) + def _extract_parts(self, content, parts={'alternatives': [], 'attachments': []}): + if content['multi']: + for part_key in content['part_map'].keys(): + self._extract_parts(content['part_map'][part_key], parts) + else: + bdoc = self.soledad.get_from_index('by-type-and-payloadhash', 'cnt', content['phash'])[0] + raw_content = bdoc.content['raw'] + headers_dict = {elem[0]: elem[1] for elem in content['headers']} + group = 'attachments' if 'attachment' in headers_dict.get('Content-Disposition', '') else 'alternatives' + parts[group].append({'ctype': content['ctype'], + 'headers': headers_dict, + 'content': raw_content}) + return parts + def remove_mail(self, mail): _mail = self.mail(mail.ident) # FIX-ME: Must go through all the part_map phash to delete all the cdocs |