MCPcopy Create free account
hub / github.com/daodst/chat / KeyBackupVersion

Function KeyBackupVersion

clientapi/routing/key_backup.go:92–117  ·  view source on GitHub ↗

KeyBackupVersion returns the key backup version specified. If `version` is empty, the latest `keyBackupVersionResponse` is returned. Implements GET /_matrix/client/r0/room_keys/version and GET /_matrix/client/r0/room_keys/version/{version}

(req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device, version string)

Source from the content-addressed store, hash-verified

90// KeyBackupVersion returns the key backup version specified. If `version` is empty, the latest `keyBackupVersionResponse` is returned.
91// Implements GET /_matrix/client/r0/room_keys/version and GET /_matrix/client/r0/room_keys/version/{version}
92func KeyBackupVersion(req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device, version string) util.JSONResponse {
93 var queryResp userapi.QueryKeyBackupResponse
94 userAPI.QueryKeyBackup(req.Context(), &userapi.QueryKeyBackupRequest{
95 UserID: device.UserID,
96 Version: version,
97 }, &queryResp)
98 if queryResp.Error != "" {
99 return util.ErrorResponse(fmt.Errorf("QueryKeyBackup: %s", queryResp.Error))
100 }
101 if !queryResp.Exists {
102 return util.JSONResponse{
103 Code: 404,
104 JSON: jsonerror.NotFound("version not found"),
105 }
106 }
107 return util.JSONResponse{
108 Code: 200,
109 JSON: keyBackupVersionResponse{
110 Algorithm: queryResp.Algorithm,
111 AuthData: queryResp.AuthData,
112 Count: queryResp.Count,
113 ETag: queryResp.ETag,
114 Version: queryResp.Version,
115 },
116 }
117}
118
119// Modify the auth data of a key backup. Version must not be empty. Request must contain a `keyBackupVersion`
120// Implements PUT /_matrix/client/r0/room_keys/version/{version}

Callers 1

SetupFunction · 0.85

Calls 2

ContextMethod · 0.80
QueryKeyBackupMethod · 0.65

Tested by

no test coverage detected