|
@@ -363,6 +363,28 @@ async def amiPJSIPShowAors():
|
|
|
app.logger.warning('AorsList: {}'.format(','.join(aors.keys())))
|
|
app.logger.warning('AorsList: {}'.format(','.join(aors.keys())))
|
|
|
return successReply(aors)
|
|
return successReply(aors)
|
|
|
|
|
|
|
|
|
|
+async def amiUserEvent(name, data):
|
|
|
|
|
+ '''AMI UserEvent
|
|
|
|
|
+ Generates AMI Event using AMI action UserEvent with name and data supplied.
|
|
|
|
|
+
|
|
|
|
|
+ Parameters:
|
|
|
|
|
+ name (string): UserEvent name
|
|
|
|
|
+ data (dict): UserEvent data
|
|
|
|
|
+
|
|
|
|
|
+ Returns:
|
|
|
|
|
+ string: None if UserEvent was successfull, error message overwise
|
|
|
|
|
+ '''
|
|
|
|
|
+ reply = await manager.send_action({**{'Action': 'UserEvent',
|
|
|
|
|
+ 'UserEvent': name},
|
|
|
|
|
+ **data})
|
|
|
|
|
+ app.logger.warning('UserEvent({})'.format(name))
|
|
|
|
|
+ if isinstance(reply, Message):
|
|
|
|
|
+ if reply.success:
|
|
|
|
|
+ return None
|
|
|
|
|
+ else:
|
|
|
|
|
+ return reply.message
|
|
|
|
|
+ return 'AMI error'
|
|
|
|
|
+
|
|
|
async def amiSetVar(variable, value):
|
|
async def amiSetVar(variable, value):
|
|
|
'''AMI SetVar
|
|
'''AMI SetVar
|
|
|
Sets variable using AMI action SetVar to value in background.
|
|
Sets variable using AMI action SetVar to value in background.
|
|
@@ -986,6 +1008,7 @@ class UserDeviceBind(Resource):
|
|
|
return bindError(user, device)
|
|
return bindError(user, device)
|
|
|
app.cache['usermap'][device] = user
|
|
app.cache['usermap'][device] = user
|
|
|
app.cache['devicemap'][user] = device
|
|
app.cache['devicemap'][user] = device
|
|
|
|
|
+ await amiUserEvent('DeviceBound',{'device': device, 'newUser': user, 'oldUser': currentUser})
|
|
|
return successfullyBound(user, device)
|
|
return successfullyBound(user, device)
|
|
|
|
|
|
|
|
@app.route('/device/<device>/off')
|
|
@app.route('/device/<device>/off')
|
|
@@ -1017,6 +1040,7 @@ class DeviceUnBind(Resource):
|
|
|
await setDeviceUser(device, 'none') # Unbind user from device
|
|
await setDeviceUser(device, 'none') # Unbind user from device
|
|
|
del app.cache['usermap'][device]
|
|
del app.cache['usermap'][device]
|
|
|
del app.cache['devicemap'][currentUser]
|
|
del app.cache['devicemap'][currentUser]
|
|
|
|
|
+ await amiUserEvent('DeviceUnbound',{'device': device, 'oldUser': currentUser})
|
|
|
return successfullyUnbound(currentUser, device)
|
|
return successfullyUnbound(currentUser, device)
|
|
|
|
|
|
|
|
@app.route('/cdr')
|
|
@app.route('/cdr')
|