From 63ec8a48842fdd930bfc8113eab36c4dcd1c43f0 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 8 Jun 2018 15:02:05 +0100 Subject: [PATCH] Directly access namespace map instead of searching for key --- .../dendrite/clientapi/routing/directory.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 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 d5df2dd2d..e7f4ef2a6 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/directory.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/directory.go @@ -116,14 +116,12 @@ func SetLocalAlias( // Check that the alias does not fall within an exclusive namespace of an // application service for _, appservice := range cfg.Derived.ApplicationServices { - for key, namespaceMaps := range appservice.NamespaceMap { - if key == "aliases" { - for _, namespace := range namespaceMaps { - if namespace.Exclusive && namespace.RegexpObject.MatchString(alias) { - return util.JSONResponse{ - Code: http.StatusBadRequest, - JSON: jsonerror.ASExclusive("Alias is reserved by an application service"), - } + if userNamespaces, ok := appservice.NamespaceMap["users"]; ok { + for _, namespace := range userNamespaces { + if namespace.Exclusive && namespace.RegexpObject.MatchString(alias) { + return util.JSONResponse{ + Code: http.StatusBadRequest, + JSON: jsonerror.ASExclusive("Alias is reserved by an application service"), } } }