]> git.parisson.com Git - teleforma.git/commitdiff
add specific channel communication layer through socket
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 19 Jan 2023 13:28:59 +0000 (14:28 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 19 Jan 2023 13:28:59 +0000 (14:28 +0100)
teleforma/models/core.py

index c9b9fbba340f02b797780e6ca0798951f8ac64e8..72a382d36624e5bcfe3f34d959a3bdc474e5a91f 100755 (executable)
@@ -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)