From 385cab8dc95dc1681c3be3dc2b52ddc46fe3cc21 Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Fri, 6 Jul 2018 03:29:15 -0700 Subject: [PATCH] Actually check if alias is reserved (#534) --- .../matrix-org/dendrite/clientapi/routing/directory.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/clientapi/routing/directory.go b/src/github.com/matrix-org/dendrite/clientapi/routing/directory.go index e7f4ef2a6..6f5765f4b 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/directory.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/directory.go @@ -115,9 +115,12 @@ func SetLocalAlias( // Check that the alias does not fall within an exclusive namespace of an // application service + // TODO: This code should eventually be refactored with: + // 1. The new method for checking for things matching an AS's namespace + // 2. Using an overall Regex object for all AS's just like we did for usernames for _, appservice := range cfg.Derived.ApplicationServices { - if userNamespaces, ok := appservice.NamespaceMap["users"]; ok { - for _, namespace := range userNamespaces { + if aliasNamespaces, ok := appservice.NamespaceMap["aliases"]; ok { + for _, namespace := range aliasNamespaces { if namespace.Exclusive && namespace.RegexpObject.MatchString(alias) { return util.JSONResponse{ Code: http.StatusBadRequest,