def each_message_from source, opts={}
begin
return if source.done? || source.has_errors?
source.each do |offset, source_labels|
if source.has_errors?
warn "error loading messages from #{source}: #{source.error.message}"
return
end
m = Message.build_from_source source, offset
m.labels += source_labels + (source.archived? ? [] : [:inbox])
m.labels.delete :unread if m.source_marked_read?
m.labels.each { |l| LabelManager << l }
HookManager.run "before-add-message", :message => m
yield m
end
rescue SourceError => e
warn "problem getting messages from #{source}: #{e.message}"
Redwood::report_broken_sources :force_to_top => true
end
end