API - minor refacto
This commit is contained in:
parent
4dc36cceec
commit
2a69745c4a
@ -132,7 +132,7 @@ class EmailService:
|
|||||||
parsed_url = parse_url(email_url)
|
parsed_url = parse_url(email_url)
|
||||||
if parsed_url.scheme != 'smtp':
|
if parsed_url.scheme != 'smtp':
|
||||||
raise InvalidEmailUrlScheme()
|
raise InvalidEmailUrlScheme()
|
||||||
credentials = (
|
username, password = (
|
||||||
parsed_url.auth.split(':')
|
parsed_url.auth.split(':')
|
||||||
if parsed_url.auth
|
if parsed_url.auth
|
||||||
else [None, None] # type: ignore
|
else [None, None] # type: ignore
|
||||||
@ -140,11 +140,11 @@ class EmailService:
|
|||||||
return {
|
return {
|
||||||
'host': parsed_url.host,
|
'host': parsed_url.host,
|
||||||
'port': 25 if parsed_url.port is None else parsed_url.port,
|
'port': 25 if parsed_url.port is None else parsed_url.port,
|
||||||
'use_tls': True if parsed_url.query == 'tls=True' else False,
|
'use_tls': parsed_url.query == 'tls=True',
|
||||||
'use_ssl': True if parsed_url.query == 'ssl=True' else False,
|
'use_ssl': parsed_url.query == 'ssl=True',
|
||||||
'username': credentials[0],
|
'username': username,
|
||||||
'password': (
|
'password': (
|
||||||
None if credentials[1] is None else unquote(credentials[1])
|
unquote(password) if isinstance(password, str) else password
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user