Commit 536c5932 authored by okhin's avatar okhin 🚴

Fixing the infinite loop and status of the calls, it works!

parent c408af90
Pipeline #623 passed with stage
in 1 second
......@@ -19,6 +19,8 @@ def ari_call(config, verbs, method, payload):
payload['app'] = config['app']
payload['api_key'] = config['key'] + ':' + config['password']
result = call(full_url, data=payload)
print(full_url)
print(payload)
result.raise_for_status()
if method.lower() == 'post':
# We need to test if we have something in the object, to eventually return it
......@@ -26,7 +28,10 @@ def ari_call(config, verbs, method, payload):
return result.json()
except:
result = requests.get(full_url, data=payload)
try:
return result.json()
except:
return '{}'
except:
raise
......@@ -34,7 +39,7 @@ class Bridge(object):
'''
This is a bridge object, we use it to manage various needed calls
'''
def __init__(self, config, name, mode):
def __init__(self, config, name, mode='mixing'):
self.name = name
self.config = config
self.mode = mode
......@@ -142,6 +147,6 @@ class Playback(object):
Let's stop a specific playback
'''
try:
return ari_call(self.config, ['playbacks', self.name], 'DEL', {})
ari_call(self.config, ['playbacks', self.name], 'DEL', {})
except:
raise
......@@ -228,7 +228,6 @@ class Call(object):
else:
self.id = callid
self.db = db
self.event_handler({'type': 'Created', 'timestamp': datetime.datetime.now().isoformat(), 'channel': {'id': 'Init'}})
except Exception as e:
phone_logger.exception(e)
raise e
......@@ -269,13 +268,6 @@ class Call(object):
There's a new event related to our call
'''
state = event['type']
try:
if self.state.startswith(state):
# We're alreaydy in this state, we just need to noop
return
except IndexError:
if state in self.actions:
getattr(self, self.actions[state])(event=event)
if state in self.actions:
getattr(self, self.actions[state])(event=event)
......@@ -346,7 +338,7 @@ class Call(object):
bridge.create()
# Step 2, moving channels
channels = ",".join([self.id + '-' + self.caller, self.id + '-' + self.callee])
phone_logger.debug("Moving channels to the created bridge: {}".format(brodge.name,))
phone_logger.debug("Moving channels to the created bridge: {}".format(bridge.name,))
bridge.addChannel(channels)
phone_logger.info("Call now fully connected: {} <-> {}".format(self.caller, self.callee))
return
......@@ -469,6 +461,7 @@ def originate(db, callid=None):
else:
call = Call(request.params['caller'], request.params['callee'], request.params['api'], db=db)
bottle_logger.debug("Originate a call: {}".format(json.dumps(call, cls=PiphoneJSONEncoder)))
call.event_handler({'type': 'Created', 'timestamp': datetime.datetime.now().isoformat(), 'channel': {'id': 'Init'}})
call.save()
head = {'call': call.url
, 'user': request.params['api']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment