aboutsummaryrefslogtreecommitdiff
path: root/keyserver/producers
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-07-28 17:38:30 +0100
committerGitHub <noreply@github.com>2020-07-28 17:38:30 +0100
commitadf7b5929401f56bedba92ef778b5e56feefc479 (patch)
treeadb05d580ddffa9aaaf6a6634eed480aee00f7c9 /keyserver/producers
parentacc8e80a51515c953c6710cb24f36fd9d1f7aeb1 (diff)
Persist partition|offset|user_id in the keyserver (#1226)
* Persist partition|offset|user_id in the keyserver Required for a query API which will be used by the syncapi which will be called when a `/sync` request comes in which will return a list of user IDs of people who have changed their device keys between two tokens. * Add tests and fix maxOffset bug * s/offset/log_offset/g because 'offset' is a reserved word in postgres
Diffstat (limited to 'keyserver/producers')
-rw-r--r--keyserver/producers/keychange.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/keyserver/producers/keychange.go b/keyserver/producers/keychange.go
index 6683a936..d59dd200 100644
--- a/keyserver/producers/keychange.go
+++ b/keyserver/producers/keychange.go
@@ -15,10 +15,12 @@
package producers
import (
+ "context"
"encoding/json"
"github.com/Shopify/sarama"
"github.com/matrix-org/dendrite/keyserver/api"
+ "github.com/matrix-org/dendrite/keyserver/storage"
"github.com/sirupsen/logrus"
)
@@ -26,6 +28,7 @@ import (
type KeyChange struct {
Topic string
Producer sarama.SyncProducer
+ DB storage.Database
}
// ProduceKeyChanges creates new change events for each key
@@ -46,6 +49,10 @@ func (p *KeyChange) ProduceKeyChanges(keys []api.DeviceKeys) error {
if err != nil {
return err
}
+ err = p.DB.StoreKeyChange(context.Background(), partition, offset, key.UserID)
+ if err != nil {
+ return err
+ }
logrus.WithFields(logrus.Fields{
"user_id": key.UserID,
"device_id": key.DeviceID,