UPDATE: Ensured primary key in newsletter cannot be duplicated

This commit is contained in:
white
2025-03-03 11:43:15 +00:00
parent 968cdc4068
commit 6f900b2fe6

View File

@@ -30,7 +30,6 @@ def send_email(email, func) -> None:
# Setup up the receiver details
body, subject = func()
print(subject, flush=True)
msg = MIMEText(body, "html")
msg["Subject"] = subject
@@ -159,6 +158,19 @@ def newsletter_conf(email):
</html>
"""
# Check if user is already in database
db = Database()
db.create_connection()
user_exists = db.fetchone("""
SELECT *
FROM newsletter
WHERE email = ?;""",
(email,))
print(user_exists, flush=True)
db.close_connection()
if user_exists is None:
add_to_newsletter(email)
return content, "Gander - Newsletter"