Merge pull request #36 from Zomatree/master

This commit is contained in:
Paul Makles
2021-08-16 13:57:09 +01:00
committed by GitHub
7 changed files with 46 additions and 9 deletions

View File

@@ -32,6 +32,8 @@ pub struct Data {
// Maximum length of 36 allows both ULIDs and UUIDs.
#[validate(length(min = 1, max = 36))]
nonce: String,
#[serde(skip_serializing_if = "Option::is_none")]
nsfw: Option<bool>,
}
#[post("/<target>/channels", data = "<info>")]
@@ -80,7 +82,9 @@ pub async fn req(user: User, target: Ref, info: Json<Data>) -> Result<Value> {
last_message: None,
default_permissions: None,
role_permissions: HashMap::new()
role_permissions: HashMap::new(),
nsfw: info.nsfw.unwrap_or_default(),
},
ChannelType::Voice => Channel::VoiceChannel {
id: id.clone(),
@@ -92,7 +96,9 @@ pub async fn req(user: User, target: Ref, info: Json<Data>) -> Result<Value> {
icon: None,
default_permissions: None,
role_permissions: HashMap::new()
role_permissions: HashMap::new(),
nsfw: info.nsfw.unwrap_or_default()
}
};

View File

@@ -18,6 +18,8 @@ pub struct Data {
// Maximum length of 36 allows both ULIDs and UUIDs.
#[validate(length(min = 1, max = 36))]
nonce: String,
#[serde(skip_serializing_if = "Option::is_none")]
nsfw: Option<bool>
}
#[post("/create", data = "<info>")]
@@ -75,6 +77,7 @@ pub async fn req(user: User, info: Json<Data>) -> Result<Value> {
icon: None,
banner: None,
nsfw: info.nsfw.unwrap_or_default()
};
Channel::TextChannel {
@@ -88,7 +91,8 @@ pub async fn req(user: User, info: Json<Data>) -> Result<Value> {
last_message: None,
default_permissions: None,
role_permissions: HashMap::new()
role_permissions: HashMap::new(),
nsfw: false
}
.publish()
.await?;

View File

@@ -18,6 +18,8 @@ pub struct Data {
categories: Option<Vec<Category>>,
system_messages: Option<SystemMessageChannels>,
remove: Option<RemoveServerField>,
#[serde(skip_serializing_if = "Option::is_none")]
nsfw: Option<bool>
}
#[patch("/<target>", data = "<data>")]
@@ -105,6 +107,10 @@ pub async fn req(user: User, target: Ref, data: Json<Data>) -> Result<EmptyRespo
set.insert("system_messages", to_bson(&system_messages).map_err(|_| Error::DatabaseError { operation: "to_document", with: "system_messages" })?);
}
if let Some(nsfw) = &data.nsfw {
set.insert("nsfw", nsfw);
}
let mut operations = doc! {};
if set.len() > 0 {
operations.insert("$set", &set);