mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-14 05:12:26 +03:00
Save and retrieve account data (#166)
* Save function for account data * Fix upsert + add empty routes and function * Save account data * Retrieval functions * Implement retrieval in /sync * Fix arrays not correctly initialised * Merge account data retrieval functions * Request DB only once per request * Initialise array * Fix comment
This commit is contained in:
parent
6d073dcf9f
commit
3e394e9e21
6 changed files with 266 additions and 18 deletions
|
@ -274,9 +274,16 @@ func Setup(
|
|||
)
|
||||
|
||||
r0mux.Handle("/user/{userID}/account_data/{type}",
|
||||
common.MakeAPI("user_account_data", func(req *http.Request) util.JSONResponse {
|
||||
// TODO: Set and get the account_data
|
||||
return util.JSONResponse{Code: 200, JSON: struct{}{}}
|
||||
common.MakeAuthAPI("user_account_data", deviceDB, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
|
||||
vars := mux.Vars(req)
|
||||
return readers.SaveAccountData(req, accountDB, device, vars["userID"], "", vars["type"])
|
||||
}),
|
||||
)
|
||||
|
||||
r0mux.Handle("/user/{userID}/rooms/{roomID}/account_data/{type}",
|
||||
common.MakeAuthAPI("user_account_data", deviceDB, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
|
||||
vars := mux.Vars(req)
|
||||
return readers.SaveAccountData(req, accountDB, device, vars["userID"], vars["roomID"], vars["type"])
|
||||
}),
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue