Format code.

This commit is contained in:
Paul
2021-04-03 14:44:01 +01:00
parent 9492e145f9
commit 7f5d6f2312
17 changed files with 170 additions and 154 deletions

View File

@@ -1,11 +1,11 @@
use crate::database::*;
use crate::util::result::{Error, Result};
use crate::notifications::events::ClientboundNotification;
use crate::util::result::{Error, Result};
use mongodb::bson::{doc, to_document};
use validator::Validate;
use rocket_contrib::json::Json;
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
use validator::Validate;
#[derive(Validate, Serialize, Deserialize)]
pub struct Data {
@@ -21,9 +21,9 @@ pub struct Data {
pub async fn req(user: User, target: Ref, info: Json<Data>) -> Result<()> {
info.validate()
.map_err(|error| Error::FailedValidation { error })?;
if info.name.is_none() && info.description.is_none() {
return Ok(())
return Ok(());
}
let target = target.fetch_channel().await?;
@@ -31,7 +31,7 @@ pub async fn req(user: User, target: Ref, info: Json<Data>) -> Result<()> {
.with_channel(&target)
.for_channel()
.await?;
if !perm.get_manage_channel() {
Err(Error::MissingPermission)?
}
@@ -49,7 +49,7 @@ pub async fn req(user: User, target: Ref, info: Json<Data>) -> Result<()> {
ClientboundNotification::ChannelUpdate {
id: id.clone(),
data: json!(info.0)
data: json!(info.0),
}
.publish(id.clone())
.await
@@ -59,7 +59,10 @@ pub async fn req(user: User, target: Ref, info: Json<Data>) -> Result<()> {
Message::create(
"00000000000000000000000000".to_string(),
id.clone(),
Content::SystemMessage(SystemMessage::ChannelRenamed { name: name.clone(), by: user.id })
Content::SystemMessage(SystemMessage::ChannelRenamed {
name: name.clone(),
by: user.id,
}),
)
.publish(&target)
.await
@@ -68,6 +71,6 @@ pub async fn req(user: User, target: Ref, info: Json<Data>) -> Result<()> {
Ok(())
}
_ => Err(Error::InvalidOperation)
_ => Err(Error::InvalidOperation),
}
}