wip draft a mini webhook

This commit is contained in:
lebaudantoine
2024-10-16 10:07:58 +02:00
parent 40d1f01277
commit e271c87a20
2 changed files with 30 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
from rest_framework.decorators import api_view
from rest_framework.response import Response
MINIO_BUCKET = "livekit-staging-livekit-egress"
# todo - discuss retry policy if the webhook fail
@api_view(["POST"])
def minio_webhook(request):
data = request.data
record = data["Records"][0]
s3 = record['s3']
bucket = s3['bucket']
bucket_name = bucket['name']
object = s3['object']
filename = object['key']
if bucket_name != MINIO_BUCKET:
return Response("Not interested in this bucket")
if object['contentType'] != 'audio/ogg':
return Response("Not interested in this file type")
print('file received', filename)
return Response("")
+2 -1
View File
@@ -5,7 +5,7 @@ from django.urls import include, path
from rest_framework.routers import DefaultRouter
from core.api import get_frontend_configuration, viewsets
from core.api import get_frontend_configuration, viewsets, demo
from core.authentication.urls import urlpatterns as oidc_urls
# - Main endpoints
@@ -24,6 +24,7 @@ urlpatterns = [
*router.urls,
*oidc_urls,
path("config/", get_frontend_configuration, name="config"),
path("minio-webhook/", demo.minio_webhook, name="demo"),
]
),
),