mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-08-30 23:07:27 +00:00
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:
@@ -15,7 +15,6 @@ auto_derived!(
|
||||
/// Discover request
|
||||
pub struct DiscoverRequest {
|
||||
/// The type of request.
|
||||
#[serde(rename = "type")]
|
||||
pub request_type: DiscoverRequestType,
|
||||
/// The ID of the bot/server
|
||||
pub request_id: String,
|
||||
|
||||
@@ -61,7 +61,7 @@ impl AbstractDiscoverRequest for MongoDb {
|
||||
find_one,
|
||||
DISCOVER_COL,
|
||||
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
|
||||
@@ -85,6 +85,6 @@ impl AbstractDiscoverRequest for MongoDb {
|
||||
find_one,
|
||||
DISCOVER_BANS_COL,
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ auto_derived!(
|
||||
#[serde(rename = "type")]
|
||||
pub request_type: DiscoverRequestType,
|
||||
/// The ID of the bot/server
|
||||
#[serde(rename = "id")]
|
||||
pub request_id: String,
|
||||
/// status of the request
|
||||
pub status: DiscoverRequestStatus,
|
||||
|
||||
Reference in New Issue
Block a user