Ver Fonte

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.
Tulir Asokan há 5 anos atrás
pai
commit
47a1d7f6cb
1 ficheiros alterados com 6 adições e 0 exclusões
  1. 6 0
      config/registration.go

+ 6 - 0
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
 }