Prevent setting null in edit. Preflight for variables.
This commit is contained in:
@@ -37,9 +37,18 @@ pub async fn req(user: User, target: Ref, info: Json<Data>) -> Result<()> {
|
|||||||
match &target {
|
match &target {
|
||||||
Channel::Group { id, .. } => {
|
Channel::Group { id, .. } => {
|
||||||
let col = get_collection("channels");
|
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(
|
col.update_one(
|
||||||
doc! { "_id": &id },
|
doc! { "_id": &id },
|
||||||
doc! { "$set": to_document(&info.0).map_err(|_| Error::DatabaseError { operation: "to_document", with: "info" })? },
|
doc! { "$set": set },
|
||||||
None
|
None
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -62,6 +62,13 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn preflight_checks() {
|
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 {
|
if *USE_EMAIL == false {
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
if !env::var("REVOLT_UNSAFE_NO_EMAIL").map_or(false, |v| v == *"1") {
|
if !env::var("REVOLT_UNSAFE_NO_EMAIL").map_or(false, |v| v == *"1") {
|
||||||
|
|||||||
Reference in New Issue
Block a user