|
@@ -208,22 +208,37 @@ async def newchannelCallback(mngr: Manager, msg: Message):
|
|
|
'callId': uid}
|
|
'callId': uid}
|
|
|
if (msg.linkedid in app.cache['cel_calls']) and ('WebCallId' in app.cache['cel_calls'][msg.linkedid]):
|
|
if (msg.linkedid in app.cache['cel_calls']) and ('WebCallId' in app.cache['cel_calls'][msg.linkedid]):
|
|
|
_cb['WebCallId'] = app.cache['cel_calls'][msg.linkedid]['WebCallId']
|
|
_cb['WebCallId'] = app.cache['cel_calls'][msg.linkedid]['WebCallId']
|
|
|
- reply = await doCallback(device, _cb)
|
|
|
|
|
|
|
+ #reply = await doCallback(device, _cb)
|
|
|
|
|
|
|
|
@manager.register_event('CEL')
|
|
@manager.register_event('CEL')
|
|
|
async def celCallback(mngr: Manager, msg: Message):
|
|
async def celCallback(mngr: Manager, msg: Message):
|
|
|
- #app.logger.warning('CEL {}'.format(msg))
|
|
|
|
|
|
|
+ app.logger.warning('CEL {}'.format(msg))
|
|
|
lid = msg.LinkedID
|
|
lid = msg.LinkedID
|
|
|
if ((msg.EventName == 'CHAN_START') and (lid == msg.UniqueID)): #save first msg
|
|
if ((msg.EventName == 'CHAN_START') and (lid == msg.UniqueID)): #save first msg
|
|
|
app.cache['cel_calls'][lid] = msg
|
|
app.cache['cel_calls'][lid] = msg
|
|
|
app.cache['cel_calls'][lid]['current_channels'] = {}
|
|
app.cache['cel_calls'][lid]['current_channels'] = {}
|
|
|
app.cache['cel_calls'][lid]['all_channels'] = {}
|
|
app.cache['cel_calls'][lid]['all_channels'] = {}
|
|
|
|
|
+
|
|
|
if (lid in app.cache['cel_calls']):
|
|
if (lid in app.cache['cel_calls']):
|
|
|
firstMessage = app.cache['cel_calls'][lid]
|
|
firstMessage = app.cache['cel_calls'][lid]
|
|
|
cid = firstMessage.CallerIDnum
|
|
cid = firstMessage.CallerIDnum
|
|
|
if firstMessage.CallerIDnum in app.cache['usermap']:
|
|
if firstMessage.CallerIDnum in app.cache['usermap']:
|
|
|
cid = app.cache['usermap'][firstMessage.CallerIDnum]
|
|
cid = app.cache['usermap'][firstMessage.CallerIDnum]
|
|
|
uid = firstMessage.LinkedID
|
|
uid = firstMessage.LinkedID
|
|
|
|
|
+ if (msg.EventName == 'CHAN_START') and (lid != msg.UniqueID) and (not msg.Channel.startswith('Local/')):
|
|
|
|
|
+ if (firstMessage.Context == 'from-pstn') or (firstMessage.get('groupCall',False)):
|
|
|
|
|
+ device = msg.CallerIDnum
|
|
|
|
|
+ user = app.cache['usermap'][device]
|
|
|
|
|
+ did = firstMessage.Exten
|
|
|
|
|
+ _cb = {'user': user,
|
|
|
|
|
+ 'device': device,
|
|
|
|
|
+ 'state': 'ringing',
|
|
|
|
|
+ 'callerId': cid,
|
|
|
|
|
+ 'did': did,
|
|
|
|
|
+ 'callId': uid}
|
|
|
|
|
+ if ('WebCallId' in app.cache['cel_calls'][msg.linkedid]):
|
|
|
|
|
+ _cb['WebCallId'] = app.cache['cel_calls'][msg.linkedid]['WebCallId']
|
|
|
|
|
+ reply = await doCallback('device', _cb)
|
|
|
if ((msg.Application == 'Queue') and
|
|
if ((msg.Application == 'Queue') and
|
|
|
(msg.EventName == 'APP_START') and
|
|
(msg.EventName == 'APP_START') and
|
|
|
(firstMessage.Context == 'from-internal') and
|
|
(firstMessage.Context == 'from-internal') and
|
|
@@ -857,14 +872,14 @@ async def rebindLostDevices():
|
|
|
|
|
|
|
|
async def userStateChangeCallback(user, state, prevState = None):
|
|
async def userStateChangeCallback(user, state, prevState = None):
|
|
|
reply = None
|
|
reply = None
|
|
|
|
|
+ device = None
|
|
|
if ('HTTP_CLIENT' in app.config) and (user in app.cache['devicemap']):
|
|
if ('HTTP_CLIENT' in app.config) and (user in app.cache['devicemap']):
|
|
|
- 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,
|
|
|
|
|
- 'state': state,
|
|
|
|
|
- 'prev_state':prevState})
|
|
|
|
|
|
|
+ device = app.cache['devicemap'][user]
|
|
|
|
|
+ if device is not None:
|
|
|
|
|
+ _cb = {'user': user,
|
|
|
|
|
+ 'state': state,
|
|
|
|
|
+ 'prev_state':prevState}
|
|
|
|
|
+ reply = await doCallback(device, _cb)
|
|
|
|
|
|
|
|
app.logger.warning('{} changed state to: {}'.format(user, state))
|
|
app.logger.warning('{} changed state to: {}'.format(user, state))
|
|
|
return reply
|
|
return reply
|