0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-11-20 08:40:14 +01:00

Treat the sender_localpart as an exclusive namespace of one user (#1790)

This commit is contained in:
Will Hunt 2021-03-05 14:57:42 +00:00 committed by GitHub
parent 1ad96e2e2d
commit fe021d3742
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -197,7 +197,7 @@ func loadAppServices(config *AppServiceAPI, derived *Derived) error {
// setupRegexps will create regex objects for exclusive and non-exclusive // setupRegexps will create regex objects for exclusive and non-exclusive
// usernames, aliases and rooms of all application services, so that other // usernames, aliases and rooms of all application services, so that other
// methods can quickly check if a particular string matches any of them. // 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 // Combine all exclusive namespaces for later string checking
var exclusiveUsernameStrings, exclusiveAliasStrings []string 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 // its contents to the overall exlusive regex string. Room regex
// not necessary as we aren't denying exclusive room ID creation // not necessary as we aren't denying exclusive room ID creation
for _, appservice := range derived.ApplicationServices { 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 { for key, namespaceSlice := range appservice.NamespaceMap {
switch key { switch key {
case "users": case "users":