Start moving to Rocket 0.5.0
This commit is contained in:
@@ -5,10 +5,10 @@ use crate::util::result::{Error, Result};
|
||||
use futures::try_join;
|
||||
use mongodb::bson::doc;
|
||||
use mongodb::options::{Collation, FindOneOptions};
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[put("/<username>/friend")]
|
||||
pub async fn req(user: User, username: String) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, username: String) -> Result<Value> {
|
||||
let col = get_collection("users");
|
||||
let doc = col
|
||||
.find_one(
|
||||
|
||||
@@ -4,10 +4,10 @@ use crate::util::result::{Error, Result};
|
||||
|
||||
use futures::try_join;
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[put("/<target>/block")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let col = get_collection("users");
|
||||
|
||||
let target = target.fetch_user().await?;
|
||||
|
||||
@@ -6,7 +6,7 @@ use mongodb::bson::doc;
|
||||
use rauth::auth::{Auth, Session};
|
||||
use regex::Regex;
|
||||
use rocket::State;
|
||||
use rocket_contrib::json::Json;
|
||||
use rocket::serde::json::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
@@ -25,7 +25,7 @@ pub struct Data {
|
||||
|
||||
#[patch("/<_ignore_id>/username", data = "<data>")]
|
||||
pub async fn req(
|
||||
auth: State<'_, Auth>,
|
||||
auth: &State<Auth>,
|
||||
session: Session,
|
||||
user: User,
|
||||
data: Json<Data>,
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::util::result::{Error, Result};
|
||||
use crate::{database::*, notifications::events::RemoveUserField};
|
||||
|
||||
use mongodb::bson::{doc, to_document};
|
||||
use rocket_contrib::json::Json;
|
||||
use rocket::serde::json::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ use crate::util::result::{Error, Result};
|
||||
|
||||
use futures::StreamExt;
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[get("/dms")]
|
||||
pub async fn req(user: User) -> Result<JsonValue> {
|
||||
pub async fn req(user: User) -> Result<Value> {
|
||||
let mut cursor = get_collection("channels")
|
||||
.find(
|
||||
doc! {
|
||||
|
||||
@@ -2,10 +2,10 @@ use crate::database::*;
|
||||
use crate::util::result::{Error, Result};
|
||||
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[get("/<target>/profile")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let target = target.fetch_user().await?;
|
||||
let perm = permissions::PermissionCalculator::new(&user)
|
||||
.with_user(&target)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::database::*;
|
||||
use crate::util::result::Result;
|
||||
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[get("/<target>/relationship")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
Ok(json!({ "status": get_relationship(&user, &target.id) }))
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::database::*;
|
||||
use crate::util::result::Result;
|
||||
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[get("/relationships")]
|
||||
pub async fn req(user: User) -> Result<JsonValue> {
|
||||
pub async fn req(user: User) -> Result<Value> {
|
||||
Ok(if let Some(vec) = user.relations {
|
||||
json!(vec)
|
||||
} else {
|
||||
|
||||
@@ -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_user().await?;
|
||||
|
||||
let perm = permissions::PermissionCalculator::new(&user)
|
||||
|
||||
@@ -4,10 +4,10 @@ use crate::util::result::{Error, Result};
|
||||
use futures::StreamExt;
|
||||
use mongodb::bson::{doc, Document};
|
||||
use mongodb::options::FindOptions;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[get("/<target>/mutual")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let users = get_collection("users")
|
||||
.find(
|
||||
doc! {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use rocket::{Request, Response};
|
||||
use rocket::response::{self, NamedFile, Responder};
|
||||
use rocket::response::{self, Responder};
|
||||
use rocket::fs::NamedFile;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::database::Ref;
|
||||
|
||||
@@ -2,11 +2,11 @@ use crate::database::*;
|
||||
use crate::util::result::{Error, Result};
|
||||
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
use ulid::Ulid;
|
||||
|
||||
#[get("/<target>/dm")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let query = if user.id == target.id {
|
||||
doc! {
|
||||
"channel_type": "SavedMessages",
|
||||
|
||||
@@ -4,10 +4,10 @@ use crate::util::result::{Error, Result};
|
||||
|
||||
use futures::try_join;
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[delete("/<target>/friend")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let col = get_collection("users");
|
||||
|
||||
let target = target.fetch_user().await?;
|
||||
|
||||
@@ -4,10 +4,10 @@ use crate::util::result::{Error, Result};
|
||||
|
||||
use futures::try_join;
|
||||
use mongodb::bson::doc;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[delete("/<target>/block")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let col = get_collection("users");
|
||||
let target = target.fetch_user().await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user