Skip to content

Commit

Permalink
Update keys endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
avgupta456 committed Nov 29, 2024
1 parent fe2b595 commit 5b10c99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/src/data/mongo/secret/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ async def get_keys(no_cache: bool = False) -> Tuple[bool, List[str]]:
secret_keys: List[str] = []


async def update_keys() -> None:
async def update_keys(no_cache: bool = False) -> None:
global secret_keys
secret_keys = await get_keys()
secret_keys = await get_keys(no_cache=no_cache)


def get_random_key() -> str:
Expand Down
13 changes: 13 additions & 0 deletions backend/src/routers/users/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@

from fastapi import APIRouter, Response, status

from src.data.mongo.secret import update_keys
from src.data.mongo.user import PublicUserModel, get_public_user as db_get_public_user
from src.utils import async_fail_gracefully

router = APIRouter()


@router.get(
"/update_keys",
status_code=status.HTTP_200_OK,
include_in_schema=False,
response_model=Dict[str, Any],
)
@async_fail_gracefully
async def update_keys_endpoint(response: Response) -> bool:
await update_keys(no_cache=True)
return True


@router.get(
"/get/metadata/{user_id}",
status_code=status.HTTP_200_OK,
Expand Down

0 comments on commit 5b10c99

Please sign in to comment.