From 11c3376f1a916c84bb8c3df57dd881cd777452e0 Mon Sep 17 00:00:00 2001 From: Adrian Moennich Date: Mon, 25 Jan 2021 16:48:09 +0100 Subject: [PATCH] VC/Zoom: Support ical metadata with HTML body This is used by the exchange calendaring plugin at CERN to avoid having to add custom linkification code. --- vc_zoom/indico_vc_zoom/plugin.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/vc_zoom/indico_vc_zoom/plugin.py b/vc_zoom/indico_vc_zoom/plugin.py index 04f3df2..eb7ebad 100644 --- a/vc_zoom/indico_vc_zoom/plugin.py +++ b/vc_zoom/indico_vc_zoom/plugin.py @@ -529,6 +529,13 @@ class ZoomPlugin(VCPluginMixin, IndicoPlugin): def _event_metadata_postprocess(self, sender, event, data, user=None, **kwargs): urls = [] + if 'description' in kwargs.get('html_fields', ()): + linebreak = '
\n' + format_link = lambda name, url: '{name}: {url}'.format(name=escape(name), url=url) + else: + linebreak = '\n' + format_link = lambda name, url: '{name}: {url}'.format(name=name, url=url) + for assoc in event.vc_room_associations: if not assoc.show or assoc.vc_room.type != 'zoom': continue @@ -539,11 +546,11 @@ class ZoomPlugin(VCPluginMixin, IndicoPlugin): (visibility == 'registered' and user is not None and event.is_user_registered(user)) or event.can_manage(user) ): - urls.append('{}: {}'.format(assoc.vc_room.name, assoc.vc_room.data['url'])) + urls.append(format_link(assoc.vc_room.name, assoc.vc_room.data['url'])) elif visibility == 'no_one': # XXX: Not sure if showing this is useful, but on the event page we show the join link # with no passcode as well, so let's the logic identical here. - urls.append('{}: {}'.format(assoc.vc_room.name, assoc.vc_room.data['public_url'])) + urls.append(format_link(assoc.vc_room.name, assoc.vc_room.data['public_url'])) if urls: - return {'description': (data['description'] + '\n\n' + '\n'.join(urls)).strip()} + return {'description': (data['description'] + (linebreak * 2) + linebreak.join(urls)).strip()}