Skip to content

Commit

Permalink
Fixed issues with attachment handling
Browse files Browse the repository at this point in the history
  • Loading branch information
robertklep committed Jan 26, 2017
1 parent f942a45 commit f2e6d0a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions quotefix/fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def fix(self):
else:
# remove attachment placeholders?
if self.app.remove_attachment_placeholders:
logger.debug('calling remove_attachment_placeholders()')
self.remove_attachment_placeholders(backend, htmlroot)

# move cursor to end of document
Expand Down Expand Up @@ -163,17 +164,18 @@ def fix(self):

def remove_attachment_placeholders(self, backend, htmlroot):
messages = objc.getInstanceVariable(backend, '_originalMessages')
if not messages:
NSLog('unable to retrieve _originalMessages')
return
for original in messages:
try:
# ElCap and older
messagebody = original.messageBody()
attachments = messagebody.attachmentFilenames()
except:
# Sierra
messagebody = original.cachedMimeBody()
if not messagebody:
NSLog('no message body')
return
attachments = messagebody.attachmentFilenames()
message = original.parsedMessage()
attachments = [ v.filename() for k, v in message.attachmentsByURL().iteritems() ]
NSLog('attachments: %@', attachments)
if not attachments:
return
Expand Down

0 comments on commit f2e6d0a

Please sign in to comment.