b7f52be4c9
CI / Run CI (push) Has been cancelled
CI / check-backend (push) Has been cancelled
CI / check-frontend (push) Has been cancelled
CI / tests (push) Has been cancelled
CI / e2e-tests (push) Has been cancelled
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled
20 lines
575 B
Python
20 lines
575 B
Python
from fastapi import HTTPException
|
|
|
|
from chainlit.data import get_data_layer
|
|
|
|
|
|
async def is_thread_author(username: str, thread_id: str):
|
|
data_layer = get_data_layer()
|
|
if not data_layer:
|
|
raise HTTPException(status_code=400, detail="Data layer not initialized")
|
|
|
|
thread_author = await data_layer.get_thread_author(thread_id)
|
|
|
|
if not thread_author:
|
|
raise HTTPException(status_code=404, detail="Thread not found")
|
|
|
|
if thread_author != username:
|
|
raise HTTPException(status_code=401, detail="Unauthorized")
|
|
else:
|
|
return True
|