implement generic K-V support for MSC4133, GET/PUT/DELETE

no PATCH still yet

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-09-14 11:16:19 -04:00
commit d75aebc373
9 changed files with 340 additions and 20 deletions
src/api/client

View file

@ -247,11 +247,18 @@ pub(crate) async fn get_profile_route(
.set_timezone(&body.user_id, response.tz.clone())
.await?;
for (profile_key, profile_key_value) in &response.custom_profile_fields {
services
.users
.set_profile_key(&body.user_id, profile_key, Some(profile_key_value.clone()))?;
}
return Ok(get_profile::v3::Response {
displayname: response.displayname,
avatar_url: response.avatar_url,
blurhash: response.blurhash,
tz: response.tz,
custom_profile_fields: response.custom_profile_fields,
});
}
}
@ -267,6 +274,11 @@ pub(crate) async fn get_profile_route(
blurhash: services.users.blurhash(&body.user_id)?,
displayname: services.users.displayname(&body.user_id)?,
tz: services.users.timezone(&body.user_id)?,
custom_profile_fields: services
.users
.all_profile_keys(&body.user_id)
.filter_map(Result::ok)
.collect(),
})
}