fix: Minor fixes for discover routes (#942)

fix: propagate NotFound instead of 500, rename fields to their proper values without affecting database insertion

Signed-off-by: IAmTomahawkx <iamtomahawkx@gmail.com>
Release-As: 0.15.3
This commit is contained in:
Tom
2026-08-24 17:50:49 -07:00
committed by GitHub
parent a6232a2655
commit 509ebbfc15
3 changed files with 3 additions and 3 deletions

View File

@@ -15,7 +15,6 @@ auto_derived!(
/// Discover request /// Discover request
pub struct DiscoverRequest { pub struct DiscoverRequest {
/// The type of request. /// The type of request.
#[serde(rename = "type")]
pub request_type: DiscoverRequestType, pub request_type: DiscoverRequestType,
/// The ID of the bot/server /// The ID of the bot/server
pub request_id: String, pub request_id: String,

View File

@@ -61,7 +61,7 @@ impl AbstractDiscoverRequest for MongoDb {
find_one, find_one,
DISCOVER_COL, DISCOVER_COL,
doc! {"request_type": bson::to_bson(&request_type).expect("failed to serialize"), "request_id": item} doc! {"request_type": bson::to_bson(&request_type).expect("failed to serialize"), "request_id": item}
)?.ok_or_else(|| create_database_error!("find_one", DISCOVER_COL)) )?.ok_or_else(|| create_error!(NotFound))
} }
/// Remove discover request /// Remove discover request
@@ -85,6 +85,6 @@ impl AbstractDiscoverRequest for MongoDb {
find_one, find_one,
DISCOVER_BANS_COL, DISCOVER_BANS_COL,
doc! {"request_type": bson::to_bson(&item_type).expect("failed to serialize"), "request_id": item} doc! {"request_type": bson::to_bson(&item_type).expect("failed to serialize"), "request_id": item}
)?.ok_or_else(|| create_database_error!("find_one", DISCOVER_COL)).map(|_: DiscoverBan| true) )?.ok_or_else(|| create_error!(NotFound)).map(|_: DiscoverBan| true)
} }
} }

View File

@@ -17,6 +17,7 @@ auto_derived!(
#[serde(rename = "type")] #[serde(rename = "type")]
pub request_type: DiscoverRequestType, pub request_type: DiscoverRequestType,
/// The ID of the bot/server /// The ID of the bot/server
#[serde(rename = "id")]
pub request_id: String, pub request_id: String,
/// status of the request /// status of the request
pub status: DiscoverRequestStatus, pub status: DiscoverRequestStatus,