소스 검색

Remove extev v2 option

Tulir Asokan 2 년 전
부모
커밋
4b0302d745
4개의 변경된 파일20개의 추가작업 그리고 12개의 파일을 삭제
  1. 1 1
      config/bridge.go
  2. 9 1
      config/upgrade.go
  3. 2 3
      example-config.yaml
  4. 8 7
      portal.go

+ 1 - 1
config/bridge.go

@@ -111,7 +111,7 @@ type BridgeConfig struct {
 	FederateRooms         bool   `yaml:"federate_rooms"`
 	FederateRooms         bool   `yaml:"federate_rooms"`
 	URLPreviews           bool   `yaml:"url_previews"`
 	URLPreviews           bool   `yaml:"url_previews"`
 	CaptionInMessage      bool   `yaml:"caption_in_message"`
 	CaptionInMessage      bool   `yaml:"caption_in_message"`
-	ExtEvPolls            int    `yaml:"extev_polls"`
+	ExtEvPolls            bool   `yaml:"extev_polls"`
 	SendWhatsAppEdits     bool   `yaml:"send_whatsapp_edits"`
 	SendWhatsAppEdits     bool   `yaml:"send_whatsapp_edits"`
 
 
 	MessageHandlingTimeout struct {
 	MessageHandlingTimeout struct {

+ 9 - 1
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", "crash_on_stream_replaced")
 	helper.Copy(up.Bool, "bridge", "url_previews")
 	helper.Copy(up.Bool, "bridge", "url_previews")
 	helper.Copy(up.Bool, "bridge", "caption_in_message")
 	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.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", "error_after")
 	helper.Copy(up.Str|up.Null, "bridge", "message_handling_timeout", "deadline")
 	helper.Copy(up.Str|up.Null, "bridge", "message_handling_timeout", "deadline")

+ 2 - 3
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.
     # 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.
     # This is currently not supported in most clients.
     caption_in_message: false
     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?
     # 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.
     # Official WhatsApp clients don't render edits yet, but once they do, the bridge should work with them right away.
     send_whatsapp_edits: false
     send_whatsapp_edits: false

+ 8 - 7
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 {
 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
 		return nil
 	}
 	}
 	pollMessage := portal.bridge.DB.Message.GetByJID(portal.Key, msg.GetPollCreationMessageKey().GetId())
 	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
 	evtType := TypeMSC3881PollResponse
-	if portal.bridge.Config.Bridge.ExtEvPolls == 2 {
-		evtType = TypeMSC3881V2PollResponse
-	}
+	//if portal.bridge.Config.Bridge.ExtEvPolls == 2 {
+	//	evtType = TypeMSC3881V2PollResponse
+	//}
 	return &ConvertedMessage{
 	return &ConvertedMessage{
 		Intent: intent,
 		Intent: intent,
 		Type:   evtType,
 		Type:   evtType,
@@ -2174,11 +2174,12 @@ func (portal *Portal) convertPollCreationMessage(intent *appservice.IntentAPI, m
 		maxChoices = len(optionNames)
 		maxChoices = len(optionNames)
 	}
 	}
 	evtType := event.EventMessage
 	evtType := event.EventMessage
-	if portal.bridge.Config.Bridge.ExtEvPolls == 1 {
+	if portal.bridge.Config.Bridge.ExtEvPolls {
 		evtType.Type = "org.matrix.msc3381.poll.start"
 		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{
 	return &ConvertedMessage{
 		Intent: intent,
 		Intent: intent,
 		Type:   evtType,
 		Type:   evtType,