summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Ferraz <tiago.ferraz@gmail.com>2015-03-30 18:13:02 -0300
committerTiago Ferraz <tiago.ferraz@gmail.com>2015-03-30 18:13:02 -0300
commit1e41f13006c66ad299d7dbc7eaad42d2aa0de1dc (patch)
treeda0165aeccfe3513df01458adae10fd9a3d069aa
parent48952940d5f65ff584404f78f29b854004f81a02 (diff)
Protection against None bdoc object
When bdoc is None, pixelated does not load emails, even though it is not necessary. Tiago & Neissi pairing
-rw-r--r--service/pixelated/adapter/soledad/soledad_reader_mixin.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/service/pixelated/adapter/soledad/soledad_reader_mixin.py b/service/pixelated/adapter/soledad/soledad_reader_mixin.py
index 24010e2d..d91218c8 100644
--- a/service/pixelated/adapter/soledad/soledad_reader_mixin.py
+++ b/service/pixelated/adapter/soledad/soledad_reader_mixin.py
@@ -14,11 +14,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import base64
+import logging
import quopri
-from pixelated.adapter.soledad.soledad_facade_mixin import SoledadDbFacadeMixin
import re
+
from pixelated.adapter.model.mail import PixelatedMail
+from pixelated.adapter.soledad.soledad_facade_mixin import SoledadDbFacadeMixin
+logger = logging.getLogger(__name__)
class SoledadReaderMixin(SoledadDbFacadeMixin, object):
@@ -98,7 +101,13 @@ class SoledadReaderMixin(SoledadDbFacadeMixin, object):
def _extract_alternative(self, hdoc, headers_dict):
bdoc = self.get_content_by_phash(hdoc['phash'])
- raw_content = bdoc.content['raw']
+
+ if bdoc is not None:
+ logger.warning("No BDOC content found for message!!!")
+ raw_content = bdoc.content['raw']
+ else:
+ raw_content = ""
+
return {'headers': headers_dict, 'content': raw_content}
def _extract_attachment(self, hdoc, headers_dict):