mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-23 22:14:06 +01:00
portal: send checkpoint for matrix messages
This commit is contained in:
parent
712dc5a7b6
commit
52f09001a7
2 changed files with 12 additions and 0 deletions
|
@ -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()
|
||||
|
|
11
portal.go
11
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue