Pārlūkot izejas kodu

fix users devices

Hal De 4 gadi atpakaļ
vecāks
revīzija
f121e69d85
1 mainītis faili ar 27 papildinājumiem un 2 dzēšanām
  1. 27 2
      app/app.py

+ 27 - 2
app/app.py

@@ -701,13 +701,36 @@ class BXfer(Resource):
       else:
         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>')
 class Hangup(Resource):
   @app.param('user', 'User to hangup', 'path')
   @app.response(HTTPStatus.OK, 'Json reply')
   @app.response(HTTPStatus.UNAUTHORIZED, 'Authorization required')
   async def get(self, user):
-    '''Blind call transfer
+    '''Call hangup
     '''
     channel = await getUserChannel(user)
     if not channel:
@@ -797,7 +820,9 @@ class UsersDevices(Resource):
       device = await getUserDevice(user)
       if ((device in NONEs) or (device == user)):
         device = None
-      data[user]=device.replace('{}&'.format(user), '')
+      else:
+        device = device.replace('{}&'.format(user), '')
+      data[user]= device
     return successReply(data)
 
 @app.route('/device/<device>/<user>/on')