Skip to content

Commit

Permalink
api: don't use bloated function for simple checks
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippKilian committed May 29, 2024
1 parent da5bb40 commit c2e52f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 3 additions & 3 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 check_str_length, ClusterGroupRelation, Meeting, Metric, Node, Parameter, Record, RecordSet, Secret, SecretMeetingList, SecretMetricsList, Stats
from rest.models import 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 @@ -116,10 +116,10 @@ async def create(self) -> HttpResponse:
if not self.meeting_id:
return HttpResponse(cst.RETURN_STRING_MISSING_MEETING_ID, content_type=cst.CONTENT_TYPE)

if not check_str_length(self.meeting_id, cst.MEETING_ID_LENGTH):
if not 2 <= len(self.meeting_id) < cst.MEETING_ID_LENGTH:
return HttpResponse(cst.RETURN_STRING_MISSING_MEETING_ID_TO_LONG, content_type=cst.CONTENT_TYPE)

if not check_str_length(self.meeting_name, cst.MEETING_NAME_LENGTH):
if not 2 <= len(self.meeting_name) < cst.MEETING_NAME_LENGTH:
return HttpResponse(cst.RETURN_STRING_WRONG_MEETING_NAME_LENGTH, content_type=cst.CONTENT_TYPE)

if not await self.is_meeting():
Expand Down
3 changes: 0 additions & 3 deletions b3lb/rest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
#
# FUNCTIONS
#
def check_str_length(value: str, max_length: int) -> bool:
return 2 <= len(value) < max_length

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

Expand Down

0 comments on commit c2e52f0

Please sign in to comment.