aboutsummaryrefslogtreecommitdiff
path: root/setup/config
diff options
context:
space:
mode:
authorWill Hunt <will@half-shot.uk>2021-03-05 14:57:42 +0000
committerGitHub <noreply@github.com>2021-03-05 14:57:42 +0000
commitfe021d374256324cc5394599fc9e018caeadc5bb (patch)
tree064ba340f149518dc8dada05d34e128c175b12d8 /setup/config
parent1ad96e2e2df9dc1f5fa7d31522babd6a64ca517f (diff)
Treat the sender_localpart as an exclusive namespace of one user (#1790)
Diffstat (limited to 'setup/config')
-rw-r--r--setup/config/config_appservice.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/setup/config/config_appservice.go b/setup/config/config_appservice.go
index a6f77abf..724f035f 100644
--- a/setup/config/config_appservice.go
+++ b/setup/config/config_appservice.go
@@ -197,7 +197,7 @@ func loadAppServices(config *AppServiceAPI, derived *Derived) error {
// setupRegexps will create regex objects for exclusive and non-exclusive
// usernames, aliases and rooms of all application services, so that other
// methods can quickly check if a particular string matches any of them.
-func setupRegexps(_ *AppServiceAPI, derived *Derived) (err error) {
+func setupRegexps(asAPI *AppServiceAPI, derived *Derived) (err error) {
// Combine all exclusive namespaces for later string checking
var exclusiveUsernameStrings, exclusiveAliasStrings []string
@@ -205,6 +205,16 @@ func setupRegexps(_ *AppServiceAPI, derived *Derived) (err error) {
// its contents to the overall exlusive regex string. Room regex
// not necessary as we aren't denying exclusive room ID creation
for _, appservice := range derived.ApplicationServices {
+ // The sender_localpart can be considered an exclusive regex for a single user, so let's do that
+ // to simplify the code
+ var senderUserIDSlice = []string{fmt.Sprintf("@%s:%s", appservice.SenderLocalpart, asAPI.Matrix.ServerName)}
+ usersSlice, found := appservice.NamespaceMap["users"]
+ if !found {
+ usersSlice = []ApplicationServiceNamespace{}
+ appservice.NamespaceMap["users"] = usersSlice
+ }
+ appendExclusiveNamespaceRegexs(&senderUserIDSlice, usersSlice)
+
for key, namespaceSlice := range appservice.NamespaceMap {
switch key {
case "users":