From 3bd56100118e5d11541ec0281ccf7ebdcbd62f6e Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 19 Jan 2023 14:28:59 +0100 Subject: [PATCH] add specific channel communication layer through socket --- teleforma/models/core.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/teleforma/models/core.py b/teleforma/models/core.py index c9b9fbba..72a382d3 100755 --- a/teleforma/models/core.py +++ b/teleforma/models/core.py @@ -459,7 +459,14 @@ class Conference(models.Model): # Notify live conferences by sending a signal to websocket. # This signal will be catched by the channel instance to notify students from teleforma.models.notification import notify - requests.post(f"{settings.CHANNEL_URL}{reverse('teleforma-live-conference-notify')}", {'id': self.id}) + if settings.DEBUG: + requests.post(f"{settings.CHANNEL_URL}{reverse('teleforma-live-conference-notify')}", {'id': self.id}) + else: + transport = httpx.HTTPTransport(uds=settings.CHANNEL_URL) + client = httpx.Client(transport=transport) + response = client.post(f"{reverse('teleforma-live-conference-notify')}", + {'id': self.id}) + assert response.status_code == 200 self.notified_live = True super(Conference, self).save(*args, **kwargs) -- 2.39.5