refactor post_parser: streamline content body construction for improved readability

This commit is contained in:
vvzvlad
2025-04-26 12:55:38 +04:00
parent 36236d4407
commit 508be049d9
+11 -12
View File
@@ -600,19 +600,19 @@ class PostParser:
forward_html = self._format_forward_info(message)
reply_html = self._format_reply_info(message)
if text_html or poll_html:
content_body.append(f'<div class="post">')
if forward_html: content_body.append(forward_html) # Forward info
if reply_html: content_body.append(reply_html) # Reply info
content_body.append(f'{text_html}')
content_body.append(f'<div class="post">')
if forward_html: content_body.append(forward_html) # Forward info
if reply_html: content_body.append(reply_html) # Reply info
if text_html: content_body.append(f'{text_html}')
content_body.append(f'<div class="message-media">')
content_body.append(f'{self._generate_html_media(message)}')
content_body.append(f'</div>')
content_body.append(f'<div class="message-media">')
content_body.append(f'{self._generate_html_media(message)}')
content_body.append(f'</div>')
if poll_html: content_body.append(poll_html) # Poll
if message.forward_origin: content_body.append(f"<br>--- Forwarded post end ---") # Forward info end
content_body.append(f'</div><br>')
if poll_html: content_body.append(poll_html) # Poll
if message.forward_origin: content_body.append(f"<br>--- Forwarded post end ---") # Forward info end
content_body.append(f'</div><br>')
html_body = '\n'.join(content_body)
html_body = self._sanitize_html(html_body)
@@ -635,7 +635,6 @@ class PostParser:
logger.debug(f"Collected media file: {channel_username}/{message.id}/{file_unique_id}")
# Check if document is a PDF file
if (message.media == MessageMediaType.DOCUMENT and
message.document is not None and hasattr(message.document, 'mime_type') and