def update_room(self, vc_room, event): client = AdminClient(self.settings) try: room_obj = self.get_room(vc_room) except RoomNotFoundAPIException: raise VCRoomNotFoundError(_("This room has been deleted from Vidyo")) owner = retrieve_principal(vc_room.data['owner'], allow_groups=False, legacy=False) changed_owner = room_obj.ownerName not in iter_user_identities(owner) if changed_owner: login_gen = iter_user_identities(owner) login = next(login_gen, None) if login is None: raise VCRoomError(_("No valid Vidyo account found for this user"), field='owner_user') room_obj.ownerName = login room_obj.name = vc_room.name room_obj.description = vc_room.data['description'] room_obj.RoomMode.hasPIN = vc_room.data['room_pin'] != "" room_obj.RoomMode.hasModeratorPIN = vc_room.data['moderation_pin'] != "" if room_obj.RoomMode.hasPIN: room_obj.RoomMode.roomPIN = vc_room.data['room_pin'] if room_obj.RoomMode.hasModeratorPIN: room_obj.RoomMode.moderatorPIN = vc_room.data['moderation_pin'] vidyo_id = vc_room.data['vidyo_id'] while True: try: client.update_room(vidyo_id, room_obj) except RoomNotFoundAPIException: raise VCRoomNotFoundError(_("This room has been deleted from Vidyo")) except APIException as err: err_msg = err.message if err_msg.startswith('Room exist for name'): raise VCRoomError(_("Room name already in use"), field='name') elif err_msg.startswith('Member not found for ownerName'): if changed_owner: login = next(login_gen, None) if not changed_owner or login is None: raise VCRoomError(_("No valid Vidyo account found for this user"), field='owner_user') room_obj.ownerName = login else: raise else: updated_room_obj = self.get_room(vc_room) update_room_from_obj(self.settings, vc_room, updated_room_obj) flag_modified(vc_room, 'data') client.set_automute(vidyo_id, vc_room.data['auto_mute']) break
def update_zoom_meeting(zoom_id, changes, is_webinar=False): """Update a meeting which already exists in the Zoom API. :param zoom_id: ID of the meeting :param changes: dictionary with new attribute values :param is_webinar: whether the call concerns a webinar (used to call the correct endpoint) """ client = ZoomIndicoClient() try: if is_webinar: client.update_webinar(zoom_id, changes) else: client.update_meeting(zoom_id, changes) except HTTPError as e: from indico_vc_zoom.plugin import ZoomPlugin ZoomPlugin.logger.exception("Error updating meeting '%s': %s", zoom_id, e.response.content) if e.response.json()['code'] == 3001: # "Meeting does not exist" raise VCRoomNotFoundError(_('Room no longer exists in Zoom')) raise VCRoomError( _("Can't update meeting. Please contact support if the error persists." ))
def refresh_room(self, vc_room, event): client = AdminClient(self.settings) try: room_obj = self.get_room(vc_room) except RoomNotFoundAPIException: raise VCRoomNotFoundError(_("This room has been deleted from Vidyo")) update_room_from_obj(self.settings, vc_room, room_obj) vc_room.data['auto_mute'] = client.get_automute(room_obj.roomID) flag_modified(vc_room, 'data')
def create_room(self, vc_room, event): """Create a new Zoom room for an event, given a VC room. In order to create the Zoom room, the function will try to do so with all the available identities of the user based on the authenticators defined in Zoom plugin's settings, in that order. :param vc_room: VCRoom -- The VC room from which to create the Zoom room :param event: Event -- The event to the Zoom room will be attached """ client = ZoomIndicoClient(self.settings) #owner = retrieve_principal(vc_room.data['owner']) owner = session.user user_id = owner.email topic = vc_room.name time_zone = event.timezone start = event.start_dt_local end = event.end_dt topic = vc_room.data['description'] type_meeting = 2 host_video = self.settings.get('host_video') participant_video = self.settings.get('participant_video') join_before_host = self.settings.get('join_before_host') mute_upon_entry = self.settings.get('auto_mute') meeting_obj = client.create_meeting( user_id=user_id, type=type_meeting, start_time=start, topic=topic, timezone=time_zone, host_video=host_video, participant_video=participant_video, join_before_host=join_before_host, mute_upon_entry=mute_upon_entry) if not meeting_obj: raise VCRoomNotFoundError( _("Could not find newly created room in Zoom")) vc_room.data.update({ 'zoom_id': unicode(meeting_obj['id']), 'url': meeting_obj['join_url'], 'start_url': meeting_obj['start_url'] }) flag_modified(vc_room, 'data') vc_room.zoom_meeting = ZoomMeeting(vc_room_id=vc_room.id, meeting=meeting_obj['id'], owned_by_user=owner, url_zoom=meeting_obj['join_url']) self.notify_owner_start_url(vc_room)
def fetch_zoom_meeting(vc_room, client=None, is_webinar=False): """Fetch a Zoom meeting from the Zoom API. :param vc_room: The `VCRoom` object :param client: a `ZoomIndicoClient` object, otherwise a fresh one will be created :param is_webinar: whether the call concerns a webinar (used to call the correct endpoint) """ try: client = client or ZoomIndicoClient() if is_webinar: return client.get_webinar(vc_room.data['zoom_id']) return client.get_meeting(vc_room.data['zoom_id']) except HTTPError as e: if e.response.status_code in {400, 404}: # Indico will automatically mark this room as deleted raise VCRoomNotFoundError( _('This room has been deleted from Zoom')) else: from indico_vc_zoom.plugin import ZoomPlugin ZoomPlugin.logger.exception('Error getting Zoom Room: %s', e.response.content) raise VCRoomError( _('Problem fetching room from Zoom. Please contact support if the error persists.' ))
def create_room(self, vc_room, event): """Create a new Bluejeans room for an event, given a VC room. In order to create the Bluejeans room, the function will try to do so with all the available identities of the user based on the authenticators defined in Bluejeans plugin's settings, in that order. :param vc_room: VCRoom -- The VC room from which to create the Bluejeans room :param event: Event -- The event to the Bluejeans room will be attached """ client = AdminClient(self.settings) owner = retrieve_principal(vc_room.data['owner']) login_gen = iter_user_identities(owner) login = next(login_gen, None) if login is None: raise VCRoomError( _("No valid Bluejeans account found for this user"), field='owner_user') extension_gen = iter_extensions( self.settings.get('indico_room_prefix'), event.id) extension = next(extension_gen) while True: room_mode = { 'isLocked': False, 'hasPIN': bool(vc_room.data['room_pin']), 'hasModeratorPIN': bool(vc_room.data['moderation_pin']) } if room_mode['hasPIN']: room_mode['roomPIN'] = vc_room.data['room_pin'] if room_mode['hasModeratorPIN']: room_mode['moderatorPIN'] = vc_room.data['moderation_pin'] room_obj = client.create_room_object( name=vc_room.name, RoomType='Public', ownerName=login, extension=extension, groupName=self.settings.get('room_group_name'), description=vc_room.data['description'], RoomMode=room_mode) if room_obj.RoomMode.hasPIN: room_obj.RoomMode.roomPIN = vc_room.data['room_pin'] if room_obj.RoomMode.hasModeratorPIN: room_obj.RoomMode.moderatorPIN = vc_room.data['moderation_pin'] try: client.add_room(room_obj) except APIException as err: err_msg = err.message if err_msg.startswith('Room exist for name'): raise VCRoomError(_("Room name already in use"), field='name') elif err_msg.startswith('Member not found for ownerName'): login = next(login_gen, None) if login is None: raise VCRoomError(_( "No valid Bluejeans account found for this user"), field='owner_user') elif err_msg.startswith('Room exist for extension'): extension = next(extension_gen) else: raise else: # get room back, in order to fetch Bluejeans-set parameters created_room = client.find_room(extension) if not created_room: raise VCRoomNotFoundError( _("Could not find newly created room in Bluejeans")) vc_room.data.update({ 'bluejeans_id': unicode(created_room.roomID), 'url': created_room.RoomMode.roomURL, 'owner_identity': created_room.ownerName }) flag_modified(vc_room, 'data') vc_room.bluejeans_extension = BluejeansExtension( vc_room_id=vc_room.id, extension=int(created_room.extension), owned_by_user=owner) client.set_automute(created_room.roomID, vc_room.data['auto_mute']) break