mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
fix empty response into webhook (#1665)
This commit is contained in:
parent
02683b8c37
commit
870d97c783
3 changed files with 36 additions and 11 deletions
|
|
@ -4,7 +4,7 @@ from abc import ABC, abstractmethod
|
|||
from asyncio import Transport
|
||||
from typing import Any, Awaitable, Callable, Dict, Optional, Set, Tuple, cast
|
||||
|
||||
from aiohttp import MultipartWriter, web
|
||||
from aiohttp import JsonPayload, MultipartWriter, Payload, web
|
||||
from aiohttp.abc import Application
|
||||
from aiohttp.typedefs import Handler
|
||||
from aiohttp.web_middlewares import middleware
|
||||
|
|
@ -151,13 +151,17 @@ class BaseRequestHandler(ABC):
|
|||
|
||||
def _build_response_writer(
|
||||
self, bot: Bot, result: Optional[TelegramMethod[TelegramType]]
|
||||
) -> MultipartWriter:
|
||||
) -> Payload:
|
||||
if not result:
|
||||
# we need to return something "empty"
|
||||
# and "empty" form doesn't work
|
||||
# since it's sending only "end" boundary w/o "start"
|
||||
return JsonPayload({})
|
||||
|
||||
writer = MultipartWriter(
|
||||
"form-data",
|
||||
boundary=f"webhookBoundary{secrets.token_urlsafe(16)}",
|
||||
)
|
||||
if not result:
|
||||
return writer
|
||||
|
||||
payload = writer.append(result.__api_method__)
|
||||
payload.set_content_disposition("form-data", name="method")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue