Beispiel #1
0
def get_mail(api_conn, char):
    headers = api_conn.char.MailMessages(characterID=char.characterID)
    headerlist = []
    for head in headers.messages:
        if Mail.objects.filter(messageID=head.messageID):
            continue
        headerlist.append(head.messageID)
        mail = Mail()
        mail.messageID = head.messageID
        try:
            mem = Member.objects.get(characterID=head.senderID)
        except Member.DoesNotExist:
            mem = get_char(head.senderID)
        mail.sender = mem
        mail.sentDate = timezone.make_aware(head.sentDate, timezone.utc)
        mail.title = head.title
        mail.save()
        if not head.toCorpOrAllianceID == '':
            rec = Recipient()
            rec.mail = mail
            rec.recipient = get_corp_or_alliance(head.toCorpOrAllianceID)
            rec.save()
        for chid in str(head.toCharacterIDs).split(','):
            if chid == '':
                break
            try:
                mem = Member.objects.get(characterID=int(chid))
            except Member.DoesNotExist:
                mem = get_char(chid)
            rec = Recipient()
            rec.mail = mail
            rec.recipient = mem
            rec.save()
        if head.toListID:
            try:
                lis = MailingList.objects.get(listID=head.toListID)
            except MailingList.DoesNotExist:
                lis = MailingList()
                lis.listID = head.toListID
                lis.displayName = "Unknown Mailing List"
                lis.save()
            rec = Recipient()
            rec.mail = mail
            rec.recipient = lis
            rec.save()
    #Get Message Body
    if not headerlist == []:
        for sub_list in tools.sublists(headerlist, sub_length=50):
            bodies = api_conn.char.MailBodies(characterID=char.characterID,
                                              ids=sub_list)
            for body in bodies.messages:
                msg = Mail.objects.get(messageID=body.messageID)
                msg.body = body.data
                msg.save()
        logger.info('Char: %s added %s mails' % (char.name, len(headerlist)))
Beispiel #2
0
def get_mail(api_conn, char):
    headers = api_conn.char.MailMessages(characterID=char.characterID)
    headerlist = []
    for head in headers.messages:
        if Mail.objects.filter(messageID=head.messageID):
            continue
        headerlist.append(head.messageID)
        mail = Mail()
        mail.messageID = head.messageID
        try:
            mem = Member.objects.get(characterID = head.senderID)
        except Member.DoesNotExist:
            mem = get_char(head.senderID)
        mail.sender = mem
        mail.sentDate = timezone.make_aware(head.sentDate, timezone.utc)
        mail.title = head.title
        mail.save()
        if not head.toCorpOrAllianceID == '':
            rec = Recipient()
            rec.mail = mail
            rec.recipient = get_corp_or_alliance(head.toCorpOrAllianceID)
            rec.save()
        for chid in str(head.toCharacterIDs).split(','):
            if chid == '':
                break
            try:
                mem = Member.objects.get(characterID = int(chid))
            except Member.DoesNotExist:
                mem = get_char(chid)
            rec = Recipient()
            rec.mail = mail
            rec.recipient = mem
            rec.save()
        if head.toListID:
            try:
                lis = MailingList.objects.get(listID=head.toListID)
            except MailingList.DoesNotExist:
                lis = MailingList()
                lis.listID = head.toListID
                lis.displayName = "Unknown Mailing List"
                lis.save()
            rec = Recipient()
            rec.mail = mail
            rec.recipient = lis
            rec.save()
    #Get Message Body
    if not headerlist == []:
        for sub_list in tools.sublists(headerlist, sub_length=50):
            bodies = api_conn.char.MailBodies(characterID = char.characterID, ids = sub_list)
            for body in bodies.messages:
                msg = Mail.objects.get(messageID = body.messageID)
                msg.body = body.data
                msg.save()
        logger.info('Char: %s added %s mails'%(char.name,len(headerlist)))
Beispiel #3
0
def get_mailing_lists(api_conn, charid):
    lists = api_conn.char.mailinglists(characterID=charid)
    for li in lists.mailingLists:
        try:
            ml = MailingList.objects.get(listID=li.listID)
            if ml.displayName == "Unknown Mailing List":
                ml.displayName = li.displayName
                ml.save()
        except MailingList.DoesNotExist:
            ml = MailingList()
            ml.listID = li.listID
            ml.displayName = li.displayName
            ml.save()
Beispiel #4
0
def get_mailing_lists(api_conn, charid):
    lists = api_conn.char.mailinglists(characterID=charid)
    for li in lists.mailingLists:
        try:
            ml = MailingList.objects.get(listID=li.listID)
            if ml.displayName == "Unknown Mailing List":
                ml.displayName = li.displayName
                ml.save()
        except MailingList.DoesNotExist:
            ml = MailingList()
            ml.listID = li.listID
            ml.displayName = li.displayName
            ml.save()