[Chandler-dev] In and Out collections should compute their contents based on the sender or recipient of an email, not the isOutbound attribute

Brian Kirsch bkirsch at osafoundation.org
Mon Oct 9 13:52:45 PDT 2006


Hello,
So I played around with Bug 6857: In and Out collections should compute 
their contents based on the sender or recipient of an email, not the 
isOutbound attribute.

Based on my experimenting I really don't see how it will be possible to 
have the In / Out collection work as described below with out a filter 
collection.

 From the design spec written by Mimi:

    Items end up in the In and Out collections regardless of whether 
they were
    received via the Mail Service or Sharing Service.

    Items end up in the In and Out collections regardless of whether 
they were
    received as Mine or Not-Mine collections.

    The only criteria is:
    + Item is a message; AND
    + If the user is in the FROM: Send via: Sent by: Edited by: Updated 
by fields,
    item goes into the OUT collection
    + If the user is in the TO: CC: fields, item goes into the IN collection
    + If the user received the email via the Mail Service, the item goes 
into the
    IN collection (even if they are not specifically enumerated in the 
Addressing
    fields)

    A single item could show up in the IN and OUT collections

    There will be some set of email in your repo that will NOT show up 
in either
    IN/OUT, namely email you receive through sharing that is neither 
FROM nor TO
    you.

    IN and OUT should not show up automatically in the Dashboard. This 
is to avoid
    the awkward scenario where a user subscribes to a share that they 
explicitly
    want to 'Keep out of Dashboard', but the share contains emails that 
are either
    FROM: or TO: them, which will in turn get picked up by the IN and OUT
    collections.

    All mail received via Mail Service should be added to the Dashboard 
collection.

    When we have a notion of Spheres, then we can have separate IN/OUT 
collections
    per sphere, and that will solve a lot of the funkiness described above.

The main issue I see is control of changes to the MailStamp type. A user 
can change the to or cc of a message at anytime. There are also a number 
of codepoints where a MailStamp is added to an item. This lack of 
control makes it very difficult to enforce the In / Out collection logic.

I have attached some Python code which I used during my experimenting to 
determine the In / Out collection adding. The mail service logic works 
great but it is the other areas where a MailStamp is assigned and its 
values altered that concerns me.

I also looked in to using an observer on the toAddress, fromAddress, and 
ccAddress of a MailStamp. But after conversations with pje it looks like 
this is not a feasible option since the value that changes 
EmailAddress.emailAddress is contained in these lists.

Unless someone has a suggestion that I am overlooking it looks like a 
filter collection for "In" and "Out" really is needed.


-Brian

-- 
Brian Kirsch 
Internationalization Architect / Mail Service Engineer
Open Source Applications Foundation
543 Howard Street 5th Floor
San Francisco, CA 94105
http://www.osafoundation.org

-------------- next part --------------
from osaf.pim.mail import *
from application import schema

"""
MailService
1. Always add in
2. Always add dashboard

THOUGHTS: 
1. inbound and outbound flags what are there role now?
"""

def addToMailCollections(view, mailMessage, fromMailService=False):
    assert(isinstance(mailMessage, MailMessage))

    pim_ns = schema.ns('osaf.pim', view)

    if fromMailService:
        pim_ns.inCollection.add(mailMessage)
        pim_ns.allCollection.add(mailMessage)

    else:
        if isInbound(view, MailStamp(mailMessage)):
            pim_ns.inCollection.add(mailMessage)

    #XXX this may not be right. Do you do this for service 
    #    stuff as well
    if isOutbound(view, MailStamp(mailMessage)):
        pim_ns.outCollection.add(mailMessage)

def isInbound(view, mailStamp):
    assert(isinstance(mailStamp, MailStamp))

    me = EmailAddress.getCurrentMeEmailAddress(view)

    if me is None:
        return False

    me = EmailAddress.format(me)

    for addr in mailStamp.toAddress:
        if EmailAddress.emailAddressesAreEqual(me, \
                       EmailAddress.format(addr))
        return True

    for addr in mailStamp.ccAddress:
        if EmailAddress.emailAddressesAreEqual(me, \
                       EmailAddress.format(addr))
        return True

    return False

def isOutbound(view, mailStamp):
    assert(isinstance(mailStamp, MailStamp))

    me = EmailAddress.getCurrentMeEmailAddress(view)

    if me is None:
        return False

    me = EmailAddress.format(me)

    if mailStamp.replyToAddress != None and \
       EmailAddress.emailAddressesAreEqual(me, \
                       EmailAddress.format(mailStamp.replyToAddress)):
        return True

    if mailStamp.fromAddress != None and \
       EmailAddress.emailAddressesAreEqual(me, \
                       EmailAddress.format(mailStamp.fromAddress)):
        return True

    #XXX: Add sent by: edited by: updated by:
    #     we don't have these values yet in mail schema
    return False


More information about the chandler-dev mailing list