forked from jmug/stoatchat
Compare commits
5
Commits
20240408-1
...
20240408-4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7703475868 | ||
|
|
4be3bdc4c3 | ||
|
|
3e26e7e89d | ||
|
|
13b95d383e | ||
|
|
3c76005c33 |
@@ -19,7 +19,6 @@ RUN sh /tmp/build-image-layer.sh tools
|
|||||||
COPY Cargo.toml Cargo.lock ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
COPY crates/bonfire/Cargo.toml ./crates/bonfire/
|
COPY crates/bonfire/Cargo.toml ./crates/bonfire/
|
||||||
COPY crates/delta/Cargo.toml ./crates/delta/
|
COPY crates/delta/Cargo.toml ./crates/delta/
|
||||||
COPY crates/quark/Cargo.toml ./crates/quark/
|
|
||||||
COPY crates/core/config/Cargo.toml ./crates/core/config/
|
COPY crates/core/config/Cargo.toml ./crates/core/config/
|
||||||
COPY crates/core/database/Cargo.toml ./crates/core/database/
|
COPY crates/core/database/Cargo.toml ./crates/core/database/
|
||||||
COPY crates/core/models/Cargo.toml ./crates/core/models/
|
COPY crates/core/models/Cargo.toml ./crates/core/models/
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ COPY scripts/build-image-layer.sh /tmp/
|
|||||||
COPY Cargo.toml Cargo.lock ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
COPY crates/bonfire/Cargo.toml ./crates/bonfire/
|
COPY crates/bonfire/Cargo.toml ./crates/bonfire/
|
||||||
COPY crates/delta/Cargo.toml ./crates/delta/
|
COPY crates/delta/Cargo.toml ./crates/delta/
|
||||||
COPY crates/quark/Cargo.toml ./crates/quark/
|
|
||||||
COPY crates/core/config/Cargo.toml ./crates/core/config/
|
COPY crates/core/config/Cargo.toml ./crates/core/config/
|
||||||
COPY crates/core/database/Cargo.toml ./crates/core/database/
|
COPY crates/core/database/Cargo.toml ./crates/core/database/
|
||||||
COPY crates/core/models/Cargo.toml ./crates/core/models/
|
COPY crates/core/models/Cargo.toml ./crates/core/models/
|
||||||
|
|||||||
@@ -2,17 +2,16 @@
|
|||||||
|
|
||||||
This is a monorepo for the Revolt backend.
|
This is a monorepo for the Revolt backend.
|
||||||
|
|
||||||
| Crate | Path | Description |
|
| Crate | Path | Description |
|
||||||
| ------------------ | -------------------------------------------------- | --------------------------------- |
|
| ------------------ | -------------------------------------------------- | ----------------------------- |
|
||||||
| `core/config` | [crates/core/config](crates/core/config) | Core: Configuration |
|
| `core/config` | [crates/core/config](crates/core/config) | Core: Configuration |
|
||||||
| `core/database` | [crates/core/database](crates/core/database) | Core: Database Implementation |
|
| `core/database` | [crates/core/database](crates/core/database) | Core: Database Implementation |
|
||||||
| `core/models` | [crates/core/models](crates/core/models) | Core: API Models |
|
| `core/models` | [crates/core/models](crates/core/models) | Core: API Models |
|
||||||
| `core/permissions` | [crates/core/permissions](crates/core/permissions) | Core: Permission Logic |
|
| `core/permissions` | [crates/core/permissions](crates/core/permissions) | Core: Permission Logic |
|
||||||
| `core/presence` | [crates/core/presence](crates/core/presence) | Core: User Presence |
|
| `core/presence` | [crates/core/presence](crates/core/presence) | Core: User Presence |
|
||||||
| `core/result` | [crates/core/result](crates/core/result) | Core: Result and Error types |
|
| `core/result` | [crates/core/result](crates/core/result) | Core: Result and Error types |
|
||||||
| `delta` | [crates/delta](crates/delta) | REST API server |
|
| `delta` | [crates/delta](crates/delta) | REST API server |
|
||||||
| `bonfire` | [crates/bonfire](crates/bonfire) | WebSocket events server |
|
| `bonfire` | [crates/bonfire](crates/bonfire) | WebSocket events server |
|
||||||
| `quark` | [crates/quark](crates/quark) | Models and logic (**DEPRECATED**) |
|
|
||||||
|
|
||||||
Note: `january`, `autumn`, and `vortex` are yet to be moved into this monorepo.
|
Note: `january`, `autumn`, and `vortex` are yet to be moved into this monorepo.
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ mod websocket;
|
|||||||
#[async_std::main]
|
#[async_std::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// Configure requirements for Bonfire.
|
// Configure requirements for Bonfire.
|
||||||
revolt_config::configure!();
|
revolt_config::configure!(events);
|
||||||
database::connect().await;
|
database::connect().await;
|
||||||
|
|
||||||
// Clean up the current region information.
|
// Clean up the current region information.
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
sentry_dsn = ""
|
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
mongodb = "mongodb://database"
|
mongodb = "mongodb://database"
|
||||||
redis = "redis://redis/"
|
redis = "redis://redis/"
|
||||||
@@ -14,7 +12,6 @@ voso_legacy = ""
|
|||||||
voso_legacy_ws = ""
|
voso_legacy_ws = ""
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
staging = false
|
|
||||||
|
|
||||||
[api.registration]
|
[api.registration]
|
||||||
invite_only = false
|
invite_only = false
|
||||||
@@ -68,3 +65,7 @@ background_size = 6000000
|
|||||||
icon_size = 2500000
|
icon_size = 2500000
|
||||||
banner_size = 6000000
|
banner_size = 6000000
|
||||||
emoji_size = 500000
|
emoji_size = 500000
|
||||||
|
|
||||||
|
[sentry]
|
||||||
|
api = ""
|
||||||
|
events = ""
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ use futures_locks::RwLock;
|
|||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
use std::env;
|
||||||
|
|
||||||
static CONFIG_BUILDER: Lazy<RwLock<Config>> = Lazy::new(|| {
|
static CONFIG_BUILDER: Lazy<RwLock<Config>> = Lazy::new(|| {
|
||||||
RwLock::new({
|
RwLock::new({
|
||||||
let mut builder = Config::builder().add_source(File::from_str(
|
let mut builder = Config::builder().add_source(File::from_str(
|
||||||
@@ -93,7 +96,6 @@ pub struct ApiWorkers {
|
|||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Api {
|
pub struct Api {
|
||||||
pub staging: bool,
|
|
||||||
pub registration: ApiRegistration,
|
pub registration: ApiRegistration,
|
||||||
pub smtp: ApiSmtp,
|
pub smtp: ApiSmtp,
|
||||||
pub vapid: ApiVapid,
|
pub vapid: ApiVapid,
|
||||||
@@ -138,13 +140,19 @@ pub struct Features {
|
|||||||
pub webhooks_enabled: bool,
|
pub webhooks_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
pub struct Sentry {
|
||||||
|
pub api: String,
|
||||||
|
pub events: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
pub database: Database,
|
pub database: Database,
|
||||||
pub hosts: Hosts,
|
pub hosts: Hosts,
|
||||||
pub api: Api,
|
pub api: Api,
|
||||||
pub features: Features,
|
pub features: Features,
|
||||||
pub sentry_dsn: String,
|
pub sentry: Sentry,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
@@ -188,7 +196,7 @@ pub async fn config() -> Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Configure logging and common Rust variables
|
/// Configure logging and common Rust variables
|
||||||
pub async fn setup_logging(release: &'static str) -> Option<sentry::ClientInitGuard> {
|
pub async fn setup_logging(release: &'static str, dsn: String) -> Option<sentry::ClientInitGuard> {
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
|
|
||||||
if std::env::var("RUST_LOG").is_err() {
|
if std::env::var("RUST_LOG").is_err() {
|
||||||
@@ -202,12 +210,11 @@ pub async fn setup_logging(release: &'static str) -> Option<sentry::ClientInitGu
|
|||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
log::info!("Starting {release}");
|
log::info!("Starting {release}");
|
||||||
|
|
||||||
let config = config().await;
|
if dsn.is_empty() {
|
||||||
if config.sentry_dsn.is_empty() {
|
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(sentry::init((
|
Some(sentry::init((
|
||||||
config.sentry_dsn,
|
dsn,
|
||||||
sentry::ClientOptions {
|
sentry::ClientOptions {
|
||||||
release: Some(release.into()),
|
release: Some(release.into()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -218,12 +225,12 @@ pub async fn setup_logging(release: &'static str) -> Option<sentry::ClientInitGu
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! configure {
|
macro_rules! configure {
|
||||||
() => {
|
($application: ident) => {
|
||||||
let _sentry = $crate::setup_logging(concat!(
|
let config = $crate::config().await;
|
||||||
env!("CARGO_PKG_NAME"),
|
let _sentry = $crate::setup_logging(
|
||||||
"@",
|
concat!(env!("CARGO_PKG_NAME"), "@", env!("CARGO_PKG_VERSION")),
|
||||||
env!("CARGO_PKG_VERSION")
|
config.sentry.$application,
|
||||||
))
|
)
|
||||||
.await;
|
.await;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ impl User {
|
|||||||
db.fetch_user(
|
db.fetch_user(
|
||||||
&db.fetch_bot_by_token(token)
|
&db.fetch_bot_by_token(token)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| create_error!(InternalError))?
|
.map_err(|_| create_error!(InvalidSession))?
|
||||||
.id,
|
.id,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ impl AbstractUsers for MongoDb {
|
|||||||
.map_err(|_| create_database_error!("find_one", "sessions"))?
|
.map_err(|_| create_database_error!("find_one", "sessions"))?
|
||||||
.ok_or_else(|| create_error!(InvalidSession))?;
|
.ok_or_else(|| create_error!(InvalidSession))?;
|
||||||
|
|
||||||
self.fetch_user(&session.id).await
|
self.fetch_user(&session.user_id).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch multiple users by their ids
|
/// Fetch multiple users by their ids
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ pub async fn authifier_config() -> AuthifierConfig {
|
|||||||
#[launch]
|
#[launch]
|
||||||
async fn rocket() -> _ {
|
async fn rocket() -> _ {
|
||||||
// Configure logging and environment
|
// Configure logging and environment
|
||||||
revolt_config::configure!();
|
revolt_config::configure!(api);
|
||||||
|
|
||||||
// Start web server
|
// Start web server
|
||||||
web().await
|
web().await
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ deps() {
|
|||||||
mkdir -p \
|
mkdir -p \
|
||||||
crates/bonfire/src \
|
crates/bonfire/src \
|
||||||
crates/delta/src \
|
crates/delta/src \
|
||||||
crates/quark/src \
|
|
||||||
crates/core/config/src \
|
crates/core/config/src \
|
||||||
crates/core/database/src \
|
crates/core/database/src \
|
||||||
crates/core/models/src \
|
crates/core/models/src \
|
||||||
@@ -35,7 +34,6 @@ deps() {
|
|||||||
tee crates/bonfire/src/main.rs |
|
tee crates/bonfire/src/main.rs |
|
||||||
tee crates/delta/src/main.rs
|
tee crates/delta/src/main.rs
|
||||||
echo '' |
|
echo '' |
|
||||||
tee crates/quark/src/lib.rs |
|
|
||||||
tee crates/core/config/src/lib.rs |
|
tee crates/core/config/src/lib.rs |
|
||||||
tee crates/core/database/src/lib.rs |
|
tee crates/core/database/src/lib.rs |
|
||||||
tee crates/core/models/src/lib.rs |
|
tee crates/core/models/src/lib.rs |
|
||||||
@@ -54,7 +52,6 @@ apps() {
|
|||||||
touch -am \
|
touch -am \
|
||||||
crates/bonfire/src/main.rs \
|
crates/bonfire/src/main.rs \
|
||||||
crates/delta/src/main.rs \
|
crates/delta/src/main.rs \
|
||||||
crates/quark/src/lib.rs \
|
|
||||||
crates/core/config/src/lib.rs \
|
crates/core/config/src/lib.rs \
|
||||||
crates/core/database/src/lib.rs \
|
crates/core/database/src/lib.rs \
|
||||||
crates/core/models/src/lib.rs \
|
crates/core/models/src/lib.rs \
|
||||||
|
|||||||
Regular → Executable
+1
-1
@@ -11,7 +11,7 @@ echo "[profile.release]" >> Cargo.toml
|
|||||||
echo "debug = true" >> Cargo.toml
|
echo "debug = true" >> Cargo.toml
|
||||||
|
|
||||||
TAG=$1-debug
|
TAG=$1-debug
|
||||||
echo "Building images, will tag for ghcr.io with $TAG-debug!"
|
echo "Building images, will tag for ghcr.io with $TAG!"
|
||||||
docker build -t ghcr.io/revoltchat/base:latest -f Dockerfile.useCurrentArch .
|
docker build -t ghcr.io/revoltchat/base:latest -f Dockerfile.useCurrentArch .
|
||||||
docker build -t ghcr.io/revoltchat/server:$TAG - < crates/delta/Dockerfile
|
docker build -t ghcr.io/revoltchat/server:$TAG - < crates/delta/Dockerfile
|
||||||
docker build -t ghcr.io/revoltchat/bonfire:$TAG - < crates/bonfire/Dockerfile
|
docker build -t ghcr.io/revoltchat/bonfire:$TAG - < crates/bonfire/Dockerfile
|
||||||
|
|||||||
Reference in New Issue
Block a user