From 4b0302d745db6b6951cdf8083f39e256987136e0 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 26 Nov 2022 18:53:08 +0200 Subject: [PATCH] Remove extev v2 option --- config/bridge.go | 2 +- config/upgrade.go | 10 +++++++++- example-config.yaml | 5 ++--- portal.go | 15 ++++++++------- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/config/bridge.go b/config/bridge.go index 7e5a06f..1ece1ed 100644 --- a/config/bridge.go +++ b/config/bridge.go @@ -111,7 +111,7 @@ type BridgeConfig struct { FederateRooms bool `yaml:"federate_rooms"` URLPreviews bool `yaml:"url_previews"` CaptionInMessage bool `yaml:"caption_in_message"` - ExtEvPolls int `yaml:"extev_polls"` + ExtEvPolls bool `yaml:"extev_polls"` SendWhatsAppEdits bool `yaml:"send_whatsapp_edits"` MessageHandlingTimeout struct { diff --git a/config/upgrade.go b/config/upgrade.go index 9d104fb..a465cfa 100644 --- a/config/upgrade.go +++ b/config/upgrade.go @@ -94,7 +94,15 @@ func DoUpgrade(helper *up.Helper) { helper.Copy(up.Bool, "bridge", "crash_on_stream_replaced") helper.Copy(up.Bool, "bridge", "url_previews") helper.Copy(up.Bool, "bridge", "caption_in_message") - helper.Copy(up.Int, "bridge", "extev_polls") + if intPolls, ok := helper.Get(up.Int, "bridge", "extev_polls"); ok { + val := "false" + if intPolls != "0" { + val = "true" + } + helper.Set(up.Bool, val, "bridge", "extev_polls") + } else { + helper.Copy(up.Bool, "bridge", "extev_polls") + } helper.Copy(up.Bool, "bridge", "send_whatsapp_edits") helper.Copy(up.Str|up.Null, "bridge", "message_handling_timeout", "error_after") helper.Copy(up.Str|up.Null, "bridge", "message_handling_timeout", "deadline") diff --git a/example-config.yaml b/example-config.yaml index a6d7261..c8fc90c 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -299,9 +299,8 @@ bridge: # Send captions in the same message as images. This will send data compatible with both MSC2530 and MSC3552. # This is currently not supported in most clients. caption_in_message: false - # Should polls be sent using MSC3381 event types? This should either be 1 for original polls MSC, - # 2 for the updated MSC as of November 2022, or 0 to use legacy m.room.message (which doesn't support voting). - extev_polls: 0 + # Should polls be sent using MSC3381 event types? + extev_polls: false # Should Matrix edits be bridged to WhatsApp edits? # Official WhatsApp clients don't render edits yet, but once they do, the bridge should work with them right away. send_whatsapp_edits: false diff --git a/portal.go b/portal.go index e139625..260123f 100644 --- a/portal.go +++ b/portal.go @@ -2101,7 +2101,7 @@ func (portal *Portal) convertListResponseMessage(intent *appservice.IntentAPI, m } func (portal *Portal) convertPollUpdateMessage(intent *appservice.IntentAPI, source *User, info *types.MessageInfo, msg *waProto.PollUpdateMessage) *ConvertedMessage { - if portal.bridge.Config.Bridge.ExtEvPolls == 0 { + if !portal.bridge.Config.Bridge.ExtEvPolls { return nil } pollMessage := portal.bridge.DB.Message.GetByJID(portal.Key, msg.GetPollCreationMessageKey().GetId()) @@ -2123,9 +2123,9 @@ func (portal *Portal) convertPollUpdateMessage(intent *appservice.IntentAPI, sou } evtType := TypeMSC3881PollResponse - if portal.bridge.Config.Bridge.ExtEvPolls == 2 { - evtType = TypeMSC3881V2PollResponse - } + //if portal.bridge.Config.Bridge.ExtEvPolls == 2 { + // evtType = TypeMSC3881V2PollResponse + //} return &ConvertedMessage{ Intent: intent, Type: evtType, @@ -2174,11 +2174,12 @@ func (portal *Portal) convertPollCreationMessage(intent *appservice.IntentAPI, m maxChoices = len(optionNames) } evtType := event.EventMessage - if portal.bridge.Config.Bridge.ExtEvPolls == 1 { + if portal.bridge.Config.Bridge.ExtEvPolls { evtType.Type = "org.matrix.msc3381.poll.start" - } else if portal.bridge.Config.Bridge.ExtEvPolls == 2 { - evtType.Type = "org.matrix.msc3381.v2.poll.start" } + //else if portal.bridge.Config.Bridge.ExtEvPolls == 2 { + // evtType.Type = "org.matrix.msc3381.v2.poll.start" + //} return &ConvertedMessage{ Intent: intent, Type: evtType,