Run cargo fmt
This commit is contained in:
@@ -19,20 +19,21 @@ pub struct Data {
|
||||
// Maximum length of 36 allows both ULIDs and UUIDs.
|
||||
#[validate(length(min = 1, max = 36))]
|
||||
nonce: String,
|
||||
users: Vec<String>
|
||||
users: Vec<String>,
|
||||
}
|
||||
|
||||
#[post("/create", data = "<info>")]
|
||||
pub async fn req(user: User, info: Json<Data>) -> Result<JsonValue> {
|
||||
info
|
||||
.validate()
|
||||
info.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
|
||||
let mut set: HashSet<String> = HashSet::from_iter(info.users.iter().cloned());
|
||||
set.insert(user.id.clone());
|
||||
|
||||
if set.len() > *MAX_GROUP_SIZE {
|
||||
Err(Error::GroupTooLarge { max: *MAX_GROUP_SIZE })?
|
||||
Err(Error::GroupTooLarge {
|
||||
max: *MAX_GROUP_SIZE,
|
||||
})?
|
||||
}
|
||||
|
||||
if get_collection("channels")
|
||||
@@ -63,9 +64,12 @@ pub async fn req(user: User, info: Json<Data>) -> Result<JsonValue> {
|
||||
id,
|
||||
nonce: Some(info.nonce.clone()),
|
||||
name: info.name.clone(),
|
||||
description: info.description.clone().unwrap_or_else(|| "A group.".to_string()),
|
||||
description: info
|
||||
.description
|
||||
.clone()
|
||||
.unwrap_or_else(|| "A group.".to_string()),
|
||||
owner: user.id,
|
||||
recipients: set.into_iter().collect::<Vec<String>>()
|
||||
recipients: set.into_iter().collect::<Vec<String>>(),
|
||||
};
|
||||
|
||||
channel.clone().publish().await?;
|
||||
|
||||
@@ -55,11 +55,8 @@ pub async fn req(user: User, target: Ref, message: Json<Data>) -> Result<JsonVal
|
||||
nonce: Some(message.nonce.clone()),
|
||||
edited: None,
|
||||
};
|
||||
|
||||
msg
|
||||
.clone()
|
||||
.publish()
|
||||
.await?;
|
||||
|
||||
msg.clone().publish().await?;
|
||||
|
||||
Ok(json!(msg))
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ use rocket::Route;
|
||||
|
||||
mod delete_channel;
|
||||
mod fetch_channel;
|
||||
mod group_create;
|
||||
mod message_delete;
|
||||
mod message_edit;
|
||||
mod message_fetch;
|
||||
mod message_query;
|
||||
mod message_send;
|
||||
mod group_create;
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![
|
||||
|
||||
Reference in New Issue
Block a user