Prevent setting null in edit. Preflight for variables.

This commit is contained in:
Paul
2021-04-01 14:01:07 +01:00
parent 32cd9d8a13
commit 56bd763820
2 changed files with 17 additions and 1 deletions

View File

@@ -37,9 +37,18 @@ pub async fn req(user: User, target: Ref, info: Json<Data>) -> Result<()> {
match &target {
Channel::Group { id, .. } => {
let col = get_collection("channels");
let mut set = doc! {};
if let Some(name) = &info.name {
set.insert("name", name.clone());
}
if let Some(description) = &info.description {
set.insert("description", description.clone());
}
col.update_one(
doc! { "_id": &id },
doc! { "$set": to_document(&info.0).map_err(|_| Error::DatabaseError { operation: "to_document", with: "info" })? },
doc! { "$set": set },
None
)
.await

View File

@@ -62,6 +62,13 @@ lazy_static! {
}
pub fn preflight_checks() {
format!("{}", *MONGO_URI);
format!("{}", *PUBLIC_URL);
format!("{}", *EXTERNAL_WS_URL);
format!("{}", *VAPID_PRIVATE_KEY);
format!("{}", *VAPID_PUBLIC_KEY);
if *USE_EMAIL == false {
#[cfg(not(debug_assertions))]
if !env::var("REVOLT_UNSAFE_NO_EMAIL").map_or(false, |v| v == *"1") {