Exemplo n.º 1
0
    def hangup_user(self, call_id, user_uuid):
        channel = Channel(call_id, self._ari)
        if not channel.exists() or channel.is_local():
            raise NoSuchCall(call_id)

        if channel.user() != user_uuid:
            raise UserPermissionDenied(user_uuid, {'call': call_id})

        self._ari.channels.hangup(channelId=call_id)
Exemplo n.º 2
0
    def make_call_from_channel(self, ari, channel):
        channel_helper = Channel(channel.id, ari)
        call = Call(channel.id)
        call.creation_time = channel.json['creationtime']
        call.status = channel.json['state']
        call.caller_id_name = channel.json['caller']['name']
        call.caller_id_number = channel.json['caller']['number']
        call.peer_caller_id_name = channel.json['connected']['name']
        call.peer_caller_id_number = channel.json['connected']['number']
        call.user_uuid = channel_helper.user()
        call.on_hold = channel_helper.on_hold()
        call.bridges = [bridge.id for bridge in ari.bridges.list() if channel.id in bridge.json['channels']]
        call.talking_to = {connected_channel.id: connected_channel.user()
                           for connected_channel in channel_helper.connected_channels()}
        call.is_caller = channel_helper.is_caller()
        call.dialed_extension = channel_helper.dialed_extension()

        return call