Private
Public Access
1
0

email processing looking for Quiske in first line

This commit is contained in:
Sander Roosendaal
2017-11-22 09:14:19 +01:00
parent b97db946af
commit 6a76ba05fa
3 changed files with 186 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ import sys
import os
import zipfile
import re
import time
from time import strftime
@@ -95,6 +95,24 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
return workoutid
def get_from_address(message):
from_address = message.from_address[0].lower()
if message.encoded:
body = message.text.splitlines()
else:
body = message.get_body().splitlines()
first_line = body[0].lower()
if "quiske" in first_line:
match = re.search(r'[\w\.-]+@[\w\.-]+', first_line)
return match.group(0)
return from_address
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
@@ -131,7 +149,9 @@ class Command(BaseCommand):
uploadoptions = uploads.upload_options(body)
from_address = message.from_address[0].lower()
from_address = get_from_address(message)
name = message.subject
# get a list of users
# theusers = User.objects.filter(email=from_address)