From 47a1d7f6cb37051bb249e2ac592ee1557605ebd8 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 11 Jun 2020 14:39:19 +0300 Subject: [PATCH] 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. --- config/registration.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/registration.go b/config/registration.go index 0524200..8763b67 100644 --- a/config/registration.go +++ b/config/registration.go @@ -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 }