linting
This commit is contained in:
parent
fad64ff064
commit
4bcc0d107f
|
@ -11,7 +11,6 @@ from email.mime.multipart import MIMEMultipart
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.utils import make_msgid, formatdate, parseaddr
|
from email.utils import make_msgid, formatdate, parseaddr
|
||||||
from smtplib import SMTP
|
from smtplib import SMTP
|
||||||
from uuid import uuid4
|
|
||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
import dkim
|
import dkim
|
||||||
|
@ -108,7 +107,7 @@ def send_activation_email(email, name, activation_link):
|
||||||
def send_reset_password_email(email, name, reset_password_link):
|
def send_reset_password_email(email, name, reset_password_link):
|
||||||
send_email(
|
send_email(
|
||||||
email,
|
email,
|
||||||
f"Reset your password on SimpleLogin",
|
"Reset your password on SimpleLogin",
|
||||||
render(
|
render(
|
||||||
"transactional/reset-password.txt",
|
"transactional/reset-password.txt",
|
||||||
name=name,
|
name=name,
|
||||||
|
@ -125,7 +124,7 @@ def send_reset_password_email(email, name, reset_password_link):
|
||||||
def send_change_email(new_email, current_email, name, link):
|
def send_change_email(new_email, current_email, name, link):
|
||||||
send_email(
|
send_email(
|
||||||
new_email,
|
new_email,
|
||||||
f"Confirm email update on SimpleLogin",
|
"Confirm email update on SimpleLogin",
|
||||||
render(
|
render(
|
||||||
"transactional/change-email.txt",
|
"transactional/change-email.txt",
|
||||||
name=name,
|
name=name,
|
||||||
|
@ -247,7 +246,7 @@ def send_email(
|
||||||
)
|
)
|
||||||
|
|
||||||
# add DKIM
|
# add DKIM
|
||||||
email_domain = SUPPORT_EMAIL[SUPPORT_EMAIL.find("@") + 1 :]
|
email_domain = SUPPORT_EMAIL[SUPPORT_EMAIL.find("@") + 1:]
|
||||||
add_dkim_signature(msg, email_domain)
|
add_dkim_signature(msg, email_domain)
|
||||||
|
|
||||||
msg_raw = to_bytes(msg)
|
msg_raw = to_bytes(msg)
|
||||||
|
@ -344,7 +343,7 @@ def get_email_domain_part(address):
|
||||||
Get the domain part from email
|
Get the domain part from email
|
||||||
ab@cd.com -> cd.com
|
ab@cd.com -> cd.com
|
||||||
"""
|
"""
|
||||||
return address[address.find("@") + 1 :].strip().lower()
|
return address[address.find("@") + 1:].strip().lower()
|
||||||
|
|
||||||
|
|
||||||
def add_dkim_signature(msg: Message, email_domain: str):
|
def add_dkim_signature(msg: Message, email_domain: str):
|
||||||
|
@ -363,7 +362,7 @@ def add_dkim_signature(msg: Message, email_domain: str):
|
||||||
|
|
||||||
# remove linebreaks from sig
|
# remove linebreaks from sig
|
||||||
sig = sig.replace("\n", " ").replace("\r", "")
|
sig = sig.replace("\n", " ").replace("\r", "")
|
||||||
msg["DKIM-Signature"] = sig[len("DKIM-Signature: ") :]
|
msg["DKIM-Signature"] = sig[len("DKIM-Signature: "):]
|
||||||
|
|
||||||
|
|
||||||
def add_or_replace_header(msg: Message, header: str, value: str):
|
def add_or_replace_header(msg: Message, header: str, value: str):
|
||||||
|
@ -519,7 +518,7 @@ def get_header_from_bounce(msg: Message, header: str) -> str:
|
||||||
r = re.search(exp, msg_str)
|
r = re.search(exp, msg_str)
|
||||||
if r:
|
if r:
|
||||||
# substr should be something like 'HEADER: 1234'
|
# substr should be something like 'HEADER: 1234'
|
||||||
substr = msg_str[r.start() : r.end()].strip()
|
substr = msg_str[r.start():r.end()].strip()
|
||||||
parts = substr.split(":")
|
parts = substr.split(":")
|
||||||
return parts[1].strip()
|
return parts[1].strip()
|
||||||
|
|
||||||
|
@ -571,9 +570,9 @@ def get_spam_from_header(spam_status_header, max_score=None) -> (bool, str):
|
||||||
# spam score
|
# spam score
|
||||||
# get the score section "score=-0.1"
|
# get the score section "score=-0.1"
|
||||||
score_section = (
|
score_section = (
|
||||||
spam_status_header[spam_status_header.find(",") + 1 :].strip().split(" ")[0]
|
spam_status_header[spam_status_header.find(",") + 1:].strip().split(" ")[0]
|
||||||
)
|
)
|
||||||
score = float(score_section[len("score=") :])
|
score = float(score_section[len("score="):])
|
||||||
if score >= max_score:
|
if score >= max_score:
|
||||||
LOG.warning("Spam score %s exceeds %s", score, max_score)
|
LOG.warning("Spam score %s exceeds %s", score, max_score)
|
||||||
return True, spam_status_header
|
return True, spam_status_header
|
||||||
|
|
Loading…
Reference in New Issue