Exemplo n.º 1
0
 def held_call_answered(self, tenant_uuid, switchboard_uuid,
                        operator_call_id, held_call_id):
     logger.debug(
         'Held call %s in switchboard %s answered by %s',
         held_call_id,
         switchboard_uuid,
         operator_call_id,
     )
     body = {
         'switchboard_uuid': switchboard_uuid,
         'operator_call_id': operator_call_id,
         'held_call_id': held_call_id
     }
     required_acl = 'events.switchboards.{uuid}.calls.held.{call_id}.answer.updated'.format(
         uuid=switchboard_uuid,
         call_id=escape_permission(held_call_id),
     )
     routing_key = 'switchboards.{uuid}.calls.held.{call_id}.answer.updated'.format(
         uuid=switchboard_uuid,
         call_id=escape_routing_key(held_call_id),
     )
     event = ArbitraryEvent(
         name='switchboard_held_call_answered',
         body=body,
         required_acl=required_acl,
     )
     event.routing_key = routing_key
     headers = {'tenant_uuid': tenant_uuid}
     self._bus.publish(event, headers=headers)
Exemplo n.º 2
0
 def queued_call_answered(self, switchboard_uuid, operator_call_id,
                          queued_call_id):
     logger.debug(
         'Queued call %s in switchboard %s answered by %s',
         queued_call_id,
         switchboard_uuid,
         operator_call_id,
     )
     body = {
         'switchboard_uuid': switchboard_uuid,
         'operator_call_id': operator_call_id,
         'queued_call_id': queued_call_id
     }
     required_acl = 'events.switchboards.{uuid}.calls.queued.{call_id}.answer.updated'.format(
         uuid=switchboard_uuid,
         call_id=escape_permission(queued_call_id),
     )
     routing_key = 'switchboards.{uuid}.calls.queued.{call_id}.answer.updated'.format(
         uuid=switchboard_uuid,
         call_id=escape_routing_key(queued_call_id),
     )
     event = ArbitraryEvent(
         name='switchboard_queued_call_answered',
         body=body,
         required_acl=required_acl,
     )
     event.routing_key = routing_key
     self._bus.publish(event)
Exemplo n.º 3
0
 def _fax_progress(self, event):
     bus_event = ArbitraryEvent(
         name='fax_progress',
         body=event,
         required_acl='events.fax'
     )
     bus_event.routing_key = 'fax.fax_progress'
     self.bus_publisher.publish(bus_event)
Exemplo n.º 4
0
 def _send_fax(self, event):
     bus_event = ArbitraryEvent(
         name='send_fax',
         body=event,
         required_acl='events.fax'
     )
     bus_event.routing_key = 'fax.send_fax'
     self.bus_publisher.publish(bus_event)
Exemplo n.º 5
0
 def _queue_caller_join(self, event):
     bus_event = ArbitraryEvent(
         name='queue_caller_join',
         body=event,
         required_acl='events.queues'
     )
     bus_event.routing_key = 'calls.queues.caller_join'
     self.bus_publisher.publish(bus_event)
Exemplo n.º 6
0
 def _queue_member_ringinuse(self, event):
     bus_event = ArbitraryEvent(
         name='queue_member_ringinuse',
         body=event,
         required_acl='events.queues'
     )
     bus_event.routing_key = 'calls.queues.member_ringinuse'
     self.bus_publisher.publish(bus_event)
Exemplo n.º 7
0
 def deleted(self, switchboard):
     event = ArbitraryEvent(
         name='switchboard_deleted',
         body=SwitchboardSchema().dump(switchboard),
         required_acl='switchboards.{uuid}.deleted'.format(
             uuid=switchboard.uuid),
     )
     event.routing_key = 'config.switchboards.{uuid}.deleted'.format(
         uuid=switchboard.uuid)
     self.bus.send_bus_event(event)
Exemplo n.º 8
0
 def _relay_channel_hung_up(self, event):
     channel_id = event['Uniqueid']
     logger.debug('Relaying to bus: channel %s ended', channel_id)
     call = self.services.make_call_from_ami_event(event)
     bus_event = ArbitraryEvent(
         name='call_ended',
         body=call_schema.dump(call).data,
         required_acl='events.calls.{}'.format(call.user_uuid)
     )
     bus_event.routing_key = 'calls.call.ended'
     self.bus_publisher.publish(bus_event, headers={'user_uuid:{uuid}'.format(uuid=call.user_uuid): True})
Exemplo n.º 9
0
 def edited(self, switchboard):
     event = ArbitraryEvent(
         name='switchboard_edited',
         body=SwitchboardSchema().dump(switchboard),
         required_acl='switchboards.{uuid}.edited'.format(uuid=switchboard.uuid),
     )
     event.routing_key = 'config.switchboards.{uuid}.edited'.format(
         uuid=switchboard.uuid
     )
     headers = self._build_headers(switchboard)
     self.bus.send_bus_event(event, headers=headers)
Exemplo n.º 10
0
    def members_associated(self, switchboard, users):
        name = 'switchboard_member_user_associated'
        routing_key = 'config.switchboards.{switchboard.uuid}.members.users.updated'
        acl = 'switchboards.{switchboard.uuid}.members.users.updated'
        body = {
            'switchboard_uuid': switchboard.uuid,
            'users': [{
                'uuid': user.uuid
            } for user in users],
        }
        event = ArbitraryEvent(name, body, acl)
        event.routing_key = routing_key.format(switchboard=switchboard)

        self.bus.send_bus_event(event)
Exemplo n.º 11
0
    def _user_event(self, event):
        if event['UserEvent'] == 'Pushmobile':
            user_uuid = event['WAZO_DST_UUID']

            body = {
                'peer_caller_id_number': event["CallerIDNum"],
                'peer_caller_id_name': event["CallerIDName"],
            }

            bus_event = ArbitraryEvent(
                name='call_push_notification',
                body=body,
                required_acl='events.calls.{}'.format(user_uuid)
            )
            bus_event.routing_key = 'calls.call.push_notification'
            self.bus_publisher.publish(bus_event, headers={'user_uuid:{uuid}'.format(uuid=user_uuid): True})
Exemplo n.º 12
0
    def _create_bus_event(self, name, routing_key, is_paused, id_, number,
                          reason, queue):
        body = {
            'agent_id': id_,
            'agent_number': number,
            'queue': queue,
            'paused': is_paused,
            'paused_reason': reason
        }

        bus_event = ArbitraryEvent(name=name,
                                   body=body,
                                   required_acl='events.statuses.agents')
        bus_event.routing_key = routing_key

        return bus_event
Exemplo n.º 13
0
 def _relay_channel_updated(self, event):
     channel_id = event['Uniqueid']
     logger.debug('Relaying to bus: channel %s updated', channel_id)
     try:
         channel = self.ari.channels.get(channelId=channel_id)
     except ARINotFound:
         logger.debug('channel %s not found', channel_id)
         return
     call = self.services.make_call_from_channel(self.ari, channel)
     bus_event = ArbitraryEvent(
         name='call_updated',
         body=call_schema.dump(call).data,
         required_acl='events.calls.{}'.format(call.user_uuid)
     )
     bus_event.routing_key = 'calls.call.updated'
     self.bus_publisher.publish(bus_event, headers={'user_uuid:{uuid}'.format(uuid=call.user_uuid): True})
Exemplo n.º 14
0
 def held_calls(self, switchboard_uuid, calls):
     body = {
         'switchboard_uuid': switchboard_uuid,
         'items': held_call_schema.dump(calls, many=True).data
     }
     logger.debug(
         'Notifying updated held calls for switchboard %s: %s calls',
         switchboard_uuid,
         len(calls),
     )
     event = ArbitraryEvent(
         name='switchboard_held_calls_updated',
         body=body,
         required_acl='events.switchboards.{uuid}.calls.held.updated'.
         format(uuid=switchboard_uuid, ),
     )
     event.routing_key = 'switchboards.{uuid}.calls.held.updated'.format(
         uuid=switchboard_uuid)
     self._bus.publish(event)
Exemplo n.º 15
0
 def queued_calls(self, tenant_uuid, switchboard_uuid, calls):
     body = {
         'switchboard_uuid': switchboard_uuid,
         'items': queued_call_schema.dump(calls, many=True).data
     }
     logger.debug(
         'Notifying updated queued calls for switchboard %s: %s calls',
         switchboard_uuid,
         len(calls),
     )
     event = ArbitraryEvent(
         name='switchboard_queued_calls_updated',
         body=body,
         required_acl='events.switchboards.{uuid}.calls.queued.updated'.
         format(uuid=switchboard_uuid, ),
     )
     event.routing_key = 'switchboards.{uuid}.calls.queued.updated'.format(
         uuid=switchboard_uuid)
     headers = {'tenant_uuid': tenant_uuid}
     self._bus.publish(event, headers=headers)
Exemplo n.º 16
0
 def _confbridge_end(self, event):
     bus_event = ArbitraryEvent(name='conference_end',
                                body=event,
                                required_acl='events.conferences')
     bus_event.routing_key = 'conferences.end'
     self.bus_publisher.publish(bus_event)
Exemplo n.º 17
0
 def _parked_call_timeout(self, event):
     bus_event = ArbitraryEvent(name='parking_parked_call_timeout',
                                body=event,
                                required_acl='events.parking')
     bus_event.routing_key = 'parking.parked_call_timeout'
     self.bus_publisher.publish(bus_event)