diff --git a/go/channelling/config.go b/go/channelling/config.go index 162398de..ac9bbaf6 100644 --- a/go/channelling/config.go +++ b/go/channelling/config.go @@ -30,6 +30,7 @@ type Config struct { ContentSecurityPolicyReportOnly string `json:"-"` // HTML content security policy in report only mode RoomTypeDefault string `json:"-"` // New rooms default to this type RoomTypes map[*regexp.Regexp]string `json:"-"` // Map of regular expression -> room type + RoomNameCaseSensitive bool // Wether the room names are case sensitive. } func (config *Config) WithModule(m string) bool { diff --git a/go/channelling/room_manager.go b/go/channelling/room_manager.go index d72a8834..bd6b6e76 100644 --- a/go/channelling/room_manager.go +++ b/go/channelling/room_manager.go @@ -24,6 +24,7 @@ package channelling import ( "fmt" "log" + "strings" "sync" "github.com/nats-io/nats" @@ -63,6 +64,7 @@ type roomManager struct { roomTypes map[string]string globalRoomID string defaultRoomID string + caseSensitive bool } type roomTypeMessage struct { @@ -77,6 +79,7 @@ func NewRoomManager(config *Config, encoder OutgoingEncoder) RoomManager { OutgoingEncoder: encoder, roomTable: make(map[string]RoomWorker), roomTypes: make(map[string]string), + caseSensitive: config.RoomNameCaseSensitive, } if config.GlobalRoomID != "" { rm.globalRoomID = rm.MakeRoomID(config.GlobalRoomID, "") @@ -264,6 +267,9 @@ func (rooms *roomManager) MakeRoomID(roomName, roomType string) string { roomType = rooms.getConfiguredRoomType(roomName) } + if !rooms.caseSensitive { + roomName = strings.ToLower(roomName) + } return fmt.Sprintf("%s:%s", roomType, roomName) } diff --git a/go/channelling/server/config.go b/go/channelling/server/config.go index a602b0ce..3ea94b65 100644 --- a/go/channelling/server/config.go +++ b/go/channelling/server/config.go @@ -144,6 +144,7 @@ func NewConfig(container phoenix.Container, tokens bool) (*channelling.Config, e ContentSecurityPolicyReportOnly: container.GetStringDefault("app", "contentSecurityPolicyReportOnly", ""), RoomTypeDefault: defaultRoomType, RoomTypes: roomTypes, + RoomNameCaseSensitive: container.GetBoolDefault("app", "caseSensitiveRooms", false), }, nil } diff --git a/server.conf.in b/server.conf.in index 04031156..6d4b9bb9 100644 --- a/server.conf.in +++ b/server.conf.in @@ -82,6 +82,9 @@ encryptionSecret = tne-default-encryption-block-key ; all users will join this room if enabled. If it is disabled then a room join ; form will be shown instead. ;defaultRoomEnabled = true +; Whether the room names are case sensitive. If enabled, different casing +; of room names are different rooms. Optional. Defaults to false. +;caseSensitiveRooms = false ; Whether a user account is required to join a room. This only has an effect ; if user accounts are enabled. Optional, defaults to false. ;authorizeRoomJoin = false