Migrate the rest of the code.
This commit is contained in:
@@ -53,7 +53,7 @@ pub async fn req(user: User, target: Ref, msg: Ref, edit: Json<Data>) -> Result<
|
||||
}
|
||||
|
||||
let obj = update.as_object_mut().unwrap();
|
||||
obj.insert("embeds".to_string(), json!(new_embeds).0);
|
||||
obj.insert("embeds".to_string(), json!(new_embeds));
|
||||
set.insert("embeds", new_embeds);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ use mongodb::{
|
||||
bson::{doc, from_document},
|
||||
options::FindOptions,
|
||||
};
|
||||
use rocket::form::Form;
|
||||
use rocket::serde::json::Value;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
@@ -37,7 +36,7 @@ pub struct Options {
|
||||
}
|
||||
|
||||
#[get("/<target>/messages?<options..>")]
|
||||
pub async fn req(user: User, target: Ref, options: Form<Options>) -> Result<Value> {
|
||||
pub async fn req(user: User, target: Ref, options: Options) -> Result<Value> {
|
||||
options
|
||||
.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
pub use rocket::response::Redirect;
|
||||
pub use rocket::http::Status;
|
||||
use rocket::{Phase, Rocket};
|
||||
use rocket::{Build, Rocket};
|
||||
|
||||
mod channels;
|
||||
mod invites;
|
||||
@@ -11,9 +11,9 @@ mod servers;
|
||||
mod sync;
|
||||
mod users;
|
||||
|
||||
pub fn mount<T: Phase>(rocket: Rocket<T>) -> Rocket<T> {
|
||||
pub fn mount(rocket: Rocket<Build>) -> Rocket<Build> {
|
||||
rocket
|
||||
.mount("/", routes![root::root])
|
||||
.mount("/", routes![root::root, root::ping])
|
||||
.mount("/onboard", onboard::routes())
|
||||
.mount("/users", users::routes())
|
||||
.mount("/channels", channels::routes())
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::util::{ratelimit::RateLimitGuard, variables::{
|
||||
}};
|
||||
|
||||
use mongodb::bson::doc;
|
||||
use rocket::serde::json::Value;
|
||||
use rocket::{http::Status, serde::json::Value};
|
||||
use rocket_governor::RocketGovernor;
|
||||
|
||||
#[get("/")]
|
||||
@@ -37,3 +37,8 @@ pub async fn root(_limitguard: RocketGovernor<'_, RateLimitGuard>) -> Value {
|
||||
"vapid": *VAPID_PUBLIC_KEY
|
||||
})
|
||||
}
|
||||
|
||||
#[get("/ping")]
|
||||
pub async fn ping(_limitguard: RocketGovernor<'_, RateLimitGuard>) -> Status {
|
||||
Status::Ok
|
||||
}
|
||||
|
||||
@@ -5,20 +5,20 @@ use crate::util::result::{Error, Result};
|
||||
use chrono::prelude::*;
|
||||
use mongodb::bson::{doc, to_bson};
|
||||
use mongodb::options::UpdateOptions;
|
||||
use rocket::form::Form;
|
||||
use rocket::serde::json::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
use std::collections::HashMap;
|
||||
|
||||
type Data = HashMap<String, String>;
|
||||
|
||||
#[derive(Serialize, Deserialize, FromForm)]
|
||||
#[derive(FromForm, Serialize, Deserialize)]
|
||||
pub struct Options {
|
||||
timestamp: Option<i64>,
|
||||
}
|
||||
|
||||
#[post("/settings/set?<options..>", data = "<data>")]
|
||||
pub async fn req(user: User, data: Json<Data>, options: Form<Options>) -> Result<()> {
|
||||
pub async fn req(user: User, data: Json<Data>, options: Options) -> Result<()> {
|
||||
let data = data.into_inner();
|
||||
let current_time = Utc::now().timestamp_millis();
|
||||
let timestamp = if let Some(timestamp) = options.timestamp {
|
||||
|
||||
Reference in New Issue
Block a user