mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
Merge branch 'master' of github.com:revoltchat/backend into webhooks
This commit is contained in:
121
Cargo.lock
generated
121
Cargo.lock
generated
@@ -2069,17 +2069,6 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "okapi"
|
||||
version = "0.7.0-rc.1"
|
||||
source = "git+https://github.com/insertish/okapi?rev=a1048d0c8cd771e424ec97d33d825c32e06aa120#a1048d0c8cd771e424ec97d33d825c32e06aa120"
|
||||
dependencies = [
|
||||
"log",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.13.0"
|
||||
@@ -2591,8 +2580,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rauth"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/insertish/rauth?rev=cbdec69c684a4854fbedba9ed1f0e7ee466bf3f7#cbdec69c684a4854fbedba9ed1f0e7ee466bf3f7"
|
||||
version = "1.0.4"
|
||||
source = "git+https://github.com/insertish/rauth?tag=1.0.4#2d3bc59623672e3ff57c49a90c4d3cd20780dbba"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"async-trait",
|
||||
@@ -2607,12 +2596,12 @@ dependencies = [
|
||||
"log",
|
||||
"mongodb",
|
||||
"nanoid",
|
||||
"okapi",
|
||||
"rand 0.8.5",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"revolt_okapi",
|
||||
"revolt_rocket_okapi",
|
||||
"rocket",
|
||||
"rocket_okapi",
|
||||
"rust-argon2",
|
||||
"schemars",
|
||||
"serde",
|
||||
@@ -2801,7 +2790,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-bonfire"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"async-tungstenite",
|
||||
@@ -2817,7 +2806,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-delta"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-std",
|
||||
@@ -2842,9 +2831,9 @@ dependencies = [
|
||||
"regex",
|
||||
"reqwest",
|
||||
"revolt-quark",
|
||||
"revolt_rocket_okapi",
|
||||
"rocket",
|
||||
"rocket_empty",
|
||||
"rocket_okapi",
|
||||
"rocket_rauth",
|
||||
"schemars",
|
||||
"serde",
|
||||
@@ -2857,7 +2846,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-quark"
|
||||
version = "0.1.0"
|
||||
version = "0.5.6"
|
||||
dependencies = [
|
||||
"async-recursion",
|
||||
"async-std",
|
||||
@@ -2880,7 +2869,6 @@ dependencies = [
|
||||
"mongodb",
|
||||
"nanoid",
|
||||
"num_enum",
|
||||
"okapi",
|
||||
"once_cell",
|
||||
"optional_struct",
|
||||
"pretty_env_logger",
|
||||
@@ -2888,11 +2876,12 @@ dependencies = [
|
||||
"redis-kiss",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"revolt_okapi",
|
||||
"revolt_rocket_okapi",
|
||||
"rocket",
|
||||
"rocket_cors",
|
||||
"rocket_empty",
|
||||
"rocket_http",
|
||||
"rocket_okapi",
|
||||
"schemars",
|
||||
"sentry",
|
||||
"serde",
|
||||
@@ -2902,6 +2891,47 @@ dependencies = [
|
||||
"web-push",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "revolt_okapi"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23bfdf7ae769c3042fe727f6e5c17363b02a64b4b33ad60c3e5f73b26df7835b"
|
||||
dependencies = [
|
||||
"log",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "revolt_rocket_okapi"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "275e1e9bd3343f75225cafa64f4bfb939c8b21c5f861141180fc0e24769ff6cf"
|
||||
dependencies = [
|
||||
"either",
|
||||
"log",
|
||||
"revolt_okapi",
|
||||
"revolt_rocket_okapi_codegen",
|
||||
"rocket",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "revolt_rocket_okapi_codegen"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc6620569d8ac8f0a1690fcca13f488503807a60e96ebf729749b59aca1dbef9"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote 1.0.18",
|
||||
"rocket_http",
|
||||
"syn 1.0.96",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.16.20"
|
||||
@@ -2996,9 +3026,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rocket_cors"
|
||||
version = "0.5.2"
|
||||
source = "git+https://github.com/lawliet89/rocket_cors?rev=5843861a88958c16bfaa0b40f0d8910772bcd2f6#5843861a88958c16bfaa0b40f0d8910772bcd2f6"
|
||||
version = "0.6.0-alpha1"
|
||||
source = "git+https://github.com/lawliet89/rocket_cors?rev=c17e8145baa4790319fdb6a473e465b960f55e7c#c17e8145baa4790319fdb6a473e465b960f55e7c"
|
||||
dependencies = [
|
||||
"http",
|
||||
"log",
|
||||
"regex",
|
||||
"rocket",
|
||||
@@ -3011,12 +3042,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rocket_empty"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/insertish/rocket_empty?branch=master#9d8234fc3bb215ea241b787301e8cff68ae53652"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c0922e47f981204fee38578a8efcf47a5c1a4ac0eb7f59e6bdfa3e61c8e3d69"
|
||||
dependencies = [
|
||||
"okapi",
|
||||
"revolt_okapi",
|
||||
"revolt_rocket_okapi",
|
||||
"rocket",
|
||||
"rocket_okapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3046,44 +3078,17 @@ dependencies = [
|
||||
"uncased",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rocket_okapi"
|
||||
version = "0.8.0-rc.1"
|
||||
source = "git+https://github.com/insertish/okapi?rev=a1048d0c8cd771e424ec97d33d825c32e06aa120#a1048d0c8cd771e424ec97d33d825c32e06aa120"
|
||||
dependencies = [
|
||||
"either",
|
||||
"log",
|
||||
"okapi",
|
||||
"rocket",
|
||||
"rocket_okapi_codegen",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rocket_okapi_codegen"
|
||||
version = "0.8.0-rc.1"
|
||||
source = "git+https://github.com/insertish/okapi?rev=a1048d0c8cd771e424ec97d33d825c32e06aa120#a1048d0c8cd771e424ec97d33d825c32e06aa120"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote 1.0.18",
|
||||
"rocket_http",
|
||||
"syn 1.0.96",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rocket_rauth"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/insertish/rauth?rev=cbdec69c684a4854fbedba9ed1f0e7ee466bf3f7#cbdec69c684a4854fbedba9ed1f0e7ee466bf3f7"
|
||||
version = "1.0.4"
|
||||
source = "git+https://github.com/insertish/rauth?tag=1.0.4#2d3bc59623672e3ff57c49a90c4d3cd20780dbba"
|
||||
dependencies = [
|
||||
"iso8601-timestamp",
|
||||
"okapi",
|
||||
"rauth",
|
||||
"revolt_okapi",
|
||||
"revolt_rocket_okapi",
|
||||
"rocket",
|
||||
"rocket_empty",
|
||||
"rocket_okapi",
|
||||
"schemars",
|
||||
"serde",
|
||||
]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-bonfire"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
license = "AGPL-3.0-or-later"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-delta"
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
license = "AGPL-3.0-or-later"
|
||||
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
||||
edition = "2018"
|
||||
@@ -51,13 +51,12 @@ mobc-redis = { version = "0.7.0", default-features = false, features = ["async-s
|
||||
|
||||
# web
|
||||
rocket = { version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
||||
rocket_empty = { git = "https://github.com/insertish/rocket_empty", branch = "master" }
|
||||
rocket_rauth = { git = "https://github.com/insertish/rauth", rev = "cbdec69c684a4854fbedba9ed1f0e7ee466bf3f7" }
|
||||
rocket_empty = { version = "0.1.1", features = ["schema"] }
|
||||
rocket_rauth = { git = "https://github.com/insertish/rauth", tag = "1.0.4" }
|
||||
|
||||
# spec generation
|
||||
schemars = "0.8.8"
|
||||
# rocket_okapi = "0.8.0-rc.1"
|
||||
rocket_okapi = { git = "https://github.com/insertish/okapi", rev = "a1048d0c8cd771e424ec97d33d825c32e06aa120", features = [ "swagger" ] }
|
||||
revolt_rocket_okapi = { version = "0.9.1", features = [ "swagger" ] }
|
||||
|
||||
# quark
|
||||
revolt-quark = { path = "../quark" }
|
||||
|
||||
@@ -12,5 +12,5 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
vergen(Config::default()).unwrap();
|
||||
vergen(Config::default()).ok();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
#[macro_use]
|
||||
extern crate rocket_okapi;
|
||||
extern crate revolt_rocket_okapi;
|
||||
#[macro_use]
|
||||
extern crate serde_json;
|
||||
#[macro_use]
|
||||
@@ -10,7 +10,9 @@ extern crate lazy_static;
|
||||
pub mod routes;
|
||||
pub mod util;
|
||||
|
||||
use revolt_quark::rauth::RAuth;
|
||||
use async_std::channel::unbounded;
|
||||
use revolt_quark::events::client::EventV1;
|
||||
use revolt_quark::rauth::{RAuth, RAuthEvent};
|
||||
use revolt_quark::DatabaseInfo;
|
||||
|
||||
#[launch]
|
||||
@@ -25,13 +27,33 @@ async fn rocket() -> _ {
|
||||
let db = DatabaseInfo::Auto.connect().await.unwrap();
|
||||
db.migrate_database().await.unwrap();
|
||||
|
||||
// Setup rAuth event channel
|
||||
let (sender, receiver) = unbounded();
|
||||
|
||||
// Setup rAuth
|
||||
let rauth = RAuth {
|
||||
database: db.clone().into(),
|
||||
config: revolt_quark::util::rauth::config(),
|
||||
event_channel: Some(sender),
|
||||
};
|
||||
|
||||
// Launch background task workers.
|
||||
// Launch a listener for rAuth events
|
||||
async_std::task::spawn(async move {
|
||||
while let Ok(event) = receiver.recv().await {
|
||||
match &event {
|
||||
RAuthEvent::CreateSession { .. } | RAuthEvent::CreateAccount { .. } => {
|
||||
EventV1::Auth(event).global().await
|
||||
}
|
||||
RAuthEvent::DeleteSession { user_id, .. }
|
||||
| RAuthEvent::DeleteAllSessions { user_id, .. } => {
|
||||
let id = user_id.to_string();
|
||||
EventV1::Auth(event).private(id).await
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Launch background task workers
|
||||
async_std::task::spawn(revolt_quark::tasks::start_workers(db.clone()));
|
||||
|
||||
// Configure CORS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
||||
use rocket::Route;
|
||||
use rocket_okapi::okapi::openapi3::OpenApi;
|
||||
|
||||
mod create;
|
||||
mod delete;
|
||||
|
||||
@@ -65,16 +65,20 @@ pub async fn message_send(
|
||||
data.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
// Validate Message is within reasonable length limits
|
||||
Message::validate_sum(&data.content, &data.embeds)?;
|
||||
|
||||
// Ensure the request is unique
|
||||
idempotency.consume_nonce(data.nonce).await?;
|
||||
|
||||
// Ensure we have permissions to send a message
|
||||
let channel = target.as_channel(db).await?;
|
||||
let mut permissions = perms(&user).channel(&channel);
|
||||
permissions
|
||||
.throw_permission_and_view_channel(db, Permission::SendMessage)
|
||||
.await?;
|
||||
|
||||
// Check the message is not empty
|
||||
if (data.content.as_ref().map_or(true, |v| v.is_empty()))
|
||||
&& (data.attachments.as_ref().map_or(true, |v| v.is_empty()))
|
||||
&& (data.embeds.as_ref().map_or(true, |v| v.is_empty()))
|
||||
@@ -82,6 +86,22 @@ pub async fn message_send(
|
||||
return Err(Error::EmptyMessage);
|
||||
}
|
||||
|
||||
// Ensure restrict_reactions is not specified without reactions list
|
||||
if let Some(interactions) = &data.interactions {
|
||||
if interactions.restrict_reactions {
|
||||
let disallowed = if let Some(list) = &interactions.reactions {
|
||||
list.len() == 0
|
||||
} else {
|
||||
true
|
||||
};
|
||||
|
||||
if disallowed {
|
||||
return Err(Error::InvalidProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start constructing the message
|
||||
let message_id = Ulid::new().to_string();
|
||||
let mut message = Message {
|
||||
id: message_id.clone(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
||||
use rocket::Route;
|
||||
use rocket_okapi::okapi::openapi3::OpenApi;
|
||||
|
||||
mod channel_ack;
|
||||
mod channel_delete;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
||||
use rocket::Route;
|
||||
use rocket_okapi::okapi::openapi3::OpenApi;
|
||||
|
||||
mod emoji_create;
|
||||
mod emoji_delete;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
||||
use rocket::Route;
|
||||
use rocket_okapi::okapi::openapi3::OpenApi;
|
||||
|
||||
mod invite_delete;
|
||||
mod invite_fetch;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use revolt_rocket_okapi::{revolt_okapi::openapi3::OpenApi, settings::OpenApiSettings};
|
||||
pub use rocket::http::Status;
|
||||
pub use rocket::response::Redirect;
|
||||
use rocket::{Build, Rocket};
|
||||
use rocket_okapi::{okapi::openapi3::OpenApi, settings::OpenApiSettings};
|
||||
|
||||
mod bots;
|
||||
mod channels;
|
||||
@@ -41,7 +41,7 @@ pub fn mount(mut rocket: Rocket<Build>) -> Rocket<Build> {
|
||||
}
|
||||
|
||||
fn custom_openapi_spec() -> OpenApi {
|
||||
use rocket_okapi::okapi::openapi3::*;
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::*;
|
||||
|
||||
let mut extensions = schemars::Map::new();
|
||||
extensions.insert(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
||||
use rocket::Route;
|
||||
use rocket_okapi::okapi::openapi3::OpenApi;
|
||||
|
||||
mod complete;
|
||||
mod hello;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
||||
use rocket::Route;
|
||||
use rocket_okapi::okapi::openapi3::OpenApi;
|
||||
|
||||
mod subscribe;
|
||||
mod unsubscribe;
|
||||
|
||||
@@ -119,11 +119,12 @@ pub async fn root() -> Result<Json<RevoltConfig>> {
|
||||
app: APP_URL.to_string(),
|
||||
vapid: VAPID_PUBLIC_KEY.to_string(),
|
||||
build: BuildInformation {
|
||||
commit_sha: env!("VERGEN_GIT_SHA").to_string(),
|
||||
commit_timestamp: env!("VERGEN_GIT_COMMIT_TIMESTAMP").to_string(),
|
||||
semver: env!("VERGEN_GIT_SEMVER").to_string(),
|
||||
origin_url: env!("GIT_ORIGIN_URL", "<missing>").to_string(),
|
||||
timestamp: env!("VERGEN_BUILD_TIMESTAMP").to_string(),
|
||||
commit_sha: env!("VERGEN_GIT_SHA", "<failed to generate>").to_string(),
|
||||
commit_timestamp: env!("VERGEN_GIT_COMMIT_TIMESTAMP", "<failed to generate>")
|
||||
.to_string(),
|
||||
semver: env!("VERGEN_GIT_SEMVER", "<failed to generate>").to_string(),
|
||||
origin_url: env!("GIT_ORIGIN_URL", "<failed to generate>").to_string(),
|
||||
timestamp: env!("VERGEN_BUILD_TIMESTAMP", "<failed to generate>").to_string(),
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
||||
use rocket::Route;
|
||||
use rocket_okapi::okapi::openapi3::OpenApi;
|
||||
|
||||
mod ban_create;
|
||||
mod ban_list;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
||||
use rocket::Route;
|
||||
use rocket_okapi::okapi::openapi3::OpenApi;
|
||||
|
||||
mod get_settings;
|
||||
mod get_unreads;
|
||||
|
||||
26
crates/delta/src/routes/users/fetch_user_flags.rs
Normal file
26
crates/delta/src/routes/users/fetch_user_flags.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use revolt_quark::{Database, Ref, Result};
|
||||
|
||||
use rocket::{serde::json::Json, State};
|
||||
use serde::Serialize;
|
||||
|
||||
/// # Flag Response
|
||||
#[derive(Serialize, JsonSchema)]
|
||||
pub struct FlagResponse {
|
||||
/// Flags
|
||||
flags: i32,
|
||||
}
|
||||
|
||||
/// # Fetch User Flags
|
||||
///
|
||||
/// Retrieve a user's flags.
|
||||
#[openapi(tag = "User Information")]
|
||||
#[get("/<target>/flags")]
|
||||
pub async fn fetch_user_flags(db: &State<Database>, target: Ref) -> Result<Json<FlagResponse>> {
|
||||
let flags = if let Ok(target) = target.as_user(db).await {
|
||||
target.flags.unwrap_or_default()
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
Ok(Json(FlagResponse { flags }))
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::{self, MediaType, RefOr};
|
||||
use rocket::http::ContentType;
|
||||
use rocket::response::{self, Responder};
|
||||
use rocket::{Request, Response};
|
||||
use rocket_okapi::okapi::openapi3::{self, MediaType, RefOr};
|
||||
use schemars::schema::{InstanceType, SchemaObject, SingleOrVec};
|
||||
|
||||
pub struct CachedFile((ContentType, Vec<u8>));
|
||||
@@ -16,10 +16,10 @@ impl<'r> Responder<'r, 'static> for CachedFile {
|
||||
}
|
||||
}
|
||||
|
||||
impl rocket_okapi::response::OpenApiResponderInner for CachedFile {
|
||||
impl revolt_rocket_okapi::response::OpenApiResponderInner for CachedFile {
|
||||
fn responses(
|
||||
_gen: &mut rocket_okapi::gen::OpenApiGenerator,
|
||||
) -> std::result::Result<openapi3::Responses, rocket_okapi::OpenApiError> {
|
||||
_gen: &mut revolt_rocket_okapi::gen::OpenApiGenerator,
|
||||
) -> std::result::Result<openapi3::Responses, revolt_rocket_okapi::OpenApiError> {
|
||||
let mut responses = schemars::Map::new();
|
||||
let mut content = schemars::Map::new();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
||||
use rocket::Route;
|
||||
use rocket_okapi::okapi::openapi3::OpenApi;
|
||||
|
||||
mod add_friend;
|
||||
mod block_user;
|
||||
@@ -9,6 +9,7 @@ mod fetch_dms;
|
||||
mod fetch_profile;
|
||||
mod fetch_self;
|
||||
mod fetch_user;
|
||||
mod fetch_user_flags;
|
||||
mod find_mutual;
|
||||
mod get_default_avatar;
|
||||
mod open_dm;
|
||||
@@ -21,6 +22,7 @@ pub fn routes() -> (Vec<Route>, OpenApi) {
|
||||
// User Information
|
||||
fetch_self::req,
|
||||
fetch_user::req,
|
||||
fetch_user_flags::fetch_user_flags,
|
||||
edit_user::req,
|
||||
change_username::req,
|
||||
get_default_avatar::req,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-quark"
|
||||
version = "0.1.0"
|
||||
version = "0.5.6"
|
||||
license = "AGPL-3.0-or-later"
|
||||
edition = "2021"
|
||||
|
||||
@@ -38,10 +38,8 @@ bson = { version = "2.1.0", features = ["chrono-0_4"] }
|
||||
|
||||
# Spec Generation
|
||||
schemars = "0.8.8"
|
||||
okapi = { git = "https://github.com/insertish/okapi", rev = "a1048d0c8cd771e424ec97d33d825c32e06aa120" }
|
||||
rocket_okapi = { git = "https://github.com/insertish/okapi", rev = "a1048d0c8cd771e424ec97d33d825c32e06aa120" }
|
||||
# okapi = "0.7.0-rc.1"
|
||||
# rocket_okapi = "0.8.0-rc.1"
|
||||
revolt_okapi = "0.9.1"
|
||||
revolt_rocket_okapi = { version = "0.9.1", features = [ "swagger" ] }
|
||||
|
||||
# Databases
|
||||
redis-kiss = { version = "0.1.3" }
|
||||
@@ -82,11 +80,11 @@ web-push = "0.7.2"
|
||||
# Implementations
|
||||
rocket_http = { optional = true, version = "0.5.0-rc.2" }
|
||||
rocket = { optional = true, version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
||||
rocket_empty = { optional = true, git = "https://github.com/insertish/rocket_empty", branch = "master" }
|
||||
rocket_cors = { optional = true, git = "https://github.com/lawliet89/rocket_cors", rev = "5843861a88958c16bfaa0b40f0d8910772bcd2f6" }
|
||||
rocket_empty = { version = "0.1.1", optional = true, features = [ "schema" ] }
|
||||
rocket_cors = { optional = true, git = "https://github.com/lawliet89/rocket_cors", rev = "c17e8145baa4790319fdb6a473e465b960f55e7c" }
|
||||
|
||||
# rAuth
|
||||
rauth = { git = "https://github.com/insertish/rauth", rev = "cbdec69c684a4854fbedba9ed1f0e7ee466bf3f7", features = [ "async-std-runtime" ] }
|
||||
rauth = { git = "https://github.com/insertish/rauth", tag = "1.0.4", features = [ "async-std-runtime" ] }
|
||||
|
||||
# Sentry
|
||||
sentry = "0.25.0"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use rauth::RAuthEvent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::models::channel::{FieldsChannel, PartialChannel};
|
||||
@@ -196,6 +197,17 @@ pub enum EventV1 {
|
||||
/// Settings updated remotely
|
||||
UserSettingsUpdate { id: String, update: UserSettings },
|
||||
|
||||
/// User has been platform banned or deleted their account
|
||||
///
|
||||
/// Clients should remove the following associated data:
|
||||
/// - Messages
|
||||
/// - DM Channels
|
||||
/// - Relationships
|
||||
/// - Server Memberships
|
||||
///
|
||||
/// User flags are specified to explain why a wipe is occurring though not all reasons will necessarily ever appear.
|
||||
UserPlatformWipe { user_id: String, flags: i32 },
|
||||
|
||||
/// New emoji
|
||||
EmojiCreate(Emoji),
|
||||
|
||||
@@ -215,5 +227,8 @@ pub enum EventV1 {
|
||||
/// Delete webhook
|
||||
WebhookDelete {
|
||||
id: String
|
||||
}
|
||||
},
|
||||
|
||||
/// Auth events
|
||||
Auth(RAuthEvent),
|
||||
}
|
||||
|
||||
@@ -559,4 +559,9 @@ impl EventV1 {
|
||||
pub async fn private(self, id: String) {
|
||||
self.p(format!("{}!", id)).await;
|
||||
}
|
||||
|
||||
/// Publish internal global event
|
||||
pub async fn global(self) {
|
||||
self.p("global".to_string()).await;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use okapi::openapi3::{SecurityScheme, SecuritySchemeData};
|
||||
use rauth::models::Session;
|
||||
use rocket_okapi::gen::OpenApiGenerator;
|
||||
use rocket_okapi::request::{OpenApiFromRequest, RequestHeaderInput};
|
||||
use revolt_okapi::openapi3::{SecurityScheme, SecuritySchemeData};
|
||||
use revolt_rocket_okapi::gen::OpenApiGenerator;
|
||||
use revolt_rocket_okapi::request::{OpenApiFromRequest, RequestHeaderInput};
|
||||
|
||||
use rocket::http::Status;
|
||||
use rocket::request::{self, FromRequest, Outcome, Request};
|
||||
@@ -53,7 +53,7 @@ impl<'r> OpenApiFromRequest<'r> for User {
|
||||
_gen: &mut OpenApiGenerator,
|
||||
_name: String,
|
||||
_required: bool,
|
||||
) -> rocket_okapi::Result<RequestHeaderInput> {
|
||||
) -> revolt_rocket_okapi::Result<RequestHeaderInput> {
|
||||
let mut requirements = schemars::Map::new();
|
||||
requirements.insert("Session Token".to_owned(), vec![]);
|
||||
|
||||
|
||||
@@ -98,6 +98,8 @@ pub struct Interactions {
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub reactions: Option<IndexSet<String>>,
|
||||
/// Whether reactions should be restricted to the given list
|
||||
///
|
||||
/// Can only be set to true if reactions list is of at least length 1
|
||||
#[serde(skip_serializing_if = "if_false", default)]
|
||||
pub restrict_reactions: bool,
|
||||
}
|
||||
|
||||
@@ -105,6 +105,8 @@ pub enum Flags {
|
||||
Deleted = 2,
|
||||
/// User was banned off the platform
|
||||
Banned = 4,
|
||||
/// User was marked as spam and removed from platform
|
||||
Spam = 8,
|
||||
}
|
||||
|
||||
/// Bot information for if the user is a bot
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use okapi::openapi3::{self, SchemaObject};
|
||||
use revolt_okapi::openapi3::SchemaObject;
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3;
|
||||
use rocket::{
|
||||
http::{ContentType, Status},
|
||||
response::{self, Responder},
|
||||
@@ -19,10 +20,10 @@ pub enum Error {
|
||||
/// This error was not labeled :(
|
||||
LabelMe,
|
||||
|
||||
// ? Onboarding related errors.
|
||||
// ? Onboarding related errors
|
||||
AlreadyOnboarded,
|
||||
|
||||
// ? User related errors.
|
||||
// ? User related errors
|
||||
UsernameTaken,
|
||||
InvalidUsername,
|
||||
UnknownUser,
|
||||
@@ -32,7 +33,7 @@ pub enum Error {
|
||||
BlockedByOther,
|
||||
NotFriends,
|
||||
|
||||
// ? Channel related errors.
|
||||
// ? Channel related errors
|
||||
UnknownChannel,
|
||||
UnknownAttachment,
|
||||
UnknownMessage,
|
||||
@@ -49,7 +50,7 @@ pub enum Error {
|
||||
AlreadyInGroup,
|
||||
NotInGroup,
|
||||
|
||||
// ? Server related errors.
|
||||
// ? Server related errors
|
||||
UnknownServer,
|
||||
InvalidRole,
|
||||
Banned,
|
||||
@@ -58,12 +59,12 @@ pub enum Error {
|
||||
},
|
||||
TooManyEmoji,
|
||||
|
||||
// ? Bot related errors.
|
||||
// ? Bot related errors
|
||||
ReachedMaximumBots,
|
||||
IsBot,
|
||||
BotIsPrivate,
|
||||
|
||||
// ? Permission errors.
|
||||
// ? Permission errors
|
||||
MissingPermission {
|
||||
permission: Permission,
|
||||
},
|
||||
@@ -74,7 +75,7 @@ pub enum Error {
|
||||
CannotGiveMissingPermissions,
|
||||
NotOwner,
|
||||
|
||||
// ? General errors.
|
||||
// ? General errors
|
||||
DatabaseError {
|
||||
operation: &'static str,
|
||||
with: &'static str,
|
||||
@@ -82,6 +83,7 @@ pub enum Error {
|
||||
InternalError,
|
||||
InvalidOperation,
|
||||
InvalidCredentials,
|
||||
InvalidProperty,
|
||||
InvalidSession,
|
||||
DuplicateNonce,
|
||||
VosoUnavailable,
|
||||
@@ -174,6 +176,7 @@ impl<'r> Responder<'r, 'static> for Error {
|
||||
Error::InternalError => Status::InternalServerError,
|
||||
Error::InvalidOperation => Status::BadRequest,
|
||||
Error::InvalidCredentials => Status::Unauthorized,
|
||||
Error::InvalidProperty => Status::BadRequest,
|
||||
Error::InvalidSession => Status::Unauthorized,
|
||||
Error::DuplicateNonce => Status::Conflict,
|
||||
Error::VosoUnavailable => Status::BadRequest,
|
||||
@@ -194,11 +197,11 @@ impl<'r> Responder<'r, 'static> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl rocket_okapi::response::OpenApiResponderInner for Error {
|
||||
impl revolt_rocket_okapi::response::OpenApiResponderInner for Error {
|
||||
fn responses(
|
||||
gen: &mut rocket_okapi::gen::OpenApiGenerator,
|
||||
) -> std::result::Result<openapi3::Responses, rocket_okapi::OpenApiError> {
|
||||
let mut content = okapi::Map::new();
|
||||
gen: &mut revolt_rocket_okapi::gen::OpenApiGenerator,
|
||||
) -> std::result::Result<openapi3::Responses, revolt_rocket_okapi::OpenApiError> {
|
||||
let mut content = revolt_okapi::Map::new();
|
||||
|
||||
let settings = schemars::gen::SchemaSettings::default().with(|s| {
|
||||
s.option_nullable = true;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use crate::{Error, Result};
|
||||
|
||||
use async_std::sync::Mutex;
|
||||
use revolt_rocket_okapi::gen::OpenApiGenerator;
|
||||
use revolt_rocket_okapi::request::{OpenApiFromRequest, RequestHeaderInput};
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::{Parameter, ParameterValue};
|
||||
use rocket::http::Status;
|
||||
use rocket::request::{FromRequest, Outcome};
|
||||
use rocket_okapi::gen::OpenApiGenerator;
|
||||
use rocket_okapi::okapi::openapi3::{Parameter, ParameterValue};
|
||||
use rocket_okapi::request::{OpenApiFromRequest, RequestHeaderInput};
|
||||
use schemars::schema::{InstanceType, SchemaObject, SingleOrVec};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
@@ -47,7 +47,7 @@ impl<'r> OpenApiFromRequest<'r> for IdempotencyKey {
|
||||
_gen: &mut OpenApiGenerator,
|
||||
_name: String,
|
||||
_required: bool,
|
||||
) -> rocket_okapi::Result<RequestHeaderInput> {
|
||||
) -> revolt_rocket_okapi::Result<RequestHeaderInput> {
|
||||
Ok(RequestHeaderInput::Parameter(Parameter {
|
||||
name: "Idempotency-Key".to_string(),
|
||||
description: Some("Unique key to prevent duplicate requests".to_string()),
|
||||
|
||||
@@ -16,8 +16,8 @@ use rocket::request::{FromRequest, Outcome};
|
||||
use rocket::serde::json::Json;
|
||||
use rocket::{Data, Request, Response};
|
||||
|
||||
use rocket_okapi::gen::OpenApiGenerator;
|
||||
use rocket_okapi::request::{OpenApiFromRequest, RequestHeaderInput};
|
||||
use revolt_rocket_okapi::gen::OpenApiGenerator;
|
||||
use revolt_rocket_okapi::request::{OpenApiFromRequest, RequestHeaderInput};
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -241,7 +241,7 @@ impl<'r> OpenApiFromRequest<'r> for Ratelimiter {
|
||||
_gen: &mut OpenApiGenerator,
|
||||
_name: String,
|
||||
_required: bool,
|
||||
) -> rocket_okapi::Result<RequestHeaderInput> {
|
||||
) -> revolt_rocket_okapi::Result<RequestHeaderInput> {
|
||||
Ok(RequestHeaderInput::None)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use rocket::Route;
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
rocket_okapi::swagger_ui::make_swagger_ui(&rocket_okapi::swagger_ui::SwaggerUIConfig {
|
||||
revolt_rocket_okapi::swagger_ui::make_swagger_ui(&revolt_rocket_okapi::swagger_ui::SwaggerUIConfig {
|
||||
url: "../openapi.json".to_owned(),
|
||||
..Default::default()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user