Example #1
0
    def stop_record(self, tenant_uuid, conference_id):
        if not Conference(tenant_uuid, conference_id, self._confd).exists():
            raise NoSuchConference(tenant_uuid, conference_id)

        try:
            response_items = self._amid.action('ConfbridgeStopRecord', {'conference': conference_id})
        except RequestException as e:
            raise XiVOAmidError(self._amid, e)

        response = response_items[0]
        if response['Response'] != 'Success':
            message = response['Message']
            if message == 'Internal error while stopping recording.':
                raise ConferenceNotRecorded(tenant_uuid, conference_id)
            raise ConferenceError(tenant_uuid, conference_id, message)
Example #2
0
    def list_participants(self, tenant_uuid, conference_id):
        if not Conference(tenant_uuid, conference_id, self._confd).exists():
            raise NoSuchConference(tenant_uuid, conference_id)

        try:
            participant_list = self._amid.action('ConfBridgeList', {'conference': conference_id})
        except RequestException as e:
            raise XiVOAmidError(self._amid, e)

        participant_list_result = participant_list.pop(0)
        if (participant_list_result['Response'] == 'Error' and
                participant_list_result['Message'] == 'No active conferences.'):
            return []

        if participant_list_result['Response'] != 'Success':
            message = participant_list_result['Message']
            raise ConferenceParticipantError(tenant_uuid,
                                             conference_id,
                                             participant_id=None,
                                             message=message)

        result = []
        for participant_list_item in participant_list:
            if participant_list_item['Event'] != 'ConfbridgeList':
                continue

            raw_participant = {
                'id': participant_list_item['Uniqueid'],
                'caller_id_name': participant_list_item['CallerIDName'],
                'caller_id_number': participant_list_item['CallerIDNum'],
                'muted': participant_list_item['Muted'] == 'Yes',
                'join_time': participant_list_item['AnsweredTime'],
                'admin': participant_list_item['Admin'] == 'Yes',
                'language': participant_list_item['Language'],
                'call_id': participant_list_item['Uniqueid'],
                'user_uuid': Channel(participant_list_item['Uniqueid'], self._ari).user(),
            }
            try:
                participant = participant_schema.load(raw_participant).data
            except ValidationError as e:
                raise ConferenceParticipantError(tenant_uuid,
                                                 conference_id,
                                                 participant_id=None,
                                                 message=str(e))
            result.append(participant)

        return result
Example #3
0
    def _notify_participant_joined(self, event):
        conference_id = int(event['Conference'])
        logger.debug('Participant joined conference %s', conference_id)
        raw_participant = {
            'id': event['Uniqueid'],
            'caller_id_name': event['CallerIDName'],
            'caller_id_number': event['CallerIDNum'],
            'muted': event['Muted'] == 'Yes',
            'answered_time': 0,
            'admin': event['Admin'] == 'Yes',
            'language': event['Language'],
            'call_id': event['Uniqueid'],
        }

        participant = participant_schema.load(raw_participant).data
        participant['user_uuid'] = event.get('ChanVariable', {}).get('XIVO_USERUUID')
        conference = Conference.from_id(conference_id, self._confd)

        participants_already_present = self._service.list_participants(conference.tenant_uuid,
                                                                       conference_id)

        self._notifier.participant_joined(conference.tenant_uuid, conference_id, participant, participants_already_present)
Example #4
0
    def record(self, tenant_uuid, conference_id):
        if not Conference(tenant_uuid, conference_id, self._confd).exists():
            raise NoSuchConference(tenant_uuid, conference_id)

        participants = self.list_participants(tenant_uuid, conference_id)
        if not participants:
            raise ConferenceHasNoParticipants(tenant_uuid, conference_id)

        body = {
            'conference': conference_id,
        }
        try:
            response_items = self._amid.action('ConfbridgeStartRecord', body)
        except RequestException as e:
            raise XiVOAmidError(self._amid, e)

        response = response_items[0]
        if response['Response'] != 'Success':
            message = response['Message']
            if message == 'Conference is already being recorded.':
                raise ConferenceAlreadyRecorded(tenant_uuid, conference_id)
            raise ConferenceError(tenant_uuid, conference_id, message)
Example #5
0
    def kick_participant(self, tenant_uuid, conference_id, participant_id):
        if not Conference(tenant_uuid, conference_id, self._confd).exists():
            raise NoSuchConference(tenant_uuid, conference_id)

        participants = self.list_participants(tenant_uuid, conference_id)
        if participant_id not in [participant['id'] for participant in participants]:
            raise NoSuchParticipant(tenant_uuid, conference_id, participant_id)

        try:
            channel = self._ari.channels.get(channelId=participant_id)
        except ARINotFound:
            raise NoSuchParticipant(tenant_uuid, conference_id, participant_id)

        try:
            response_items = self._amid.action('ConfbridgeKick', {'conference': conference_id,
                                                                  'channel': channel.json['name']})
        except RequestException as e:
            raise XiVOAmidError(self._amid, e)

        response = response_items[0]
        if response['Response'] != 'Success':
            message = response['Message']
            raise ConferenceParticipantError(tenant_uuid, conference_id, participant_id, message)