Example #1
0
def process_person_info(parent, person_info, addresses):
    from contextIO2 import Contact
    contacts = {}
    to_addrs = []
    to_contacts = []
    from_addr = None
    from_contact = None

    if addresses.has_key('to'):
        for info in addresses['to']:
            person_info[info.get('email')].setdefault('name', info.get('name'))
            to_addrs.append(info.get('email'))

    info = addresses['from']
    person_info[info.get('email')].setdefault('name', info.get('name'))
    from_addr = info.get('email')

    for addr, d in person_info.items():
        info = {
            'email': addr,
        }
        if d:
            info['thumbnail'] = d.get('thumbnail')
            info['name'] = d.get('name')
        c = Contact(parent, info)
        contacts.setdefault(addr, c)

        if addr in to_addrs:
            to_contacts.append(c)
            to_addrs.remove(addr)

        elif addr == from_addr:
            from_contact = c

    return contacts, to_contacts, from_contact
Example #2
0
 def get(self):
     current_email = users.get_current_user().email()
     if validateUser(self.request.cookies, current_email):
         emailAddr = self.request.get('email')
         ctxIO = ContextIO(consumer_key=settings.CONTEXTIO_OAUTH_KEY,
                           consumer_secret=settings.CONTEXTIO_OAUTH_SECRET)
         messages = Contact(
             Account(
                 ctxIO,
                 {'id': self.request.cookies['ctxioid'].decode('utf-8')}), {
                     'email': emailAddr
                 }).get_messages(limit=25)
         self.response.out.write(json.dumps(messages))
     else:
         self.response.out.write('[]')
Example #3
0
def process_person_info(parent, person_info, addresses):
    try:
        from contextIO2 import Contact
    except ImportError:
        from .__init__ import Contact
    contacts = {}
    to_addrs = []
    to_contacts = []
    from_addr = None
    from_contact = None

    if 'to' in addresses:
        for info in addresses['to']:
            person_info[info.get('email')].setdefault('name', info.get('name'))
            to_addrs.append(info.get('email'))

    info = addresses['from']
    person_info[info.get('email')].setdefault('name', info.get('name'))
    from_addr = info.get('email')

    for addr, d in list(person_info.items()):
        info = {
            'email': addr,
            'thumbnail': d.get('thumbnail'),
            'name': d.get('name')
        }
        c = Contact(parent, info)
        contacts.setdefault(addr, c)

        if addr in to_addrs:
            to_contacts.append(c)
            to_addrs.remove(addr)

        elif addr == from_addr:
            from_contact = c

    return contacts, to_contacts, from_contact