Compare commits
5 Commits
20241213-1
...
20241220-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b15006a50 | ||
|
|
ac731e547d | ||
|
|
443f374f23 | ||
|
|
42367f477c | ||
|
|
3cb91151ca |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,3 +7,5 @@ target
|
||||
|
||||
.vercel
|
||||
.DS_Store
|
||||
|
||||
.idea
|
||||
@@ -13,3 +13,8 @@ members = [
|
||||
[patch.crates-io]
|
||||
redis22 = { package = "redis", version = "0.22.3", git = "https://github.com/revoltchat/redis-rs", rev = "1a41faf356fd21aebba71cea7eb7eb2653e5f0ef" }
|
||||
redis23 = { package = "redis", version = "0.23.1", git = "https://github.com/revoltchat/redis-rs", rev = "f8ca28ab85da59d2ccde526b4d2fb390eff5a5f9" }
|
||||
# authifier = { package = "authifier", version = "1.0.8", path = "../authifier/crates/authifier" }
|
||||
# rocket_authifier = { package = "rocket_authifier", version = "1.0.8", path = "../authifier/crates/rocket_authifier" }
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
||||
@@ -25,6 +25,7 @@ COPY crates/core/presence/Cargo.toml ./crates/core/presence/
|
||||
COPY crates/core/result/Cargo.toml ./crates/core/result/
|
||||
COPY crates/services/autumn/Cargo.toml ./crates/services/autumn/
|
||||
COPY crates/services/january/Cargo.toml ./crates/services/january/
|
||||
COPY crates/daemons/pushd/Cargo.toml ./crates/daemons/pushd/
|
||||
RUN sh /tmp/build-image-layer.sh deps
|
||||
|
||||
# Build all apps
|
||||
|
||||
@@ -23,6 +23,17 @@ macro_rules! report_error {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "report-macros")]
|
||||
#[macro_export]
|
||||
macro_rules! capture_internal_error {
|
||||
( $expr: expr ) => {
|
||||
$crate::capture_message(
|
||||
&format!("{:?} ({}:{}:{})", $expr, file!(), line!(), column!()),
|
||||
$crate::Level::Error,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "report-macros")]
|
||||
#[macro_export]
|
||||
macro_rules! report_internal_error {
|
||||
|
||||
@@ -25,6 +25,26 @@ pub use mongodb;
|
||||
#[macro_use]
|
||||
extern crate bson;
|
||||
|
||||
#[macro_export]
|
||||
#[cfg(debug_assertions)]
|
||||
macro_rules! query {
|
||||
( $self: ident, $type: ident, $collection: expr, $($rest:expr),+ ) => {
|
||||
Ok($self.$type($collection, $($rest),+).await.unwrap())
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
#[cfg(not(debug_assertions))]
|
||||
macro_rules! query {
|
||||
( $self: ident, $type: ident, $collection: expr, $($rest:expr),+ ) => {
|
||||
$self.$type($collection, $($rest),+).await
|
||||
.map_err(|err| {
|
||||
revolt_config::capture_internal_error!(err);
|
||||
create_database_error!(stringify!($type), $collection)
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! database_derived {
|
||||
( $( $item:item )+ ) => {
|
||||
$(
|
||||
|
||||
@@ -45,7 +45,7 @@ auto_derived!(
|
||||
Image {
|
||||
width: isize,
|
||||
height: isize,
|
||||
// animated: bool // TODO: https://docs.rs/image/latest/image/trait.AnimationDecoder.html
|
||||
// animated: bool // TODO: https://docs.rs/image/latest/image/trait.AnimationDecoder.html for APNG support
|
||||
},
|
||||
/// File is a video with specific dimensions
|
||||
Video { width: isize, height: isize },
|
||||
|
||||
@@ -171,7 +171,7 @@ impl AbstractMessages for MongoDb {
|
||||
self.find_with_options(
|
||||
COL,
|
||||
doc! {
|
||||
"ids": {
|
||||
"_id": {
|
||||
"$in": ids
|
||||
}
|
||||
},
|
||||
|
||||
@@ -189,23 +189,6 @@ macro_rules! create_database_error {
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
#[cfg(debug_assertions)]
|
||||
macro_rules! query {
|
||||
( $self: ident, $type: ident, $collection: expr, $($rest:expr),+ ) => {
|
||||
Ok($self.$type($collection, $($rest),+).await.unwrap())
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
#[cfg(not(debug_assertions))]
|
||||
macro_rules! query {
|
||||
( $self: ident, $type: ident, $collection: expr, $($rest:expr),+ ) => {
|
||||
$self.$type($collection, $($rest),+).await
|
||||
.map_err(|_| create_database_error!(stringify!($type), $collection))
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ErrorType;
|
||||
|
||||
@@ -7,7 +7,7 @@ FROM gcr.io/distroless/cc-debian12:nonroot
|
||||
COPY --from=builder /home/rust/src/target/release/revolt-delta ./
|
||||
COPY --from=debian /usr/bin/uname /usr/bin/uname
|
||||
|
||||
EXPOSE 8000
|
||||
ENV ROCKET_ADDRESS 0.0.0.0
|
||||
EXPOSE 14702
|
||||
ENV ROCKET_ADDRESS=0.0.0.0
|
||||
USER nonroot
|
||||
CMD ["./revolt-delta"]
|
||||
|
||||
@@ -64,7 +64,8 @@ lazy_static! {
|
||||
})
|
||||
// TODO config
|
||||
// .max_capacity(1024 * 1024 * 1024) // Cache up to 1GiB in memory
|
||||
.max_capacity(512 * 1024 * 1024) // Cache up to 512MiB in memory
|
||||
// .max_capacity(512 * 1024 * 1024) // Cache up to 512MiB in memory
|
||||
.max_capacity(2 * 1024 * 1024 * 1024) // Cache up to 2GiB in memory
|
||||
.time_to_live(Duration::from_secs(5 * 60)) // For up to 5 minutes
|
||||
.build();
|
||||
}
|
||||
@@ -366,8 +367,8 @@ async fn fetch_preview(
|
||||
|
||||
let hash = file.as_hash(&db).await?;
|
||||
|
||||
// Only process image files
|
||||
if !matches!(hash.metadata, Metadata::Image { .. }) {
|
||||
// Only process image files and don't process GIFs
|
||||
if !matches!(hash.metadata, Metadata::Image { .. }) || hash.content_type == "image/gif" {
|
||||
return Ok(
|
||||
Redirect::permanent(&format!("/{tag}/{file_id}/{}", file.filename)).into_response(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user