use regex_match instead of re.fullmatch()
This commit is contained in:
parent
5e7730c35c
commit
79ca39a625
|
@ -1,6 +1,6 @@
|
||||||
|
import re
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import re2 as re
|
|
||||||
from email_validator import validate_email, EmailNotValidError
|
from email_validator import validate_email, EmailNotValidError
|
||||||
from sqlalchemy.exc import IntegrityError, DataError
|
from sqlalchemy.exc import IntegrityError, DataError
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ from app.models import (
|
||||||
Mailbox,
|
Mailbox,
|
||||||
EmailLog,
|
EmailLog,
|
||||||
Contact,
|
Contact,
|
||||||
AutoCreateRule,
|
|
||||||
)
|
)
|
||||||
|
from app.regex_utils import regex_match
|
||||||
|
|
||||||
|
|
||||||
def try_auto_create(address: str) -> Optional[Alias]:
|
def try_auto_create(address: str) -> Optional[Alias]:
|
||||||
|
@ -139,9 +139,7 @@ def try_auto_create_via_domain(address: str) -> Optional[Alias]:
|
||||||
local = get_email_local_part(address)
|
local = get_email_local_part(address)
|
||||||
|
|
||||||
for rule in custom_domain.auto_create_rules:
|
for rule in custom_domain.auto_create_rules:
|
||||||
rule: AutoCreateRule
|
if regex_match(rule.regex, local):
|
||||||
regex = re.compile(rule.regex)
|
|
||||||
if re.fullmatch(regex, local):
|
|
||||||
LOG.d(
|
LOG.d(
|
||||||
"%s passes %s on %s",
|
"%s passes %s on %s",
|
||||||
address,
|
address,
|
||||||
|
|
Loading…
Reference in a new issue