handle updates without backgroundtasks trial
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
from fastapi import APIRouter, Request, Response, BackgroundTasks
|
from typing import Annotated
|
||||||
|
from fastapi import APIRouter, Request, Response, BackgroundTasks, Depends
|
||||||
from fastapi.datastructures import State
|
from fastapi.datastructures import State
|
||||||
|
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||||
from ..main import QBotApp
|
from ..main import QBotApp
|
||||||
|
|
||||||
|
|
||||||
from ..db import async_session
|
from ..db import async_session, get_db
|
||||||
from aiogram.types import Update
|
from aiogram.types import Update
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
||||||
@@ -14,7 +16,7 @@ router = APIRouter()
|
|||||||
|
|
||||||
@router.post("/webhook")
|
@router.post("/webhook")
|
||||||
async def telegram_webhook(
|
async def telegram_webhook(
|
||||||
# db_session: Annotated[AsyncSession, Depends(get_db)],
|
db_session: Annotated[AsyncSession, Depends(get_db)],
|
||||||
request: Request,
|
request: Request,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
):
|
):
|
||||||
@@ -30,12 +32,21 @@ async def telegram_webhook(
|
|||||||
except Exception:
|
except Exception:
|
||||||
logger.error("Invalid request", exc_info=True)
|
logger.error("Invalid request", exc_info=True)
|
||||||
return Response(status_code=400)
|
return Response(status_code=400)
|
||||||
background_tasks.add_task(
|
|
||||||
feed_bot_update,
|
await app.dp.feed_webhook_update(
|
||||||
app=app,
|
bot=app.bot,
|
||||||
update=update,
|
update=update,
|
||||||
|
db_session=db_session,
|
||||||
|
app=app,
|
||||||
app_state=request.state,
|
app_state=request.state,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# background_tasks.add_task(
|
||||||
|
# feed_bot_update,
|
||||||
|
# app=app,
|
||||||
|
# update=update,
|
||||||
|
# app_state=request.state,
|
||||||
|
# )
|
||||||
return Response(status_code=200)
|
return Response(status_code=200)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user