|
@@ -17,6 +17,7 @@
|
|
package config
|
|
package config
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "errors"
|
|
"fmt"
|
|
"fmt"
|
|
"strings"
|
|
"strings"
|
|
"text/template"
|
|
"text/template"
|
|
@@ -144,6 +145,24 @@ func (bc BridgeConfig) GetManagementRoomTexts() bridgeconfig.ManagementRoomTexts
|
|
return bc.ManagementRoomText
|
|
return bc.ManagementRoomText
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func boolToInt(val bool) int {
|
|
|
|
+ if val {
|
|
|
|
+ return 1
|
|
|
|
+ }
|
|
|
|
+ return 0
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (bc BridgeConfig) Validate() error {
|
|
|
|
+ _, hasWildcard := bc.Permissions["*"]
|
|
|
|
+ _, hasExampleDomain := bc.Permissions["example.com"]
|
|
|
|
+ _, hasExampleUser := bc.Permissions["@admin:example.com"]
|
|
|
|
+ exampleLen := boolToInt(hasWildcard) + boolToInt(hasExampleUser) + boolToInt(hasExampleDomain)
|
|
|
|
+ if len(bc.Permissions) <= exampleLen {
|
|
|
|
+ return errors.New("bridge.permissions not configured")
|
|
|
|
+ }
|
|
|
|
+ return nil
|
|
|
|
+}
|
|
|
|
+
|
|
type umBridgeConfig BridgeConfig
|
|
type umBridgeConfig BridgeConfig
|
|
|
|
|
|
func (bc *BridgeConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
func (bc *BridgeConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|