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

fix missing POST headers if an asset is sent #127

Merged
merged 1 commit into from
May 23, 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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# ChangeLog

## 3.2.2 - 2024-05-23

Fixes:
- fix missing specific POST Header when an asset is sent

## 3.2.1 - 2024-05-21

Changes:
- adjust to BBB 2.7.8 API changes
- forbid POST request for `join` endpoint ()
- adjustments for POST headers are already handled
- adjustments for POST headers are already handled
- meeting name check:
- add check for meeting name length for faster response without sending a request to backend systems
- meeting name length must be between 2 and 256 characters as given by BBB API restrictions
Expand Down
17 changes: 16 additions & 1 deletion b3lb/rest/classes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,22 @@ class ClientB3lbRequest:
node: Union[Node, None]
secret: Union[Secret, None]
state: str
has_assets: bool
ENDPOINTS_PASS_THROUGH: List[str]
ENDPOINTS: Dict[str, Any]

#### Class functions
async def _check_post_headers(self) -> Dict[str, Any]:
if not self.has_assets:
# request wasn't manipulated by B3LB
return self.request.headers

# An asset was added by B3LB
headers = dict(self.request.headers.copy())
headers["Content-Type"] = "application/xml"
headers["Content-Length"] = str(len(self.body))
return headers

#### Asynchronous BBB Endpoints
async def create(self) -> HttpResponse:
"""
Expand Down Expand Up @@ -234,7 +247,7 @@ async def pass_through(self) -> HttpResponse:
await self.set_node_by_meeting_id()
async with ClientSession() as session:
if self.request.method == "POST":
async with session.post(await sync_to_async(self.get_node_endpoint_url_encoded)(), data=self.body) as res:
async with session.post(await sync_to_async(self.get_node_endpoint_url_encoded)(), data=self.body, headers=await self._check_post_headers()) as res:
return HttpResponse(await res.text(), status=res.status, content_type=res.headers.get('content-type', cst.CONTENT_TYPE))
else:
async with session.get(await sync_to_async(self.get_node_endpoint_url_encoded)()) as res:
Expand Down Expand Up @@ -367,6 +380,7 @@ def check_parameters(self, meeting: Meeting = None, created: bool = False):
else:
self.body = f'<modules><module name="presentation"><document url="{self.secret.tenant.asset.slide_url}" filename="{self.secret.tenant.asset.s_filename}"></document></module></modules>'
self.request.method = "POST"
self.has_assets = True

# check if records are enabled
if self.secret.is_record_enabled:
Expand Down Expand Up @@ -528,6 +542,7 @@ async def set_secret_by_slug_and_slug_id(self, slug: str, sub_id: int):

## INIT ##
def __init__(self, request: HttpRequest, endpoint: str):
self.has_assets = False
self.request = request
self.endpoint = endpoint
self.parameters = {}
Expand Down
Loading