Skip to content

Commit f1c51fd

Browse files
committed
[FIX] AMI events not send webhook
1 parent 03d36a9 commit f1c51fd

4 files changed

Lines changed: 14 additions & 13 deletions

File tree

const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "1.0.6"
1+
VERSION = "1.0.7"

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ fastapi==0.111.0
66
panoramisk==1.4
77
pydantic==2.7.1
88
pydantic_settings==2.2.1
9+
# for ami
10+
requests==2.32.3
911
websockets==12.0
1012
# asterisk-ami==0.1.7

services/ami.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import logging
55
import posixpath
66

7-
import httpx
7+
import requests
88
from panoramisk import Manager
99

1010
from schemas.config_schema import AmiConfig
@@ -68,7 +68,7 @@ def on_connect(self, mngr):
6868
async def on_shutdown(self, mngr):
6969
log.info("AMI shutdown...")
7070

71-
async def send_webhook_event(self, manager, payload: dict):
71+
def send_webhook_event(self, manager, payload: dict):
7272
"""send asterisk ami event to customer webhook url
7373
7474
Arguments:
@@ -77,14 +77,13 @@ async def send_webhook_event(self, manager, payload: dict):
7777
try:
7878
log.info("AMI event:")
7979
log.info(payload)
80-
async with httpx.AsyncClient() as client:
81-
res = await client.post(
82-
posixpath.join(self.webhook_url, "ami"),
83-
json=payload,
84-
headers={
85-
"Authorization": f"Basic {self.api_key_base64}",
86-
},
87-
)
88-
res.raise_for_status()
80+
res = requests.post(
81+
posixpath.join(self.webhook_url, "ami"),
82+
json=dict(payload),
83+
headers={
84+
"Authorization": f"Basic {self.api_key_base64}",
85+
},
86+
)
87+
res.raise_for_status()
8988
except Exception as exc:
9089
log.exception("Unknown AMI send_webhook_event error: %s", exc)

services/websocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(
4747
self.api_key_base64 = api_key_base64
4848

4949
self.websocket_url = (
50-
f"{websocket_url}?api_key={api_key}&app=AsteriskAgentPython&subscribeAll=true"
50+
f"{websocket_url}?api_key={api_key}&app=AsteriskAgentPythonDev&subscribeAll=true"
5151
)
5252
self.webhook_url = webhook_url
5353
self.timeout = timeout

0 commit comments

Comments
 (0)