diff --git a/config/config.go b/config/config.go index 78ad457..9cd8cae 100644 --- a/config/config.go +++ b/config/config.go @@ -121,6 +121,7 @@ func (config *Config) MakeAppService() (*appservice.AppService, error) { as.HomeserverURL = config.Homeserver.Address as.Host.Hostname = config.AppService.Hostname as.Host.Port = config.AppService.Port + as.MessageSendCheckpointEndpoint = config.Homeserver.MessageSendCheckpointEndpoint as.DefaultHTTPRetries = 4 var err error as.Registration, err = config.GetRegistration() diff --git a/portal.go b/portal.go index 9cc6e6c..988dbda 100644 --- a/portal.go +++ b/portal.go @@ -43,6 +43,7 @@ import ( "golang.org/x/image/webp" "google.golang.org/protobuf/proto" + "maunium.net/go/mautrix/bridge" "maunium.net/go/mautrix/format" "go.mau.fi/whatsmeow" @@ -2144,8 +2145,14 @@ func (portal *Portal) HandleMatrixMessage(sender *User, evt *event.Event) { if err != nil { portal.log.Errorln("Error sending message: %v", err) portal.sendErrorMessage(err.Error(), true) + checkpoint := bridge.NewErrorMessageSendCheckpoint(evt.ID, evt.RoomID, bridge.StepRemote, evt.Type, err) + checkpoint.MessageType = evt.Content.AsMessage().MsgType + go checkpoint.Send(portal.bridge.Config.Homeserver.MessageSendCheckpointEndpoint, portal.bridge.AS.Registration.AppToken) } else { portal.log.Debugfln("Handled Matrix event %s", evt.ID) + checkpoint := bridge.NewMessageSendCheckpoint(evt.ID, evt.RoomID, bridge.StepRemote, bridge.StatusSuccesss, evt.Type) + checkpoint.MessageType = evt.Content.AsMessage().MsgType + go checkpoint.Send(portal.bridge.Config.Homeserver.MessageSendCheckpointEndpoint, portal.bridge.AS.Registration.AppToken) portal.sendDeliveryReceipt(evt.ID) dbMsg.MarkSent(ts) } @@ -2179,8 +2186,12 @@ func (portal *Portal) HandleMatrixRedaction(sender *User, evt *event.Event) { _, err := sender.Client.RevokeMessage(portal.Key.JID, msg.JID) if err != nil { portal.log.Errorfln("Error handling Matrix redaction %s: %v", evt.ID, err) + checkpoint := bridge.NewErrorMessageSendCheckpoint(evt.ID, evt.RoomID, bridge.StepRemote, evt.Type, err) + go checkpoint.Send(portal.bridge.Config.Homeserver.MessageSendCheckpointEndpoint, portal.bridge.AS.Registration.AppToken) } else { portal.log.Debugfln("Handled Matrix redaction %s of %s", evt.ID, evt.Redacts) + checkpoint := bridge.NewMessageSendCheckpoint(evt.ID, evt.RoomID, bridge.StepRemote, bridge.StatusSuccesss, evt.Type) + go checkpoint.Send(portal.bridge.Config.Homeserver.MessageSendCheckpointEndpoint, portal.bridge.AS.Registration.AppToken) portal.sendDeliveryReceipt(evt.ID) } }