-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_capturio_mail.py
98 lines (78 loc) · 3.85 KB
/
get_capturio_mail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import logging, email
from google.appengine.api import mail
class GetMailHandler():
def __init__(self, senderMail):
self.responseMail = mail.EmailMessage(
sender = "Capturio crew <crew@captur.io>",
to = senderMail
)
def sendResponse(self, typeOfResponse, attachments = None):
if(typeOfResponse == "noAttachment"):
self.responseMail.subject = "We didn't find any ID image in your last email"
self.responseMail.body = """
We're sorry but we didn't find any ID image in your last email. Please double check and make sure you've got one ID image so that we can send you the associated contact information.
"""
elif(typeOfResponse == "tooManyAttachments"):
self.responseMail.subject = "Too many files in your last email. We process only one image per email"
self.responseMail.body = """
We're sorry but we received too many files from you. For the moment, we only process one image per email. Please send us only one image and we will send you the associated contact information
"""
elif(typeOfResponse == "imageExtensionInvalid"):
self.responseMail.subject = "Image extension not recognized. Please send us a .jpeg/.jpg, .png or .gif image"
self.responseMail.body = """
We're sorry but we did not recognize the extension of your image. Please make sure to send a .jpeg/.jpg , .png or .gif image.
"""
elif(typeOfResponse == "noMatchingImage"):
self.responseMail.subject = "We don't know this image"
self.responseMail.body = """
We're sorry but we don't know this image. Please retry with a picture with more light and/or precision.
"""
elif(typeOfResponse == "noVcardAssociated"):
self.responseMail.subject = "The user we found did not associate any vcard"
self.responseMail.body = """
We're sorry but the user matching your image did not associate any vcard. We'll ping him so that he'll input this information!
"""
elif(typeOfResponse == "vcardAttached"):
self.responseMail.subject = "[Capturio rocks] Please find attached the vcard you requested"
self.responseMail.body = """
Please find attached the vcard associated with the image you sent earlier. Isn't it magical? Feel free to send us other images.
"""
self.responseMail.attachments = attachments
elif(typeOfResponse == "error"):
self.responseMail.subject = "An error occurred"
self.responseMail.body = """
We're sorry but an error occurred. Please retry in a couple of minutes.
"""
hello = """
Hey,
"""
signature = """
Ping us soon again!
Captur.io crew
PS: If your vcard is not associated yet with one of your personal object, just send both to post@captur.io. For more information, go to http://captur.io
"""
self.responseMail.body = hello + self.responseMail.body + signature
self.responseMail.send()
logging.info("responseMail sent")
def sendAlert(self, typeOfResponse, attachments = None, label = None, mail = None):
if(typeOfResponse == "justCapturedRequesterWithVcard"):
self.responseMail.subject = "[Vcard attached] You have been captured by another person on Captur.io"
self.responseMail.body = """
The following person: %s (%s) captured you with Capturio! He just receives your vcard because you have probably shown him your Capturio object! Please find also attached his own vcard.
""" % (label, mail)
self.responseMail.attachments = attachments
elif(typeOfResponse == "justCapturedRequesterWithoutVcard"):
self.responseMail.subject = "You have been captured by another person on Captur.io"
self.responseMail.body = """
The following person: %s (%s) captured you with Capturio! He just receives your vcard because you have probably shown him your Capturio object!
""" % (label, mail)
hello = """
Hey,
"""
signature = """
Ping us soon again!
Capturio crew
"""
self.responseMail.body = hello + self.responseMail.body + signature
self.responseMail.send()
logging.info("alert sent")