diff --git a/appservice/eventprocessor.go b/appservice/eventprocessor.go index f4488f65..437d8536 100644 --- a/appservice/eventprocessor.go +++ b/appservice/eventprocessor.go @@ -24,9 +24,9 @@ const ( Sync ) -type EventHandler func(evt *event.Event) -type OTKHandler func(otk *mautrix.OTKCount) -type DeviceListHandler func(otk *mautrix.DeviceLists, since string) +type EventHandler = func(evt *event.Event) +type OTKHandler = func(otk *mautrix.OTKCount) +type DeviceListHandler = func(lists *mautrix.DeviceLists, since string) type EventProcessor struct { ExecMode ExecMode diff --git a/crypto/machine.go b/crypto/machine.go index 838c2e89..c0f8eacb 100644 --- a/crypto/machine.go +++ b/crypto/machine.go @@ -15,7 +15,6 @@ import ( "github.com/rs/zerolog" - "maunium.net/go/mautrix/appservice" "maunium.net/go/mautrix/crypto/ssss" "maunium.net/go/mautrix/id" @@ -181,7 +180,13 @@ func (mach *OlmMachine) OwnIdentity() *id.Device { } } -func (mach *OlmMachine) AddAppserviceListener(ep *appservice.EventProcessor) { +type asEventProcessor interface { + On(evtType event.Type, handler func(evt *event.Event)) + OnOTK(func(otk *mautrix.OTKCount)) + OnDeviceList(func(lists *mautrix.DeviceLists, since string)) +} + +func (mach *OlmMachine) AddAppserviceListener(ep asEventProcessor) { // ToDeviceForwardedRoomKey and ToDeviceRoomKey should only be present inside encrypted to-device events ep.On(event.ToDeviceEncrypted, mach.HandleToDeviceEvent) ep.On(event.ToDeviceRoomKeyRequest, mach.HandleToDeviceEvent)