diff --git a/config/config.go b/config/config.go index f2bf82f..8b4d822 100644 --- a/config/config.go +++ b/config/config.go @@ -73,6 +73,8 @@ type Config struct { WhatsApp struct { OSName string `yaml:"os_name"` BrowserName string `yaml:"browser_name"` + + DebugDecodeBeforeSend bool `yaml:"debug_decode_before_send"` } `yaml:"whatsapp"` Bridge BridgeConfig `yaml:"bridge"` diff --git a/config/upgrade.go b/config/upgrade.go index ad151d2..0b4bedd 100644 --- a/config/upgrade.go +++ b/config/upgrade.go @@ -69,6 +69,7 @@ func (helper *UpgradeHelper) doUpgrade() { helper.Copy(Str, "whatsapp", "os_name") helper.Copy(Str, "whatsapp", "browser_name") + helper.Copy(Bool, "whatsapp", "debug_decode_before_send") helper.Copy(Str, "bridge", "username_template") helper.Copy(Str, "bridge", "displayname_template") diff --git a/example-config.yaml b/example-config.yaml index 359060c..beb58aa 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -91,6 +91,8 @@ whatsapp: # Must be "unknown" for a generic icon or a valid browser name if you want a specific icon. # List of valid browser names: https://github.com/tulir/whatsmeow/blob/8b34d886d543b72e5f4699cf5b2797f68d598f78/binary/proto/def.proto#L38-L51 browser_name: unknown + # Decode outgoing binary XML payloads to try to make sure they're valid before sending to WhatsApp. + debug_decode_before_send: false # Bridge config bridge: diff --git a/go.mod b/go.mod index a2f7ec2..21195d5 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/prometheus/client_golang v1.11.1 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/tidwall/gjson v1.14.0 - go.mau.fi/whatsmeow v0.0.0-20220425070941-bf3901f10cd9 + go.mau.fi/whatsmeow v0.0.0-20220425142103-46b439456742 golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 golang.org/x/net v0.0.0-20220412020605-290c469a71a5 google.golang.org/protobuf v1.28.0 diff --git a/go.sum b/go.sum index 337bcf6..2bf79f7 100644 --- a/go.sum +++ b/go.sum @@ -120,8 +120,8 @@ github.com/yuin/goldmark v1.4.11 h1:i45YIzqLnUc2tGaTlJCyUxSG8TvgyGqhqOZOUKIjJ6w= github.com/yuin/goldmark v1.4.11/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg= go.mau.fi/libsignal v0.0.0-20220425070825-c40c839ee6a0 h1:3IQF2bgAyibdo77hTejwuJe4jlypj9QaE4xCQuxrThM= go.mau.fi/libsignal v0.0.0-20220425070825-c40c839ee6a0/go.mod h1:kBOXTvYyDG/q1Ihgvd4J6WenGPh7wtEGvPKF6vmf5ak= -go.mau.fi/whatsmeow v0.0.0-20220425070941-bf3901f10cd9 h1:qvADKrQ2RzizRJh4R39h6bHedKCbOrI38JuGE+Ec6xI= -go.mau.fi/whatsmeow v0.0.0-20220425070941-bf3901f10cd9/go.mod h1:iUBgOLNaqShLrR17u0kIiRptIGFH+nbT1tRhaWBEX/c= +go.mau.fi/whatsmeow v0.0.0-20220425142103-46b439456742 h1:0DFoHvUhQJf+X8pzgXFvCaEfv/nxO0yb2fn5JpCovjY= +go.mau.fi/whatsmeow v0.0.0-20220425142103-46b439456742/go.mod h1:iUBgOLNaqShLrR17u0kIiRptIGFH+nbT1tRhaWBEX/c= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= diff --git a/user.go b/user.go index 2ef1e2d..b7952e6 100644 --- a/user.go +++ b/user.go @@ -333,6 +333,7 @@ var ErrAlreadyLoggedIn = errors.New("already logged in") func (user *User) createClient(sess *store.Device) { user.Client = whatsmeow.NewClient(sess, &waLogger{user.log.Sub("Client")}) + user.Client.DebugDecodeBeforeSend = user.bridge.Config.WhatsApp.DebugDecodeBeforeSend user.Client.AddEventHandler(user.HandleEvent) user.Client.SetForceActiveDeliveryReceipts(user.bridge.Config.Bridge.ForceActiveDeliveryReceipts) user.Client.GetMessageForRetry = func(to types.JID, id types.MessageID) *waProto.Message {