Re: [sieve] Fwd: New Version Notification for draft-bosch-sieve-duplicate-01.txt

Stephan Bosch <stephan@rename-it.nl> Tue, 12 March 2013 21:14 UTC

Return-Path: <stephan@rename-it.nl>
X-Original-To: sieve@ietfa.amsl.com
Delivered-To: sieve@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 322DC21F896E for <sieve@ietfa.amsl.com>; Tue, 12 Mar 2013 14:14:39 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.24
X-Spam-Level:
X-Spam-Status: No, score=0.24 tagged_above=-999 required=5 tests=[AWL=0.744, BAYES_00=-2.599, HELO_EQ_NL=0.55, HOST_EQ_NL=1.545]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bh5h4AfGiMeM for <sieve@ietfa.amsl.com>; Tue, 12 Mar 2013 14:14:38 -0700 (PDT)
Received: from drpepper.rename-it.nl (drpepper.rename-it.nl [217.119.238.16]) by ietfa.amsl.com (Postfix) with ESMTP id 7592721F896D for <sieve@ietf.org>; Tue, 12 Mar 2013 14:14:37 -0700 (PDT)
Received: from klara.student.utwente.nl ([130.89.162.218]:50569 helo=[10.168.3.2]) by drpepper.rename-it.nl with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from <stephan@rename-it.nl>) id 1UFWWm-0008FG-W5; Tue, 12 Mar 2013 22:14:34 +0100
Message-ID: <513F9A9E.6010008@rename-it.nl>
Date: Tue, 12 Mar 2013 22:14:06 +0100
From: Stephan Bosch <stephan@rename-it.nl>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3
MIME-Version: 1.0
To: Alexey Melnikov <alexey.melnikov@isode.com>
References: <20130210000420.4778.87812.idtracker@ietfa.amsl.com> <5116E5ED.20307@rename-it.nl> <513B1839.3050202@rename-it.nl> <4A7CD266-C585-4389-8098-C3D1C25912B5@isode.com>
In-Reply-To: <4A7CD266-C585-4389-8098-C3D1C25912B5@isode.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-RenameIT-MailScanner-SpamScore: -2.3 (--)
X-RenameIT-MailScanner-SpamCheck: No, score=-2.3 required=5.0 tests=ALL_TRUSTED, BAYES_00 autolearn=ham version=3.3.1
Cc: Sieve mailing list <sieve@ietf.org>
Subject: Re: [sieve] Fwd: New Version Notification for draft-bosch-sieve-duplicate-01.txt
X-BeenThere: sieve@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: SIEVE Working Group <sieve.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/sieve>, <mailto:sieve-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/sieve>
List-Post: <mailto:sieve@ietf.org>
List-Help: <mailto:sieve-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/sieve>, <mailto:sieve-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 12 Mar 2013 21:14:39 -0000

Hi Alexey,

On 3/10/2013 3:01 PM, Alexey Melnikov wrote:
> On 9 Mar 2013, at 11:08, Stephan Bosch <stephan@rename-it.nl> wrote:
>
>> I made a new version of the "duplicate" draft. It should address the comments by Ned and Alexey.
>> Any thoughts about this?
> This looks much better, thank you.
>
> One new issue is that I don't understand how :value works. Maybe it is a Sunday morning effect. Maybe you can show an example or two?

To detect duplicates, some more or less unique identifying string value 
must be extracted from the message and compared between deliveries. For 
most cases, the contents of the Message-ID header is the best choice; 
that is what it is meant for. However, to accommodate more complex uses, 
the duplicate test has the flexibility to choose a different string 
value for comparison. Using the :value argument, the string value can be 
set manually to an arbitrary string. Typically, one would compose this 
string using variable substitutions. One can for example compose it from 
parts of a header, the envelope, multiple headers, parts of the message 
body or even the current date; whatever is appropriate for the application.

There is one example of the use of :value in the draft (the second one). 
I should perhaps make the subject header structure a bit more complex to 
justify its use in this example (because :header would work here as well).

Another example would be the following scenario. A mail user receives 
XMPP notifications about new mail through Sieve. Sometimes a single 
contact sends many messages in a short period of time and the user wants 
to prevent being notified of all of those messages. He wants to be 
notified about messages from each person at most once per 30 minutes. He 
writes the following script:

require ["variables", "envelope","enotify", "duplicate"];

if envelope :matches "from" "*" { set "sender" "${1}"; }
if header :matches "subject" "*" { set "subject" "${1}"; }

if not duplicate :seconds 1800 :value "${sender}") {
     notify :message "[SIEVE] ${from}: ${subject}" 
"xmpp:user@im.example.com";
}

So this example uses the message envelope sender rather than the 
Message-ID header as an identifier for duplicate checking.

This example can be extended to allow multiple messages from the same 
sender in close succession as long as the discussed topic is different. 
This could be done as follows:

require ["variables", "envelope","enotify", "duplicate"];

if envelope :matches "from" "*" { set "sender" "${1}"; }
if header :matches "subject" "*" { set "subject" "${1}"; }

if string :comparator "i;ascii-casemap" :matches "${subject}" "Re:*" {
     set "topic" "${1}";
} else {
     set "topic" "${subject}";
}

if not duplicate :seconds 1800 :value "${sender} ${topic}") {
     notify :message "[SIEVE] ${from}: ${topic}" "xmpp:user@im.example.com";
}

Regards,

Stephan.