Beispiel #1
0
def test_room_cleanup(create_event, create_dummy_room, dummy_avatar,
                      freeze_time, db):
    """Test that 'old' Vidyo rooms are correctly detected"""
    freeze_time(datetime(2015, 2, 1))

    events = {}
    for id_, (evt_name, end_date) in enumerate(
        (('Event one', datetime(2012, 1, 1, tzinfo=utc)),
         ('Event two', datetime(2013, 1, 1, tzinfo=utc)),
         ('Event three', datetime(2014, 1, 1, tzinfo=utc)),
         ('Event four', datetime(2015, 1, 1, tzinfo=utc))),
            start=1):
        events[id_] = create_event(id_,
                                   title=evt_name,
                                   end_dt=end_date,
                                   start_dt=end_date)

    for id_, (vidyo_id, extension, evt_ids) in enumerate(
        ((1234, 5678, (1, 2, 3, 4)), (1235, 5679, (1, 2)), (1235, 5679, (2, )),
         (1236, 5670, (4, )), (1237, 5671, ())),
            start=1):
        room = create_dummy_room('test_room_{}'.format(id_), extension,
                                 dummy_avatar, {'vidyo_id': vidyo_id})
        for evt_id in evt_ids:
            VCRoomEventAssociation(vc_room=room, linked_event=events[evt_id])
            db.session.flush()

    from indico_vc_vidyo.task import find_old_vidyo_rooms

    assert {r.id for r in find_old_vidyo_rooms(180)} == {2, 3, 5}
Beispiel #2
0
def process_vc_room_association(plugin, event, vc_room, form, event_vc_room=None, allow_same_room=False):
    # disable autoflush, so that the new event_vc_room does not influence the result
    with db.session.no_autoflush:
        if event_vc_room is None:
            event_vc_room = VCRoomEventAssociation()

        plugin.update_data_association(event, vc_room, event_vc_room, form.data)

        # check whether there is a room-event association already present
        # for the given event, room and plugin
        q = VCRoomEventAssociation.find(
            VCRoomEventAssociation.event_id == event.id,
            VCRoomEventAssociation.link_type == event_vc_room.link_type,
            VCRoomEventAssociation.link_id == event_vc_room.link_id,
            _join=VCRoom
        )

        if allow_same_room:
            q = q.filter(VCRoom.id != vc_room.id)

        existing = {x.vc_room for x in q}

    if event_vc_room.link_type != VCRoomLinkType.event and existing:
        transaction.abort()
        flash(_("There is already a VC room attached to '{link_object_title}'.").format(
            link_object_title=resolve_title(event_vc_room.link_object)), 'error')
        return None
    elif event_vc_room.link_type == VCRoomLinkType.event and vc_room in existing:
        transaction.abort()
        flash(_("This {plugin_name} room is already attached to the event.").format(plugin_name=plugin.friendly_name),
              'error')
        return None
    else:
        return event_vc_room
Beispiel #3
0
    def clone_room(self, old_event_vc_room, link_object):
        """Clone the room, returning a new :class:`VCRoomEventAssociation`.

        :param old_event_vc_room: the original :class:`VCRoomEventAssociation`
        :param link_object: the new object the association will be tied to
        :return: the new :class:`VCRoomEventAssociation`
        """
        return VCRoomEventAssociation(show=old_event_vc_room.show,
                                      data=old_event_vc_room.data,
                                      link_object=link_object)
Beispiel #4
0
 def clone(self, new_event, options):
     if 'vc_rooms' not in options:
         return
     for old_event_vc_room in VCRoomEventAssociation.find_for_event(self.event, include_hidden=True):
         event_vc_room = VCRoomEventAssociation(event_id=int(new_event.id),
                                                link_type=old_event_vc_room.link_type,
                                                link_id=old_event_vc_room.link_id,
                                                show=old_event_vc_room.show,
                                                data=old_event_vc_room.data)
         if event_vc_room.link_object is not None:
             event_vc_room.vc_room = old_event_vc_room.vc_room
             db.session.add(event_vc_room)
Beispiel #5
0
    def migrate_event_booking(self, vc_room, booking):
        ch_idx = self.zodb_root['conferences']
        booking_params = booking._bookingParams

        old_link_type = getattr(booking, '_linkVideoType', None)
        link_type = (VCRoomLinkType.get(MAP_LINK_TYPES[booking._linkVideoType]) if old_link_type
                     else VCRoomLinkType.event)

        if booking._conf.id not in ch_idx:
            print cformat(
                "[%{red!}WARNING%{reset}] %{yellow!}{} is linked to event '{}' but the latter seems to have been"
                " deleted. Removing link."
            ).format(vc_room, booking._conf.id)
            return

        if link_type == VCRoomLinkType.event:
            extracted_id = None
        elif not booking._linkVideoId:
            print cformat(
                "[%{red!}WARNING%{reset}] %{yellow!}{} is linked to a {} but no id given%{reset}. Linking to event."
            ).format(vc_room, link_type.name)
            extracted_id = None
            link_type = VCRoomLinkType.event
        else:
            extracted_id = extract_id(booking._linkVideoId)

        if link_type != VCRoomLinkType.event and not is_valid_link(booking._conf, link_type, extracted_id):
            print cformat(
                "[%{red!}WARNING%{reset}] %{yellow!}{} is linked to a {} but it does not exist%{reset}. "
                "Linking to event."
            ).format(vc_room, link_type.name)
            link_type = VCRoomLinkType.event
            extracted_id = None

        event_vc_room = VCRoomEventAssociation(
            event_id=booking._conf.id,
            vc_room=vc_room,
            link_type=link_type,
            link_id=extracted_id,
            show=not booking._hidden
        )
        event_vc_room.data = {
            'show_pin': booking_params['displayPin'],
            'show_phone_numbers': booking_params.get('displayPhoneNumbers', True),
            'show_autojoin': booking_params['displayURL'],
        }

        db.session.add(event_vc_room)
        print cformat('%{green}<->%{reset} %{cyan!}{}%{reset} %{red!}{}%{reset} [%{yellow}{}%{reset}]').format(
            booking._conf.id, booking._roomId, old_link_type)
Beispiel #6
0
    def _create_meeting(name='New Room'):
        user_joe = create_user(1, email='*****@*****.**')

        vc_room = VCRoom(type='zoom',
                         status=VCRoomStatus.created,
                         name=name,
                         created_by_id=0,
                         data={
                             'description': 'something something',
                             'password': '******',
                             'host': user_joe.identifier,
                             'meeting_type': 'meeting',
                             'mute_host_video': False,
                             'mute_audio': False,
                             'mute_participant_video': False,
                             'waiting_room': False
                         })
        VCRoomEventAssociation(linked_event=dummy_event,
                               vc_room=vc_room,
                               link_type=VCRoomLinkType.event,
                               data={})
        db.session.flush()
        zoom_plugin.create_room(vc_room, dummy_event)
        return vc_room