Run cargo fmt.

This commit is contained in:
Paul Makles
2021-01-18 20:26:26 +00:00
parent bd789b6825
commit a1a921bbcb
19 changed files with 141 additions and 142 deletions

View File

@@ -1,11 +1,11 @@
use crate::database::*;
use crate::util::result::{Error, Result};
use serde::{Serialize, Deserialize};
use rocket_contrib::json::Json;
use validator::Validate;
use mongodb::bson::doc;
use rocket_contrib::json::Json;
use serde::{Deserialize, Serialize};
use ulid::Ulid;
use validator::Validate;
#[derive(Validate, Serialize, Deserialize)]
pub struct Data {
@@ -18,7 +18,8 @@ pub struct Data {
#[post("/<target>/messages", data = "<message>")]
pub async fn req(user: User, target: Ref, message: Json<Data>) -> Result<()> {
message.validate()
message
.validate()
.map_err(|error| Error::FailedValidation { error })?;
let target = target.fetch_channel().await?;
@@ -33,11 +34,15 @@ pub async fn req(user: User, target: Ref, message: Json<Data>) -> Result<()> {
doc! {
"nonce": &message.nonce
},
None
None,
)
.await
.map_err(|_| Error::DatabaseError { operation: "find_one", with: "message" })?
.is_some() {
.map_err(|_| Error::DatabaseError {
operation: "find_one",
with: "message",
})?
.is_some()
{
Err(Error::AlreadySentMessage)?
}