Move message_send_checkpoint to appservice package

This commit is contained in:
Sumner Evans 2021-11-17 13:37:05 -07:00
commit ff483f33aa
No known key found for this signature in database
GPG key ID: 8904527AB50022FD
2 changed files with 7 additions and 9 deletions

View file

@ -18,7 +18,6 @@ import (
"github.com/gorilla/mux"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/bridge"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/id"
)
@ -218,17 +217,17 @@ func (as *AppService) sendMessageSendCheckpoint(evt *event.Event) error {
return nil
}
if _, ok := bridge.GetCheckpointTypes()[evt.Type]; !ok {
if _, ok := GetCheckpointTypes()[evt.Type]; !ok {
return nil
}
as.Log.Debugfln("Sending message send checkpoint for %s to API server", evt.ID)
checkpoint := bridge.NewMessageSendCheckpoint(evt.ID, evt.RoomID, bridge.StepBridge, bridge.StatusSuccesss, evt.Type)
checkpoint := NewMessageSendCheckpoint(evt.ID, evt.RoomID, StepBridge, StatusSuccesss, evt.Type)
if evt.Type == event.EventMessage {
checkpoint.MessageType = evt.Content.AsMessage().MsgType
}
return checkpoint.Send(endpoint, as.Registration.AppToken)
return checkpoint.Send(as)
}
// GetRoom handles a /rooms GET call from the homeserver.

View file

@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package bridge
package appservice
import (
"bytes"
@ -16,7 +16,6 @@ import (
"time"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/appservice"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/id"
)
@ -94,7 +93,7 @@ func GetCheckpointTypes() map[event.Type]interface{} {
}
}
func (cp *MessageSendCheckpoint) Send(as *appservice.AppService) error {
func (cp *MessageSendCheckpoint) Send(as *AppService) error {
return SendCheckpoints(as, []*MessageSendCheckpoint{cp})
}
@ -102,11 +101,11 @@ type CheckpointsJSON struct {
Checkpoints []*MessageSendCheckpoint `json:"checkpoints"`
}
func SendCheckpoints(as *appservice.AppService, checkpoints []*MessageSendCheckpoint) error {
func SendCheckpoints(as *AppService, checkpoints []*MessageSendCheckpoint) error {
checkpointsJSON := CheckpointsJSON{Checkpoints: checkpoints}
if as.HasWebsocket() {
return as.SendWebsocket(&appservice.WebsocketRequest{
return as.SendWebsocket(&WebsocketRequest{
Command: "message_checkpoint",
Data: checkpointsJSON,
})