[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sup-talk] Hook before-add-message, any way to know if this message is in a topic I replied to ?
Wael Nasreddine, 2010-12-23 14:04:
> I added this method to my before-add-message hook and I call it at the
> very end of the before-add-hook (so it's executed at the end)
>
> ------- CUT
> def show_if_participated(message)
> return if message.has_label? :inbox
>
> my_emails = ['wael.nasreddine@gmail.com', 'anotheremail@example.com']
> ts = ThreadSet.new Index.instance, $config[:thread_by_subject]
> ts.load_thread_for_message message
> message_thread = ts.thread_for message
> return unless message_thread
> message.add_label :inbox if my_emails.any? { |email|
> message_thread.authors.include? email }
> end
> ------- CUT
>
> However it's not working, I remove ~/.sup/xapian and ran sup-sync,
> this email does not have the inbox label however it's one of the
> thread that I replied to in a mailing list, what's wrong with my
> function?
On the surface it looks like it should work. Couple of questions
raise when I look at the code. Does the thread loading actually work
like that? I might have been awfully wrong. Does #authors return
email addresses or Person instances? Did your reply come from one of
the addresses listed in my_emails? Did you reply only once and was
that message the last one of it's thread to be indexed? Your first
mail to particular thread obviously won't trigger
show_if_participated(), but subsequent mails will.
Does your hook look like this? (Judging by your explanation, it most
probably does)
...
def show_if_participated(message)
end
...
show_if_participated(message)
...
--
Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk