|
@@ -165,7 +165,23 @@ async def presenceStatusCallback(mngr: Manager, msg: Message):
|
|
|
|
|
|
|
|
@manager.register_event('Newchannel')
|
|
@manager.register_event('Newchannel')
|
|
|
async def newchannelCallback(mngr: Manager, msg: Message):
|
|
async def newchannelCallback(mngr: Manager, msg: Message):
|
|
|
- app.logger.warning(pformat(msg))
|
|
|
|
|
|
|
+ if (msg.channelstate == '4') and (msg.exten in app.cache['devicemap']) and ('HTTP_CLIENT' in app.config):
|
|
|
|
|
+ user = msg.exten
|
|
|
|
|
+ device = app.cache['devicemap'][user]
|
|
|
|
|
+ if msg.calleridnum in app.cache['usermap']:
|
|
|
|
|
+ cid = app.cache['usermap'][msg.calleridnum]
|
|
|
|
|
+ else:
|
|
|
|
|
+ cid = msg.calleridnum
|
|
|
|
|
+ uid = msg.uniqueid
|
|
|
|
|
+ row = await db.fetch_one(query='SELECT url FROM callback_urls WHERE device = :device',
|
|
|
|
|
+ values={'device': app.cache['devicemap'][user]})
|
|
|
|
|
+ if row is not None:
|
|
|
|
|
+ reply = await app.config['HTTP_CLIENT'].post(row['url'],
|
|
|
|
|
+ json={'user': user,
|
|
|
|
|
+ 'device': device,
|
|
|
|
|
+ 'state': 'ringing',
|
|
|
|
|
+ 'callerId': cid,
|
|
|
|
|
+ 'uniqueId': uid})
|
|
|
|
|
|
|
|
async def getCDR(start=None,
|
|
async def getCDR(start=None,
|
|
|
end=None,
|
|
end=None,
|