|
|
@@ -1184,11 +1184,44 @@ class Originate(Resource):
|
|
|
device = device.replace('{}&'.format(user), '')
|
|
|
_act = { 'Action':'Originate',
|
|
|
'Channel':'PJSIP/{}'.format(device),
|
|
|
- 'Context':'from-internal',
|
|
|
+ 'Context':'from-internal-c2c',
|
|
|
'Exten':number,
|
|
|
'Priority': '1',
|
|
|
'Async':'true',
|
|
|
- 'Callerid': '{} <{}>'.format(user, user)}
|
|
|
+ 'Callerid': '{} <{}>'.format(user, device)}
|
|
|
+ app.logger.warning(_act)
|
|
|
+ await manager.send_action(_act)
|
|
|
+ return successfullyOriginated(user, number)
|
|
|
+ #reply = await manager.send_action(_act)
|
|
|
+ #if isinstance(reply, Message):
|
|
|
+ # if reply.success:
|
|
|
+ # return successfullyOriginated(user, number)
|
|
|
+ # else:
|
|
|
+ # return errorReply(reply.message)
|
|
|
+
|
|
|
+@app.route('/originate_test/<user>/<number>')
|
|
|
+class Originate_test(Resource):
|
|
|
+ @authRequired
|
|
|
+ @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
|
|
|
+ '''
|
|
|
+ if (user != request.user) and (not request.admin):
|
|
|
+ abort(401)
|
|
|
+ device = await getUserDevice(user)
|
|
|
+ if device in NONEs:
|
|
|
+ return noUserDevice(user)
|
|
|
+ device = device.replace('{}&'.format(user), '')
|
|
|
+ _act = { 'Action':'Originate',
|
|
|
+ 'Channel':'PJSIP/{}'.format(device),
|
|
|
+ 'Context':'form-internal-c2c',
|
|
|
+ 'Exten':number,
|
|
|
+ 'Priority': '1',
|
|
|
+ 'Async':'true',
|
|
|
+ 'Callerid': '{} <{}>'.format(user, device)}
|
|
|
app.logger.warning(_act)
|
|
|
await manager.send_action(_act)
|
|
|
return successfullyOriginated(user, number)
|