Add displayname and avatar_url endpoints

Add PUT and GET /_matrix/client/r0/profile/{userId}/displayname Endpoint
Add PUT and GET /_matrix/client/r0/profile/{userId}/avatar_url Endpoint
Add GET /_matrix/client/r0/profile/{userId} Endpoint

Took 2 hours 16 minutes
This commit is contained in:
Marcel 2020-04-09 18:49:27 +02:00
parent 11e75e7081
commit 062c5521f0
3 changed files with 189 additions and 1 deletions

View file

@ -52,6 +52,8 @@ impl MultiValue {
pub struct Database {
pub userid_password: sled::Tree,
pub userid_deviceids: MultiValue,
pub profile_displayname: sled::Tree,
pub profile_avatar_url: sled::Tree,
pub deviceid_token: sled::Tree,
pub token_userid: sled::Tree,
pub pduid_pdus: sled::Tree,
@ -75,6 +77,8 @@ impl Database {
Self {
userid_password: db.open_tree("userid_password").unwrap(),
userid_deviceids: MultiValue(db.open_tree("userid_deviceids").unwrap()),
profile_displayname: db.open_tree("profile_displayname").unwrap(),
profile_avatar_url: db.open_tree("profile_avatar_url").unwrap(),
deviceid_token: db.open_tree("deviceid_token").unwrap(),
token_userid: db.open_tree("token_userid").unwrap(),
pduid_pdus: db.open_tree("pduid_pdus").unwrap(),
@ -103,6 +107,22 @@ impl Database {
String::from_utf8_lossy(&v),
);
}
println!("# AccountData -> Displayname:");
for (k, v) in self.profile_displayname.iter().map(|r| r.unwrap()) {
println!(
"{:?} -> {:?}",
String::from_utf8_lossy(&k),
String::from_utf8_lossy(&v),
);
}
println!("# AccountData -> AvatarURL:");
for (k, v) in self.profile_avatar_url.iter().map(|r| r.unwrap()) {
println!(
"{:?} -> {:?}",
String::from_utf8_lossy(&k),
String::from_utf8_lossy(&v),
);
}
println!("\n# DeviceId -> Token:");
for (k, v) in self.deviceid_token.iter().map(|r| r.unwrap()) {
println!(