Re-add support for resend_bridge_info

This commit is contained in:
Tulir Asokan 2022-06-27 11:46:30 +03:00
parent 219265c706
commit 68b0f3d0a4
5 changed files with 16 additions and 25 deletions

View file

@ -153,6 +153,10 @@ func (bc BridgeConfig) GetManagementRoomTexts() bridgeconfig.ManagementRoomTexts
return bc.ManagementRoomText
}
func (bc BridgeConfig) GetResendBridgeInfo() bool {
return bc.ResendBridgeInfo
}
func boolToInt(val bool) int {
if val {
return 1

2
go.mod
View file

@ -15,7 +15,7 @@ require (
golang.org/x/net v0.0.0-20220513224357-95641704303c
google.golang.org/protobuf v1.28.0
maunium.net/go/maulogger/v2 v2.3.2
maunium.net/go/mautrix v0.11.1-0.20220624154909-41327530d7f9
maunium.net/go/mautrix v0.11.1-0.20220627084514-69fba8124313
)
require (

4
go.sum
View file

@ -107,5 +107,5 @@ maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
maunium.net/go/maulogger/v2 v2.3.2 h1:1XmIYmMd3PoQfp9J+PaHhpt80zpfmMqaShzUTC7FwY0=
maunium.net/go/maulogger/v2 v2.3.2/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
maunium.net/go/mautrix v0.11.1-0.20220624154909-41327530d7f9 h1:HUA1EayJMINIPygutVXl9GhMe/Zw4VhaIzNuh1tjgUs=
maunium.net/go/mautrix v0.11.1-0.20220624154909-41327530d7f9/go.mod h1:CiKpMhAx5QZFHK03jpWb0iKI3sGU8x6+LfsOjDrcO8I=
maunium.net/go/mautrix v0.11.1-0.20220627084514-69fba8124313 h1:pYpj5vc8qsNtA4sSIdAZr//jisD6wqDONzTAB4irIAg=
maunium.net/go/mautrix v0.11.1-0.20220627084514-69fba8124313/go.mod h1:CiKpMhAx5QZFHK03jpWb0iKI3sGU8x6+LfsOjDrcO8I=

22
main.go
View file

@ -141,9 +141,6 @@ func (br *WABridge) Start() {
go br.Metrics.Start()
}
if br.Config.Bridge.ResendBridgeInfo {
go br.ResendBridgeInfo()
}
go br.Loop()
}
@ -187,25 +184,6 @@ func (br *WABridge) WarnUsersAboutDisconnection() {
br.usersLock.Unlock()
}
func (br *WABridge) ResendBridgeInfo() {
// FIXME
//if *dontSaveConfig {
// br.Log.Warnln("Not setting resend_bridge_info to false in config due to --no-update flag")
//} else {
// err := config.Mutate(*configPath, func(helper *configupgrade.Helper) {
// helper.Set(configupgrade.Bool, "false", "bridge", "resend_bridge_info")
// })
// if err != nil {
// br.Log.Errorln("Failed to save config after setting resend_bridge_info to false:", err)
// }
//}
//br.Log.Infoln("Re-sending bridge info state event to all portals")
//for _, portal := range br.GetAllPortals() {
// portal.UpdateBridgeInfo()
//}
//br.Log.Infoln("Finished re-sending bridge info state events")
}
func (br *WABridge) StartUsers() {
br.Log.Debugln("Starting users")
foundAnySessions := false

View file

@ -118,6 +118,15 @@ func (br *WABridge) GetAllPortals() []*Portal {
return br.dbPortalsToPortals(br.DB.Portal.GetAll())
}
func (br *WABridge) GetAllIPortals() (iportals []bridge.Portal) {
portals := br.GetAllPortals()
iportals = make([]bridge.Portal, len(portals))
for i, portal := range portals {
iportals[i] = portal
}
return iportals
}
func (br *WABridge) GetAllPortalsByJID(jid types.JID) []*Portal {
return br.dbPortalsToPortals(br.DB.Portal.GetAllByJID(jid))
}