Email rework and additional notifications

This commit is contained in:
Thastertyn committed 2024-05-04 10:18:01 +02:00
1 parent a22d8becbb
commit 4fb09e8fd7
7 files changed
+98 -27

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
from flask_mail import Message
from app import flask_mail
from app.mail.messages import messages
def send_mail(message: str, recipient: str):
body = messages[message]["body"]
subject = messages[message]["subject"]
msg = Message(subject, recipients=[recipient], body=body)
try:
flask_mail.send(msg)
return True
except Exception as e:
print(f"Failed to send email. Error: {e}")
return False
+24
View File
@@ -0,0 +1,24 @@
import datetime
messages = {
"register": {
"subject": "Successfully registered!",
"body": "Congratulations! Your account has been successfully created.\nThis mail also serves as a test that the email address is correct"
},
"login": {
"subject": "New Login detected!",
"body": "A new login token has been created"
},
"logout": {
"subject": "Successfully logged out",
"body": "A login has been revoked. No further action is needed."
},
"update": {
"subject": "Account updated",
"body": "Your account has been successfully updated. This also means you have been logged out of everywhere"
},
"delete": {
"subject": "Account Deleted!",
"body": "Your account has been deleted. No further action needed"
}
}