Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: kevinr@free-dissociation.com (Kevin Riggle)
Subject: [sup-talk] [PATCH] Add an after-add-message hook
Date: Sun, 16 Aug 2009 17:47:09 -0400	[thread overview]
Message-ID: <1250459229-4500-1-git-send-email-kevinr@free-dissociation.com> (raw)

From: Kevin Riggle <kevinr at black-opal.mit.edu>

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.
---
 lib/sup/poll.rb |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
index 8a9d218..e4b7e02 100644
--- a/lib/sup/poll.rb
+++ b/lib/sup/poll.rb
@@ -11,6 +11,12 @@ Variables:
   message: the new message
 EOS
 
+  HookManager.register "after-add-message", <<EOS
+Executes after a message is added to the index.
+Variables:
+  message: the new message
+EOS
+
   HookManager.register "before-poll", <<EOS
 Executes immediately before a poll for new messages commences.
 No variables.
@@ -156,6 +162,7 @@ EOS
         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 "after-add-message", :message => m_new
       end
     rescue SourceError => e
       Redwood::log "problem getting messages from #{source}: #{e.message}"
-- 
1.6.0.4



             reply	other threads:[~2009-08-16 21:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-16 21:47 Kevin Riggle [this message]
2009-08-18 17:56 ` William Morgan
2009-08-18 23:36   ` Kevin Riggle
2009-08-19 18:55     ` William Morgan
2009-08-21  1:57       ` Kevin Riggle
2009-08-24 22:44         ` William Morgan
2009-09-02 13:53           ` William Morgan
2009-08-21  2:07       ` Kevin Riggle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1250459229-4500-1-git-send-email-kevinr@free-dissociation.com \
    --to=kevinr@free-dissociation.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox