diff options
author | Kegsay <kegan@matrix.org> | 2020-08-03 12:29:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-03 12:29:58 +0100 |
commit | ffcb6d2ea199cfa985e72ffbdcb884fb9bc9f54d (patch) | |
tree | 6d25818803444fead9ab18db15e88e30be6641c6 /keyserver/internal | |
parent | b5cb1d153458ad83abdfbebed7405dd9da159cb8 (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.go | 11 |
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{}) |