# frozen_string_literal: true require "cgi" module Decidim module Meetings # This class handles the streaming url to be included in the iframe present # in the live event. For some services it's required to transforma a bit # the structure of the URL. class MeetingIframeEmbedder # Public: Initializes the service. # online_meeting_service_url - A String containing the url of the online meeting def initialize(online_meeting_service_url) @online_meeting_service_url = online_meeting_service_url end def embed_transformed_url(request_host) return nil if parsed_online_meeting_uri.nil? case parsed_online_meeting_uri.host when "www.youtube.com" transform_youtube_url(parsed_online_meeting_uri) when "www.twitch.tv" transform_twitch_url(parsed_online_meeting_uri, request_host) else online_meeting_service_url end end def embeddable? return nil if parsed_online_meeting_uri.nil? EMBEDDABLE_SERVICES.include?(parsed_online_meeting_uri.host) end def embed_code(request_host) return nil if parsed_online_meeting_uri.nil? %(