This commit is contained in:
j3d1 2024-04-26 15:56:15 +02:00
parent 08bdafae1b
commit 312e9a465a
2 changed files with 10 additions and 5 deletions

View file

@ -57,7 +57,7 @@ class NotificationDispatcher:
for target in targets: for target in targets:
if target.channel_type == 'telegram': if target.channel_type == 'telegram':
await telegram_notify(message, target.channel_target) await telegram_notify(message, target.channel_target)
if target.channel_type == 'mail': elif target.channel_type == 'email':
print("Sending mail to:", target.channel_target) print("Sending mail to:", target.channel_target)
else: else:
print("Unknown channel type:", target.channel_type) print("Unknown channel type:", target.channel_type)

View file

@ -250,10 +250,14 @@ Your c3lf (Cloakroom + Lost&Found) Team'''.format(active_issue_thread.short_uuid
active_issue_thread.save() active_issue_thread.save()
notification = None notification = None
if new: if len(active_issue_thread.name) > 50:
notification = f"New issue {active_issue_thread.short_uuid()} created by {sender}" notify_subject = active_issue_thread.name[:47] + "..."
else: else:
notification = f"Reply to issue {active_issue_thread.short_uuid()} by {sender}" notify_subject = active_issue_thread.name
if new:
notification = f"New issue \"{active_issue_thread.name}\" [{active_issue_thread.short_uuid()}] created by {sender}"
else:
notification = f"Reply to issue \"{active_issue_thread.name}\" [{active_issue_thread.short_uuid()}] by {sender}"
return email, new, reply, notification return email, new, reply, notification
@ -279,7 +283,8 @@ class LMTPHandler:
content = envelope.content content = envelope.content
email, new, reply, notification = await database_sync_to_async(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', reference=email.id) systemevent = await database_sync_to_async(SystemEvent.objects.create)(type='email received',
reference=email.id)
log.info(f"Created system event {systemevent.id}") log.info(f"Created system event {systemevent.id}")
channel_layer = get_channel_layer() channel_layer = get_channel_layer()
await channel_layer.group_send( await channel_layer.group_send(