aboutsummaryrefslogtreecommitdiff
path: root/keyserver/api
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-08-03 17:07:06 +0100
committerGitHub <noreply@github.com>2020-08-03 17:07:06 +0100
commitfb56bbf0b7d4b21da3f55b066e71d24bf4599887 (patch)
tree707e8051385e92c176f2c99cb3d03607724b8309 /keyserver/api
parentffcb6d2ea199cfa985e72ffbdcb884fb9bc9f54d (diff)
Generate stream IDs for locally uploaded device keys (#1236)
* Breaking: add stream_id to keyserver_device_keys table * Add tests for stream ID generation * Fix whitelist
Diffstat (limited to 'keyserver/api')
-rw-r--r--keyserver/api/api.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/keyserver/api/api.go b/keyserver/api/api.go
index eb2f9e24..080d0e5f 100644
--- a/keyserver/api/api.go
+++ b/keyserver/api/api.go
@@ -43,6 +43,13 @@ func (k *KeyError) Error() string {
return k.Err
}
+// DeviceMessage represents the message produced into Kafka by the key server.
+type DeviceMessage struct {
+ DeviceKeys
+ // A monotonically increasing number which represents device changes for this user.
+ StreamID int
+}
+
// DeviceKeys represents a set of device keys for a single device
// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-upload
type DeviceKeys struct {
@@ -50,10 +57,20 @@ type DeviceKeys struct {
UserID string
// The device ID of this device
DeviceID string
+ // The device display name
+ DisplayName string
// The raw device key JSON
KeyJSON []byte
}
+// WithStreamID returns a copy of this device message with the given stream ID
+func (k *DeviceKeys) WithStreamID(streamID int) DeviceMessage {
+ return DeviceMessage{
+ DeviceKeys: *k,
+ StreamID: streamID,
+ }
+}
+
// OneTimeKeys represents a set of one-time keys for a single device
// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-upload
type OneTimeKeys struct {