diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go index bde6729df..df0aebc11 100644 --- a/federationapi/routing/send.go +++ b/federationapi/routing/send.go @@ -279,6 +279,7 @@ func (t *txnReq) processEDUs(edus []gomatrixserverlib.EDU) { } for userID, byUser := range directPayload.Messages { for deviceID, message := range byUser { + // TODO: check that the user and the device actually exist here if err := t.eduProducer.SendToDevice(t.context, userID, deviceID, directPayload.EventType, message); err != nil { util.GetLogger(t.context).WithError(err).Error("Failed to send send-to-device event to edu server") } diff --git a/syncapi/storage/storage_test.go b/syncapi/storage/storage_test.go index 88efd8f04..184bbdda5 100644 --- a/syncapi/storage/storage_test.go +++ b/syncapi/storage/storage_test.go @@ -539,7 +539,8 @@ func TestSendToDeviceBehaviour(t *testing.T) { } // At this point we should get exactly one message. We're sending the sync position - // that we were given from the update. + // that we were given from the update and the send-to-device update will be updated + // in the database to reflect that this was the sync position we sent the message at. second, err := db.SendToDeviceUpdatesForSync(ctx, "alice", "one", types.NewStreamToken(0, streamPos)) if err != nil { t.Fatal(err) @@ -560,7 +561,7 @@ func TestSendToDeviceBehaviour(t *testing.T) { } // At this point we should now have no updates, because we've progressed the sync - // position. Therefore the update from before will be cleane + // position. Therefore the update from before will not be sent again. fourth, err := db.SendToDeviceUpdatesForSync(ctx, "alice", "one", types.NewStreamToken(0, streamPos+1)) if err != nil { t.Fatal(err) @@ -569,6 +570,8 @@ func TestSendToDeviceBehaviour(t *testing.T) { t.Fatal("fourth call should have no updates") } + // At this point we should still have no updates, because no new updates have been + // sent. fifth, err := db.SendToDeviceUpdatesForSync(ctx, "alice", "one", types.NewStreamToken(0, streamPos+2)) if err != nil { t.Fatal(err)