aboutsummaryrefslogtreecommitdiff
path: root/keyserver/internal
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-08-03 12:29:58 +0100
committerGitHub <noreply@github.com>2020-08-03 12:29:58 +0100
commitffcb6d2ea199cfa985e72ffbdcb884fb9bc9f54d (patch)
tree6d25818803444fead9ab18db15e88e30be6641c6 /keyserver/internal
parentb5cb1d153458ad83abdfbebed7405dd9da159cb8 (diff)
Produce OTK counts in /sync response (#1235)
* Add QueryOneTimeKeys for /sync extensions * Unbreak tests * Produce OTK counts in /sync response * Linting
Diffstat (limited to 'keyserver/internal')
-rw-r--r--keyserver/internal/internal.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/keyserver/internal/internal.go b/keyserver/internal/internal.go
index bb828663..3c8dff84 100644
--- a/keyserver/internal/internal.go
+++ b/keyserver/internal/internal.go
@@ -168,6 +168,17 @@ func (a *KeyInternalAPI) claimRemoteKeys(
util.GetLogger(ctx).WithField("num_keys", keysClaimed).Info("Claimed remote keys")
}
+func (a *KeyInternalAPI) QueryOneTimeKeys(ctx context.Context, req *api.QueryOneTimeKeysRequest, res *api.QueryOneTimeKeysResponse) {
+ count, err := a.DB.OneTimeKeysCount(ctx, req.UserID, req.DeviceID)
+ if err != nil {
+ res.Error = &api.KeyError{
+ Err: fmt.Sprintf("Failed to query OTK counts: %s", err),
+ }
+ return
+ }
+ res.Count = *count
+}
+
func (a *KeyInternalAPI) QueryKeys(ctx context.Context, req *api.QueryKeysRequest, res *api.QueryKeysResponse) {
res.DeviceKeys = make(map[string]map[string]json.RawMessage)
res.Failures = make(map[string]interface{})