From 9477e9af862bbb81a247ade7c396c491c0a01072 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sun, 29 Jul 2018 03:12:21 +0300 Subject: [PATCH] Implement Gone request handler --- aiogram/dispatcher/webhook.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/aiogram/dispatcher/webhook.py b/aiogram/dispatcher/webhook.py index ca717202..970fd655 100644 --- a/aiogram/dispatcher/webhook.py +++ b/aiogram/dispatcher/webhook.py @@ -7,6 +7,7 @@ import typing from typing import Dict, List, Optional, Union from aiohttp import web +from aiohttp.web_exceptions import HTTPGone from .. import types from ..bot import api @@ -245,6 +246,19 @@ class WebhookRequestHandler(web.View): context.set_value('TELEGRAM_IP', ip_address) +class GoneRequestHandler(web.View): + """ + If a webhook returns the HTTP error 410 Gone for all requests for more than 23 hours successively, + it can be automatically removed. + """ + + async def get(self): + raise HTTPGone() + + async def post(self): + raise HTTPGone() + + def configure_app(dispatcher, app: web.Application, path=DEFAULT_WEB_PATH): """ You can prepare web.Application for working with webhook handler.