diff options
author | Alex Chen <Cnly@users.noreply.github.com> | 2019-07-12 21:36:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-12 21:36:17 +0800 |
commit | f8463063ac4f45e61dfd0b27647bf00a8d05daa1 (patch) | |
tree | 059861610bc6d1d284c8c0c1823455b3572e46ea /clientapi/routing/directory.go | |
parent | 7edf197eccc89cb7368ed31df47c9d15f24d0923 (diff) |
Fix #661 appservice can't set aliases in its own namespace (#731)
Fixes #661.
Diffstat (limited to 'clientapi/routing/directory.go')
-rw-r--r-- | clientapi/routing/directory.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/clientapi/routing/directory.go b/clientapi/routing/directory.go index b23dfbfb..ab85e86a 100644 --- a/clientapi/routing/directory.go +++ b/clientapi/routing/directory.go @@ -117,12 +117,16 @@ func SetLocalAlias( // 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 aliasNamespaces, ok := appservice.NamespaceMap["aliases"]; ok { - for _, namespace := range aliasNamespaces { - if namespace.Exclusive && namespace.RegexpObject.MatchString(alias) { - return util.JSONResponse{ - Code: http.StatusBadRequest, - JSON: jsonerror.ASExclusive("Alias is reserved by an application service"), + // Don't prevent AS from creating aliases in its own namespace + // Note that Dendrite uses SenderLocalpart as UserID for AS users + if device.UserID != appservice.SenderLocalpart { + if aliasNamespaces, ok := appservice.NamespaceMap["aliases"]; ok { + for _, namespace := range aliasNamespaces { + if namespace.Exclusive && namespace.RegexpObject.MatchString(alias) { + return util.JSONResponse{ + Code: http.StatusBadRequest, + JSON: jsonerror.ASExclusive("Alias is reserved by an application service"), + } } } } |