diff --git a/set_version.sh b/set_version.sh index f1ba005e2d3be7955b7c0d0fad621fd97d78af10..ffe5b037d09cdb50f4e86fa1be146f8f296a72f9 100755 --- a/set_version.sh +++ b/set_version.sh @@ -1,3 +1,3 @@ #!/bin/bash -export version=0.4.1-alpha.7-patch.0 +export version=0.4.1-alpha.7-patch.2 echo "pub const VERSION: &str = \"${version}\";" > src/version.rs diff --git a/src/routes/channels/edit_channel.rs b/src/routes/channels/edit_channel.rs index 82710206a03ca2b5e240d4946eae2768c81d8a97..5242ec9e2a2c21a0435e8153e86b41d2fa3101be 100644 --- a/src/routes/channels/edit_channel.rs +++ b/src/routes/channels/edit_channel.rs @@ -26,7 +26,7 @@ pub async fn req(user: User, target: Ref, data: Json<Data>) -> Result<()> { data.validate() .map_err(|error| Error::FailedValidation { error })?; - if data.name.is_none() || data.description.is_none() || data.icon.is_none() || data.remove.is_none() { + if data.name.is_none() && data.description.is_none() && data.icon.is_none() && data.remove.is_none() { return Ok(()) } @@ -85,14 +85,16 @@ pub async fn req(user: User, target: Ref, data: Json<Data>) -> Result<()> { operations.insert("$unset", unset); } - get_collection("channels") - .update_one( - doc! { "_id": &id }, - operations, - None - ) - .await - .map_err(|_| Error::DatabaseError { operation: "update_one", with: "channel" })?; + if operations.len() > 0 { + get_collection("channels") + .update_one( + doc! { "_id": &id }, + operations, + None + ) + .await + .map_err(|_| Error::DatabaseError { operation: "update_one", with: "channel" })?; + } ClientboundNotification::ChannelUpdate { id: id.clone(), diff --git a/src/routes/users/edit_user.rs b/src/routes/users/edit_user.rs index 54747a386a847f0f7599ecce14e230de20ffe954..5ce6b247a803662b2ab7c9845a23521e0f2be7b8 100644 --- a/src/routes/users/edit_user.rs +++ b/src/routes/users/edit_user.rs @@ -35,7 +35,7 @@ pub async fn req(user: User, data: Json<Data>, _ignore_id: String) -> Result<()> data.validate() .map_err(|error| Error::FailedValidation { error })?; - if data.status.is_none() || data.profile.is_none() || data.avatar.is_none() || data.remove.is_none() { + if data.status.is_none() && data.profile.is_none() && data.avatar.is_none() && data.remove.is_none() { return Ok(()) } @@ -119,13 +119,15 @@ pub async fn req(user: User, data: Json<Data>, _ignore_id: String) -> Result<()> operations.insert("$unset", unset); } - get_collection("users") - .update_one(doc! { "_id": &user.id }, operations, None) - .await - .map_err(|_| Error::DatabaseError { - operation: "update_one", - with: "user", - })?; + if operations.len() > 0 { + get_collection("users") + .update_one(doc! { "_id": &user.id }, operations, None) + .await + .map_err(|_| Error::DatabaseError { + operation: "update_one", + with: "user", + })?; + } if let Some(status) = &data.status { ClientboundNotification::UserUpdate { diff --git a/src/version.rs b/src/version.rs index 4611a2e0b3412e713adaad6d93b2458a465731fc..f0629a005baee96f4db0885749267467f567ec58 100644 --- a/src/version.rs +++ b/src/version.rs @@ -1 +1 @@ -pub const VERSION: &str = "0.4.1-alpha.7-patch.0"; +pub const VERSION: &str = "0.4.1-alpha.7-patch.2";