I want to do some unrelated processing on each message I receive, but I
don't want to block the message being added to the index. This patch
adds a hook which runs /after/ the message is added to the index.
message: the new message
EOS
message: the new message
EOS
+ HookManager.register "after-add-message", <<EOS
+Executes after all messages are added to the index.
+Variables:
+ messages: an array of the new messages added
+EOS
+
HookManager.register "before-poll", <<EOS
Executes immediately before a poll for new messages commences.
No variables.
HookManager.register "before-poll", <<EOS
Executes immediately before a poll for new messages commences.
No variables.
begin
return if source.done? || source.has_errors?
begin
return if source.done? || source.has_errors?
source.each do |offset, default_labels|
if source.has_errors?
Redwood::log "error loading messages from #{source}: #{source.error.message}"
source.each do |offset, default_labels|
if source.has_errors?
Redwood::log "error loading messages from #{source}: #{source.error.message}"
end
m_new = Message.build_from_source source, offset
end
m_new = Message.build_from_source source, offset
m_old = Index.build_message m_new.id
m_new.labels += default_labels + (source.archived? ? [] : [:inbox])
m_old = Index.build_message m_new.id
m_new.labels += default_labels + (source.archived? ? [] : [:inbox])
Index.sync_message m_ret, opts
UpdateManager.relay self, :added, m_ret unless m_old
end
Index.sync_message m_ret, opts
UpdateManager.relay self, :added, m_ret unless m_old
end
+ HookManager.run "after-add-message", :messages => messages
+
rescue SourceError => e
Redwood::log "problem getting messages from #{source}: #{e.message}"
Redwood::report_broken_sources :force_to_top => true
rescue SourceError => e
Redwood::log "problem getting messages from #{source}: #{e.message}"
Redwood::report_broken_sources :force_to_top => true