From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.42.228.134 with SMTP id je6cs219491icb; Mon, 3 Jan 2011 12:51:05 -0800 (PST) Received: by 10.229.212.6 with SMTP id gq6mr18355639qcb.150.1294087864765; Mon, 03 Jan 2011 12:51:04 -0800 (PST) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id e14si15466716vcn.201.2011.01.03.12.51.04; Mon, 03 Jan 2011 12:51:04 -0800 (PST) Received-SPF: pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-talk-bounces@rubyforge.org Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 3A892185839D; Mon, 3 Jan 2011 15:51:04 -0500 (EST) Received: from kuovi.tilus.net (kuovi.tilus.net [80.68.89.168]) by rubyforge.org (Postfix) with ESMTP id A42DB185837B for ; Mon, 3 Jan 2011 15:47:00 -0500 (EST) Received: by kuovi.tilus.net (Postfix, from userid 1000) id 95C52601A; Mon, 3 Jan 2011 22:46:59 +0200 (EET) From: Tero Tilus To: sup-talk In-reply-to: <1293105681-sup-7985@Phoenix> References: <1292845256-sup-6025@Phoenix> <1292846110-sup-9522@tilus.net> <1293105681-sup-7985@Phoenix> Date: Mon, 03 Jan 2011 22:46:59 +0200 Message-Id: <1294086796-sup-9450@tilus.net> User-Agent: Sup/git Subject: Re: [sup-talk] Hook before-add-message, any way to know if this message is in a topic I replied to ? X-BeenThere: sup-talk@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: User & developer discussion of Sup List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-talk-bounces@rubyforge.org Errors-To: sup-talk-bounces@rubyforge.org 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