Implement DoublePuppetServerMap

This commit is contained in:
abmantis 2021-11-01 23:17:44 +00:00
parent 328633b07a
commit 16dee2aa56
3 changed files with 15 additions and 1 deletions

View file

@ -96,6 +96,8 @@ type BridgeConfig struct {
Relay RelaybotConfig `yaml:"relay"`
DoublePuppetServerMap map[string]string `yaml:"double_puppet_server_map"`
usernameTemplate *template.Template `yaml:"-"`
displaynameTemplate *template.Template `yaml:"-"`
}

View file

@ -84,7 +84,16 @@ func (puppet *Puppet) newCustomIntent() (*appservice.IntentAPI, error) {
if len(puppet.CustomMXID) == 0 {
return nil, ErrNoCustomMXID
}
client, err := mautrix.NewClient(puppet.bridge.AS.HomeserverURL, puppet.CustomMXID, puppet.AccessToken)
_, homeserver, err := puppet.CustomMXID.Parse()
if err != nil {
return nil, err
}
homeserverUrl, found := puppet.bridge.Config.Bridge.DoublePuppetServerMap[homeserver]
if !found {
puppet.log.Debugfln("Homeserver not found in double puppet server map. Using local homeserver")
homeserverUrl = puppet.bridge.AS.HomeserverURL
}
client, err := mautrix.NewClient(homeserverUrl, puppet.CustomMXID, puppet.AccessToken)
if err != nil {
return nil, err
}

View file

@ -219,6 +219,9 @@ bridge:
"example.com": user
"@admin:example.com": admin
double_puppet_server_map:
"matrix.org": https://matrix.org
relay:
# Whether relay mode should be allowed. If allowed, `!wa set-relay` can be used to turn any
# authenticated user into a relaybot for that chat.