Merge remote-tracking branch 'abmantis/double_puppet_server_map'

This commit is contained in:
Tulir Asokan 2021-11-06 13:40:18 +02:00
commit 348b7bfe7b
3 changed files with 15 additions and 1 deletions

View file

@ -92,6 +92,8 @@ type BridgeConfig struct {
Relay RelaybotConfig `yaml:"relay"` Relay RelaybotConfig `yaml:"relay"`
DoublePuppetServerMap map[string]string `yaml:"double_puppet_server_map"`
usernameTemplate *template.Template `yaml:"-"` usernameTemplate *template.Template `yaml:"-"`
displaynameTemplate *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 { if len(puppet.CustomMXID) == 0 {
return nil, ErrNoCustomMXID 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 { if err != nil {
return nil, err return nil, err
} }

View file

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