Commit fff062ff authored by okhin's avatar okhin 🚴

Let's remove a channel from the moh-bridge when switching to something else

parent 13e61270
Pipeline #839 passed with stage
in 2 seconds
......@@ -19,8 +19,6 @@ 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
......@@ -80,6 +78,15 @@ class Bridge(object):
except:
raise
def removeChannel(self, channel):
'''
We want to remove a channel from the bridge
'''
try:
return ari_call(self.config, ['bridges', self.name, 'removeChannel'], 'POST', {'channel': channel})
except:
raise
def delete(self):
'''
Let's delete the bridge
......
......@@ -345,7 +345,11 @@ class Call(object):
bridge.create()
except Exception as e:
raise e
# Step 2, moving channels
# Step 2, removing callee channel from hold
moh_bridge = ari.Bridge(config['asterisk'], config['moh']['name'])
channel = self.id + '-' + sanitize_phonenumber(self.callee)
phone_logger.debug("Remove callee channel from moh")
moh_bridge.removeChannel(channel)
channels = ",".join([self.id
+ '-' + sanitize_phonenumber(self.caller),
self.id
......@@ -360,6 +364,7 @@ class Call(object):
# Moving the channel to the MOH Bridge
phone_logger.debug('Moving call {} to the garage'.format(event['channel']['id']))
moh_bridge = ari.Bridge(config['asterisk'], config['moh']['name'])
result = moh_bridge.status()
moh_bridge.addChannel(event['channel']['id'])
moh_bridge.startMoh(config['moh']['class'])
except Exception as e:
......
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