forked from MirrorHub/mautrix-whatsapp
Update numbering of retry checkpoints
This commit is contained in:
parent
0106c5ccf2
commit
66371d0faf
3 changed files with 8 additions and 7 deletions
2
go.mod
2
go.mod
|
@ -14,7 +14,7 @@ require (
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||||
maunium.net/go/mauflag v1.0.0
|
maunium.net/go/mauflag v1.0.0
|
||||||
maunium.net/go/maulogger/v2 v2.3.1
|
maunium.net/go/maulogger/v2 v2.3.1
|
||||||
maunium.net/go/mautrix v0.10.5
|
maunium.net/go/mautrix v0.10.6-0.20211206194350-22ee22dccd9f
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -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/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 h1:fwBYJne0pHvJrrIPHK+TAPfyxxbBEz46oVGez2x0ODE=
|
||||||
maunium.net/go/maulogger/v2 v2.3.1/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
|
maunium.net/go/maulogger/v2 v2.3.1/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
|
||||||
maunium.net/go/mautrix v0.10.5 h1:zGHYjyY7dEREYJYPTPemOWFTe3wLXySz6zuJsgVbZ5E=
|
maunium.net/go/mautrix v0.10.6-0.20211206194350-22ee22dccd9f h1:xa2THJban4GMeZ5g6g0vMK/KZ1cmEpVtcIuwyyNTeDU=
|
||||||
maunium.net/go/mautrix v0.10.5/go.mod h1:k4Ng5oci83MEbqPL6KOjPdbU7f8v01KlMjR/zTQ+7mA=
|
maunium.net/go/mautrix v0.10.6-0.20211206194350-22ee22dccd9f/go.mod h1:k4Ng5oci83MEbqPL6KOjPdbU7f8v01KlMjR/zTQ+7mA=
|
||||||
|
|
|
@ -343,10 +343,11 @@ func (mx *MatrixHandler) HandleEncrypted(evt *event.Event) {
|
||||||
if errors.Is(err, NoSessionFound) {
|
if errors.Is(err, NoSessionFound) {
|
||||||
content := evt.Content.AsEncrypted()
|
content := evt.Content.AsEncrypted()
|
||||||
mx.log.Debugfln("Couldn't find session %s trying to decrypt %s, waiting %d seconds...", content.SessionID, evt.ID, int(sessionWaitTimeout.Seconds()))
|
mx.log.Debugfln("Couldn't find session %s trying to decrypt %s, waiting %d seconds...", content.SessionID, evt.ID, int(sessionWaitTimeout.Seconds()))
|
||||||
|
mx.as.SendErrorMessageSendCheckpoint(evt, appservice.StepDecrypted, err, false, decryptionRetryCount)
|
||||||
|
decryptionRetryCount++
|
||||||
if mx.bridge.Crypto.WaitForSession(evt.RoomID, content.SenderKey, content.SessionID, sessionWaitTimeout) {
|
if mx.bridge.Crypto.WaitForSession(evt.RoomID, content.SenderKey, content.SessionID, sessionWaitTimeout) {
|
||||||
mx.log.Debugfln("Got session %s after waiting, trying to decrypt %s again", content.SessionID, evt.ID)
|
mx.log.Debugfln("Got session %s after waiting, trying to decrypt %s again", content.SessionID, evt.ID)
|
||||||
decrypted, err = mx.bridge.Crypto.Decrypt(evt)
|
decrypted, err = mx.bridge.Crypto.Decrypt(evt)
|
||||||
decryptionRetryCount++
|
|
||||||
} else {
|
} else {
|
||||||
mx.as.SendErrorMessageSendCheckpoint(evt, appservice.StepDecrypted, fmt.Errorf("didn't receive encryption keys"), false, decryptionRetryCount)
|
mx.as.SendErrorMessageSendCheckpoint(evt, appservice.StepDecrypted, fmt.Errorf("didn't receive encryption keys"), false, decryptionRetryCount)
|
||||||
go mx.waitLongerForSession(evt)
|
go mx.waitLongerForSession(evt)
|
||||||
|
@ -387,17 +388,17 @@ func (mx *MatrixHandler) waitLongerForSession(evt *event.Event) {
|
||||||
mx.log.Debugfln("Got session %s after waiting more, trying to decrypt %s again", content.SessionID, evt.ID)
|
mx.log.Debugfln("Got session %s after waiting more, trying to decrypt %s again", content.SessionID, evt.ID)
|
||||||
decrypted, err := mx.bridge.Crypto.Decrypt(evt)
|
decrypted, err := mx.bridge.Crypto.Decrypt(evt)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
mx.as.SendMessageSendCheckpoint(decrypted, appservice.StepDecrypted, 1)
|
mx.as.SendMessageSendCheckpoint(decrypted, appservice.StepDecrypted, 2)
|
||||||
mx.bridge.EventProcessor.Dispatch(decrypted)
|
mx.bridge.EventProcessor.Dispatch(decrypted)
|
||||||
_, _ = mx.bridge.Bot.RedactEvent(evt.RoomID, resp.EventID)
|
_, _ = mx.bridge.Bot.RedactEvent(evt.RoomID, resp.EventID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mx.log.Warnfln("Failed to decrypt %s: %v", evt.ID, err)
|
mx.log.Warnfln("Failed to decrypt %s: %v", evt.ID, err)
|
||||||
mx.as.SendErrorMessageSendCheckpoint(evt, appservice.StepDecrypted, err, true, 1)
|
mx.as.SendErrorMessageSendCheckpoint(evt, appservice.StepDecrypted, err, true, 2)
|
||||||
update.Body = fmt.Sprintf("\u26a0 Your message was not bridged: %v", err)
|
update.Body = fmt.Sprintf("\u26a0 Your message was not bridged: %v", err)
|
||||||
} else {
|
} else {
|
||||||
mx.log.Debugfln("Didn't get %s, giving up on %s", content.SessionID, evt.ID)
|
mx.log.Debugfln("Didn't get %s, giving up on %s", content.SessionID, evt.ID)
|
||||||
mx.as.SendErrorMessageSendCheckpoint(evt, appservice.StepDecrypted, fmt.Errorf("didn't receive encryption keys"), true, 1)
|
mx.as.SendErrorMessageSendCheckpoint(evt, appservice.StepDecrypted, fmt.Errorf("didn't receive encryption keys"), true, 2)
|
||||||
update.Body = "\u26a0 Your message was not bridged: the bridge hasn't received the decryption keys. " +
|
update.Body = "\u26a0 Your message was not bridged: the bridge hasn't received the decryption keys. " +
|
||||||
"If this error keeps happening, try restarting your client."
|
"If this error keeps happening, try restarting your client."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue