|
@@ -701,13 +701,36 @@ class BXfer(Resource):
|
|
|
else:
|
|
else:
|
|
|
return errorReply(reply.message)
|
|
return errorReply(reply.message)
|
|
|
|
|
|
|
|
|
|
+@app.route('/originate/<user>/<number>')
|
|
|
|
|
+class Originate(Resource):
|
|
|
|
|
+ @app.param('user', 'User initiating the call', 'path')
|
|
|
|
|
+ @app.param('number', 'Destination number', 'path')
|
|
|
|
|
+ @app.response(HTTPStatus.OK, 'Json reply')
|
|
|
|
|
+ @app.response(HTTPStatus.UNAUTHORIZED, 'Authorization required')
|
|
|
|
|
+ async def get(self, user, number):
|
|
|
|
|
+ '''Originate call
|
|
|
|
|
+ '''
|
|
|
|
|
+ _r, _data = await amiCommand('channel originate local/1100@from-internal extension 8005551212@outbound-allroutes')
|
|
|
|
|
+ channel = await getUserChannel(user)
|
|
|
|
|
+ if not channel:
|
|
|
|
|
+ return noUserChannel(userA)
|
|
|
|
|
+ reply = await manager.send_action({'Action':'BlindTransfer',
|
|
|
|
|
+ 'Channel':channel,
|
|
|
|
|
+ 'async':'false',
|
|
|
|
|
+ 'Exten':userB})
|
|
|
|
|
+ if isinstance(reply, Message):
|
|
|
|
|
+ if reply.success:
|
|
|
|
|
+ return successfullyTransfered(userA, userB)
|
|
|
|
|
+ else:
|
|
|
|
|
+ return errorReply(reply.message)
|
|
|
|
|
+
|
|
|
@app.route('/hangup/<user>')
|
|
@app.route('/hangup/<user>')
|
|
|
class Hangup(Resource):
|
|
class Hangup(Resource):
|
|
|
@app.param('user', 'User to hangup', 'path')
|
|
@app.param('user', 'User to hangup', 'path')
|
|
|
@app.response(HTTPStatus.OK, 'Json reply')
|
|
@app.response(HTTPStatus.OK, 'Json reply')
|
|
|
@app.response(HTTPStatus.UNAUTHORIZED, 'Authorization required')
|
|
@app.response(HTTPStatus.UNAUTHORIZED, 'Authorization required')
|
|
|
async def get(self, user):
|
|
async def get(self, user):
|
|
|
- '''Blind call transfer
|
|
|
|
|
|
|
+ '''Call hangup
|
|
|
'''
|
|
'''
|
|
|
channel = await getUserChannel(user)
|
|
channel = await getUserChannel(user)
|
|
|
if not channel:
|
|
if not channel:
|
|
@@ -797,7 +820,9 @@ class UsersDevices(Resource):
|
|
|
device = await getUserDevice(user)
|
|
device = await getUserDevice(user)
|
|
|
if ((device in NONEs) or (device == user)):
|
|
if ((device in NONEs) or (device == user)):
|
|
|
device = None
|
|
device = None
|
|
|
- data[user]=device.replace('{}&'.format(user), '')
|
|
|
|
|
|
|
+ else:
|
|
|
|
|
+ device = device.replace('{}&'.format(user), '')
|
|
|
|
|
+ data[user]= device
|
|
|
return successReply(data)
|
|
return successReply(data)
|
|
|
|
|
|
|
|
@app.route('/device/<device>/<user>/on')
|
|
@app.route('/device/<device>/<user>/on')
|