email processing looking for Quiske in first line
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user