stash
This commit is contained in:
parent
bc0d06e00d
commit
0445238d19
2 changed files with 11 additions and 5 deletions
|
@ -6,7 +6,7 @@ from urllib.parse import quote as urlencode
|
|||
from core.settings import TELEGRAM_BOT_TOKEN, TELEGRAM_GROUP_CHAT_ID
|
||||
from mail.protocol import send_smtp, make_notification
|
||||
from notifications.models import UserNotificationChannel
|
||||
from notifications.templates import render_notification_new_ticket, render_notification_reply_ticket
|
||||
from notifications.templates import render_notification_new_ticket_async, render_notification_reply_ticket_async
|
||||
from tickets.models import IssueThread
|
||||
|
||||
|
||||
|
@ -64,7 +64,8 @@ class NotificationDispatcher:
|
|||
print("Error: Invalid message format")
|
||||
|
||||
async def dispatch(self, ticket, event_id, new):
|
||||
message = render_notification_new_ticket(ticket) if new else await render_notification_reply_ticket(ticket)
|
||||
message = await render_notification_new_ticket_async(
|
||||
ticket) if new else await render_notification_reply_ticket_async(ticket)
|
||||
print("Dispatching message:", message, "with event_id:", event_id)
|
||||
targets = await self.get_notification_targets()
|
||||
# await telegram_notify(message, TELEGRAM_GROUP_CHAT_ID)
|
||||
|
|
|
@ -37,22 +37,27 @@ def render_template(template, **kwargs):
|
|||
return None
|
||||
|
||||
|
||||
@database_sync_to_async
|
||||
def render_auto_reply(ticket):
|
||||
eventslug = ticket.event.slug if ticket.event else "37C3" # TODO 37C3 should not be hardcoded
|
||||
return render_template('auto_reply', ticket_name=ticket.name, ticket_uuid=ticket.short_uuid(),
|
||||
ticket_id=ticket.id, event_slug=eventslug, ticket_url=ticket_url(ticket))
|
||||
|
||||
|
||||
@database_sync_to_async
|
||||
def render_notification_new_ticket(ticket):
|
||||
eventslug = ticket.event.slug if ticket.event else "37C3" # TODO 37C3 should not be hardcoded
|
||||
return render_template('new_issue_notification', ticket_name=ticket.name, ticket_uuid=ticket.short_uuid(),
|
||||
ticket_id=ticket.id, event_slug=eventslug, ticket_url=ticket_url(ticket))
|
||||
|
||||
|
||||
@database_sync_to_async
|
||||
async def render_notification_new_ticket_async(ticket):
|
||||
return await database_sync_to_async(render_notification_new_ticket)(ticket)
|
||||
|
||||
|
||||
def render_notification_reply_ticket(ticket):
|
||||
eventslug = ticket.event.slug if ticket.event else "37C3" # TODO 37C3 should not be hardcoded
|
||||
return render_template('reply_issue_notification', ticket_name=ticket.name, ticket_uuid=ticket.short_uuid(),
|
||||
ticket_id=ticket.id, event_slug=eventslug, ticket_url=ticket_url(ticket))
|
||||
|
||||
|
||||
async def render_notification_reply_ticket_async(ticket):
|
||||
return await database_sync_to_async(render_notification_reply_ticket)(ticket)
|
||||
|
|
Loading…
Reference in a new issue