Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for static SIP Pins #5068

Open
wants to merge 124 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
71dd8f8
st
Mar 21, 2023
2b915ba
Static SIP
Mar 24, 2023
d55c30f
revert locale dev change
Mar 24, 2023
7fab7af
revert locale dev change
Mar 24, 2023
af1c240
sample.env update with VoiceBrige config
Mar 24, 2023
ebc4a87
Update room.rb, mistake in comment
SebastianAppDev Mar 27, 2023
7940467
Improved room sharing
Mar 28, 2023
741c482
merge SIP into ics
Mar 28, 2023
96df717
Voice Brige database migration for existing rooms
Mar 29, 2023
fb5f20d
Merge branch 'SIP' of https://github.com/SebastianAppDev/greenlight i…
Mar 29, 2023
6419f8e
Merge branch 'SIP' into ics
Mar 29, 2023
be32835
Merge branch 'ics' into master
SebastianAppDev Mar 29, 2023
32efa91
Improved data migration
Mar 29, 2023
3596405
improved database voice_brige population
Mar 29, 2023
8470182
Merge branch 'master' into SIP
SebastianAppDev Mar 29, 2023
a91eb30
Merge branch 'master' of https://github.com/bigbluebutton/greenlight …
May 30, 2023
dc82894
Merge branch 'bigbluebutton-master' into SIP
May 30, 2023
84ee009
Merge branch 'master' of https://github.com/bigbluebutton/greenlight …
Sep 25, 2023
97a4cfc
Merge branch 'bigbluebutton-master'
Sep 25, 2023
b3660ee
Merge branch 'master' of https://github.com/SebastianAppDev/greenlight
Sep 25, 2023
b7a8b5f
Merge pull request #4 from SebastianAppDev/master
SebastianAppDev Sep 25, 2023
cfe7f2f
Merge branch 'master' of https://github.com/bigbluebutton/greenlight …
SebastianAppDev Oct 23, 2023
ce805a2
Merge branch 'bigbluebutton-master' into SIP
SebastianAppDev Oct 23, 2023
1cf3422
Merge branch 'SIP' of https://github.com/SebastianAppDev/greenlight i…
SebastianAppDev Oct 23, 2023
24aed75
Fixed mixup with the ICS branch.
SebastianAppDev Oct 23, 2023
9d534b6
Fixed missing import
SebastianAppDev Oct 23, 2023
fab69d8
Add env EXTERNAL_AUTH and replace checks for OPENID_CONNECT with chec…
Ithanil Oct 30, 2023
9db6db2
Make server recordings rake a bit smarter (#5484)
farhatahmad Nov 1, 2023
7ada110
Fix case sensitive emails (#5485)
farhatahmad Nov 1, 2023
6c600df
Fixed various issues with users and providers (#5488)
farhatahmad Nov 1, 2023
da113a8
Changes to local accounts (#5489)
farhatahmad Nov 1, 2023
878ee23
Fix double logo on require authentication view (#5490)
farhatahmad Nov 1, 2023
cbbf361
More fixes for local migrations (#5491)
farhatahmad Nov 1, 2023
ac9d420
Hotfix for local accounts (#5492)
farhatahmad Nov 1, 2023
bf939e6
Fix joining interval (#5494)
farhatahmad Nov 1, 2023
eba4122
Recording view improvements (#5497)
farhatahmad Nov 3, 2023
b2f49d5
Fix recordings processing to work with pagination (#5498)
farhatahmad Nov 3, 2023
a311475
added delete presentation string to en.json and delete presentation f…
SilentFlameCR Nov 13, 2023
b4c8a9f
removed last 2 instances of recordings showing up when recordings dis…
SilentFlameCR Nov 14, 2023
d775829
Translate app/assets/locales/en.json in el (#5511)
transifex-integration[bot] Nov 14, 2023
782e082
[Snyk] Security upgrade active_storage_validations from 1.0.4 to 1.1.…
jfederico Nov 14, 2023
51a8e52
Fix failing rspecs (#5519)
farhatahmad Nov 14, 2023
b8b6b51
Bump @babel/traverse from 7.20.13 to 7.23.2 (#5471)
dependabot[bot] Nov 14, 2023
af8692c
Bump axios from 0.26.1 to 1.6.0 (#5508)
dependabot[bot] Nov 14, 2023
c96ec6a
fix: Gemfile & Gemfile.lock to reduce vulnerabilities (#5455)
antobinary Nov 14, 2023
0be6249
Use exec to let the container runtime send signals straight to rails …
danimo Nov 14, 2023
b39d14a
Remove Sign Up button when using OIDC (#5431)
jdr00t Nov 14, 2023
1f42f01
Remove active_record_serializer logs in prod (#5520)
farhatahmad Nov 15, 2023
bbbdd04
fix error with trailing slash (#5522)
farhatahmad Nov 15, 2023
7e164e4
Increased room limit max to 10000 (#5530)
farhatahmad Nov 20, 2023
ce3ea25
extended join url to accept joinFormName to autofill join name (#5526)
SilentFlameCR Nov 20, 2023
73112a2
Add a new role permission for receiving an email on user signup (#5529)
farhatahmad Nov 20, 2023
68dce64
Fix issue with recordings resync when no recordings are returned (#5538)
farhatahmad Nov 20, 2023
ef68ad3
Make changes to openid_connect uid field (#5523)
farhatahmad Nov 20, 2023
2cdd41d
Translate app/assets/locales/en.json in gl (#5541)
transifex-integration[bot] Nov 20, 2023
6cdd3d6
Translate config/locales/en.yml in gl (#5540)
transifex-integration[bot] Nov 20, 2023
2de243f
Updates for file config/locales/en.yml in ru (#5531)
transifex-integration[bot] Nov 20, 2023
1960ec7
Prevent local users from signing in if external accounts is enabled (…
farhatahmad Nov 20, 2023
ddffe54
feat(migrations): Import password digests from Greenlight2 (#5507)
danimo Nov 20, 2023
b83e0d9
Translate config/locales/en.yml in ar (#5550)
transifex-integration[bot] Nov 21, 2023
ca8e31e
Translate config/locales/en.yml in fa_IR (#5549)
transifex-integration[bot] Nov 21, 2023
80c9d51
Translate app/assets/locales/en.json in fa_IR (#5548)
transifex-integration[bot] Nov 21, 2023
287ec2e
Translate config/locales/en.yml in el (#5546)
transifex-integration[bot] Nov 21, 2023
c2e0c63
Translate app/assets/locales/en.json in el (#5545)
transifex-integration[bot] Nov 21, 2023
138037a
added links to docs (#5544)
SilentFlameCR Nov 21, 2023
b5f0f36
Translate config/locales/en.yml in fr (#5552)
transifex-integration[bot] Nov 21, 2023
9b25ab0
added wording to explain default language a little more concisely in …
SilentFlameCR Nov 21, 2023
1ff48d9
Fix failing rspecs (#5554)
farhatahmad Nov 21, 2023
87f5c28
fixed admin room access issues (#5543)
SilentFlameCR Nov 21, 2023
f69ccac
Remove reset password rake task (#5557)
farhatahmad Nov 21, 2023
4074bf8
[Snyk] Security upgrade rspec-rails from 6.0.3 to 6.0.4 (#5555)
jfederico Nov 21, 2023
5ad668a
[Snyk] Security upgrade factory_bot_rails from 6.2.0 to 6.3.0 (#5532)
jfederico Nov 21, 2023
80b814b
Upgrade factory bot (#5558)
farhatahmad Nov 21, 2023
256d435
Add default for openid_uid_field to .en (#5563)
farhatahmad Nov 22, 2023
36033d7
Add email notification to external users (#5565)
farhatahmad Nov 22, 2023
3fb0a97
Translate app/assets/locales/en.json in tr (#5562)
transifex-integration[bot] Nov 22, 2023
48020dd
Translate config/locales/en.yml in tr (#5561)
transifex-integration[bot] Nov 22, 2023
774625c
More fixes for email notification (#5566)
farhatahmad Nov 22, 2023
de0437d
Translate config/locales/en.yml in ja (#5573)
transifex-integration[bot] Nov 23, 2023
0c85c19
Updates for file app/assets/locales/en.json in ja (#5572)
transifex-integration[bot] Nov 23, 2023
f0cab9e
Translate config/locales/en.yml in fr (#5571)
transifex-integration[bot] Nov 23, 2023
4f2b9c7
Translate config/locales/en.yml in gl (#5570)
transifex-integration[bot] Nov 23, 2023
347c865
Translate config/locales/en.yml in gl (#5569)
transifex-integration[bot] Nov 23, 2023
ad32bff
Translate config/locales/en.yml in tr (#5568)
transifex-integration[bot] Nov 23, 2023
455734a
Translate config/locales/en.yml in tr (#5567)
transifex-integration[bot] Nov 23, 2023
a60f3e4
Fixed issues with uploads (profile, presentation, branding) (#5590)
farhatahmad Nov 29, 2023
58679cd
Translate config/locales/en.yml in ru (#5586)
transifex-integration[bot] Nov 29, 2023
34c1bf8
Translate app/assets/locales/en.json in ru (#5585)
transifex-integration[bot] Nov 29, 2023
c167158
Translate config/locales/en.yml in fa_IR (#5582)
transifex-integration[bot] Nov 29, 2023
8ea8290
Translate config/locales/en.yml in fa_IR (#5581)
transifex-integration[bot] Nov 29, 2023
24a1855
Translate config/locales/en.yml in ar (#5576)
transifex-integration[bot] Nov 29, 2023
18849e7
Translate config/locales/en.yml in el (#5575)
transifex-integration[bot] Nov 29, 2023
2afc7cc
Fix site settings not updating (#5591)
farhatahmad Nov 30, 2023
c890b31
Static SIP
Mar 24, 2023
d98163b
revert locale dev change
Mar 24, 2023
e6e33c9
sample.env update with VoiceBrige config
Mar 24, 2023
9e99052
st
Mar 21, 2023
8076e83
Improved room sharing
Mar 28, 2023
e40dfaa
Fixed mixup with the ICS branch.
SebastianAppDev Oct 23, 2023
965cbe3
Fixed missing import
SebastianAppDev Oct 23, 2023
2a0e980
FIX wrong imports
SebastianAppDev Dec 20, 2023
8b51efa
Improved number space filling
SebastianAppDev Dec 20, 2023
868375b
style improvements
SebastianAppDev Dec 20, 2023
9decdb9
FIX unused imports
SebastianAppDev Dec 20, 2023
6b806ae
Custom PIN Length
SebastianAppDev Jun 13, 2024
cc0cf0d
Custom PIN Length
SebastianAppDev Jun 14, 2024
860460e
Merge master
SebastianAppDev Jun 14, 2024
8d43f9d
Fix merge messup
SebastianAppDev Jun 14, 2024
987915f
Removed changes to unrelated files
SebastianAppDev Jun 14, 2024
e8d4d4f
Removed changes to unrelated files
SebastianAppDev Jun 14, 2024
9600e2d
Fix rubocop issues
SebastianAppDev Jun 17, 2024
1bb4725
Merge branch 'master' into SIP
SebastianAppDev Jun 28, 2024
ffee326
Merge branch 'master' into SIP
SebastianAppDev Jul 12, 2024
97027f4
Fix config double assignment
SebastianAppDev Jul 15, 2024
aaeccf0
Merge branch 'bigbluebutton:master' into SIP
SebastianAppDev Aug 2, 2024
b6ec5c2
Merge branch 'master' into SIP
SebastianAppDev Aug 19, 2024
6cabe36
Merge branch 'master' into SIP
SebastianAppDev Sep 17, 2024
d4c9563
rspec
SebastianAppDev Sep 18, 2024
653b71e
eslint
SebastianAppDev Sep 18, 2024
3501181
rspec
SebastianAppDev Sep 18, 2024
2da029f
rspec
SebastianAppDev Sep 18, 2024
1ee9e16
re run tests
SebastianAppDev Oct 8, 2024
306d6ba
Gammer fix
SebastianAppDev Oct 8, 2024
e97338f
Merge branch 'bigbluebutton:master' into SIP
SebastianAppDev Nov 11, 2024
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
Empty file removed app/assets/builds/.keep
Empty file.
10 changes: 9 additions & 1 deletion app/assets/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"close": "Schließen",
"delete": "Löschen",
"copy": "Einladungslink kopieren",
"copy_voice_bridge": "Telefoneinwahl kopieren",
"copy_viewer_code": "Zugangscode für Zuhörerende kopieren",
"copy_moderator_code": "Zugangscode für Moderation kopieren",
"or": "oder",
Expand Down Expand Up @@ -125,7 +126,13 @@
"meeting_invitation": "Du wurdest zur Teilnahme eingeladen",
"meeting_not_started": "Die Konferenz hat noch nicht begonnen",
"join_meeting_automatically": "Beitritt erfolgt automatisch, sobald die Konferenz beginnt",
"recording_consent": "Ich nehme zur Kenntnis, dass die Sitzung aufgezeichnet werden kann. Dies wird meine Stimme und mein Bild einschließen, wenn dies aktiviert ist."
"recording_consent": "Ich nehme zur Kenntnis, dass die Sitzung aufgezeichnet werden kann. Dies wird meine Stimme und mein Bild einschließen, wenn dies aktiviert ist.",
"invite_to_meeting": "{{ name }} lädt Sie ein, an einem Meeting teilzunehmen.",
"join_by_url": "An Besprechung per URL teilnehmen",
"alternative_options": "Alternative Optionen zur Teilnahme",
"download_ics": ".ics-Kalenderdatei herunterladen",
"share_meeting": "Raum teilen",
"join_by_phone": "mit Telefoneinwahl beitreten"
},
"presentation": {
"presentation": "Präsentation",
Expand Down Expand Up @@ -403,6 +410,7 @@
"access_code_generated": "Zugangscode generiert.",
"access_code_deleted": "Zugriffcode wurde gelöscht.",
"copied_meeting_url": "Die URL der Konferenz wurde kopiert. Der Link kann verwendet werden, um an der Konferenz teilzunehmen.",
"copied_voice_bridge": "Die Telefonnummer und der Pin wurden kopiert. Diese können genutzt werden um an der Konferenz teilzunehmen.",
"copied_viewer_code": "Zugangscode für Zuhörende wurde in die Zwischenablage kopiert.",
"copied_moderator_code": "Zugangscode für Moderation wurde in die Zwischenablage kopiert."
},
Expand Down
10 changes: 9 additions & 1 deletion app/assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"close": "Close",
"delete": "Delete",
"copy": "Copy Join Link",
"copy_voice_bridge": "Copy Phone Dialup",
"copy_viewer_code": "Copy Viewer Code",
"copy_moderator_code": "Copy Moderator Code",
"or": "Or",
Expand Down Expand Up @@ -126,7 +127,13 @@
"meeting_invitation": "You have been invited to join",
"meeting_not_started": "The meeting has not started yet",
"join_meeting_automatically": "You will automatically join when the meeting starts",
"recording_consent": "I acknowledge that this session may be recorded. This may include my voice and video if enabled."
"recording_consent": "I acknowledge that this session may be recorded. This may include my voice and video if enabled.",
"invite_to_meeting": "{{ name }} invites you to join a meeting.",
"join_by_url": "Join room by URL",
"alternative_options": "Alternative options to join",
"download_ics": "Download .ics calender file",
"share_meeting": "Share Room",
"join_by_phone": "join with telephone dial-up"
},
"presentation": {
"presentation": "Presentation",
Expand Down Expand Up @@ -412,6 +419,7 @@
"access_code_generated": "A new access code has been generated.",
"access_code_deleted": "The access code has been deleted.",
"copied_meeting_url": "The meeting URL has been copied. The link can be used to join the meeting.",
"copied_voice_bridge": "The phone number and pin have been copied. They can be used to join the conference.",
"copied_viewer_code": "The viewer access code has been copied.",
"copied_moderator_code": "The moderator access code has been copied."
},
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v1/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def create
room = Room.new(name: room_params[:name], user_id: room_params[:user_id])

if room.save
logger.info "room(friendly_id):#{room.friendly_id} created for user(id):#{room.user_id}"
logger.info "room(friendly_id):#{room.friendly_id} created for user(id):#{room.user_id} with voice brige: #{room.voice_bridge}"
render_data status: :created
else
render_error errors: room.errors.to_a, status: :bad_request
Expand Down Expand Up @@ -160,7 +160,7 @@ def find_room
end

def room_params
params.require(:room).permit(:name, :user_id, :presentation)
params.require(:room).permit(:name, :user_id, :voice_bridge, :presentation)
end
end
end
Expand Down
33 changes: 24 additions & 9 deletions app/javascript/components/rooms/RoomCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import React, { useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { Button, Card, Stack } from 'react-bootstrap';
import PropTypes from 'prop-types';
import { DocumentDuplicateIcon, LinkIcon } from '@heroicons/react/24/outline';
import { DocumentDuplicateIcon, LinkIcon, PhoneIcon } from '@heroicons/react/24/outline';
import { toast } from 'react-toastify';
import { useTranslation } from 'react-i18next';
import { useAuth } from '../../contexts/auth/AuthProvider';
Expand All @@ -41,28 +41,33 @@ export default function RoomCard({ room }) {
toast.success(t('toast.success.room.copied_meeting_url'));
}

function copyVoiceBridge(voiceBridge, voiceBridgePhoneNumber) {
navigator.clipboard.writeText(`Tel.: ${voiceBridgePhoneNumber} Pin: ${voiceBridge}`);
toast.success(t('toast.success.room.copied_voice_bridge'));
}

return (
<Card id="room-card" className="h-100 card-shadow border-0">
<Card.Body className="pb-0" onClick={handleClick}>
<Stack direction="horizontal">
<div className="room-icon rounded">
{ room?.shared_owner
{room?.shared_owner
? <LinkIcon className="hi-m text-brand pt-4 d-block mx-auto" />
: <UserBoardIcon className="hi-m text-brand pt-4 d-block mx-auto" />}
</div>
{ room?.online
{room?.online
&& <MeetingBadges count={room?.participants} />}
</Stack>

<Stack className="my-4">
<Card.Title className="mb-0"> { room.name } </Card.Title>
{ room.shared_owner && (
<Card.Title className="mb-0"> {room.name} </Card.Title>
{room.shared_owner && (
<span className="text-muted">{ t('room.shared_by') } {' '} <strong>{ room.shared_owner }</strong></span>
)}
{ room.last_session ? (
<span className="text-muted"> { t('room.last_session', { localizedTime }) } </span>
{room.last_session ? (
<span className="text-muted"> {t('room.last_session', { localizedTime })} </span>
) : (
<span className="text-muted mt-2"> { t('room.no_last_session') } </span>
<span className="text-muted mt-2"> {t('room.no_last_session')} </span>
)}
</Stack>
</Card.Body>
Expand All @@ -73,9 +78,17 @@ export default function RoomCard({ room }) {
>
<DocumentDuplicateIcon className="hi-m mt-1 text-muted" />
</Button>
{typeof room.voice_bridge_phone_number !== 'undefined' && (
<Button
variant="icon"
onClick={() => copyVoiceBridge(room.voice_bridge, room.voice_bridge_phone_number)}
>
<PhoneIcon className="hi-m mt-1 text-muted" />
</Button>
)}
<Button variant="brand-outline" className="btn btn-md float-end" onClick={startMeeting.mutate} disabled={startMeeting.isLoading}>
{startMeeting.isLoading && <Spinner className="me-2" />}
{ room.online ? (
{room.online ? (
t('join')
) : (
t('start')
Expand All @@ -101,5 +114,7 @@ RoomCard.propTypes = {
shared_owner: PropTypes.string,
online: PropTypes.bool,
participants: PropTypes.number,
voice_bridge: PropTypes.string,
voice_bridge_phone_number: PropTypes.string,
}).isRequired,
};
56 changes: 36 additions & 20 deletions app/javascript/components/rooms/room/Room.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
Stack, Button, Col, Row, Dropdown,
} from 'react-bootstrap';
import { Link, useParams } from 'react-router-dom';
import { HomeIcon, Square2StackIcon } from '@heroicons/react/24/outline';
import { HomeIcon, Square2StackIcon, PhoneIcon } from '@heroicons/react/24/outline';
import { toast } from 'react-toastify';
import { useTranslation } from 'react-i18next';
import { useAuth } from '../../../contexts/auth/AuthProvider';
Expand Down Expand Up @@ -58,6 +58,11 @@ export default function Room() {
}
}

function copyVoiceBridge(voiceBridge, voiceBridgePhoneNumber) {
navigator.clipboard.writeText(`Tel.: ${voiceBridgePhoneNumber} Pin: ${voiceBridge}`);
toast.success(t('toast.success.room.copied_voice_bridge'));
}

return (
<>
<Title>{room?.name}</Title>
Expand All @@ -72,27 +77,27 @@ export default function Room() {
<Row className="py-5">
<Col className="col-4">
{
isRoomLoading
? (
<RoomNamePlaceHolder />
) : (
<Stack className="room-header-wrapper">
<Stack direction="horizontal" gap={2}>
<h1>{room?.name}</h1>
<Stack direction="horizontal" className="mb-1">
{ room?.online
&& <MeetingBadges count={room?.participants} />}
{ room?.shared && <SharedBadge ownerName={room?.owner_name} /> }
</Stack>
isRoomLoading
? (
<RoomNamePlaceHolder />
) : (
<Stack className="room-header-wrapper">
<Stack direction="horizontal" gap={2}>
<h1>{room?.name}</h1>
<Stack direction="horizontal" className="mb-1">
{room?.online
&& <MeetingBadges count={room?.participants} />}
{room?.shared && <SharedBadge ownerName={room?.owner_name} />}
</Stack>
{ room?.last_session ? (
<span className="text-muted"> { t('room.last_session', { localizedTime }) } </span>
) : (
<span className="text-muted"> { t('room.no_last_session') } </span>
)}
</Stack>
)
}
{room?.last_session ? (
<span className="text-muted"> {t('room.last_session', { localizedTime })} </span>
) : (
<span className="text-muted"> {t('room.no_last_session')} </span>
)}
</Stack>
)
}
</Col>
<Col>
<Row>
Expand All @@ -116,6 +121,17 @@ export default function Room() {
<Square2StackIcon className="hi-s me-1" />
{ t('copy') }
</Button>
{!isRoomLoading && typeof room.voice_bridge_phone_number !== 'undefined' && (
<Button
variant="brand-outline"
type="button"
className="btn dropdown-main"
onClick={() => copyVoiceBridge(room?.voice_bridge, room?.voice_bridge_phone_number)}
>
<PhoneIcon className="hi-s me-1" />
{t('copy_voice_bridge')}
</Button>
)}
{ (roomSettings?.data?.glModeratorAccessCode || roomSettings?.data?.glViewerAccessCode) && (
<Dropdown.Toggle
variant="brand-outline"
Expand Down
23 changes: 22 additions & 1 deletion app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Room < ApplicationRecord
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_voice_bridge, on: :create
before_save :scan_presentation_for_virus

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

# Create unique pin for voice brige max 10^x - 10^(x-1) unique ids (x = length of the pin)
# x can be set in the .env to create a larger range for a server with many rooms
# No leading Zeros
def set_voice_bridge
self.voice_bridge = nil

return if Rails.application.config.voice_bridge_phone_number.nil?

pin_len = Rails.application.config.sip_pin_length
max_pins = 10.pow(pin_len) - 10.pow(pin_len - 1) - 1

return if Room.all.where.not(voice_bridge: nil).length >= max_pins # Check if pins are left

# Pick random pin
id = SecureRandom.random_number(10.pow(pin_len) - 1)
# Ensure uniqueness and if not take next free pin
id = ((id + 1) % max_pins) + 10.pow(pin_len - 1) while Room.exists?(voice_bridge: id) || id < 10.pow(pin_len - 1)

self.voice_bridge = id
end

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

Expand Down
7 changes: 7 additions & 0 deletions app/serializers/current_room_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class CurrentRoomSerializer < ApplicationSerializer

attribute :last_session, if: -> { object.last_session }

attribute :voice_bridge, if: -> { Rails.application.config.voice_bridge_phone_number }
attribute :voice_bridge_phone_number, if: -> { Rails.application.config.voice_bridge_phone_number }

def presentation_name
presentation_file_name(object)
end
Expand All @@ -34,4 +37,8 @@ def thumbnail
def owner_name
object.user.name
end

def voice_bridge_phone_number
Rails.application.config.voice_bridge_phone_number
end
end
6 changes: 6 additions & 0 deletions app/serializers/room_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ class RoomSerializer < ApplicationSerializer
attributes :id, :name, :friendly_id, :online, :participants, :last_session

attribute :shared_owner, if: -> { object.shared }
attribute :voice_bridge, if: -> { Rails.application.config.voice_bridge_phone_number }
attribute :voice_bridge_phone_number, if: -> { Rails.application.config.voice_bridge_phone_number }

def shared_owner
object.user.name
end

def voice_bridge_phone_number
Rails.application.config.voice_bridge_phone_number
end
end
3 changes: 2 additions & 1 deletion app/services/meeting_starter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def initialize(room:, base_url:, current_user:, provider:)

def call
# TODO: amir - Check the legitimately of the action.
options = RoomSettingsGetter.new(room_id: @room.id, provider: @room.user.provider, current_user: @current_user, only_bbb_options: true).call
options = RoomSettingsGetter.new(room_id: @room.id, provider: @room.user.provider, current_user: @current_user, only_bbb_options: true,
voice_bridge: @room.voice_bridge).call
viewer_code = RoomSettingsGetter.new(
room_id: @room.id,
provider: @room.user.provider,
Expand Down
11 changes: 10 additions & 1 deletion app/services/room_settings_getter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ class RoomSettingsGetter
# Hash(`<option_name> => {'true' => <Postive>, 'false' => <Negative>})`
SPECIAL_OPTIONS = { 'guestPolicy' => { 'true' => 'ASK_MODERATOR', 'false' => 'ALWAYS_ACCEPT' } }.freeze

def initialize(room_id:, provider:, current_user:, settings: [], show_codes: false, only_enabled: false, only_bbb_options: false)
def initialize(room_id:, provider:, current_user:, settings: [], show_codes: false, only_enabled: false, only_bbb_options: false, voice_bridge: nil)
@current_user = current_user
@room_id = room_id
@only_bbb_options = only_bbb_options # When used only BBB options (not prefixed with 'gl') will be returned.
@only_enabled = only_enabled # When used only optional and force enabled options will be returned.
@show_codes = show_codes # When used access code values will be returned.
@settings = settings # When given only the settings contained in the Array<String> will be returned.
@voice_bridge = voice_bridge

# Fetching only rooms configs that are not optional to overwrite the settings values.
@rooms_configs = MeetingOption.joins(:rooms_configurations)
Expand All @@ -55,6 +56,8 @@ def call
infer_codes(room_settings:, access_codes:) # Access codes should map their forced values as intended.
infer_can_record(room_settings:) if room_settings['record'] && @rooms_configs['record'].nil?

set_voice_brige(room_settings:)

room_settings
end

Expand Down Expand Up @@ -98,4 +101,10 @@ def infer_can_record(room_settings:)

room_settings['record'] = 'false'
end

def set_voice_brige(room_settings:)
return if @voice_bridge.nil?

room_settings['voiceBridge'] = @voice_bridge.to_s
end
end
4 changes: 4 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class Application < Rails::Application
config.relative_url_root = '/' if config.relative_url_root.blank?

I18n.load_path += Dir[Rails.root.join('config/locales/*.{rb,yml}').to_s]

config.voice_bridge_phone_number = ENV.fetch('VOICE_BRIDGE_PHONE_NUMBER', nil)
config.sip_pin_length = ENV.fetch('SIP_PIN_LENGTH', 5)

config.i18n.fallbacks = %i[en]
config.i18n.enforce_available_locales = false

Expand Down
Loading
Loading