Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
piphone
piphone-sip
Commits
fff062ff
Commit
fff062ff
authored
Feb 06, 2017
by
okhin
Browse files
Let's remove a channel from the moh-bridge when switching to something else
parent
13e61270
Pipeline
#839
passed with stage
in 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ari.py
View file @
fff062ff
...
...
@@ -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
...
...
piphone.py
View file @
fff062ff
...
...
@@ -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
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment