feat: add id field to role (#470)

This commit is contained in:
Angelo Kontaxis
2026-01-09 20:06:16 +00:00
committed by GitHub
parent a5387b64af
commit 2afea56e56
14 changed files with 124 additions and 69 deletions

View File

@@ -40,17 +40,10 @@ pub async fn create(
}));
};
let role = Role {
name: data.name,
// Rank of the new role should be below the lowest role
rank: server.roles.len() as i64,
colour: None,
hoist: false,
permissions: Default::default(),
};
let role = Role::create(db, &server, data.name).await?;
Ok(Json(v0::NewRoleResponse {
id: role.create(db, &server.id).await?,
id: role.id.clone(),
role: role.into(),
}))
}

View File

@@ -37,7 +37,7 @@ pub async fn delete(
return Err(create_error!(NotElevated));
}
role.delete(db, &server.id, &role_id).await?;
role.delete(db, &server.id).await?;
for channel_id in &server.channels {
let channel = Reference::from_unchecked(channel_id).as_channel(db).await?;

View File

@@ -61,7 +61,6 @@ pub async fn edit(
role.update(
db,
&server.id,
&role_id,
partial,
remove.into_iter().map(Into::into).collect(),
)