fixup treat the sender_localpart as an exclusive namespace of one user (#2255)

Signed-off-by: Nick Cao <nickcao@nichi.co>

Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
This commit is contained in:
Nick Cao 2022-03-24 21:57:00 +08:00 committed by GitHub
parent ad818a4370
commit bb31b25f1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -209,13 +209,14 @@ func setupRegexps(asAPI *AppServiceAPI, derived *Derived) (err error) {
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 // The sender_localpart can be considered an exclusive regex for a single user, so let's do that
// to simplify the code // to simplify the code
var senderUserIDSlice = []string{fmt.Sprintf("@%s:%s", appservice.SenderLocalpart, asAPI.Matrix.ServerName)} users, found := appservice.NamespaceMap["users"]
usersSlice, found := appservice.NamespaceMap["users"]
if !found { if !found {
usersSlice = []ApplicationServiceNamespace{} users = []ApplicationServiceNamespace{}
appservice.NamespaceMap["users"] = usersSlice
} }
appendExclusiveNamespaceRegexs(&senderUserIDSlice, usersSlice) appservice.NamespaceMap["users"] = append(users, ApplicationServiceNamespace{
Exclusive: true,
Regex: regexp.QuoteMeta(fmt.Sprintf("@%s:%s", appservice.SenderLocalpart, asAPI.Matrix.ServerName)),
})
for key, namespaceSlice := range appservice.NamespaceMap { for key, namespaceSlice := range appservice.NamespaceMap {
switch key { switch key {