Merge pull request #14 from machka-pasla/dev

Move tribute webhook route to service
This commit is contained in:
Machka Pasla
2025-06-24 19:18:34 +03:00
committed by GitHub
4 changed files with 10 additions and 12 deletions
View File
-9
View File
@@ -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)
+2 -3
View File
@@ -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}")
+8
View File
@@ -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)