iamfebin's picture
feat: rename companion to Auri, remove typewriter sound, add JRPG dialogue box, async AI fallback, and unit tests
664a5eb
Raw History Blame Contribute Delete
860 Bytes
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)