Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
refactor: pull out magic number into constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushuo committed Feb 18, 2024
1 parent eed5e1c commit 2068e67
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/src/service/map_collaborator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use crate::{
service::users,
};

/// The maximum number of collaborators a map can have.
const MAX_COLLABORATORS: usize = 30;

/// Get all collaborators for a map.
///
/// # Errors
Expand Down Expand Up @@ -77,10 +80,10 @@ pub async fn create(

let current_collaborators = MapCollaborator::find_by_map_id(map_id, &mut conn).await?;

if current_collaborators.len() >= 30 {
if current_collaborators.len() >= MAX_COLLABORATORS {
return Err(ServiceError::new(
StatusCode::BAD_REQUEST,
"A map can have at most 30 collaborators.".to_owned(),
format!("A map can have at most {MAX_COLLABORATORS} collaborators."),
));
}

Expand Down

0 comments on commit 2068e67

Please sign in to comment.