From 0bcfbedfd20ee552190df0fa08d34414486fcc7e Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Tue, 28 Jun 2022 20:32:23 +0200 Subject: [PATCH 1/3] feat(api): api-v1 fixed search live sessions --- ee/api/routers/subs/v1_api_ee.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/api/routers/subs/v1_api_ee.py b/ee/api/routers/subs/v1_api_ee.py index 05f732974..b402cc051 100644 --- a/ee/api/routers/subs/v1_api_ee.py +++ b/ee/api/routers/subs/v1_api_ee.py @@ -25,7 +25,7 @@ def get_sessions_live(projectKey: str, userId: str = None, context: schemas.Curr @app_apikey.post('/v1/{projectKey}/assist/sessions', tags=["api"]) -def sessions_live(projectKey: int, data: schemas.LiveSessionsSearchPayloadSchema = Body(...), +def sessions_live(projectKey: str, data: schemas.LiveSessionsSearchPayloadSchema = Body(...), context: schemas.CurrentContext = Depends(OR_context)): return core.sessions_live(projectId=projects.get_internal_project_id(projectKey), data=data, context=context) From 4b0f3e1ffc3c26c1e69358f573dc99d7f33a0099 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Tue, 28 Jun 2022 20:34:47 +0200 Subject: [PATCH 2/3] feat(api): api-v1 handle wrong projectKey --- ee/api/routers/subs/v1_api_ee.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ee/api/routers/subs/v1_api_ee.py b/ee/api/routers/subs/v1_api_ee.py index b402cc051..a4706ff5a 100644 --- a/ee/api/routers/subs/v1_api_ee.py +++ b/ee/api/routers/subs/v1_api_ee.py @@ -20,12 +20,16 @@ def get_assist_credentials(): @app_apikey.get('/v1/{projectKey}/assist/sessions', tags=["api"]) def get_sessions_live(projectKey: str, userId: str = None, context: schemas.CurrentContext = Depends(OR_context)): - return core.get_sessions_live(projectId=projects.get_internal_project_id(projectKey), - userId=userId, context=context) + projectId = projects.get_internal_project_id(projectKey) + if projectId is None: + return {"errors": ["invalid projectKey"]} + return core.get_sessions_live(projectId=projectId, userId=userId, context=context) @app_apikey.post('/v1/{projectKey}/assist/sessions', tags=["api"]) def sessions_live(projectKey: str, data: schemas.LiveSessionsSearchPayloadSchema = Body(...), context: schemas.CurrentContext = Depends(OR_context)): - return core.sessions_live(projectId=projects.get_internal_project_id(projectKey), - data=data, context=context) + projectId = projects.get_internal_project_id(projectKey) + if projectId is None: + return {"errors": ["invalid projectKey"]} + return core.sessions_live(projectId=projectId, data=data, context=context) From 6b292a3ae719aba2b016a63acc9c06d0e040b069 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Tue, 28 Jun 2022 20:43:00 +0200 Subject: [PATCH 3/3] feat(api): fixed assist error response --- api/chalicelib/core/assist.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/chalicelib/core/assist.py b/api/chalicelib/core/assist.py index 090a13d42..efbc7b5c6 100644 --- a/api/chalicelib/core/assist.py +++ b/api/chalicelib/core/assist.py @@ -49,11 +49,11 @@ def __get_live_sessions_ws(project_id, data): if connected_peers.status_code != 200: print("!! issue with the peer-server") print(connected_peers.text) - return [] + return {"total": 0, "sessions": []} live_peers = connected_peers.json().get("data", []) except requests.exceptions.Timeout: print("Timeout getting Assist response") - live_peers = [] + live_peers = {"total": 0, "sessions": []} except Exception as e: print("issue getting Live-Assist response") print(str(e)) @@ -62,7 +62,7 @@ def __get_live_sessions_ws(project_id, data): print(connected_peers.text) except: print("couldn't get response") - live_peers = [] + live_peers = {"total": 0, "sessions": []} _live_peers = live_peers if "sessions" in live_peers: _live_peers = live_peers["sessions"]