Enable automatically re-requesting undecryptable messages from phone

This commit is contained in:
Tulir Asokan 2023-08-03 16:44:54 +03:00
parent c19b5b18b0
commit 27290b7ebd
4 changed files with 14 additions and 8 deletions

4
go.mod
View file

@ -12,13 +12,13 @@ require (
github.com/rs/zerolog v1.29.1
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/tidwall/gjson v1.14.4
go.mau.fi/whatsmeow v0.0.0-20230802154236-954a5c8cefe0
go.mau.fi/whatsmeow v0.0.0-20230803134242-fe6785536744
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
golang.org/x/image v0.9.0
golang.org/x/net v0.12.0
google.golang.org/protobuf v1.31.0
maunium.net/go/maulogger/v2 v2.4.1
maunium.net/go/mautrix v0.15.5-0.20230728182848-1ef656165098
maunium.net/go/mautrix v0.15.5-0.20230729114956-ff77fa8ec663
)
require (

8
go.sum
View file

@ -68,8 +68,8 @@ 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-20230802154236-954a5c8cefe0 h1:Ukvl6H0a41fkzL7frv1207u3R52quHNe/zVM41Kdyjs=
go.mau.fi/whatsmeow v0.0.0-20230802154236-954a5c8cefe0/go.mod h1:+ObGpFE6cbbY4hKc1FmQH9MVfqaemmlXGXSnwDvCOyE=
go.mau.fi/whatsmeow v0.0.0-20230803134242-fe6785536744 h1:DzsCDn0VqGohyjkztZ9mXqPqSV33ZZ94nSLeK6zZB3I=
go.mau.fi/whatsmeow v0.0.0-20230803134242-fe6785536744/go.mod h1:+ObGpFE6cbbY4hKc1FmQH9MVfqaemmlXGXSnwDvCOyE=
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=
@ -131,5 +131,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.5-0.20230728182848-1ef656165098 h1:1MA35IEVXHzgFnJEcgAoawNcDedRZjXoHdwylhPURLs=
maunium.net/go/mautrix v0.15.5-0.20230728182848-1ef656165098/go.mod h1:dBaDmsnOOBM4a+gKcgefXH73pHGXm+MCJzCs1dXFgrw=
maunium.net/go/mautrix v0.15.5-0.20230729114956-ff77fa8ec663 h1:tsXiuaWnBe9Xa/ms8tUhsJ4x7tPbQJ94fugqBIC0vsw=
maunium.net/go/mautrix v0.15.5-0.20230729114956-ff77fa8ec663/go.mod h1:dBaDmsnOOBM4a+gKcgefXH73pHGXm+MCJzCs1dXFgrw=

View file

@ -746,10 +746,15 @@ func (portal *Portal) handleMessage(source *User, evt *events.Message, historica
existingMsg := portal.bridge.DB.Message.GetByJID(portal.Key, msgID)
if existingMsg != nil {
if existingMsg.Error == database.MsgErrDecryptionFailed {
resolveType := "sender"
if evt.UnavailableRequestID != "" {
resolveType = "phone"
}
Segment.Track(source.MXID, "WhatsApp undecryptable message resolved", map[string]interface{}{
"messageID": evt.Info.ID,
"messageID": evt.Info.ID,
"resolveType": resolveType,
})
portal.log.Debugfln("Got decryptable version of previously undecryptable message %s (%s)", msgID, msgType)
portal.log.Debugfln("Got decryptable version of previously undecryptable message %s (%s) via %s", msgID, msgType, resolveType)
} else {
portal.log.Debugfln("Not handling %s (%s): message is duplicate", msgID, msgType)
return

View file

@ -496,6 +496,7 @@ func (user *User) createClient(sess *store.Device) {
user.Client = whatsmeow.NewClient(sess, &waLogger{user.log.Sub("Client")})
user.Client.AddEventHandler(user.HandleEvent)
user.Client.SetForceActiveDeliveryReceipts(user.bridge.Config.Bridge.ForceActiveDeliveryReceipts)
user.Client.AutomaticMessageRerequestFromPhone = true
user.Client.GetMessageForRetry = func(requester, to types.JID, id types.MessageID) *waProto.Message {
Segment.Track(user.MXID, "WhatsApp incoming retry (message not found)", map[string]interface{}{
"requester": user.obfuscateJID(requester),