From c2e52f0b4028c54c4398e88304e9ffcbaa7e1280 Mon Sep 17 00:00:00 2001 From: Philipp Kilian Date: Wed, 29 May 2024 11:15:14 +0200 Subject: [PATCH] api: don't use bloated function for simple checks --- b3lb/rest/classes/api.py | 6 +++--- b3lb/rest/models.py | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/b3lb/rest/classes/api.py b/b3lb/rest/classes/api.py index a68c317..a495e13 100644 --- a/b3lb/rest/classes/api.py +++ b/b3lb/rest/classes/api.py @@ -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 @@ -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(): diff --git a/b3lb/rest/models.py b/b3lb/rest/models.py index 94ccccf..3cbc92f 100644 --- a/b3lb/rest/models.py +++ b/b3lb/rest/models.py @@ -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)