From 2a4a2a285ca95431892d016ff0988f5e1032f13c Mon Sep 17 00:00:00 2001
From: Mikhail Sennikov <mifls@yandex.ru>
Date: Thu, 25 Jan 2024 19:53:38 +0300
Subject: [PATCH] Fix Depends

---
 Backend/proxy_switch/swarm_switch.py | 16 +++++++++-------
 database/api/cam_groups.py           |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/Backend/proxy_switch/swarm_switch.py b/Backend/proxy_switch/swarm_switch.py
index 496304b..0b45118 100644
--- a/Backend/proxy_switch/swarm_switch.py
+++ b/Backend/proxy_switch/swarm_switch.py
@@ -1,4 +1,4 @@
-from fastapi import APIRouter, Response, HTTPException, status
+from fastapi import APIRouter, Response, HTTPException, status, Depends
 
 from node.swarm import NodeSwarm
 from database.schemas.cam_groups import GroupFull
@@ -8,18 +8,20 @@ swarm = NodeSwarm()
 
 
 @switch_router.post("/set_group_id/{group_id}", response_model=GroupFull)
-async def set_group(
-        group_id: int
+async def set_group_id(
+        group_id: int,
+        set_group_by_id=Depends(swarm.set_group_by_id)
 ):
-    group = await swarm.set_group_by_id(group_id)
+    group = await set_group_by_id(group_id)
     return group
 
 
 @switch_router.post("/set_group_slug/{group_slug}", response_model=GroupFull)
-async def set_group(
-        group_slug: str
+async def set_group_slug(
+        group_slug: str,
+        set_group_by_slug=Depends(swarm.set_group_by_slug)
 ):
-    group = await swarm.set_group_by_slug(group_slug)
+    group = await set_group_by_slug(group_slug)
     return group
 
 
diff --git a/database/api/cam_groups.py b/database/api/cam_groups.py
index 9a5c325..2c3b1de 100644
--- a/database/api/cam_groups.py
+++ b/database/api/cam_groups.py
@@ -107,7 +107,7 @@ async def list_user_groups(
 
 
 @db_cam_groups_router.post("/user/{user_id}", response_model=GroupFull, tags=["Users"])
-async def add_cam_group(
+async def add_user_group(
         user_id: int,
         group_id: int,
         user_repo: UserRepository = Depends(db.get_repository(UserRepository)),
-- 
GitLab