This commit is contained in:
jedi 2024-05-04 00:47:32 +02:00
parent a7827e53cc
commit 21fddfe631
2 changed files with 5 additions and 6 deletions

View file

@ -164,9 +164,9 @@ def parse_email_body(raw, log=None):
attachments.append(attachment)
if 'inline' in cdispo:
body = body + f'<img src="cid:{attachment.id}">'
log.info("Image", ctype, attachment.id)
log.info("Image %s %s", ctype, attachment.id)
else:
log.info("Attachment", ctype, cdispo)
log.info("Attachment %s %s" % (ctype, cdispo))
else:
if parsed.get_content_type() == 'text/plain':
body = parsed.get_payload()
@ -177,7 +177,7 @@ def parse_email_body(raw, log=None):
soup = BeautifulSoup(body, 'html.parser')
body = re.sub(r'([\r\n]+.?)*[\r\n]', r'\n', soup.get_text()).strip('\n')
else:
log.warning("Unknown content type", parsed.get_content_type())
log.warning("Unknown content type %s", parsed.get_content_type())
body = "Unknown content type"
body = unescape_and_decode_quoted_printable(body)
body = unescape_and_decode_base64(body)

View file

@ -43,8 +43,7 @@ class NotificationDispatcher:
@database_sync_to_async
def get_ticket(self, ticket_id):
return IssueThread.objects.filter(id=ticket_id).select_related('event').prefetch_related('state_changes',
'assignments').first()
return IssueThread.objects.filter(id=ticket_id).select_related('event').first()
async def run_forever(self):
# Infinite loop to continuously listen for messages
@ -68,7 +67,7 @@ class NotificationDispatcher:
message = render_notification_new_ticket(ticket) if new else await render_notification_reply_ticket(ticket)
print("Dispatching message:", message, "with event_id:", event_id)
targets = await self.get_notification_targets()
#await telegram_notify(message, TELEGRAM_GROUP_CHAT_ID)
# await telegram_notify(message, TELEGRAM_GROUP_CHAT_ID)
for target in targets:
if target.channel_type == 'telegram':
print("Sending telegram notification to:", target.channel_target)