Skip to content

Commit

Permalink
recording: fix record ready callback
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippKilian committed May 16, 2024
1 parent f1a6a5c commit 0c5ab94
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 21 deletions.
1 change: 1 addition & 0 deletions b3lb/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ django-environ==0.11.2
django-redis==5.4.0
django-storages==1.14.2
intervaltree==3.1.0
pyjwt==2.8.0
psycopg2cffi==2.9.0
requests==2.31.0
uvicorn[standard]==0.23.2
Expand Down
7 changes: 6 additions & 1 deletion b3lb/rest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from rest.classes.storage import DBStorage
from storages.backends.s3 import ClientError, S3Storage
from textwrap import wrap
from typing import Any, Dict
from typing import Any, Dict, List
import rest.b3lb.constants as cst
import uuid as uid

Expand Down Expand Up @@ -418,6 +418,11 @@ def records_effective_hold_time(self) -> int:
else:
return min(self.records_hold_time, self.tenant.records_hold_time)

@property
def secrets(self) -> List[str]:
# returns all secrets for secret rollover use-cases
return [self.secret, self.secret2]


class SecretAdmin(admin.ModelAdmin):
model = Secret
Expand Down
30 changes: 21 additions & 9 deletions b3lb/rest/task/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
from django.utils import timezone as tz
from django.conf import settings
from os import makedirs, path
from requests import get
from jwt import encode as jwt_encode
from requests import post
if settings.B3LB_RENDERING:
from rest.b3lb.make_xges import render_xges
from rest.models import Record, RecordSet, RecordProfile, SecretRecordProfileRelation
from subprocess import DEVNULL, PIPE, Popen
from tempfile import TemporaryDirectory


def render_by_profile(record_set: RecordSet, record_profile: RecordProfile, tempdir: str):
def render_by_profile(record_set: RecordSet, record_profile: RecordProfile, tempdir: str) -> str:
"""
Render RecordSet with given RecordProfile in tempdir with
Expand Down Expand Up @@ -59,6 +60,7 @@ def render_by_profile(record_set: RecordSet, record_profile: RecordProfile, temp
record.published = True
record.save()
print(f"Finished rendering {record_set.__str__()} with profile {record_profile.name}")
return str(record.uuid)


def render_record(record_set: RecordSet):
Expand All @@ -79,18 +81,28 @@ def render_record(record_set: RecordSet):
profile_relations = SecretRecordProfileRelation.objects.filter(secret=record_set.secret)
if profile_relations.count() > 0:
for profile_relation in profile_relations:
render_by_profile(record_set, profile_relation.record_profile, tempdir)
record_id = render_by_profile(record_set, profile_relation.record_profile, tempdir)
else:
for record_profile in RecordProfile.objects.filter(is_default=True):
render_by_profile(record_set, record_profile, tempdir)
record_id = render_by_profile(record_set, record_profile, tempdir)

# implementation of recording ready callback url
# https://docs.bigbluebutton.org/development/api/#recording-ready-callback-url
if record_set.recording_ready_origin_url:
success = False
for secret in record_set.secret.secrets:
body = {"signed_parameters": jwt_encode({"meeting_id": record_set.meta_meeting_id, "record_id": record_id}, secret)}
response = post(record_set.recording_ready_origin_url, json=body)
print(f"Send record ready callback to: {record_set.recording_ready_origin_url} with return code: {response.status_code}")
if 200 <= response.status_code <= 299:
success = True
break

if not success:
return False

record_set.status = RecordSet.RENDERED
record_set.save()
if record_set.recording_ready_origin_url:
try:
get(record_set.recording_ready_origin_url)
except:
pass
return True


Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.


FROM alpine:3.17 AS build
FROM alpine:3.19 AS build

RUN apk --no-cache add build-base python3 python3-dev postgresql-dev libffi-dev py3-pip py3-wheel gcc gobject-introspection-dev

ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /usr/local/lib/python3.10/site-packages
ENV PYTHONPATH /usr/local/lib/python3.11/site-packages

WORKDIR /usr/src/app

COPY b3lb/requirements.txt ./
RUN pip3 install --no-cache-dir --prefix=/usr/local -r requirements.txt


FROM alpine:3.17
FROM alpine:3.19

RUN apk --no-cache add python3 postgresql-libs libffi py3-pip tar

ARG B3LBUID=8318
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /usr/local/lib/python3.10/site-packages
ENV PYTHONPATH /usr/local/lib/python3.11/site-packages

WORKDIR /usr/src/app

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.


FROM alpine:3.17 AS build
FROM alpine:3.19 AS build

RUN apk --no-cache add build-base python3 python3-dev postgresql-dev libffi-dev py3-pip py3-wheel tar gcc gobject-introspection-dev

ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /usr/local/lib/python3.10/site-packages
ENV PYTHONPATH /usr/local/lib/python3.11/site-packages
ENV ENV_FILE .env.dev

WORKDIR /usr/src/app
Expand Down
7 changes: 4 additions & 3 deletions docker/Dockerfile.pypy
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.


FROM pypy:3.9-slim AS build
FROM pypy:3.10-slim AS build

RUN apt-get update && apt-get install -y build-essential libpq-dev libcairo2-dev gcc python3-dev libgirepository1.0-dev

ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /usr/local/lib/pypy3.10/site-packages

WORKDIR /usr/src/app

COPY b3lb/requirements.txt ./
RUN pip3 install --no-cache-dir --prefix=/usr/local -r requirements.txt


FROM pypy:3.9-slim
FROM pypy:3.10-slim

RUN apt-get update && apt-get install -y libpq5 tar

ARG B3LBUID=8318
ARG ENV_FILE=.env.dev
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /usr/local/lib/pypy3.9/site-packages
ENV PYTHONPATH /usr/local/lib/pypy3.10/site-packages

WORKDIR /usr/src/app

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.static
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.


FROM alpine:3.17 AS build
FROM alpine:3.19 AS build

RUN apk --no-cache add build-base python3 python3-dev postgresql-dev libffi-dev py3-pip py3-wheel gcc gobject-introspection-dev

ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /usr/local/lib/python3.10/site-packages
ENV PYTHONPATH /usr/local/lib/python3.11/site-packages

WORKDIR /usr/src/app

Expand Down

0 comments on commit 0c5ab94

Please sign in to comment.