Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ class Room < ApplicationRecord
validates :name, presence: true
validates :friendly_id, presence: true, uniqueness: true
validates :meeting_id, presence: true, uniqueness: true
validates :dial_in_pin, presence: true, uniqueness: true, length: { is: 6 }, numericality: { only_integer: true }
validates :presentation,
content_type: Rails.configuration.uploads[:presentations][:formats],
size: { less_than: Rails.configuration.uploads[:presentations][:max_size] }

validates :name, length: { minimum: 1, maximum: 255 }
validates :recordings_processing, numericality: { only_integer: true, greater_than_or_equal_to: 0 }

before_validation :set_friendly_id, :set_meeting_id, on: :create
before_validation :set_friendly_id, :set_meeting_id, :set_dial_in_pin, on: :create
before_save :scan_presentation_for_virus

after_create :create_meeting_options
Expand Down Expand Up @@ -102,6 +103,16 @@ def set_meeting_id
retry
end

# Generate a unique 6-digit dial_in_pin for SIP access
def set_dial_in_pin
pin = SecureRandom.random_number(1_000_000).to_s.rjust(6, '0')
raise if Room.exists?(dial_in_pin: pin) # Ensure uniqueness

self.dial_in_pin = pin
rescue StandardError
retry
end

def scan_presentation_for_virus
return if !virus_scan? || !attachment_changes['presentation']

Expand Down
4 changes: 4 additions & 0 deletions app/services/meeting_starter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def call
options.merge!(computed_options(access_code: viewer_code['glViewerAccessCode']))
options.delete('muteOnStart') unless options['muteOnStart'] == 'true'

# Add dial_in_pin to meeting metadata for SIP access
options['meta_dial-in-pin'] = @room.dial_in_pin

retries = 0
begin
meeting = BigBlueButtonApi.new(provider: @provider).start_meeting(room: @room, options:, presentation_url:)
Expand All @@ -64,6 +67,7 @@ def computed_options(access_code:)
room_url = "#{root_url(host: @base_url)}rooms/#{@room.friendly_id}/join"
moderator_message = "#{I18n.t('meeting.moderator_message', locale: @current_user&.language&.to_sym)}<br>#{room_url}"
moderator_message += "<br>#{I18n.t('meeting.access_code', code: access_code, locale: @current_user&.language&.to_sym)}" if access_code.present?
moderator_message += "<br>#{I18n.t('meeting.dial_in_pin', pin: @room.dial_in_pin, locale: @current_user&.language&.to_sym)}"
{
moderatorOnlyMessage: moderator_message,
loginURL: room_url,
Expand Down
1 change: 1 addition & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ de:
meeting:
moderator_message: "Um jemanden zur Konferenz einzuladen, verschicke diesen Link:"
access_code: "Zugangscode: %{code}"
dial_in_pin: "Wählcode (PIN): %{pin}"
email:
activation:
account_activation: Kontoaktivierung
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ en:
meeting:
moderator_message: "To invite someone to the meeting, send them this link:"
access_code: "Access Code: %{code}"
dial_in_pin: "Dial-In PIN: %{pin}"
email:
activation:
account_activation: Account Activation
Expand Down
24 changes: 24 additions & 0 deletions db/migrate/20260611000000_add_dial_in_pin_to_rooms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
#
# Copyright (c) 2022 BigBlueButton Inc. and by respective authors (see below).
#
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# Greenlight 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with Greenlight; if not, see <http://www.gnu.org/licenses/>.

# frozen_string_literal: true

class AddDialInPinToRooms < ActiveRecord::Migration[7.0]
def change
add_column :rooms, :dial_in_pin, :string, null: true
add_index :rooms, :dial_in_pin, unique: true
end
end
44 changes: 44 additions & 0 deletions docs/DIAL_IN_SIP_PIN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Dial-In SIP Pin Feature

## Overview
Implements automatic generation and display of Dial-In SIP PINs for room creation in Greenlight. The PIN (6-digit number) is generated on room creation and can be accessed by owners and admins.

## Changes Made

### Database Migration
- **File**: `db/migrate/20260611000000_add_dial_in_pin_to_rooms.rb`
- Adds `dial_in_pin` column (string) to `rooms` table
- Creates unique index on `dial_in_pin` column
- Initial value: `NULL` (for backward compatibility)

### Room Model Updates
- **File**: `app/models/room.rb`
- Added validation for `dial_in_pin` (6-digit, numeric, unique)
- Added `set_dial_in_pin` callback to generate PIN on room creation
- PIN format: 6-digit zero-padded number (000000-999999)
- Retry mechanism to handle collisions

### BigBlueButton Integration
- **File**: `app/services/meeting_starter.rb`
- Added `dial_in_pin` to meeting metadata as `meta_dial-in-pin`
- PIN included in moderator welcome message
- PIN passed to BigBlueButton API for SIP configuration

## PIN Generation Logic
```ruby
pin = SecureRandom.random_number(1_000_000).to_s.rjust(6, '0')
```

## Security Considerations
- **Access Control**: PIN visible only to room owner and admins
- **Uniqueness**: Database constraint ensures PIN uniqueness
- **Randomness**: Uses `SecureRandom` for cryptographic randomness
- **No Modification**: PIN is set only once on room creation

## Next Steps
1. Create UI components to display PIN after room creation
2. Add PIN copy-to-clipboard functionality
3. Add PIN regeneration option (optional, for advanced use)
4. Add i18n string for dial_in_pin message
5. Create tests for PIN generation and validation
6. API endpoint to retrieve PIN (only for authorized users)