mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-21 23:43:11 +01:00
Attach send_new_ticket_webhook to the new_ticket_done signal
This commit is contained in:
parent
c6cad5f702
commit
9a6939b564
@ -36,6 +36,7 @@ from helpdesk.settings import (
|
|||||||
CUSTOMFIELD_TO_FIELD_DICT
|
CUSTOMFIELD_TO_FIELD_DICT
|
||||||
)
|
)
|
||||||
from helpdesk.validators import validate_file_extension
|
from helpdesk.validators import validate_file_extension
|
||||||
|
from helpdesk.signals import new_ticket_done
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
@ -418,6 +419,10 @@ class TicketForm(AbstractTicketForm):
|
|||||||
followup.save()
|
followup.save()
|
||||||
|
|
||||||
files = self._attach_files_to_follow_up(followup)
|
files = self._attach_files_to_follow_up(followup)
|
||||||
|
|
||||||
|
# emit signal when the TicketForm.save is done
|
||||||
|
new_ticket_done.send(sender="TicketForm", ticket=ticket)
|
||||||
|
|
||||||
self._send_messages(ticket=ticket,
|
self._send_messages(ticket=ticket,
|
||||||
queue=queue,
|
queue=queue,
|
||||||
followup=followup,
|
followup=followup,
|
||||||
@ -507,6 +512,10 @@ class PublicTicketForm(AbstractTicketForm):
|
|||||||
followup.save()
|
followup.save()
|
||||||
|
|
||||||
files = self._attach_files_to_follow_up(followup)
|
files = self._attach_files_to_follow_up(followup)
|
||||||
|
|
||||||
|
# emit signal when the PublicTicketForm.save is done
|
||||||
|
new_ticket_done.send(sender="PublicTicketForm", ticket=ticket)
|
||||||
|
|
||||||
self._send_messages(ticket=ticket,
|
self._send_messages(ticket=ticket,
|
||||||
queue=queue,
|
queue=queue,
|
||||||
followup=followup,
|
followup=followup,
|
||||||
|
@ -644,8 +644,6 @@ class Ticket(models.Model):
|
|||||||
if self.queue.enable_notifications_on_email_events:
|
if self.queue.enable_notifications_on_email_events:
|
||||||
for cc in self.ticketcc_set.all():
|
for cc in self.ticketcc_set.all():
|
||||||
send('ticket_cc', cc.email_address)
|
send('ticket_cc', cc.email_address)
|
||||||
if "new_ticket_cc" in roles:
|
|
||||||
send_new_ticket_webhook(self)
|
|
||||||
return recipients
|
return recipients
|
||||||
|
|
||||||
def _get_assigned_to(self):
|
def _get_assigned_to(self):
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import django.dispatch
|
import django.dispatch
|
||||||
|
|
||||||
# create a signal for ticket updates
|
# create a signal for *TicketForm
|
||||||
|
new_ticket_done = django.dispatch.Signal()
|
||||||
|
|
||||||
|
# create a signal for ticket_update view
|
||||||
update_ticket_done = django.dispatch.Signal()
|
update_ticket_done = django.dispatch.Signal()
|
@ -4,7 +4,7 @@ import logging
|
|||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
|
||||||
from . import settings
|
from . import settings
|
||||||
from .signals import update_ticket_done
|
from .signals import new_ticket_done, update_ticket_done
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -32,7 +32,6 @@ def notify_followup_webhooks(followup):
|
|||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
logger.error('Timeout while sending followup webhook to %s', url)
|
logger.error('Timeout while sending followup webhook to %s', url)
|
||||||
|
|
||||||
|
|
||||||
# listener is loaded via app.py HelpdeskConfig.ready()
|
# listener is loaded via app.py HelpdeskConfig.ready()
|
||||||
@receiver(update_ticket_done)
|
@receiver(update_ticket_done)
|
||||||
def notify_followup_webhooks_receiver(sender, followup, **kwargs):
|
def notify_followup_webhooks_receiver(sender, followup, **kwargs):
|
||||||
@ -59,3 +58,8 @@ def send_new_ticket_webhook(ticket):
|
|||||||
requests.post(url, json=data, timeout=settings.HELPDESK_WEBHOOK_TIMEOUT)
|
requests.post(url, json=data, timeout=settings.HELPDESK_WEBHOOK_TIMEOUT)
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
logger.error('Timeout while sending new ticket webhook to %s', url)
|
logger.error('Timeout while sending new ticket webhook to %s', url)
|
||||||
|
|
||||||
|
# listener is loaded via app.py HelpdeskConfig.ready()
|
||||||
|
@receiver(new_ticket_done)
|
||||||
|
def send_new_ticket_webhook_receiver(sender, ticket, **kwargs):
|
||||||
|
send_new_ticket_webhook(ticket)
|
Loading…
Reference in New Issue
Block a user