mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-29 01:33:10 -06:00
Apparently only the current version supports uploading keys
This commit is contained in:
parent
97bf18bda3
commit
c46f7d6316
|
|
@ -546,6 +546,7 @@ Responds correctly when backup is empty
|
||||||
Can backup keys
|
Can backup keys
|
||||||
Can update keys with better versions
|
Can update keys with better versions
|
||||||
Will not update keys with worse versions
|
Will not update keys with worse versions
|
||||||
|
Will not back up to an old backup version
|
||||||
Can create more than 10 backup versions
|
Can create more than 10 backup versions
|
||||||
Can delete backup
|
Can delete backup
|
||||||
Deleted & recreated backups are empty
|
Deleted & recreated backups are empty
|
||||||
|
|
|
||||||
|
|
@ -444,10 +444,6 @@ func (a *UserInternalAPI) QueryOpenIDToken(ctx context.Context, req *api.QueryOp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *UserInternalAPI) PerformKeyBackup(ctx context.Context, req *api.PerformKeyBackupRequest, res *api.PerformKeyBackupResponse) {
|
func (a *UserInternalAPI) PerformKeyBackup(ctx context.Context, req *api.PerformKeyBackupRequest, res *api.PerformKeyBackupResponse) {
|
||||||
logrus.Infof("PerformKeyBackup REQ= %+v", *req)
|
|
||||||
defer func() {
|
|
||||||
logrus.Infof("PerformKeyBackup RESP= %+v", *res)
|
|
||||||
}()
|
|
||||||
// Delete metadata
|
// Delete metadata
|
||||||
if req.DeleteBackup {
|
if req.DeleteBackup {
|
||||||
if req.Version == "" {
|
if req.Version == "" {
|
||||||
|
|
@ -488,8 +484,8 @@ func (a *UserInternalAPI) PerformKeyBackup(ctx context.Context, req *api.Perform
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *UserInternalAPI) uploadBackupKeys(ctx context.Context, req *api.PerformKeyBackupRequest, res *api.PerformKeyBackupResponse) {
|
func (a *UserInternalAPI) uploadBackupKeys(ctx context.Context, req *api.PerformKeyBackupRequest, res *api.PerformKeyBackupResponse) {
|
||||||
// ensure the version metadata exists
|
// you can only upload keys for the CURRENT version
|
||||||
version, _, _, _, deleted, err := a.AccountDB.GetKeyBackup(ctx, req.UserID, req.Version)
|
version, _, _, _, deleted, err := a.AccountDB.GetKeyBackup(ctx, req.UserID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.Error = fmt.Sprintf("failed to query version: %s", err)
|
res.Error = fmt.Sprintf("failed to query version: %s", err)
|
||||||
return
|
return
|
||||||
|
|
@ -498,6 +494,11 @@ func (a *UserInternalAPI) uploadBackupKeys(ctx context.Context, req *api.Perform
|
||||||
res.Error = "backup was deleted"
|
res.Error = "backup was deleted"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if version != req.Version {
|
||||||
|
res.BadInput = true
|
||||||
|
res.Error = fmt.Sprintf("%s isn't the current version, %s is.", req.Version, version)
|
||||||
|
return
|
||||||
|
}
|
||||||
res.Exists = true
|
res.Exists = true
|
||||||
res.Version = version
|
res.Version = version
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue