From c2bda58ad6d950f551d2b912e64da354824fa6f0 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 6 Apr 2023 13:44:21 +0300 Subject: [PATCH] Update outgoing edit format --- go.mod | 6 +++--- go.sum | 14 +++++++------- portal.go | 22 +++++++++------------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index 50661fa..4c5cacb 100644 --- a/go.mod +++ b/go.mod @@ -11,12 +11,12 @@ require ( github.com/prometheus/client_golang v1.14.0 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/tidwall/gjson v1.14.4 - go.mau.fi/whatsmeow v0.0.0-20230316102651-f0c131192076 + go.mau.fi/whatsmeow v0.0.0-20230406104207-886f40e6f4f2 golang.org/x/image v0.6.0 golang.org/x/net v0.8.0 google.golang.org/protobuf v1.28.1 maunium.net/go/maulogger/v2 v2.4.1 - maunium.net/go/mautrix v0.15.0 + maunium.net/go/mautrix v0.15.1-0.20230405144343-a47718edca66 ) require ( @@ -38,7 +38,7 @@ require ( github.com/yuin/goldmark v1.5.4 // indirect go.mau.fi/libsignal v0.1.0 // indirect go.mau.fi/zeroconfig v0.1.2 // indirect - golang.org/x/crypto v0.6.0 // indirect + golang.org/x/crypto v0.7.0 // indirect golang.org/x/sys v0.6.0 // indirect golang.org/x/text v0.8.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/go.sum b/go.sum index 9833a53..96f7612 100644 --- a/go.sum +++ b/go.sum @@ -52,7 +52,7 @@ github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= @@ -67,14 +67,14 @@ github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU= github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.mau.fi/libsignal v0.1.0 h1:vAKI/nJ5tMhdzke4cTK1fb0idJzz1JuEIpmjprueC+c= go.mau.fi/libsignal v0.1.0/go.mod h1:R8ovrTezxtUNzCQE5PH30StOQWWeBskBsWE55vMfY9I= -go.mau.fi/whatsmeow v0.0.0-20230316102651-f0c131192076 h1:ph3DJJLtffjUlmspbQXBTk13GvBNFAWhGnT8vQNuBWo= -go.mau.fi/whatsmeow v0.0.0-20230316102651-f0c131192076/go.mod h1:zoTtv1CupGEyTew7TOwnBmTbHB4pVad2OzjTf5CVwa0= +go.mau.fi/whatsmeow v0.0.0-20230406104207-886f40e6f4f2 h1:A5KW5iiMn8e2JOntwbwLTbyaMHBEQYnibaKiOqvba1c= +go.mau.fi/whatsmeow v0.0.0-20230406104207-886f40e6f4f2/go.mod h1:zoTtv1CupGEyTew7TOwnBmTbHB4pVad2OzjTf5CVwa0= go.mau.fi/zeroconfig v0.1.2 h1:DKOydWnhPMn65GbXZOafgkPm11BvFashZWLct0dGFto= go.mau.fi/zeroconfig v0.1.2/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/image v0.6.0 h1:bR8b5okrPI3g/gyZakLZHeWxAR8Dn5CyxXv1hLH5g/4= golang.org/x/image v0.6.0/go.mod h1:MXLdDR43H7cDJq5GEGXEVeeNhPgi+YYEQ2pC1byI1x0= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -134,5 +134,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.4.1 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL8= maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho= -maunium.net/go/mautrix v0.15.0 h1:gkK9HXc1SSPwY7qOAqchzj2xxYqiOYeee8lr28A2g/o= -maunium.net/go/mautrix v0.15.0/go.mod h1:1v8QVDd7q/eJ+eg4sgeOSEafBAFhkt4ab2i97M3IkNQ= +maunium.net/go/mautrix v0.15.1-0.20230405144343-a47718edca66 h1:P+UbO87hsxpY0HyzAS36VmzuEqz/vzhmO0wClaAlxl0= +maunium.net/go/mautrix v0.15.1-0.20230405144343-a47718edca66/go.mod h1:Ei+ijYIMoQ3at2vJrMbEQq/pN2fB3h18clD8PyVyTD0= diff --git a/portal.go b/portal.go index a66afa9..2e72c0c 100644 --- a/portal.go +++ b/portal.go @@ -3969,19 +3969,15 @@ func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, ev if editRootMsg != nil { msg = &waProto.Message{ - EditedMessage: &waProto.FutureProofMessage{ - Message: &waProto.Message{ - ProtocolMessage: &waProto.ProtocolMessage{ - Key: &waProto.MessageKey{ - FromMe: proto.Bool(true), - Id: proto.String(editRootMsg.JID), - RemoteJid: proto.String(portal.Key.JID.String()), - }, - Type: waProto.ProtocolMessage_MESSAGE_EDIT.Enum(), - EditedMessage: msg, - TimestampMs: proto.Int64(evt.Timestamp), - }, + ProtocolMessage: &waProto.ProtocolMessage{ + Key: &waProto.MessageKey{ + FromMe: proto.Bool(true), + Id: proto.String(editRootMsg.JID), + RemoteJid: proto.String(portal.Key.JID.String()), }, + Type: waProto.ProtocolMessage_MESSAGE_EDIT.Enum(), + EditedMessage: msg, + TimestampMs: proto.Int64(evt.Timestamp), }, } } @@ -4075,7 +4071,7 @@ func (portal *Portal) HandleMatrixMessage(sender *User, evt *event.Event, timing dbMsgType := database.MsgNormal if msg.PollCreationMessage != nil || msg.PollCreationMessageV2 != nil { dbMsgType = database.MsgMatrixPoll - } else if msg.EditedMessage == nil { + } else if msg.GetProtocolMessage().GetType() != waProto.ProtocolMessage_MESSAGE_EDIT { portal.MarkDisappearing(nil, origEvtID, time.Duration(portal.ExpirationTime)*time.Second, time.Now()) } else { dbMsgType = database.MsgEdit