Fix typing
This commit is contained in:
parent
a3051d7c33
commit
669b687722
1 changed files with 3 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict, Literal, Optional, cast
|
from typing import Any, Dict, Literal, Optional, Tuple, cast
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
||||||
|
|
@ -77,7 +77,7 @@ def get_destination(bot_settings: BotSettings, routing_key: str) -> Optional[str
|
||||||
return bot_settings.routing_keys.get(routing_key, None)
|
return bot_settings.routing_keys.get(routing_key, None)
|
||||||
|
|
||||||
|
|
||||||
async def receive_helper(request: Request):
|
async def receive_helper(request: Request) -> Tuple[str, Any]:
|
||||||
payload: Any = await request.json()
|
payload: Any = await request.json()
|
||||||
routing_key = request.path_params["routing_key"]
|
routing_key = request.path_params["routing_key"]
|
||||||
room_id = get_destination(request.app.state.bot_settings, routing_key)
|
room_id = get_destination(request.app.state.bot_settings, routing_key)
|
||||||
|
|
@ -88,7 +88,7 @@ async def receive_helper(request: Request):
|
||||||
)
|
)
|
||||||
payload_str = json.dumps(payload, sort_keys=True, indent=2)
|
payload_str = json.dumps(payload, sort_keys=True, indent=2)
|
||||||
logging.info(f"received payload: \n {payload_str}")
|
logging.info(f"received payload: \n {payload_str}")
|
||||||
return payload
|
return room_id, payload
|
||||||
|
|
||||||
|
|
||||||
@app.post("/hook/pagerduty/{routing_key}")
|
@app.post("/hook/pagerduty/{routing_key}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue