Skip to content

Commit

Permalink
ImapFolderAgent: Handle a mail without a body
Browse files Browse the repository at this point in the history
This addresses huginn#745.
  • Loading branch information
knu committed May 13, 2015
1 parent 1a43bd2 commit 5641e0b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/models/agents/imap_folder_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -525,17 +525,19 @@ def initialize(client, fetch_data, props = {})

def has_attachment?
@has_attachment ||=
begin
data = @client.uid_fetch(@uid, 'BODYSTRUCTURE').first
if data = @client.uid_fetch(@uid, 'BODYSTRUCTURE').first
struct_has_attachment?(data.attr['BODYSTRUCTURE'])
else
false
end
end

def fetch
@parsed ||=
begin
data = @client.uid_fetch(@uid, 'BODY.PEEK[]').first
if data = @client.uid_fetch(@uid, 'BODY.PEEK[]').first
Mail.read_from_string(data.attr['BODY[]'])
else
Mail.read_from_string('')
end
end

Expand Down

0 comments on commit 5641e0b

Please sign in to comment.