mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-11-12 04:52:40 +01:00
Add better logs for Matrix redaction handling
This commit is contained in:
parent
0784132649
commit
1ad17048cc
3 changed files with 11 additions and 18 deletions
2
go.mod
2
go.mod
|
@ -8,7 +8,7 @@ require (
|
|||
github.com/mattn/go-sqlite3 v1.14.9
|
||||
github.com/prometheus/client_golang v1.11.0
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
go.mau.fi/whatsmeow v0.0.0-20211027162736-a1c695172891
|
||||
go.mau.fi/whatsmeow v0.0.0-20211027183133-07bcb11ceb48
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
|
||||
google.golang.org/protobuf v1.27.1
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
|
|
4
go.sum
4
go.sum
|
@ -139,8 +139,8 @@ github.com/tidwall/sjson v1.2.3 h1:5+deguEhHSEjmuICXZ21uSSsXotWMA0orU783+Z7Cp8=
|
|||
github.com/tidwall/sjson v1.2.3/go.mod h1:5WdjKx3AQMvCJ4RG6/2UYT7dLrGvJUV1x4jdTAyGvZs=
|
||||
go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2 h1:xpQTMgJGGaF+c8jV/LA/FVXAPJxZbSAGeflOc+Ly6uQ=
|
||||
go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2/go.mod h1:3XlVlwOfp8f9Wri+C1D4ORqgUsN4ZvunJOoPjQMBhos=
|
||||
go.mau.fi/whatsmeow v0.0.0-20211027162736-a1c695172891 h1:QemoafkIJVRrCr8mKA9AUb1ACrTiv0wa7R/VtQV3Xwo=
|
||||
go.mau.fi/whatsmeow v0.0.0-20211027162736-a1c695172891/go.mod h1:ODEmmqeUn9eBDQHFc1S902YA3YFLtmaBujYRRFl53jI=
|
||||
go.mau.fi/whatsmeow v0.0.0-20211027183133-07bcb11ceb48 h1:e4cAP66APziJd8YFAJbYtPtkMJLi4wullnqs87lWZWo=
|
||||
go.mau.fi/whatsmeow v0.0.0-20211027183133-07bcb11ceb48/go.mod h1:ODEmmqeUn9eBDQHFc1S902YA3YFLtmaBujYRRFl53jI=
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
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=
|
||||
|
|
23
portal.go
23
portal.go
|
@ -2435,27 +2435,20 @@ func (portal *Portal) HandleMatrixRedaction(sender *User, evt *event.Event) {
|
|||
}
|
||||
|
||||
msg := portal.bridge.DB.Message.GetByMXID(evt.Redacts)
|
||||
if msg == nil || msg.Sender.User != sender.JID.User {
|
||||
if msg == nil {
|
||||
portal.log.Debugfln("Ignoring redaction %s of unknown event by %s", msg, sender.MXID)
|
||||
return
|
||||
} else if msg.Sender.User != sender.JID.User {
|
||||
portal.log.Debugfln("Ignoring redaction %s of %s/%s by %s: message was sent by someone else (%s, not %s)", evt.ID, msg.MXID, msg.JID, sender.MXID, msg.Sender, sender.JID)
|
||||
return
|
||||
}
|
||||
|
||||
portal.log.Debugfln("Received redaction event %s", evt.ID)
|
||||
info := portal.generateMessageInfo(sender)
|
||||
portal.log.Debugln("Sending redaction", evt.ID, "to WhatsApp", info.ID)
|
||||
err := sender.Client.SendMessage(portal.Key.JID, info.ID, &waProto.Message{
|
||||
ProtocolMessage: &waProto.ProtocolMessage{
|
||||
Type: waProto.ProtocolMessage_REVOKE.Enum(),
|
||||
Key: &waProto.MessageKey{
|
||||
FromMe: proto.Bool(true),
|
||||
Id: proto.String(msg.JID),
|
||||
RemoteJid: proto.String(portal.Key.JID.String()),
|
||||
},
|
||||
},
|
||||
})
|
||||
portal.log.Debugfln("Sending redaction %s of %s/%s to WhatsApp", evt.ID, msg.MXID, msg.JID)
|
||||
err := sender.Client.RevokeMessage(portal.Key.JID, msg.JID)
|
||||
if err != nil {
|
||||
portal.log.Errorfln("Error handling Matrix redaction %s: %v", evt.ID, err)
|
||||
} else {
|
||||
portal.log.Debugln("Handled Matrix redaction %s of %s", evt.ID, evt.Redacts)
|
||||
portal.log.Debugfln("Handled Matrix redaction %s of %s", evt.ID, evt.Redacts)
|
||||
portal.sendDeliveryReceipt(evt.ID)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue