Add option to resend bridge info to all portals
This commit is contained in:
parent
8bcf81879d
commit
59e2015fa7
@ -62,6 +62,7 @@ type BridgeConfig struct {
|
||||
|
||||
InviteOwnPuppetForBackfilling bool `yaml:"invite_own_puppet_for_backfilling"`
|
||||
PrivateChatPortalMeta bool `yaml:"private_chat_portal_meta"`
|
||||
ResendBridgeInfo bool `yaml:"resend_bridge_info"`
|
||||
|
||||
WhatsappThumbnail bool `yaml:"whatsapp_thumbnail"`
|
||||
|
||||
|
@ -141,6 +141,10 @@ bridge:
|
||||
# chat portal rooms. This can be useful if the previous field works fine,
|
||||
# but causes room avatar/name bugs.
|
||||
private_chat_portal_meta: false
|
||||
# Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run.
|
||||
# This field will automatically be changed back to false after it,
|
||||
# except if the config file is not writable.
|
||||
resend_bridge_info: false
|
||||
|
||||
# Whether or not thumbnails from WhatsApp should be sent.
|
||||
# They're disabled by default due to very low resolution.
|
||||
|
2
go.mod
2
go.mod
@ -15,7 +15,7 @@ require (
|
||||
gopkg.in/yaml.v2 v2.3.0
|
||||
maunium.net/go/mauflag v1.0.0
|
||||
maunium.net/go/maulogger/v2 v2.1.1
|
||||
maunium.net/go/mautrix v0.5.0-rc.3
|
||||
maunium.net/go/mautrix v0.5.0
|
||||
)
|
||||
|
||||
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.2.8
|
||||
|
2
go.sum
2
go.sum
@ -69,3 +69,5 @@ maunium.net/go/mautrix v0.5.0-rc.2 h1:ohx+dprvMS6Txm+suMx5pbjl0rjDpfftFxgXhx/+Us
|
||||
maunium.net/go/mautrix v0.5.0-rc.2/go.mod h1:LnkFnB1yjCbb8V+upoEHDGvI/F38NHSTWYCe2RRJgSY=
|
||||
maunium.net/go/mautrix v0.5.0-rc.3 h1:ltb6mF6pck1YzEkuC13V4UtSGDIxaq+XqzIdSg7vgMI=
|
||||
maunium.net/go/mautrix v0.5.0-rc.3/go.mod h1:LnkFnB1yjCbb8V+upoEHDGvI/F38NHSTWYCe2RRJgSY=
|
||||
maunium.net/go/mautrix v0.5.0 h1:lEVvdrF5leCon005PDs8yO8VTLgEFZ8lWATaRmwCj0M=
|
||||
maunium.net/go/mautrix v0.5.0/go.mod h1:LnkFnB1yjCbb8V+upoEHDGvI/F38NHSTWYCe2RRJgSY=
|
||||
|
17
main.go
17
main.go
@ -283,6 +283,23 @@ func (bridge *Bridge) Start() {
|
||||
go bridge.Crypto.Start()
|
||||
}
|
||||
go bridge.StartUsers()
|
||||
|
||||
if bridge.Config.Bridge.ResendBridgeInfo {
|
||||
go bridge.ResendBridgeInfo()
|
||||
}
|
||||
}
|
||||
|
||||
func (bridge *Bridge) ResendBridgeInfo() {
|
||||
bridge.Config.Bridge.ResendBridgeInfo = false
|
||||
err := bridge.Config.Save(*configPath)
|
||||
if err != nil {
|
||||
bridge.Log.Errorln("Failed to save config after setting resend_bridge_info to false:", err)
|
||||
}
|
||||
bridge.Log.Infoln("Re-sending bridge info state event to all portals")
|
||||
for _, portal := range bridge.GetAllPortals() {
|
||||
portal.UpdateBridgeInfo()
|
||||
}
|
||||
bridge.Log.Infoln("Finished re-sending bridge info state events")
|
||||
}
|
||||
|
||||
func (bridge *Bridge) LoadRelaybot() {
|
||||
|
@ -835,6 +835,11 @@ func (portal *Portal) getBridgeInfo() (string, event.Content) {
|
||||
}
|
||||
|
||||
func (portal *Portal) UpdateBridgeInfo() {
|
||||
if len(portal.MXID) == 0 {
|
||||
portal.log.Debugln("Not updating bridge info: no Matrix room created")
|
||||
return
|
||||
}
|
||||
portal.log.Debugln("Updating bridge info...")
|
||||
stateKey, content := portal.getBridgeInfo()
|
||||
_, err := portal.MainIntent().SendStateEvent(portal.MXID, StateBridgeInfo, stateKey, content)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user