Update schemas and resolve some warnings

This commit is contained in:
jude
2024-07-16 10:42:32 +01:00
parent 54ee3594eb
commit febd04c374
26 changed files with 221 additions and 164 deletions

View File

@@ -16,17 +16,15 @@ pub async fn get_guild_roles(id: u64, cookies: &CookieJar<'_>, ctx: &State<Conte
offline!(Ok(json!(vec![RoleInfo { name: "@everyone".to_string(), id: "1".to_string() }])));
check_authorization(cookies, ctx.inner(), id).await?;
let roles_res = ctx.cache.guild_roles(id);
let roles_res = ctx.cache.guild(id).map(|g| {
g.roles
.iter()
.map(|(_, r)| RoleInfo { id: r.id.to_string(), name: r.name.to_string() })
.collect::<Vec<RoleInfo>>()
});
match roles_res {
Some(roles) => {
let roles = roles
.iter()
.map(|(_, r)| RoleInfo { id: r.id.to_string(), name: r.name.to_string() })
.collect::<Vec<RoleInfo>>();
Ok(json!(roles))
}
Some(roles) => Ok(json!(roles)),
None => {
warn!("Could not fetch roles from {}", id);