mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 05:26:59 +00:00
fix: newly created roles should be ranked the lowest
This commit is contained in:
@@ -175,6 +175,8 @@ auto_derived!(
|
||||
/// Ranking position
|
||||
///
|
||||
/// Smaller values take priority.
|
||||
///
|
||||
/// **Removed** - no effect, use the edit server role positions route
|
||||
pub rank: Option<i64>,
|
||||
}
|
||||
|
||||
|
||||
@@ -40,20 +40,10 @@ pub async fn create(
|
||||
}));
|
||||
};
|
||||
|
||||
let member_rank = query.get_member_rank();
|
||||
let rank = if let Some(given_rank) = data.rank {
|
||||
if given_rank <= member_rank.unwrap_or(i64::MIN) {
|
||||
return Err(create_error!(NotElevated));
|
||||
}
|
||||
|
||||
given_rank
|
||||
} else {
|
||||
member_rank.unwrap_or(0).saturating_add(1)
|
||||
};
|
||||
|
||||
let role = Role {
|
||||
name: data.name,
|
||||
rank,
|
||||
// Rank of the new role should be below the lowest role
|
||||
rank: server.roles.len() as i64,
|
||||
colour: None,
|
||||
hoist: false,
|
||||
permissions: Default::default(),
|
||||
|
||||
Reference in New Issue
Block a user