@@ -31,26 +31,27 @@ import (
3131)
3232
3333type Config struct {
34- Title string // Title
35- ver string // Version (not exported to Javascript)
36- S string // Static URL prefix with version
37- B string // Base URL
38- Token string // Server token
39- StunURIs []string // STUN server URIs
40- TurnURIs []string // TURN server URIs
41- Tokens bool // True when we got a tokens file
42- Version string // Server version number
43- UsersEnabled bool // Flag if users are enabled
44- UsersAllowRegistration bool // Flag if users can register
45- UsersMode string // Users mode string
46- DefaultRoomEnabled bool // Flag if default room ("") is enabled
47- Plugin string // Plugin to load
48- AuthorizeRoomCreation bool // Whether a user account is required to create rooms
49- AuthorizeRoomJoin bool // Whether a user account is required to join rooms
50- Modules []string // List of enabled modules
51- globalRoomID string // Id of the global room (not exported to Javascript)
52- contentSecurityPolicy string // HTML content security policy
53- contentSecurityPolicyReportOnly string // HTML content security policy in report only mode
34+ Title string // Title
35+ ver string // Version (not exported to Javascript)
36+ S string // Static URL prefix with version
37+ B string // Base URL
38+ Token string // Server token
39+ StunURIs []string // STUN server URIs
40+ TurnURIs []string // TURN server URIs
41+ Tokens bool // True when we got a tokens file
42+ Version string // Server version number
43+ UsersEnabled bool // Flag if users are enabled
44+ UsersAllowRegistration bool // Flag if users can register
45+ UsersMode string // Users mode string
46+ DefaultRoomEnabled bool // Flag if default room ("") is enabled
47+ Plugin string // Plugin to load
48+ AuthorizeRoomCreation bool // Whether a user account is required to create rooms
49+ AuthorizeRoomJoin bool // Whether a user account is required to join rooms
50+ Modules []string // List of enabled modules
51+ modulesTable map [string ]bool // Map of enabled modules
52+ globalRoomID string // Id of the global room (not exported to Javascript)
53+ contentSecurityPolicy string // HTML content security policy
54+ contentSecurityPolicyReportOnly string // HTML content security policy in report only mode
5455}
5556
5657func NewConfig (container phoenix.Container , tokens bool ) * Config {
@@ -88,11 +89,18 @@ func NewConfig(container phoenix.Container, tokens bool) *Config {
8889 trimAndRemoveDuplicates (& turnURIs )
8990
9091 // Get enabled modules.
91- allModules := []string {"screensharing" , "youtube" , "presentation" }
92- modules := allModules [:0 ]
93- for _ , module := range allModules {
92+ modulesTable := map [string ]bool {
93+ "screensharing" : true ,
94+ "youtube" : true ,
95+ "presentation" : true ,
96+ "contacts" : true ,
97+ }
98+ modules := []string {}
99+ for module , _ := range modulesTable {
94100 if container .GetBoolDefault ("modules" , module , true ) {
95101 modules = append (modules , module )
102+ } else {
103+ modulesTable [module ] = false
96104 }
97105 }
98106 log .Println ("Enabled modules:" , modules )
@@ -115,6 +123,7 @@ func NewConfig(container phoenix.Container, tokens bool) *Config {
115123 AuthorizeRoomCreation : container .GetBoolDefault ("app" , "authorizeRoomCreation" , false ),
116124 AuthorizeRoomJoin : container .GetBoolDefault ("app" , "authorizeRoomJoin" , false ),
117125 Modules : modules ,
126+ modulesTable : modulesTable ,
118127 globalRoomID : container .GetStringDefault ("app" , "globalRoom" , "" ),
119128 contentSecurityPolicy : container .GetStringDefault ("app" , "contentSecurityPolicy" , "" ),
120129 contentSecurityPolicyReportOnly : container .GetStringDefault ("app" , "contentSecurityPolicyReportOnly" , "" ),
@@ -125,6 +134,15 @@ func (config *Config) Get(request *http.Request) (int, interface{}, http.Header)
125134 return 200 , config , http.Header {"Content-Type" : {"application/json; charset=utf-8" }}
126135}
127136
137+ func (config * Config ) WithModule (m string ) bool {
138+
139+ if val , ok := config .modulesTable [m ]; ok && val {
140+ return true
141+ }
142+ return false
143+
144+ }
145+
128146// Helper function to clean up string arrays.
129147func trimAndRemoveDuplicates (data * []string ) {
130148 found := make (map [string ]bool )
0 commit comments