Skip to content

Commit

Permalink
Add hide all chats endpoint (#3423)
Browse files Browse the repository at this point in the history
  • Loading branch information
olliestanley committed Jun 14, 2023
1 parent 463d729 commit 023b89a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions inference/server/oasst_inference_server/routes/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,15 @@ async def handle_update_chat(
except Exception:
logger.exception("Error when updating chat")
return fastapi.Response(status_code=500)


@router.put("/hide_all")
async def handle_hide_all_chats(
ucr: deps.UserChatRepository = fastapi.Depends(deps.create_user_chat_repository),
) -> fastapi.Response:
"""Allows the client to hide all the user's chats."""
try:
await ucr.hide_all_chats()
except Exception:
logger.exception("Error when hiding chats")
return fastapi.Response(status_code=500)
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,9 @@ async def update_chat(
chat.active_thread_tail_message_id = active_thread_tail_message_id

await self.session.commit()

async def hide_all_chats(self) -> None:
chats = await self.get_chats(include_hidden=False)
for chat in chats:
chat.hidden = True
await self.session.commit()

0 comments on commit 023b89a

Please sign in to comment.