<commit_before>#
# Copyright (C) 2012 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#

class AdobeConnectConference < WebConference

  MAX_USERNAME_LENGTH = 60

  # Public: Start a new conference and return its key. (required by WebConference)
  #
  # Returns a conference key string.
  def initiate_conference
    unless conference_key.present?
      create_meeting unless meeting_exists?
      save
    end

    find_conference_key
  end

  # Public: Determine the status of the conference (required by WebConference).
  #
  # Returns conference status as a symbol (either :active or :closed).
  def conference_status
    if meeting_exists?
      :active
    else
      :closed
    end
  end

  # Public: Add an admin to the conference and create a meeting URL (required by WebConference).
  #
  # admin - The user to add to the conference as an admin.
  # _ - Included for compatibility w/ web_conference.rb
  #
  # Returns a meeting URL string.
  def admin_join_url(admin, _ = nil)
    user = add_host(admin)

    if config[:use_sis_ids] == "no" 
      settings = { :username => user.username, :password => <PASSWORD>,
        :domain => CanvasConnect.config[:domain] }

      service = AdobeConnect::Service.new(settings)
      service.log_in

      "#{meeting_url}?session=#{service.session}"
    else
      meeting_url
    end 
  end

  # Public: Add a participant to the conference and create a meeting URL.
  #         Make the user a conference admin if they have permissions to create
  #         a conference (required by WebConference).
  #
  # user - The user to add to the conference as an admin.
  # _ - Included for compatibility w/ web_conference.rb
  #
  # Returns a meeting URL string.
  def participant_join_url(user, _ = nil)
    if grants_right?(user, nil, :initiate)
      admin_join_url(user)
    elsif config[:use_sis_ids] == "no" 
      "#{meeting_url}?guestName=#{URI.escape(user.name)}"
    else 
      meeting_url
    end
  end

  # Public: List all of the recordings for a meeting
  #
  # Returns an Array of MeetingArchive, or an empty Array if there are no recordings
  def recordings
    if key = find_conference_key
        CanvasConnect::MeetingArchive.retrieve(key).map do |recording|
        {
          recording_id: recording.id,
          duration_minutes: recording.duration.to_i,
          title: recording.name,
          updated_at: recording.date_modified,
          created_at: recording.date_created,
          playback_url: "#{config[:domain]}#{recording.url_path}",
        }<commit_msg>Make sure conference recordings are public<commit_after>#
# Copyright (C) 2012 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#

class AdobeConnectConference < WebConference

  MAX_USERNAME_LENGTH = 60

  # Public: Start a new conference and return its key. (required by WebConference)
  #
  # Returns a conference key string.
  def initiate_conference
    unless conference_key.present?
      create_meeting unless meeting_exists?
      save
    end

    find_conference_key
  end

  # Public: Determine the status of the conference (required by WebConference).
  #
  # Returns conference status as a symbol (either :active or :closed).
  def conference_status
    if meeting_exists?
      :active
    else
      :closed
    end
  end

  # Public: Add an admin to the conference and create a meeting URL (required by WebConference).
  #
  # admin - The user to add to the conference as an admin.
  # _ - Included for compatibility w/ web_conference.rb
  #
  # Returns a meeting URL string.
  def admin_join_url(admin, _ = nil)
    user = add_host(admin)

    if config[:use_sis_ids] == "no"
      settings = { :username => user.username, :password => <PASSWORD>,
        :domain => CanvasConnect.config[:domain] }

      service = AdobeConnect::Service.new(settings)
      service.log_in

      "#{meeting_url}?session=#{service.session}"
    else
      meeting_url
    end
  end

  # Public: Add a participant to the conference and create a meeting URL.
  #         Make the user a conference admin if they have permissions to create
  #         a conference (required by WebConference).
  #
  # user - The user to add to the conference as an admin.
  # _ - Included for compatibility w/ web_conference.rb
  #
  # Returns a meeting URL string.
  def participant_join_url(user, _ = nil)
    if grants_right?(user, nil, :initiate)
      admin_join_url(user)
    elsif config[:use_sis_ids] == "no"
      "#{meeting_url}?guestName=#{URI.escape(user.name)}"
    else
      meeting_url
    end
  end

  # Public: List all of the recordings for a meeting
  #
  # Returns an Array of MeetingArchive, or an empty Array if there are no recordings
  def recordings
    if key = find_conference_key
      recordings = CanvasConnect::MeetingArchive.retrieve(key)
      recordings.each { |r| make_conference_public(r.id) }
      recordings.map do |recording|
        {
          recording_id: recording.id,
          duration_minutes: recording.duration.to_i,
          title: recording.name,
          updated_at: recording.date_modified,
          created_at: recording.date_created,
          playback_url: "#{config[:domain]}#{recording.url_path}",
        }
{'fraction_non_alphanumeric': 0.07657375508925775, 'fraction_numerical': 0.002192295646727216, 'mean_word_length': 3.099486521181001, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6704148', 'n_tokens_mistral': 1859, 'n_tokens_neox': 1803, 'n_words': 678}