diff --git a/bot/handlers/webhooks/__init__.py b/bot/handlers/webhooks/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/bot/handlers/webhooks/tribute.py b/bot/handlers/webhooks/tribute.py deleted file mode 100644 index cd4cee4..0000000 --- a/bot/handlers/webhooks/tribute.py +++ /dev/null @@ -1,9 +0,0 @@ -from aiohttp import web -from bot.services.tribute_service import TributeService - - -async def tribute_webhook_route(request: web.Request): - tribute_service: TributeService = request.app['tribute_service'] - raw_body = await request.read() - signature_header = request.headers.get('trbt-signature') - return await tribute_service.handle_webhook(raw_body, signature_header) diff --git a/bot/main_bot.py b/bot/main_bot.py index ba63d3c..a934f3f 100644 --- a/bot/main_bot.py +++ b/bot/main_bot.py @@ -32,10 +32,9 @@ from bot.services.subscription_service import SubscriptionService from bot.services.referral_service import ReferralService from bot.services.promo_code_service import PromoCodeService from bot.services.stars_service import StarsService -from bot.services.tribute_service import TributeService +from bot.services.tribute_service import TributeService, tribute_webhook_route from bot.handlers.user import payment as user_payment_webhook_module -from bot.handlers.webhooks import tribute as tribute_webhook_module class DBSessionMiddleware(BaseMiddleware): @@ -344,7 +343,7 @@ async def run_bot(settings_param: Settings): if tribute_path.startswith('/'): app.router.add_post( tribute_path, - tribute_webhook_module.tribute_webhook_route) + tribute_webhook_route) logging.info( f"Tribute webhook route configured at: [POST] {tribute_path}") diff --git a/bot/services/tribute_service.py b/bot/services/tribute_service.py index c86493f..deb2152 100644 --- a/bot/services/tribute_service.py +++ b/bot/services/tribute_service.py @@ -146,3 +146,11 @@ class TributeService: else: await session.commit() return web.Response(status=200, text="ok") + + +async def tribute_webhook_route(request: web.Request): + """AIOHTTP route handler for Tribute webhook calls.""" + tribute_service: TributeService = request.app['tribute_service'] + raw_body = await request.read() + signature_header = request.headers.get('trbt-signature') + return await tribute_service.handle_webhook(raw_body, signature_header)