Generate AS registrations with bot sync workaround

Looks like synapse isn't going to be fixed soon (matrix-org/synapse#5758),
so this changes all registrations to be generated using the workaround:
the sender_localpart is set to a random string and the actual AS bot is
added as another namespace.
This commit is contained in:
Tulir Asokan 2020-06-11 14:39:19 +03:00
parent 7c799f1faa
commit 47a1d7f6cb

View file

@ -33,6 +33,12 @@ func (config *Config) NewRegistration() (*appservice.Registration, error) {
config.AppService.ASToken = registration.AppToken
config.AppService.HSToken = registration.ServerToken
// Workaround for https://github.com/matrix-org/synapse/pull/5758
registration.SenderLocalpart = appservice.RandomString(32)
botRegex := regexp.MustCompile(fmt.Sprintf("^@%s:%s$", config.AppService.Bot.Username, config.Homeserver.Domain))
registration.Namespaces.RegisterUserIDs(botRegex, true)
return registration, nil
}