Merge pull request #408 from mautrix/double-puppeting-key-for-redactions

double puppeting: add flag to redaction events
This commit is contained in:
Sumner Evans 2021-12-16 09:21:03 -07:00 committed by GitHub
commit cb3a9a381c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

2
go.mod
View file

@ -14,7 +14,7 @@ require (
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
maunium.net/go/mauflag v1.0.0
maunium.net/go/maulogger/v2 v2.3.1
maunium.net/go/mautrix v0.10.6-0.20211206194350-22ee22dccd9f
maunium.net/go/mautrix v0.10.7-0.20211216152136-eead69535244
)
require (

4
go.sum
View file

@ -221,5 +221,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.3.1 h1:fwBYJne0pHvJrrIPHK+TAPfyxxbBEz46oVGez2x0ODE=
maunium.net/go/maulogger/v2 v2.3.1/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
maunium.net/go/mautrix v0.10.6-0.20211206194350-22ee22dccd9f h1:xa2THJban4GMeZ5g6g0vMK/KZ1cmEpVtcIuwyyNTeDU=
maunium.net/go/mautrix v0.10.6-0.20211206194350-22ee22dccd9f/go.mod h1:k4Ng5oci83MEbqPL6KOjPdbU7f8v01KlMjR/zTQ+7mA=
maunium.net/go/mautrix v0.10.7-0.20211216152136-eead69535244 h1:T5kmB+OjrLkcZ8VQYTgHNQ7FllFsr6klb/JtOrldUhs=
maunium.net/go/mautrix v0.10.7-0.20211216152136-eead69535244/go.mod h1:k4Ng5oci83MEbqPL6KOjPdbU7f8v01KlMjR/zTQ+7mA=

View file

@ -1236,10 +1236,14 @@ func (portal *Portal) HandleMessageRevoke(user *User, info *types.MessageInfo, k
return false
}
intent := portal.bridge.GetPuppetByJID(info.Sender).IntentFor(portal)
_, err := intent.RedactEvent(portal.MXID, msg.MXID)
redactionReq := mautrix.ReqRedact{Extra: map[string]interface{}{}}
if intent.IsCustomPuppet {
redactionReq.Extra[doublePuppetKey] = doublePuppetValue
}
_, err := intent.RedactEvent(portal.MXID, msg.MXID, redactionReq)
if err != nil {
if errors.Is(err, mautrix.MForbidden) {
_, err = portal.MainIntent().RedactEvent(portal.MXID, msg.MXID)
_, err = portal.MainIntent().RedactEvent(portal.MXID, msg.MXID, redactionReq)
if err != nil {
portal.log.Errorln("Failed to redact %s: %v", msg.JID, err)
}