This commit is contained in:
Kegan Dougal 2021-07-27 18:40:43 +01:00
parent c46f7d6316
commit dd802ed3d4
2 changed files with 11 additions and 3 deletions

View file

@ -896,7 +896,8 @@ func Setup(
}),
).Methods(http.MethodGet, http.MethodOptions)
// Key Backup Versions
// Key Backup Versions (Metadata)
r0mux.Handle("/room_keys/version/{version}",
httputil.MakeAuthAPI("get_backup_keys_version", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
@ -935,7 +936,8 @@ func Setup(
}),
).Methods(http.MethodPost, http.MethodOptions)
// E2E Backup Keys
// Inserting E2E Backup Keys
// Bulk room and session
r0mux.Handle("/room_keys/keys",
httputil.MakeAuthAPI("put_backup_keys", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
@ -1022,6 +1024,8 @@ func Setup(
}),
).Methods(http.MethodPut)
// Querying E2E Backup Keys
r0mux.Handle("/room_keys/keys",
httputil.MakeAuthAPI("get_backup_keys", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
return GetBackupKeys(req, userAPI, device, req.URL.Query().Get("version"), "", "")
@ -1046,6 +1050,8 @@ func Setup(
}),
).Methods(http.MethodGet, http.MethodOptions)
// Deleting E2E Backup Keys
// Supplying a device ID is deprecated.
r0mux.Handle("/keys/upload/{deviceID}",
httputil.MakeAuthAPI("keys_upload", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {

View file

@ -539,8 +539,10 @@ func (a *UserInternalAPI) QueryKeyBackup(ctx context.Context, req *api.QueryKeyB
res.Exists = !deleted
if !req.ReturnKeys {
// TODO return the counts
res.Count, err = a.AccountDB.CountBackupKeys(ctx, version, req.UserID)
if err != nil {
res.Error = fmt.Sprintf("failed to count keys: %s", err)
}
return
}