File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 11import logging
22import re
33from html import unescape
4- from typing import Optional
4+ from typing import Optional , Union
55
66from src .render .main import MessageDef , render_email
77from src .schemas .messages import EmailSendModel
1515
1616def _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
2426class 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
You can’t perform that action at this time.
0 commit comments