forked from MirrorHub/mautrix-whatsapp
Implement DoublePuppetServerMap
This commit is contained in:
parent
328633b07a
commit
16dee2aa56
3 changed files with 15 additions and 1 deletions
|
@ -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:"-"`
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue