Add still_working field for status event on soft timeouts

This commit is contained in:
Tulir Asokan 2022-07-01 11:02:35 +03:00
parent bf4c01648f
commit 61f3aa9704
4 changed files with 6 additions and 4 deletions

2
go.mod
View file

@ -15,7 +15,7 @@ require (
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e
google.golang.org/protobuf v1.28.0
maunium.net/go/maulogger/v2 v2.3.2
maunium.net/go/mautrix v0.11.1-0.20220630174618-e98784f2fe26
maunium.net/go/mautrix v0.11.1-0.20220701080156-c1b72fa6aa65
)
require (

4
go.sum
View file

@ -108,5 +108,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.2 h1:1XmIYmMd3PoQfp9J+PaHhpt80zpfmMqaShzUTC7FwY0=
maunium.net/go/maulogger/v2 v2.3.2/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
maunium.net/go/mautrix v0.11.1-0.20220630174618-e98784f2fe26 h1:wkfsp2ozyAQ9Vr9oAXbS9caWLhIffQ/Lxa04t7iUY54=
maunium.net/go/mautrix v0.11.1-0.20220630174618-e98784f2fe26/go.mod h1:Lj4pBam5P0zIvieIFHnGsuaj+xfFtI3y/sC8yGlyna8=
maunium.net/go/mautrix v0.11.1-0.20220701080156-c1b72fa6aa65 h1:AJTuICX//UNA7PEJGIfTsLNg+an1wTBcy+71aZZOaEY=
maunium.net/go/mautrix v0.11.1-0.20220701080156-c1b72fa6aa65/go.mod h1:Lj4pBam5P0zIvieIFHnGsuaj+xfFtI3y/sC8yGlyna8=

View file

@ -24,6 +24,7 @@ import (
"go.mau.fi/whatsmeow"
log "maunium.net/go/maulogger/v2"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/bridge"
"maunium.net/go/mautrix/event"
@ -146,6 +147,7 @@ func (portal *Portal) sendStatusEvent(evtID, lastRetry id.EventID, err error) {
content.Reason = reason
content.IsCertain = &isCertain
content.CanRetry = &canRetry
content.StillWorking = errors.Is(err, errMessageTakingLong)
content.Error = err.Error()
}
_, err = intent.SendMessageEvent(portal.MXID, event.BeeperMessageStatus, &content)

View file

@ -3099,7 +3099,7 @@ func (portal *Portal) HandleMatrixMessage(sender *User, evt *event.Event) {
if portal.bridge.Config.Bridge.MessageHandlingTimeout.ErrorAfter > 0 {
remainingTime := portal.bridge.Config.Bridge.MessageHandlingTimeout.ErrorAfter - messageAge
if remainingTime < 0 {
go ms.sendMessageMetrics(evt, fmt.Errorf("%w (message is %s old)", errTimeoutBeforeHandling, messageAge), "Timeout handling", true)
go ms.sendMessageMetrics(evt, errTimeoutBeforeHandling, "Timeout handling", true)
return
} else if remainingTime < 1*time.Second {
portal.log.Warnfln("Message %s was delayed before reaching the bridge, only have %s (of %s timeout) until delay warning", evt.ID, remainingTime, portal.bridge.Config.Bridge.MessageHandlingTimeout.ErrorAfter)