Bladeren bron

Blind call transfer added

Hal De 4 jaren geleden
bovenliggende
commit
9d1f5eef8a
1 gewijzigde bestanden met toevoegingen van 25 en 0 verwijderingen
  1. 25 0
      app/app.py

+ 25 - 0
app/app.py

@@ -637,6 +637,31 @@ class AtXfer(Resource):
       else:
         return errorReply(reply.message)
 
+@app.route('/bxfer/<userA>/<userB>')
+class BXfer(Resource):
+  @app.param('userA', 'User initiating the blind transfer', 'path')
+  @app.param('userB', 'Transfer destination user', 'path')
+  @app.response(HTTPStatus.OK, 'Json reply')
+  @app.response(HTTPStatus.UNAUTHORIZED, 'Authorization required')
+  async def get(self, userA, userB):
+    '''Blind call transfer
+    '''
+    device = await getUserDevice(userA)
+    if device in NONEs:
+      return noUserDevice(userA)
+    channel = await amiDeviceChannel(device)
+    if channel in NONEs:
+      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('/users/states')
 class UsersStates(Resource):
   @app.response(HTTPStatus.OK, 'JSON reply with user:state map or error message')