Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Greenlight v3 recording ready url #125

Merged
merged 3 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# ChangeLog

## 3.2.0 - 2024-05-16

Changes:
- add new BBB 2.6 API parameters
- preUploadedPresentation
- preUploadedPresentationName
- errorRedirectUrl
- userdata-bbb_fullaudio_bridge
- refactor Parameter model
- added python dependencies:
- pyjwt: `2.8.0`
- bumped python dependencies:
- Django: `3.2.19` => `3.2.25`
- PyGObject: `3.44.1` => `3.48.2`
- aiohttp: `3.8.4` => `3.9.5`
- boto3: `1.26.163` => `1.34.106`
- celery: `5.3.1` => `5.3.4`
- django-cacheops: `7.0.1` => `7.0.2`
- django-celery-beat: `2.5.0` => `2.6.0`
- django-db-file-storage: `0.5.5` => `0.5.6.1`
- django-environ: `0.10.0` => `0.11.2`
- django-redis: `5.3.0` => `5.4.0`
- django-storages: `1.13.2` => `1.14.3`
- uvicorn[standard]: `0.22.0` => `0.29.0`

Fixes:
- fix record ready callback
- fix value check for empty parameters
- fix errors when a very long meeting name (>500 chars) was given

## 3.1.1 - 2023-09-28

Fixes:
Expand Down
19 changes: 10 additions & 9 deletions b3lb/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# b3lb v3.1 - Delay update to Django 4.x because of dependencies
Django==3.2.23
PyGObject==3.46.0
aiohttp==3.8.6
boto3==1.28.77
Django==3.2.25
PyGObject==3.48.2
aiohttp==3.9.5
boto3==1.34.106
django-extensions==3.2.3
celery==5.3.4
celery==5.4.0
celery-singleton==0.3.1
django-cacheops==7.0.2
django-db-file-storage==0.5.5
django-celery-admin==0.1
django-celery-beat==2.5.0
django-celery-beat==2.6.0
django-celery-results==2.5.1
django-db-file-storage==0.5.6.1
django-environ==0.11.2
django-redis==5.4.0
django-storages==1.14.2
django-storages==1.14.3
intervaltree==3.1.0
pyjwt==2.8.0
psycopg2cffi==2.9.0
requests==2.31.0
uvicorn[standard]==0.23.2
uvicorn[standard]==0.29.0
xmltodict==0.13.0
4 changes: 2 additions & 2 deletions b3lb/rest/classes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from rest.b3lb.metrics import incr_metric, update_create_metrics
from rest.b3lb.parameters import ALLOW_START_STOP_RECORDING, AUTO_START_RECORDING, BLOCK, LOGO, OVERRIDE, PARAMETERS_CREATE, PARAMETERS_JOIN, RECORD, SET, USERDATA_BBB_CUSTOM_STYLE_URL
from rest.b3lb.utils import get_checksum
from rest.models import ClusterGroupRelation, Meeting, Metric, Node, Parameter, Record, RecordSet, Secret, SecretMeetingList, SecretMetricsList, Stats
from rest.models import check_room_name, ClusterGroupRelation, Meeting, Metric, Node, Parameter, Record, RecordSet, Secret, SecretMeetingList, SecretMetricsList, Stats
from typing import Any, Dict, List, Literal, Union
from uuid import UUID
from urllib.parse import urlencode
Expand Down Expand Up @@ -432,7 +432,7 @@ def is_node_free(self) -> bool:

## Getter Routines ##
def get_meeting_defaults(self) -> Dict[str, Any]:
return {"id": self.meeting_id, "secret": self.secret, "node": self.node, "room_name": self.parameters.get("name", "Unknown"), "end_callback_url": self.parameters.get("meta_endCallbackUrl", "")}
return {"id": self.meeting_id, "secret": self.secret, "node": self.node, "room_name": check_room_name(self.parameters.get("name", "Unknown")), "end_callback_url": self.parameters.get("meta_endCallbackUrl", "")}

def get_node_endpoint_url(self) -> str:
parameter_str = ""
Expand Down
12 changes: 11 additions & 1 deletion b3lb/rest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@
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


#
# FUNCTIONS
#
def check_room_name(name: str) -> str:
if len(name) > cst.MEETING_NAME_LENGTH:
return name[:cst.MEETING_NAME_LENGTH]
return name

def get_nonce():
return get_random_string(cst.NONCE_LENGTH, cst.NONCE_CHAR_POOL)

Expand Down Expand Up @@ -418,6 +423,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
Loading