forked from jmug/stoatchat
Fetch messages route.
This commit is contained in:
@@ -4,7 +4,7 @@ use crate::util::result::{Error, Result};
|
||||
use validator::Validate;
|
||||
use rocket::http::RawStr;
|
||||
use rocket::request::FromParam;
|
||||
use mongodb::bson::{doc, from_bson, Bson};
|
||||
use mongodb::bson::{Bson, doc, from_bson, from_document};
|
||||
use serde::{Deserialize, Serialize, de::DeserializeOwned};
|
||||
|
||||
#[derive(Validate, Serialize, Deserialize)]
|
||||
@@ -34,8 +34,8 @@ impl Ref {
|
||||
.ok_or_else(|| Error::UnknownUser)?;
|
||||
|
||||
Ok(
|
||||
from_bson::<T>(Bson::Document(doc)).map_err(|_| Error::DatabaseError {
|
||||
operation: "from_bson",
|
||||
from_document::<T>(doc).map_err(|_| Error::DatabaseError {
|
||||
operation: "from_document",
|
||||
with: &collection,
|
||||
})?,
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::database::*;
|
||||
|
||||
use mongodb::bson::{doc, from_bson, Bson};
|
||||
use mongodb::bson::{Bson, doc, from_bson, from_document};
|
||||
use rauth::auth::Session;
|
||||
use rocket::http::Status;
|
||||
use rocket::request::{self, FromRequest, Outcome, Request};
|
||||
@@ -22,7 +22,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for User {
|
||||
.await
|
||||
{
|
||||
if let Some(doc) = result {
|
||||
Outcome::Success(from_bson(Bson::Document(doc)).unwrap())
|
||||
Outcome::Success(from_document(doc).unwrap())
|
||||
} else {
|
||||
Outcome::Failure((Status::Forbidden, rauth::util::Error::InvalidSession))
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use super::super::{get_collection, get_db};
|
||||
|
||||
use crate::rocket::futures::StreamExt;
|
||||
use log::info;
|
||||
use mongodb::bson::{doc, from_bson, Bson};
|
||||
use mongodb::bson::{Bson, doc, from_bson, from_document};
|
||||
use mongodb::options::FindOptions;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -23,7 +23,7 @@ pub async fn migrate_database() {
|
||||
|
||||
if let Some(doc) = data {
|
||||
let info: MigrationInfo =
|
||||
from_bson(Bson::Document(doc)).expect("Failed to read migration information.");
|
||||
from_document(doc).expect("Failed to read migration information.");
|
||||
|
||||
let revision = run_migrations(info.revision).await;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user