mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-21 15:33:09 +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
|
||||
)
|
||||
from helpdesk.validators import validate_file_extension
|
||||
from helpdesk.signals import new_ticket_done
|
||||
import logging
|
||||
|
||||
|
||||
@ -418,6 +419,10 @@ class TicketForm(AbstractTicketForm):
|
||||
followup.save()
|
||||
|
||||
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,
|
||||
queue=queue,
|
||||
followup=followup,
|
||||
@ -507,6 +512,10 @@ class PublicTicketForm(AbstractTicketForm):
|
||||
followup.save()
|
||||
|
||||
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,
|
||||
queue=queue,
|
||||
followup=followup,
|
||||
|
@ -644,8 +644,6 @@ class Ticket(models.Model):
|
||||
if self.queue.enable_notifications_on_email_events:
|
||||
for cc in self.ticketcc_set.all():
|
||||
send('ticket_cc', cc.email_address)
|
||||
if "new_ticket_cc" in roles:
|
||||
send_new_ticket_webhook(self)
|
||||
return recipients
|
||||
|
||||
def _get_assigned_to(self):
|
||||
|
@ -1,4 +1,7 @@
|
||||
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()
|
@ -4,7 +4,7 @@ import logging
|
||||
from django.dispatch import receiver
|
||||
|
||||
from . import settings
|
||||
from .signals import update_ticket_done
|
||||
from .signals import new_ticket_done, update_ticket_done
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -32,7 +32,6 @@ def notify_followup_webhooks(followup):
|
||||
except requests.exceptions.Timeout:
|
||||
logger.error('Timeout while sending followup webhook to %s', url)
|
||||
|
||||
|
||||
# listener is loaded via app.py HelpdeskConfig.ready()
|
||||
@receiver(update_ticket_done)
|
||||
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)
|
||||
except requests.exceptions.Timeout:
|
||||
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