]> git.cworth.org Git - sup/commitdiff
Merge branch 'after-add-message-hook' into next
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Mon, 24 Aug 2009 22:44:13 +0000 (18:44 -0400)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Mon, 24 Aug 2009 23:11:44 +0000 (19:11 -0400)
Conflicts:

lib/sup/poll.rb

1  2 
lib/sup/poll.rb

diff --cc lib/sup/poll.rb
index 46fe5c5ed2cc700c294e92a2a802be47fdd754cd,fb3aacf4311a297bca2923c3e7aeda050dc63c32..e8da5570fb44687aa1339afffa4c9b8836289005
@@@ -137,22 -144,31 +143,26 @@@ EO
      begin
        return if source.done? || source.has_errors?
  
 -      source.each do |offset, default_labels|
+       messages = []
 +      source.each do |offset, source_labels|
          if source.has_errors?
 -          Redwood::log "error loading messages from #{source}: #{source.error.message}"
 +          warn "error loading messages from #{source}: #{source.error.message}"
            return
          end
  
 -        m_new = Message.build_from_source source, offset
 -        messages.push(m_new)
 -        m_old = Index.build_message m_new.id
 +        m = Message.build_from_source source, offset
 +        m.labels += source_labels + (source.archived? ? [] : [:inbox])
 +        m.labels.delete :unread if m.source_marked_read? # preserve read status if possible
 +        m.labels.each { |l| LabelManager << l }
++        messages.push m
  
 -        m_new.labels += default_labels + (source.archived? ? [] : [:inbox])
 -        m_new.labels << :sent if source.uri.eql?(SentManager.source_uri)
 -        m_new.labels.delete :unread if m_new.source_marked_read?
 -        m_new.labels.each { |l| LabelManager << l }
 -
 -        HookManager.run "before-add-message", :message => m_new
 -        m_ret = yield(m_old, m_new, offset) or next if block_given?
 -        Index.sync_message m_ret, opts
 -        UpdateManager.relay self, :added, m_ret unless m_old
 +        HookManager.run "before-add-message", :message => m
 +        yield m
        end
+       HookManager.run "after-add-message", :messages => messages
      rescue SourceError => e
 -      Redwood::log "problem getting messages from #{source}: #{e.message}"
 +      warn "problem getting messages from #{source}: #{e.message}"
        Redwood::report_broken_sources :force_to_top => true
      end
    end