Start moving to Rocket 0.5.0
This commit is contained in:
@@ -3,7 +3,7 @@ use crate::util::result::{Error, Result};
|
||||
use crate::{database::*, notifications::events::RemoveChannelField};
|
||||
|
||||
use mongodb::bson::{doc, to_document};
|
||||
use rocket_contrib::json::Json;
|
||||
use rocket::serde::json::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::database::*;
|
||||
use crate::util::result::{Error, Result};
|
||||
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[get("/<target>")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let target = target.fetch_channel().await?;
|
||||
|
||||
let perm = permissions::PermissionCalculator::new(&user)
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::util::result::{Error, Result};
|
||||
use crate::util::variables::MAX_GROUP_SIZE;
|
||||
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::{Json, JsonValue};
|
||||
use rocket::serde::json::{Json, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
use std::iter::FromIterator;
|
||||
@@ -23,7 +23,7 @@ pub struct Data {
|
||||
}
|
||||
|
||||
#[post("/create", data = "<info>")]
|
||||
pub async fn req(user: User, info: Json<Data>) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, info: Json<Data>) -> Result<Value> {
|
||||
let info = info.into_inner();
|
||||
info.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::util::result::{Error, Result};
|
||||
|
||||
use mongodb::bson::doc;
|
||||
use nanoid::nanoid;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
lazy_static! {
|
||||
static ref ALPHABET: [char; 54] = [
|
||||
@@ -14,7 +14,7 @@ lazy_static! {
|
||||
}
|
||||
|
||||
#[post("/<target>/invites")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let target = target.fetch_channel().await?;
|
||||
let perm = permissions::PermissionCalculator::new(&user)
|
||||
.with_channel(&target)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::database::*;
|
||||
use crate::util::result::{Error, Result};
|
||||
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[get("/<target>/members")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let target = target.fetch_channel().await?;
|
||||
|
||||
let perm = permissions::PermissionCalculator::new(&user)
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::util::result::{Error, Result};
|
||||
|
||||
use chrono::Utc;
|
||||
use mongodb::bson::{doc, Bson, DateTime, Document};
|
||||
use rocket_contrib::json::Json;
|
||||
use rocket::serde::json::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::database::*;
|
||||
use crate::util::result::{Error, Result};
|
||||
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[get("/<target>/messages/<msg>")]
|
||||
pub async fn req(user: User, target: Ref, msg: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref, msg: Ref) -> Result<Value> {
|
||||
let channel = target.fetch_channel().await?;
|
||||
channel.has_messaging()?;
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ use mongodb::{
|
||||
bson::{doc, from_document},
|
||||
options::FindOptions,
|
||||
};
|
||||
use rocket::request::Form;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::form::Form;
|
||||
use rocket::serde::json::Value;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Serialize, Deserialize, FromFormValue)]
|
||||
#[derive(Serialize, Deserialize, FromFormField)]
|
||||
pub enum Sort {
|
||||
Latest,
|
||||
Oldest,
|
||||
@@ -37,7 +37,7 @@ pub struct Options {
|
||||
}
|
||||
|
||||
#[get("/<target>/messages?<options..>")]
|
||||
pub async fn req(user: User, target: Ref, options: Form<Options>) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref, options: Form<Options>) -> Result<Value> {
|
||||
options
|
||||
.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::util::result::{Error, Result};
|
||||
|
||||
use futures::StreamExt;
|
||||
use mongodb::bson::{doc, from_document};
|
||||
use rocket_contrib::json::{Json, JsonValue};
|
||||
use rocket::serde::json::{Json, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
@@ -12,7 +12,7 @@ pub struct Options {
|
||||
}
|
||||
|
||||
#[post("/<target>/messages/stale", data = "<data>")]
|
||||
pub async fn req(user: User, target: Ref, data: Json<Options>) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref, data: Json<Options>) -> Result<Value> {
|
||||
if data.ids.len() > 150 {
|
||||
return Err(Error::TooManyIds);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ use mongodb::{
|
||||
bson::{doc, from_document},
|
||||
options::FindOptions,
|
||||
};
|
||||
use rocket_contrib::json::{Json, JsonValue};
|
||||
use rocket::serde::json::{Json, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Serialize, Deserialize, FromFormValue)]
|
||||
#[derive(Serialize, Deserialize, FromFormField)]
|
||||
pub enum Sort {
|
||||
Relevance,
|
||||
Latest,
|
||||
@@ -42,7 +42,7 @@ pub struct Options {
|
||||
}
|
||||
|
||||
#[post("/<target>/search", data = "<options>")]
|
||||
pub async fn req(user: User, target: Ref, options: Json<Options>) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref, options: Json<Options>) -> Result<Value> {
|
||||
options
|
||||
.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::util::result::{Error, Result};
|
||||
|
||||
use mongodb::{bson::doc, options::FindOneOptions};
|
||||
use regex::Regex;
|
||||
use rocket_contrib::json::{Json, JsonValue};
|
||||
use rocket::serde::json::{Json, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ulid::Ulid;
|
||||
use validator::Validate;
|
||||
@@ -33,7 +33,7 @@ lazy_static! {
|
||||
}
|
||||
|
||||
#[post("/<target>/messages", data = "<message>")]
|
||||
pub async fn req(user: User, target: Ref, message: Json<Data>) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref, message: Json<Data>) -> Result<Value> {
|
||||
let message = message.into_inner();
|
||||
message
|
||||
.validate()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::Json;
|
||||
use rocket::serde::json::Json;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use validator::Contains;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::Json;
|
||||
use rocket::serde::json::Json;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use crate::database::*;
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::database::*;
|
||||
use crate::util::result::{Error, Result};
|
||||
use crate::util::variables::{USE_VOSO, VOSO_MANAGE_TOKEN, VOSO_URL};
|
||||
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
@@ -11,7 +11,7 @@ struct CreateUserResponse {
|
||||
}
|
||||
|
||||
#[post("/<target>/join_call")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
if !*USE_VOSO {
|
||||
return Err(Error::VosoUnavailable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user