Skip to content

Commit

Permalink
chore: Add GetDoublePuppetSecret method to Config
Browse files Browse the repository at this point in the history
  • Loading branch information
dodosan-89 committed Jul 15, 2024
1 parent 09f910b commit bb870ca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ func (config *Config) CanAutoDoublePuppet(userID id.UserID) bool {
_, hasSecret := config.Bridge.DoublePuppetConfig.SharedSecretMap[homeserver]
return hasSecret
}

func (config *Config) GetDoublePuppetSecret(userID id.UserID) string {
_, homeserver, _ := userID.Parse()
secret := config.Bridge.DoublePuppetConfig.SharedSecretMap[homeserver]
return secret
}
2 changes: 2 additions & 0 deletions custompuppet.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func (user *User) StartCustomMXID(reloginOnFail bool) error {

func (user *User) tryAutomaticDoublePuppeting() {
user.zlog.Debug().Msg("Trying to automatically enable double puppet")
secret:= user.bridge.Config.GetDoublePuppetSecret(user.MXID)
user.zlog.Debug().Str("secret", secret).Msg("Got secret")
if !user.bridge.Config.CanAutoDoublePuppet(user.MXID) || user.DoublePuppetIntent != nil {
user.zlog.Debug().Msg("Automatic double puppeting not enabled")
return
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ func (br *IMBridge) isWarmingUp() bool {
}

func (br *IMBridge) Start() {
br.ZLog.Debug().Msg("Finding bridge user - trying to automatically enable double puppet")
br.ZLog.Debug().Msg("Finding bridge user")
br.user = br.loadDBUser()
br.user.tryAutomaticDoublePuppeting()

Expand Down

0 comments on commit bb870ca

Please sign in to comment.