Spaces:
Running
Running
File size: 860 Bytes
664a5eb 8800c81 664a5eb 8800c81 664a5eb 8800c81 664a5eb 8800c81 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import asyncio
from fastapi import APIRouter, Depends, HTTPException
import db
import gdrive_sync
from core.auth import Client, get_auth_session
router = APIRouter(tags=["sync"])
@router.post("/api/sync")
async def trigger_sync(client: Client = Depends(get_auth_session)):
user_id = db.get_current_user_id(client)
if user_id == "sandbox-user-id":
return {
"message": "Google Drive Sync is not available in Sandbox Mode. Please log in to sync your notes."
}
try:
res = await asyncio.to_thread(gdrive_sync.sync_gdrive, client)
return {"message": res}
except Exception as e:
import traceback
err_msg = f"Sync endpoint exception: {str(e)}\n{traceback.format_exc()}"
await asyncio.to_thread(db.log_trace, err_msg)
raise HTTPException(status_code=500, detail=err_msg)
|