Skip to content

Commit 8d67201

Browse files
committed
Sandeep comments
1 parent c3a87aa commit 8d67201

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/spam/email_checker.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import re
33
from html import unescape
4-
from typing import Optional
4+
from typing import Optional, Union
55

66
from src.render.main import MessageDef, render_email
77
from src.schemas.messages import EmailSendModel
@@ -15,10 +15,12 @@
1515

1616
def _clean_html_body(
1717
html_body: Optional[str] = None,
18-
) -> str:
18+
) -> Union[str, None]:
19+
'''
20+
Cleans the html body - removes HTML tags and whitespaces
21+
'''
1922
if isinstance(html_body, str) and html_body.strip():
2023
return _white_space_re.sub(' ', unescape(_html_tag_re.sub('', html_body)))
21-
return ''
2224

2325

2426
class EmailSpamChecker:
@@ -69,7 +71,7 @@ async def check_spam(self, m: EmailSendModel):
6971
"subject": subject,
7072
"company": company_name,
7173
"company_code": m.company_code,
72-
"email_main_body": _clean_html_body(context.get('main_message__render', '')) or 'no main body',
74+
"email_main_body": _clean_html_body(context.get('main_message__render')) or 'no main body',
7375
},
7476
)
7577
return spam_result

0 commit comments

Comments
 (0)