This commit is contained in:
j3d1 2024-04-26 00:18:04 +02:00
parent 6d07b3eefc
commit c1e7a8910d

View file

@ -249,13 +249,13 @@ Your c3lf (Cloakroom + Lost&Found) Team'''.format(active_issue_thread.short_uuid
active_issue_thread.state = 'pending_open' active_issue_thread.state = 'pending_open'
active_issue_thread.save() active_issue_thread.save()
notifcation = None notification = None
if new: if new:
notifcation = f"New issue {active_issue_thread.short_uuid()} created by {sender}" notification = f"New issue {active_issue_thread.short_uuid()} created by {sender}"
else: else:
notifcation = f"Reply to issue {active_issue_thread.short_uuid()} by {sender}" notification = f"Reply to issue {active_issue_thread.short_uuid()} by {sender}"
return email, new, reply, notifcation return email, new, reply, notification
class LMTPHandler: class LMTPHandler:
@ -277,7 +277,7 @@ class LMTPHandler:
content = None content = None
try: try:
content = envelope.content content = envelope.content
email, new, reply = await receive_email(envelope, log) email, new, reply, notification = await database_sync_to_async(receive_email)(envelope, log)
log.info(f"Created email {email.id}") log.info(f"Created email {email.id}")
systemevent = await database_sync_to_async(SystemEvent.objects.create)(type='email received', systemevent = await database_sync_to_async(SystemEvent.objects.create)(type='email received',
reference=email.id) reference=email.id)
@ -287,10 +287,11 @@ class LMTPHandler:
'general', {"type": "generic.event", "name": "send_message_to_frontend", "event_id": systemevent.id, 'general', {"type": "generic.event", "name": "send_message_to_frontend", "event_id": systemevent.id,
"message": "email received"}) "message": "email received"})
log.info(f"Sent message to frontend") log.info(f"Sent message to frontend")
if notifcation: if notification:
log.info(f"Sending notification {notification}")
await channel_layer.group_send( await channel_layer.group_send(
'general', {"type": "generic.event", "name": "user_notification", "event_id": systemevent.id, 'general', {"type": "generic.event", "name": "user_notification", "event_id": systemevent.id,
"message": notifcation}) "message": notification})
if new and reply: if new and reply:
log.info('Sending message to %s' % reply['To']) log.info('Sending message to %s' % reply['To'])
await send_smtp(reply) await send_smtp(reply)