Compare commits

..
27 Commits
Author SHA1 Message Date
izzy 25025da70a Merge branch 'main' into 3-otel 2026-04-01 21:14:44 +01:00
izzy d1631f6262 test: correct image size of extra bytes jpeg test
Signed-off-by: izzy <me@insrt.uk>
2026-01-25 20:22:47 +00:00
izzy 94aaeed758 chore: remove un-used import
Signed-off-by: izzy <me@insrt.uk>
2026-01-25 19:49:36 +00:00
izzy 945b7a6ecb Merge branch '2-refactor-core-files' into 3-otel 2026-01-25 19:49:08 +00:00
izzy 6418da51cd Merge branch 'main' into 2-refactor-core-files
# Conflicts:
#	Cargo.lock
2026-01-25 19:49:08 +00:00
izzy 74e36c7c2a Merge branch '2-refactor-core-files' into 3-otel 2026-01-24 23:44:18 +00:00
izzy 239112f935 Merge branch '1-mise-git-town' into 2-refactor-core-files 2026-01-24 23:44:17 +00:00
izzy 5968514231 Merge branch 'main' into 1-mise-git-town 2026-01-24 23:44:16 +00:00
izzy 0c3f76a406 Merge branch '2-refactor-core-files' into 3-otel 2026-01-24 23:36:45 +00:00
izzy f988b09d9a Merge branch '1-mise-git-town' into 2-refactor-core-files 2026-01-24 23:36:44 +00:00
izzy facaf3869f Merge branch 'main' into 1-mise-git-town 2026-01-24 23:36:42 +00:00
izzy c96f89aaa9 Merge branch '2-refactor-core-files' into 3-otel 2026-01-24 23:35:50 +00:00
izzy 03d790007d Merge branch '1-mise-git-town' into 2-refactor-core-files 2026-01-24 23:35:49 +00:00
izzy 270a9ac625 Merge branch 'main' into 1-mise-git-town 2026-01-24 23:35:48 +00:00
izzy 6acc7a3e46 Merge branch '2-refactor-core-files' into 3-otel 2026-01-24 02:18:54 +00:00
izzy e6a2571303 Merge branch '1-mise-git-town' into 2-refactor-core-files 2026-01-24 02:18:53 +00:00
izzy ef36df5da1 Merge branch 'main' into 1-mise-git-town 2026-01-24 02:18:51 +00:00
izzy d552442b43 Merge branch '2-refactor-core-files' into 3-otel 2026-01-24 02:11:10 +00:00
izzy 0fb4981556 Merge branch '1-mise-git-town' into 2-refactor-core-files 2026-01-24 02:11:09 +00:00
izzy 6b00c5aa42 Merge branch 'main' into 1-mise-git-town 2026-01-24 02:11:08 +00:00
izzy 503885d8dc Merge branch '1-mise-git-town' into 2-refactor-core-files 2026-01-24 02:02:55 +00:00
izzy e896bec16a Merge branch 'main' into 1-mise-git-town 2026-01-24 02:02:54 +00:00
izzy 7468ba5b8a trigger workflow
Signed-off-by: izzy <me@insrt.uk>
2026-01-24 02:01:30 +00:00
izzy d9ca1b8805 trigger workflow 2026-01-24 01:57:27 +00:00
izzy 97511059a4 feat: add otel logging, integrate with tracing 2026-01-24 01:27:32 +00:00
izzy e896582a5c feat: repository architecture for files crate w. added tests
Signed-off-by: izzy <me@insrt.uk>
2026-01-24 01:25:42 +00:00
izzy 9c2ae59ecf chore: add git-town tool
Signed-off-by: izzy <me@insrt.uk>
2026-01-24 01:21:33 +00:00
42 changed files with 397 additions and 354 deletions

No files matched your search

-24
View File
@@ -1,24 +0,0 @@
<!-- Describe your changes -->
Fixes # (issue)
## How was this PR tested?
<!-- What did you do to test your changes? -->
- [ ] Test A
- [ ] Test B
## Checklist:
- [ ] I have carefully read [the contributing guidelines](https://developers.stoat.chat/developing/contrib/)
- [ ] I have performed a self-review of my own code
- [ ] I have made corresponding changes to the documentation if applicable
- [ ] I have no unrelated changes in the PR
- [ ] I have confirmed that any new dependencies are strictly necessary
- [ ] I have written tests for new code (if applicable)
- [ ] I have followed naming conventions/patterns in the surrounding code
## Please declare, if any, LLM usage involved in creating this PR
...
-9
View File
@@ -16,13 +16,4 @@ idiomatic_version_file_enable_tools = ["rust"]
[tasks.start]
description = "Run all services"
depends = ["docker:start", "build"]
wait_for = ["docker:start", "build"]
run = [{ task = "service:*" }]
[env]
BUILDER = "cargo"
DOCKER_NETWORK_NAME = "stoatchat_default"
DATABASE_PORT = "27017"
RABBIT_PORT = "5672"
REDIS_PORT = "6379"
_.file = { path = ".env", tools = true }
+1 -1
View File
@@ -2,4 +2,4 @@
#MISE description="Build project"
set -e
${BUILDER} build "$@"
cargo build "$@"
+1 -9
View File
@@ -2,12 +2,4 @@
#MISE description="Start Docker containers"
set -e
docker compose up -d
docker run \
--network=${DOCKER_NETWORK_NAME} \
--name wait \
--rm dokku/wait -c \
rabbit:${RABBIT_PORT},\
database:${DATABASE_PORT},\
redis:${REDIS_PORT}
docker compose up -d "$@"
+1 -1
View File
@@ -2,4 +2,4 @@
#MISE description="Stop Docker containers"
set -e
docker compose down
docker compose down "$@"
+1 -1
View File
@@ -1,3 +1,3 @@
{
".": "0.12.1"
".": "0.12.0"
}
-10
View File
@@ -1,15 +1,5 @@
# Changelog
## [0.12.1](https://github.com/stoatchat/stoatchat/compare/v0.12.0...v0.12.1) (2026-04-10)
### Bug Fixes
* add migration to update existing files to be animated ([#705](https://github.com/stoatchat/stoatchat/issues/705)) ([f2c056a](https://github.com/stoatchat/stoatchat/commit/f2c056a1515be493b195f3f5db5886c2ddf36700))
* don't send self dm notifications ([#706](https://github.com/stoatchat/stoatchat/issues/706)) ([f30b729](https://github.com/stoatchat/stoatchat/commit/f30b729ca90d0be6853c57ab4935694e5e59ae56))
* mise start + missing docker image ([#564](https://github.com/stoatchat/stoatchat/issues/564)) ([fb8fe16](https://github.com/stoatchat/stoatchat/commit/fb8fe1655776791421284a6a093e86f0320c258a))
* test failure due to wrong assertion ([#707](https://github.com/stoatchat/stoatchat/issues/707)) ([f81e329](https://github.com/stoatchat/stoatchat/commit/f81e3291bdd57af9ceedb2987b111acc7051d69c))
## [0.12.0](https://github.com/stoatchat/stoatchat/compare/v0.11.5...v0.12.0) (2026-03-28)
Generated
+171 -25
View File
@@ -4671,7 +4671,7 @@ dependencies = [
"log",
"parking_lot",
"pbjson-types",
"prost",
"prost 0.12.6",
"rand 0.9.2",
"reqwest 0.11.27",
"scopeguard",
@@ -4693,7 +4693,7 @@ dependencies = [
"parking_lot",
"pbjson",
"pbjson-types",
"prost",
"prost 0.12.6",
"prost-types",
"serde",
"thiserror 1.0.69",
@@ -5484,6 +5484,90 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "opentelemetry"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b84bcd6ae87133e903af7ef497404dda70c60d0ea14895fc8a5e6722754fc2a0"
dependencies = [
"futures-core",
"futures-sink",
"js-sys",
"pin-project-lite 0.2.16",
"thiserror 2.0.18",
"tracing",
]
[[package]]
name = "opentelemetry-appender-tracing"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef6a1ac5ca3accf562b8c306fa8483c85f4390f768185ab775f242f7fe8fdcc2"
dependencies = [
"opentelemetry",
"tracing",
"tracing-core",
"tracing-subscriber",
]
[[package]]
name = "opentelemetry-http"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7a6d09a73194e6b66df7c8f1b680f156d916a1a942abf2de06823dd02b7855d"
dependencies = [
"async-trait",
"bytes 1.10.1",
"http 1.3.1",
"opentelemetry",
"reqwest 0.12.23",
]
[[package]]
name = "opentelemetry-otlp"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f69cd6acbb9af919df949cd1ec9e5e7fdc2ef15d234b6b795aaa525cc02f71f"
dependencies = [
"http 1.3.1",
"opentelemetry",
"opentelemetry-http",
"opentelemetry-proto",
"opentelemetry_sdk",
"prost 0.14.3",
"reqwest 0.12.23",
"thiserror 2.0.18",
"tracing",
]
[[package]]
name = "opentelemetry-proto"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7175df06de5eaee9909d4805a3d07e28bb752c34cab57fa9cff549da596b30f"
dependencies = [
"opentelemetry",
"opentelemetry_sdk",
"prost 0.14.3",
"tonic",
"tonic-prost",
]
[[package]]
name = "opentelemetry_sdk"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e14ae4f5991976fd48df6d843de219ca6d31b01daaab2dad5af2badeded372bd"
dependencies = [
"futures-channel",
"futures-executor",
"futures-util",
"opentelemetry",
"percent-encoding",
"rand 0.9.2",
"thiserror 2.0.18",
]
[[package]]
name = "ordered-multimap"
version = "0.4.3"
@@ -5612,7 +5696,7 @@ checksum = "2580e33f2292d34be285c5bc3dba5259542b083cfad6037b6d70345f24dcb735"
dependencies = [
"heck 0.4.1",
"itertools 0.11.0",
"prost",
"prost 0.12.6",
"prost-types",
]
@@ -5626,7 +5710,7 @@ dependencies = [
"chrono",
"pbjson",
"pbjson-build",
"prost",
"prost 0.12.6",
"prost-build",
"serde",
]
@@ -6209,7 +6293,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29"
dependencies = [
"bytes 1.10.1",
"prost-derive",
"prost-derive 0.12.6",
]
[[package]]
name = "prost"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2ea70524a2f82d518bce41317d0fae74151505651af45faf1ffbd6fd33f0568"
dependencies = [
"bytes 1.10.1",
"prost-derive 0.14.3",
]
[[package]]
@@ -6226,7 +6320,7 @@ dependencies = [
"once_cell",
"petgraph",
"prettyplease",
"prost",
"prost 0.12.6",
"prost-types",
"regex",
"syn 2.0.106",
@@ -6246,13 +6340,26 @@ dependencies = [
"syn 2.0.106",
]
[[package]]
name = "prost-derive"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b"
dependencies = [
"anyhow",
"itertools 0.14.0",
"proc-macro2",
"quote 1.0.40",
"syn 2.0.106",
]
[[package]]
name = "prost-types"
version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0"
dependencies = [
"prost",
"prost 0.12.6",
]
[[package]]
@@ -6742,7 +6849,9 @@ dependencies = [
"base64 0.22.1",
"bytes 1.10.1",
"encoding_rs",
"futures-channel",
"futures-core",
"futures-util",
"h2 0.4.12",
"http 1.3.1",
"http-body 1.0.1",
@@ -6798,7 +6907,7 @@ dependencies = [
[[package]]
name = "revolt-autumn"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"axum",
"axum-macros",
@@ -6812,6 +6921,10 @@ dependencies = [
"lazy_static",
"moka",
"nanoid",
"opentelemetry",
"opentelemetry-appender-tracing",
"opentelemetry-otlp",
"opentelemetry_sdk",
"revolt-config",
"revolt-database",
"revolt-files",
@@ -6837,7 +6950,7 @@ dependencies = [
[[package]]
name = "revolt-bonfire"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"async-channel 2.5.0",
"async-std",
@@ -6868,7 +6981,7 @@ dependencies = [
[[package]]
name = "revolt-coalesced"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"indexmap 2.13.0",
"lru 0.16.3",
@@ -6877,7 +6990,7 @@ dependencies = [
[[package]]
name = "revolt-config"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"async-std",
"cached",
@@ -6894,7 +7007,7 @@ dependencies = [
[[package]]
name = "revolt-crond"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"log",
"revolt-config",
@@ -6906,7 +7019,7 @@ dependencies = [
[[package]]
name = "revolt-database"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"amqprs",
"async-lock 2.8.0",
@@ -6956,7 +7069,7 @@ dependencies = [
[[package]]
name = "revolt-delta"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"amqprs",
"async-channel 1.9.0",
@@ -7006,7 +7119,7 @@ dependencies = [
[[package]]
name = "revolt-files"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"aes-gcm",
"anyhow",
@@ -7034,7 +7147,7 @@ dependencies = [
[[package]]
name = "revolt-gifbox"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"axum",
"axum-extra",
@@ -7057,7 +7170,7 @@ dependencies = [
[[package]]
name = "revolt-january"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"async-recursion",
"axum",
@@ -7085,7 +7198,7 @@ dependencies = [
[[package]]
name = "revolt-models"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"indexmap 1.9.3",
"iso8601-timestamp",
@@ -7104,14 +7217,14 @@ dependencies = [
[[package]]
name = "revolt-parser"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"logos",
]
[[package]]
name = "revolt-permissions"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"async-std",
"async-trait",
@@ -7126,7 +7239,7 @@ dependencies = [
[[package]]
name = "revolt-presence"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"async-std",
"log",
@@ -7138,7 +7251,7 @@ dependencies = [
[[package]]
name = "revolt-pushd"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"amqprs",
"anyhow",
@@ -7169,7 +7282,7 @@ dependencies = [
[[package]]
name = "revolt-ratelimits"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"async-trait",
"authifier",
@@ -7186,7 +7299,7 @@ dependencies = [
[[package]]
name = "revolt-result"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"axum",
"log",
@@ -7202,7 +7315,7 @@ dependencies = [
[[package]]
name = "revolt-voice-ingress"
version = "0.12.1"
version = "0.12.0"
dependencies = [
"amqprs",
"async-std",
@@ -9115,6 +9228,38 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
[[package]]
name = "tonic"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fec7c61a0695dc1887c1b53952990f3ad2e3a31453e1f49f10e75424943a93ec"
dependencies = [
"async-trait",
"base64 0.22.1",
"bytes 1.10.1",
"http 1.3.1",
"http-body 1.0.1",
"http-body-util",
"percent-encoding",
"pin-project",
"sync_wrapper 1.0.2",
"tokio-stream",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "tonic-prost"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a55376a0bbaa4975a3f10d009ad763d8f4108f067c7c2e74f3001fb49778d309"
dependencies = [
"bytes 1.10.1",
"prost 0.14.3",
"tonic",
]
[[package]]
name = "totp-lite"
version = "2.0.1"
@@ -9157,6 +9302,7 @@ dependencies = [
"pin-project-lite 0.2.16",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
+33 -25
View File
@@ -76,14 +76,6 @@ mise install
mise build
```
> [!TIP]
> You can override `BUILDER` in your `.env` file to run cargo with mold if you installed it:
>
> ```bash
> # .env
> BUILDER = "mold --run cargo"
> ```
A default configuration `Revolt.toml` is present in this project that is suited for development.
If you'd like to change anything, create a `Revolt.overrides.toml` file and specify relevant variables.
@@ -118,9 +110,21 @@ If you'd like to change anything, create a `Revolt.overrides.toml` file and spec
> ports: !override
> - "14072:5672"
> - "14672:15672"
>
> victoria-metrics:
> ports: !override
> - "18428:8428"
>
> victoria-logs:
> ports: !override
> - "19428:9428"
>
> victoria-traces:
> ports: !override
> - "14428:10428"
> ```
>
> With the corresponding Revolt configuration:
> And corresponding Revolt configuration:
>
> ```toml
> # Revolt.overrides.toml
@@ -132,25 +136,32 @@ If you'd like to change anything, create a `Revolt.overrides.toml` file and spec
> [rabbit]
> port = 14072
> ```
>
> And mise configuration
>
> ```bash
> #.env
> DATABASE_PORT = "14017"
> RABBIT_PORT = "14072"
> REDIS_PORT = "14079"
> ```
Then continue:
```bash
cp livekit.example.yml livekit.yml
# start other necessary services
docker compose up -d
mise start
# run the API server
cargo run --bin revolt-delta
# run the events server
cargo run --bin revolt-bonfire
# run the file server
cargo run --bin revolt-autumn
# run the proxy server
cargo run --bin revolt-january
# run the tenor proxy
cargo run --bin revolt-gifbox
# run the push daemon (not usually needed in regular development)
cargo run --bin revolt-pushd
# hint:
# mold -run <cargo build, cargo run, etc...>
# mold -run ./scripts/start.sh
```
You can start a web client by doing the following in another terminal:
You can start a web client by doing the following:
```bash
# if you do not have yarn yet and have a modern Node.js:
@@ -164,9 +175,6 @@ cd stoat-web
When signing up, go to http://localhost:14080 to find confirmation/password reset emails.
To stop all services, hit (CTRL + c) in the terminal you ran `mise start` and run `mise docker:stop`
## Deployment Guide
### Cutting new crate releases
@@ -202,7 +210,7 @@ If you have bumped the crate versions, proceed to [GitHub releases](https://gith
First, start the required services:
```sh
docker compose up -d
docker compose -f docker-compose.db.yml up -d
```
Now run tests for whichever database:
+22
View File
@@ -1,3 +1,5 @@
name: stoat-backend
services:
# Redis
redis:
@@ -69,9 +71,29 @@ services:
MAILDEV_INCOMING_USER: smtp
MAILDEV_INCOMING_PASS: smtp
# LiveKit
livekit:
image: ghcr.io/stoatchat/livekit-server:v1.9.13
command: --config /etc/livekit.yml
network_mode: "host"
volumes:
- ./livekit.yml:/etc/livekit.yml
# VM
victoria-metrics:
image: victoriametrics/victoria-metrics:latest
ports:
- 8428:8428
# VL
victoria-logs:
image: docker.io/victoriametrics/victoria-logs:v1.43.1
ports:
- 9428:9428
command: -storageDataPath=victoria-logs-data
# VT
victoria-traces:
image: docker.io/victoriametrics/victoria-traces:latest
ports:
- 10428:10428
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-bonfire"
version = "0.12.1"
version = "0.12.0"
license = "AGPL-3.0-or-later"
edition = "2021"
publish = false
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-coalesced"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "MIT"
authors = ["Paul Makles <me@insrt.uk>", "Zomatree <me@zomatree.live>"]
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-config"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "MIT"
authors = ["Paul Makles <me@insrt.uk>"]
@@ -38,4 +38,4 @@ sentry = { version = "0.31.5", optional = true }
sentry-anyhow = { version = "0.38.1", optional = true }
# Core
revolt-result = { version = "0.12.1", path = "../result", optional = true }
revolt-result = { version = "0.12.0", path = "../result", optional = true }
-1
View File
@@ -480,7 +480,6 @@ pub async fn setup_logging(release: &'static str, dsn: String) -> Option<sentry:
std::env::set_var("ROCKET_ADDRESS", "0.0.0.0");
}
pretty_env_logger::init();
log::info!("Starting {release}");
if dsn.is_empty() {
+7 -7
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-database"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "AGPL-3.0-or-later"
authors = ["Paul Makles <me@insrt.uk>"]
@@ -32,19 +32,19 @@ default = ["mongodb", "async-std-runtime", "tasks"]
[dependencies]
# Core
revolt-config = { version = "0.12.1", path = "../config", features = [
revolt-config = { version = "0.12.0", path = "../config", features = [
"report-macros",
] }
revolt-result = { version = "0.12.1", path = "../result" }
revolt-models = { version = "0.12.1", path = "../models", features = [
revolt-result = { version = "0.12.0", path = "../result" }
revolt-models = { version = "0.12.0", path = "../models", features = [
"validator",
] }
revolt-presence = { version = "0.12.1", path = "../presence" }
revolt-permissions = { version = "0.12.1", path = "../permissions", features = [
revolt-presence = { version = "0.12.0", path = "../presence" }
revolt-permissions = { version = "0.12.0", path = "../permissions", features = [
"serde",
"bson",
] }
revolt-parser = { version = "0.12.1", path = "../parser" }
revolt-parser = { version = "0.12.0", path = "../parser" }
# Utility
log = "0.4"
@@ -46,7 +46,8 @@ auto_derived!(
width: isize,
height: isize,
thumbhash: Option<Vec<u8>>,
animated: Option<bool>,
#[serde(default)]
animated: bool,
},
/// File is a video with specific dimensions
Video { width: isize, height: isize },
@@ -17,12 +17,6 @@ pub trait AbstractAttachmentHashes: Sync + Send {
/// Update an attachment hash nonce value.
async fn set_attachment_hash_nonce(&self, hash: &str, nonce: &str) -> Result<()>;
/// Updates the attachments animated metadata value.
///
/// The primary use for this is to update the metadata for existing uploaded files, this
/// can only be used for images.
async fn set_attachment_hash_animated(&self, hash: &str, animated: bool) -> Result<()>;
/// Delete attachment hash by id.
async fn delete_attachment_hash(&self, id: &str) -> Result<()>;
}
@@ -48,29 +48,6 @@ impl AbstractAttachmentHashes for MongoDb {
.map_err(|_| create_database_error!("update_one", COL))
}
/// Updates the attachments animated metadata value.
///
/// The primary use for this is to update the metadata for existing uploaded files, this
/// can only be used for images.
async fn set_attachment_hash_animated(&self, hash: &str, animated: bool) -> Result<()> {
self.col::<FileHash>(COL)
.update_one(
doc! {
"_id": hash,
"metadata.type": "Image",
"metadata.animated": { "$exists": false },
},
doc! {
"$set": {
"metadata.animated": animated
}
},
)
.await
.map(|_| ())
.map_err(|_| create_database_error!("update_one", COL))
}
/// Delete attachment hash by id.
async fn delete_attachment_hash(&self, id: &str) -> Result<()> {
query!(self, delete_one_by_id, COL, id).map(|_| ())
@@ -1,6 +1,7 @@
use revolt_result::Result;
use crate::{FileHash, Metadata, ReferenceDb};
use crate::FileHash;
use crate::ReferenceDb;
use super::AbstractAttachmentHashes;
@@ -38,29 +39,6 @@ impl AbstractAttachmentHashes for ReferenceDb {
}
}
/// Updates the attachments animated metadata value.
///
/// The primary use for this is to update the metadata for existing uploaded files, this
/// can only be used for images.
async fn set_attachment_hash_animated(&self, hash: &str, animated: bool) -> Result<()> {
let mut hashes = self.file_hashes.lock().await;
if let Some(FileHash {
metadata:
Metadata::Image {
animated: Some(animated_metadata),
..
},
..
}) = hashes.get_mut(hash)
{
*animated_metadata = animated;
Ok(())
} else {
Err(create_error!(NotFound))
}
}
/// Delete attachment hash by id.
async fn delete_attachment_hash(&self, id: &str) -> Result<()> {
let mut file_hashes = self.file_hashes.lock().await;
+3 -3
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-files"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "AGPL-3.0-or-later"
authors = ["Paul Makles <me@insrt.uk>"]
@@ -27,10 +27,10 @@ typenum = "1.17.0"
aws-config = "1.5.5"
aws-sdk-s3 = { version = "1.46.0", features = ["behavior-version-latest"] }
revolt-config = { version = "0.12.1", path = "../config", features = [
revolt-config = { version = "0.12.0", path = "../config", features = [
"report-macros",
] }
revolt-result = { version = "0.12.1", path = "../result" }
revolt-result = { version = "0.12.0", path = "../result" }
# image processing
jxl-oxide = { workspace = true }
+3 -3
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-models"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "MIT"
authors = ["Paul Makles <me@insrt.uk>"]
@@ -21,8 +21,8 @@ default = ["serde", "partials", "rocket"]
[dependencies]
# Core
revolt-config = { version = "0.12.1", path = "../config" }
revolt-permissions = { version = "0.12.1", path = "../permissions" }
revolt-config = { version = "0.12.0", path = "../config" }
revolt-permissions = { version = "0.12.0", path = "../permissions" }
# Utility
regex = "1.11"
+1 -1
View File
@@ -51,7 +51,7 @@ auto_derived!(
width: usize,
height: usize,
thumbhash: Option<Vec<u8>>,
animated: Option<bool>,
animated: bool,
},
/// File is a video with specific dimensions
Video { width: usize, height: usize },
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-parser"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "MIT"
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-permissions"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "MIT"
authors = ["Paul Makles <me@insrt.uk>"]
@@ -22,7 +22,7 @@ async-std = { version = "1.8.0", features = ["attributes"] }
[dependencies]
# Core
revolt-result = { version = "0.12.1", path = "../result" }
revolt-result = { version = "0.12.0", path = "../result" }
# Utility
auto_ops = "0.3.0"
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-presence"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "AGPL-3.0-or-later"
authors = ["Paul Makles <me@insrt.uk>"]
@@ -17,7 +17,7 @@ redis-is-patched = []
async-std = { version = "1.8.0", features = ["attributes"] }
# Config for loading Redis URI
revolt-config = { version = "0.12.1", path = "../config" }
revolt-config = { version = "0.12.0", path = "../config" }
[dependencies]
# Utility
+4 -4
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-ratelimits"
version = "0.12.1"
version = "0.12.0"
edition = "2024"
license = "MIT"
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
@@ -18,9 +18,9 @@ axum = ["dep:axum", "revolt-database/axum-impl"]
default = ["rocket", "axum"]
[dependencies]
revolt-database = { version = "0.12.1", path = "../database" }
revolt-result = { version = "0.12.1", path = "../result" }
revolt-config = { version = "0.12.1", path = "../config" }
revolt-database = { version = "0.12.0", path = "../database" }
revolt-result = { version = "0.12.0", path = "../result" }
revolt-config = { version = "0.12.0", path = "../config" }
rocket = { version = "0.5.1", optional = true }
revolt_rocket_okapi = { version = "0.10.0", optional = true }
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-result"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "MIT"
authors = ["Paul Makles <me@insrt.uk>"]
+5 -5
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-crond"
version = "0.12.1"
version = "0.12.0"
license = "AGPL-3.0-or-later"
authors = ["Paul Makles <me@insrt.uk>"]
edition = "2021"
@@ -17,7 +17,7 @@ log = "0.4"
tokio = { version = "1" }
# Core
revolt-database = { version = "0.12.1", path = "../../core/database" }
revolt-result = { version = "0.12.1", path = "../../core/result" }
revolt-config = { version = "0.12.1", path = "../../core/config" }
revolt-files = { version = "0.12.1", path = "../../core/files" }
revolt-database = { version = "0.12.0", path = "../../core/database" }
revolt-result = { version = "0.12.0", path = "../../core/result" }
revolt-config = { version = "0.12.0", path = "../../core/config" }
revolt-files = { version = "0.12.0", path = "../../core/files" }
+7 -7
View File
@@ -1,24 +1,24 @@
[package]
name = "revolt-pushd"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "AGPL-3.0-or-later"
publish = false
[dependencies]
revolt-result = { version = "0.12.1", path = "../../core/result" }
revolt-config = { version = "0.12.1", path = "../../core/config", features = [
revolt-result = { version = "0.12.0", path = "../../core/result" }
revolt-config = { version = "0.12.0", path = "../../core/config", features = [
"report-macros",
"anyhow",
] }
revolt-database = { version = "0.12.1", path = "../../core/database" }
revolt-models = { version = "0.12.1", path = "../../core/models", features = [
revolt-database = { version = "0.12.0", path = "../../core/database" }
revolt-models = { version = "0.12.0", path = "../../core/models", features = [
"validator",
] }
revolt-presence = { version = "0.12.1", path = "../../core/presence", features = [
revolt-presence = { version = "0.12.0", path = "../../core/presence", features = [
"redis-is-patched",
] }
revolt-parser = { version = "0.12.1", path = "../../core/parser" }
revolt-parser = { version = "0.12.0", path = "../../core/parser" }
anyhow = { version = "1.0.98" }
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-voice-ingress"
version = "0.12.1"
version = "0.12.0"
license = "AGPL-3.0-or-later"
edition = "2021"
publish = false
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-delta"
version = "0.12.1"
version = "0.12.0"
license = "AGPL-3.0-or-later"
authors = ["Paul Makles <paulmakles@gmail.com>"]
edition = "2018"
+18 -14
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-autumn"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "AGPL-3.0-or-later"
publish = false
@@ -40,29 +40,33 @@ serde = { version = "1.0", features = ["derive"] }
# Async runtime
tokio = { version = "1.0", features = ["full"] }
# Logging
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
# Core crates
revolt-files = { version = "0.12.1", path = "../../core/files" }
revolt-config = { version = "0.12.1", path = "../../core/config" }
revolt-database = { version = "0.12.1", path = "../../core/database", features = [
revolt-files = { version = "0.12.0", path = "../../core/files" }
revolt-config = { version = "0.12.0", path = "../../core/config" }
revolt-database = { version = "0.12.0", path = "../../core/database", features = [
"axum-impl",
] }
revolt-result = { version = "0.12.1", path = "../../core/result", features = [
revolt-result = { version = "0.12.0", path = "../../core/result", features = [
"utoipa",
"axum",
] }
revolt-ratelimits = { version = "0.12.1", path = "../../core/ratelimits", features = ["axum"] }
revolt-ratelimits = { version = "0.12.0", path = "../../core/ratelimits", features = ["axum"] }
# Axum / web server
tempfile = "3.12.0"
axum-macros = "0.4.1"
axum_typed_multipart = "0.12.1"
axum = { version = "0.7.5", features = ["multipart"] }
tower-http = { version = "0.5.2", features = ["cors"] }
axum-macros = { workspace = true }
axum_typed_multipart = { workspace = true }
axum = { workspace = true }
tower-http = { workspace = true }
# OpenAPI & documentation generation
utoipa-scalar = { version = "0.1.0", features = ["axum"] }
utoipa = { version = "4.2.3", features = ["axum_extras", "ulid"] }
# OpenTelemetry
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
opentelemetry = { workspace = true }
opentelemetry_sdk = { workspace = true }
opentelemetry-otlp = { workspace = true }
opentelemetry-appender-tracing = { workspace = true }
+9 -79
View File
@@ -1,5 +1,5 @@
use std::{
io::{Cursor, Read, Write},
io::{Cursor, Read},
time::Duration,
};
@@ -15,10 +15,9 @@ use lazy_static::lazy_static;
use revolt_config::{config, report_internal_error};
use revolt_database::{iso8601_timestamp::Timestamp, Database, FileHash, Metadata, User};
use revolt_files::{
create_thumbnail, decode_image, fetch_from_s3, is_animated, upload_to_s3,
AUTHENTICATION_TAG_SIZE_BYTES,
create_thumbnail, decode_image, fetch_from_s3, upload_to_s3, AUTHENTICATION_TAG_SIZE_BYTES,
};
use revolt_result::{create_error, Error, Result, ToRevoltError};
use revolt_result::{create_error, Error, Result};
use serde::{Deserialize, Serialize};
use sha2::Digest;
use tempfile::NamedTempFile;
@@ -26,11 +25,8 @@ use tokio::time::Instant;
use tower_http::cors::{AllowHeaders, Any, CorsLayer};
use utoipa::ToSchema;
use crate::{
exif::strip_metadata, metadata::generate_metadata, mime_type::determine_mime_type, AppState,
};
use crate::{exif::strip_metadata, metadata::generate_metadata, mime_type::determine_mime_type, AppState};
/// Build the API router
pub async fn router() -> Router<AppState> {
let config = config().await;
@@ -61,8 +57,6 @@ pub async fn router() -> Router<AppState> {
}
lazy_static! {
/// Short-lived file cache to allow us to populate different CDN regions without increasing bandwidth to S3 provider
/// Uploads will also be stored here to prevent immediately queued downloads from doing the entire round-trip
static ref S3_CACHE: moka::future::Cache<String, Result<Vec<u8>>> = moka::future::Cache::builder()
.weigher(|_key, value: &Result<Vec<u8>>| -> u32 {
std::mem::size_of::<Result<Vec<u8>>>() as u32 + if let Ok(vec) = value {
@@ -79,7 +73,6 @@ lazy_static! {
.build();
}
/// Retrieve hash information and file data by given hash
async fn retrieve_file_by_hash(hash: &FileHash) -> Result<Vec<u8>> {
if let Some(data) = S3_CACHE.get(&hash.id).await {
data
@@ -90,17 +83,15 @@ async fn retrieve_file_by_hash(hash: &FileHash) -> Result<Vec<u8>> {
}
}
/// Successful root response
#[derive(Serialize, Debug, ToSchema)]
pub struct RootResponse {
autumn: &'static str,
version: &'static str,
}
/// Capture crate version from Cargo
static CRATE_VERSION: &str = env!("CARGO_PKG_VERSION");
/// Root response from service
/// Get information about the service
#[utoipa::path(
get,
path = "/",
@@ -115,7 +106,6 @@ async fn root() -> Json<RootResponse> {
})
}
/// Empty handler for OPTIONS routes
async fn options() {}
/// Available tags to upload to
@@ -179,28 +169,19 @@ async fn upload_file(
Path(tag): Path<Tag>,
TypedMultipart(UploadPayload { mut file }): TypedMultipart<UploadPayload>,
) -> Result<Json<UploadResponse>> {
// Fetch configuration
let now = Instant::now();
let config = config().await;
// Keep track of processing time
let now = Instant::now();
// Extract the filename, or give it a generic name
let filename = file.metadata.file_name.unwrap_or("unnamed-file".to_owned());
// Load file to memory
let mut buf = Vec::<u8>::new();
report_internal_error!(file.contents.read_to_end(&mut buf))?;
// Take note of original file size
let original_file_size = buf.len();
// Ensure the file is not empty
if original_file_size < config.files.limit.min_file_size {
return Err(create_error!(FileTooSmall));
}
// Get user's file upload limits
let limits = user.limits().await;
let size_limit = *limits
.file_upload_size_limit
@@ -211,24 +192,19 @@ async fn upload_file(
return Err(create_error!(FileTooLarge { max: size_limit }));
}
// Generate sha256 hash
let original_hash = {
let mut hasher = sha2::Sha256::new();
hasher.update(&buf);
hasher.finalize()
};
// Generate an ID for this file
let id = if matches!(tag, Tag::emojis) {
ulid::Ulid::new().to_string()
} else {
nanoid::nanoid!(42)
};
// Determine the mime type for the file
let mime_type = determine_mime_type(&mut file.contents, &buf, &filename);
// Check blocklist for mime type
if config
.files
.blocked_mime_types
@@ -238,15 +214,11 @@ async fn upload_file(
return Err(create_error!(FileTypeNotAllowed));
}
// Determine metadata for the file
let metadata = generate_metadata(&file.contents, mime_type);
// Block non-images for non-attachment uploads
if !matches!(tag, Tag::attachments) && !matches!(metadata, Metadata::Image { .. }) {
return Err(create_error!(FileTypeNotAllowed));
}
// Find an existing hash and use that if possible
let file_hash_exists = if let Ok(file_hash) = db
.fetch_attachment_hash(&format!("{original_hash:02x}"))
.await
@@ -269,10 +241,8 @@ async fn upload_file(
false
};
// Strip metadata
let (buf, metadata) = strip_metadata(file.contents, buf, metadata, mime_type).await?;
// Virus scan files if ClamAV is configured
if matches!(metadata, Metadata::File)
&& (config.files.scan_mime_types.is_empty()
|| config.files.scan_mime_types.iter().any(|v| v == mime_type))
@@ -281,7 +251,6 @@ async fn upload_file(
return Err(create_error!(InternalError));
}
// Print file information for debug purposes
let new_file_size = buf.len() + AUTHENTICATION_TAG_SIZE_BYTES;
let processed_hash = {
let mut hasher = sha2::Sha256::new();
@@ -293,7 +262,6 @@ async fn upload_file(
tracing::info!("Received file {filename}\nOriginal hash: {original_hash:02x}\nOriginal size: {original_file_size} bytes\nMime type: {mime_type}\nMetadata: {metadata:?}\nProcessed file size: {new_file_size} bytes ({:.2}%).\nProcessed hash: {processed_hash:02x}\nProcessing took {time_to_process:?}", process_ratio * 100.0);
// Create hash entry in database
let file_hash = FileHash {
id: format!("{original_hash:02x}"),
processed_hash: format!("{processed_hash:02x}"),
@@ -309,21 +277,17 @@ async fn upload_file(
size: new_file_size as isize,
};
// Add attachment hash if it doesn't exist
if !file_hash_exists {
db.insert_attachment_hash(&file_hash).await?;
}
// Upload the file to S3 and commit nonce to database
let upload_start = Instant::now();
let nonce = upload_to_s3(&file_hash.bucket_id, &file_hash.id, &buf).await?;
db.set_attachment_hash_nonce(&file_hash.id, &nonce).await?;
// Debug information
let time_to_upload = Instant::now() - upload_start;
tracing::info!("Took {time_to_upload:?} to upload {new_file_size} bytes to S3.");
// Finally, create the file and return its ID
let tag: &'static str = tag.into();
db.insert_attachment(&file_hash.into_file(id.clone(), tag.to_owned(), filename, user.id))
.await?;
@@ -371,44 +335,19 @@ async fn fetch_preview(
let tag_str: &'static str = tag.clone().into();
let file = db.fetch_attachment(tag_str, &file_id).await?;
// Ignore deleted files
if file.deleted.is_some_and(|v| v) {
return Err(create_error!(NotFound));
}
// Ignore files that haven't been attached
if file.used_for.is_none() {
return Err(create_error!(NotFound));
}
let hash = file.as_hash(&db).await?;
let mut data = None;
let is_animated = matches!(hash.metadata, Metadata::Image { animated: true, .. });
// If animated is unset, check the file contents to see if it is animated and update the filehash
let is_animated = match &hash.metadata {
Metadata::Image {
animated: Some(value),
..
} => *value,
Metadata::Image { animated: None, .. } => {
let file_data = retrieve_file_by_hash(&hash).await?;
let mut named_file = NamedTempFile::new().to_internal_error()?;
named_file.write(&file_data).to_internal_error()?;
data = Some(file_data);
// If it fails for some reason, set it to not be animated
let animated = is_animated(&named_file, &hash.content_type).unwrap_or(false);
db.set_attachment_hash_animated(&hash.id, animated).await?;
animated
}
_ => false,
};
// Only process image files and don't process GIFs if not avatar or icon
// Process GIFs if avatar or icon
if !matches!(hash.metadata, Metadata::Image { .. })
|| (is_animated && !matches!(tag, Tag::avatars | Tag::icons))
{
@@ -417,14 +356,8 @@ async fn fetch_preview(
);
}
// Original image data
let data = if let Some(data) = data {
data
} else {
retrieve_file_by_hash(&hash).await?
};
let data = retrieve_file_by_hash(&hash).await?;
// Read image and create thumbnail
let data = create_thumbnail(
decode_image(&mut Cursor::new(data), &file.content_type)?,
tag_str,
@@ -466,17 +399,14 @@ async fn fetch_file(
let tag: &'static str = tag.clone().into();
let file = db.fetch_attachment(tag, &file_id).await?;
// Ignore deleted files
if file.deleted.is_some_and(|v| v) {
return Err(create_error!(NotFound));
}
// Ignore files that haven't been attached
if file.used_for.is_none() {
return Err(create_error!(NotFound));
}
// Ensure filename is correct
if file_name != file.filename {
if file_name == "original" {
return Ok(
-2
View File
@@ -3,7 +3,6 @@ use std::time::Duration;
use revolt_config::{config, report_internal_error};
use revolt_result::Result;
/// Initialise ClamAV
pub async fn init() {
let config = config().await;
@@ -32,7 +31,6 @@ pub async fn init() {
}
}
/// Scan for malware
pub async fn is_malware(buf: &[u8]) -> Result<bool> {
let config = config().await;
if config.files.clamd_host.is_empty() {
+7 -28
View File
@@ -8,7 +8,6 @@ use revolt_result::{create_error, Result};
use tempfile::NamedTempFile;
use tokio::process::Command;
/// Strip EXIF data from given file and produce new file and metadata
pub async fn strip_metadata(
file: NamedTempFile,
buf: Vec<u8>,
@@ -42,20 +41,16 @@ pub async fn strip_metadata(
// }
// Apply orientation manually & strip all other EXIF data
"image/jpeg" | "image/png" | "image/avif" | "image/tiff" => {
// Create a reader
let mut cursor = Cursor::new(buf);
// Decode the image
let image = report_internal_error!(report_internal_error!(ImageReader::new(
&mut cursor
)
.with_guessed_format())?
.decode());
// Reset read position
cursor.set_position(0);
// Extract orientation data
let exif_reader = Reader::new();
let rotation = match exif_reader.read_from_container(&mut cursor) {
Ok(exif) => match exif.get_field(exif::Tag::Orientation, exif::In::PRIMARY) {
@@ -65,12 +60,10 @@ pub async fn strip_metadata(
_ => 0,
};
// Create a buffer to write to
let mut bytes: Vec<u8> = Vec::new();
let mut writer = Cursor::new(&mut bytes);
// Apply the EXIF rotation
// See https://jdhao.github.io/2019/07/31/image_rotation_exif_info/
// https://jdhao.github.io/2019/07/31/image_rotation_exif_info/
report_internal_error!(match &rotation {
2 => image?.fliph(),
3 => image?.rotate180(),
@@ -92,7 +85,6 @@ pub async fn strip_metadata(
},
))?;
// Calculate dimensions after rotation.
let (width, height) = match &rotation {
2 | 4 | 5 | 7 => (*height, *width),
_ => (*width, *height),
@@ -108,16 +100,13 @@ pub async fn strip_metadata(
},
))
}
// JXLs store EXIF data but we don't have the ability to write them
// TODO: JXLs store EXIF data but we don't have the ability to write them
"image/jxl" => Ok((buf, metadata)),
// All other images that cannot store EXIF data
// assume all other images that cannot store EXIF data
_ => Ok((buf, metadata)),
},
// Use ffmpeg to copy video stream and probe new metadata
Metadata::Video { .. } => match mime {
// Strip EXIF data by copying video stream
"video/mp4" | "video/webm" | "video/quicktime" => {
// Pick the correct file format for ffmpeg
let ext = match mime {
"video/mp4" => "mp4",
"video/webm" => "webm",
@@ -125,30 +114,22 @@ pub async fn strip_metadata(
_ => unreachable!(),
};
// Temporary output file
let mut out_file = report_internal_error!(NamedTempFile::new())?;
// Process the file with ffmpeg
report_internal_error!(
Command::new("ffmpeg")
.args([
// Overwrite the temporary file
"-y",
// Read original uploaded file
"-i",
file.path().to_str().ok_or(create_error!(InternalError))?,
// Strip any metadata
"-map_metadata",
"-map_metadata", // strip metadata
"-1",
// Copy video / audio data to new file
"-c:v",
"-c:v", // just copy the streams
"copy",
"-c:a",
"copy",
// Select correct file format
"-f",
ext,
// Save to new temporary file
out_file
.path()
.to_str()
@@ -158,19 +139,17 @@ pub async fn strip_metadata(
.await
)?;
// Probe the file again
let metadata = crate::metadata::generate_metadata(&out_file, mime);
// Read the file from disk
let mut buf = Vec::<u8>::new();
report_internal_error!(out_file.read_to_end(&mut buf))?;
Ok((buf, metadata))
}
// Assume all other video formats cannot store EXIF data
// assume all other video formats cannot store EXIF data
_ => Ok((buf, metadata)),
},
// all other file types don't store EXIF data
// assume all other file types don't store EXIF data
_ => Ok((buf, metadata)),
}
}
+72 -8
View File
@@ -6,6 +6,7 @@ use axum_macros::FromRef;
use revolt_database::{Database, DatabaseInfo};
use revolt_ratelimits::axum as ratelimiter;
use tokio::net::TcpListener;
use tower_http::trace::TraceLayer;
use utoipa::{
openapi::security::{ApiKey, ApiKeyValue, SecurityScheme},
Modify, OpenApi,
@@ -27,13 +28,32 @@ struct AppState {
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
// Configure logging and environment
revolt_config::configure!(files);
let logger_provider = init_logs();
// Wait for ClamAV
let otel_layer = OpenTelemetryTracingBridge::new(&logger_provider);
let filter_otel = EnvFilter::new("info")
.add_directive("hyper=off".parse().unwrap())
.add_directive("tonic=off".parse().unwrap())
.add_directive("h2=off".parse().unwrap())
.add_directive("reqwest=off".parse().unwrap());
let otel_layer = otel_layer.with_filter(filter_otel);
let filter_fmt = EnvFilter::new("info");
let fmt_layer = tracing_subscriber::fmt::layer()
.with_thread_names(true)
.with_filter(filter_fmt);
tracing_subscriber::registry()
.with(otel_layer)
.with(fmt_layer)
.init();
revolt_config::configure!(files);
clamav::init().await;
// Configure API schema
#[derive(OpenApi)]
#[openapi(
modifiers(&SecurityAddon),
@@ -76,7 +96,6 @@ async fn main() -> Result<(), std::io::Error> {
}
}
// Connect to the database
let db = DatabaseInfo::Auto.connect().await.unwrap();
let ratelimits = ratelimiter::RatelimitStorage::new(ratelimits::AutumnRatelimits);
@@ -85,7 +104,6 @@ async fn main() -> Result<(), std::io::Error> {
ratelimit_storage: ratelimits,
};
// Configure Axum and router
let app = Router::new()
.merge(Scalar::with_url("/scalar", ApiDoc::openapi()))
.nest("/", api::router().await)
@@ -94,10 +112,56 @@ async fn main() -> Result<(), std::io::Error> {
state.clone(),
ratelimiter::ratelimit_middleware,
))
.layer(TraceLayer::new_for_http())
.with_state(state);
// Configure TCP listener and bind
let address = SocketAddr::from((Ipv4Addr::UNSPECIFIED, 14704));
let listener = TcpListener::bind(&address).await?;
axum::serve(listener, app.into_make_service()).await
axum::serve(listener, app.into_make_service()).await?;
if let Err(e) = logger_provider.shutdown() {
panic!("logger provider failed to shut down");
}
Ok(())
}
use opentelemetry::trace::{TraceContextExt, Tracer};
use opentelemetry::KeyValue;
use opentelemetry::{global, InstrumentationScope};
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge;
use opentelemetry_otlp::{LogExporter, MetricExporter, Protocol, SpanExporter, WithExportConfig};
use opentelemetry_sdk::logs::SdkLoggerProvider;
use opentelemetry_sdk::metrics::SdkMeterProvider;
use opentelemetry_sdk::trace::SdkTracerProvider;
use opentelemetry_sdk::Resource;
use std::error::Error;
use std::sync::OnceLock;
use tracing::info;
use tracing_subscriber::prelude::*;
use tracing_subscriber::EnvFilter;
fn get_resource() -> Resource {
static RESOURCE: OnceLock<Resource> = OnceLock::new();
RESOURCE
.get_or_init(|| {
Resource::builder()
.with_service_name("basic-otlp-example-grpc")
.build()
})
.clone()
}
fn init_logs() -> SdkLoggerProvider {
let exporter = LogExporter::builder()
.with_http()
.with_endpoint("http://localhost:19428/insert/opentelemetry/v1/logs")
.with_protocol(Protocol::HttpBinary)
.build()
.expect("Failed to create log exporter");
SdkLoggerProvider::builder()
.with_resource(get_resource())
.with_batch_exporter(exporter)
.build()
}
+1 -3
View File
@@ -20,7 +20,6 @@ static SUPPORTED_IMAGE_MIME: [&str; 9] = [
"image/webp",
];
/// Generate metadata from file, using mime type as a hint
pub fn generate_metadata(f: &NamedTempFile, mime_type: &str) -> Metadata {
if SUPPORTED_IMAGE_MIME.contains(&mime_type) {
image_size(f)
@@ -37,7 +36,7 @@ pub fn generate_metadata(f: &NamedTempFile, mime_type: &str) -> Metadata {
thumbhash::rgba_to_thumb_hash(width as usize, height as usize, &rgba)
})
.ok(),
animated: is_animated(f, mime_type).or(Some(false)),
animated: is_animated(f, mime_type).unwrap_or(false),
})
.unwrap_or_default()
} else if mime_type.starts_with("video/") {
@@ -56,7 +55,6 @@ pub fn generate_metadata(f: &NamedTempFile, mime_type: &str) -> Metadata {
}
}
/// Subroutine to ensure data isn't corrupted
pub fn validate_from_metadata(
reader: Cursor<Vec<u8>>,
metadata: Metadata,
-4
View File
@@ -1,15 +1,12 @@
use tempfile::NamedTempFile;
/// Determine the mime type of the given temporary file and filename
pub fn determine_mime_type(f: &mut NamedTempFile, buf: &[u8], file_name: &str) -> &'static str {
// Force certain extensions into particular mime types
if file_name.to_lowercase().ends_with(".apk") {
return "application/vnd.android.package-archive";
} else if file_name.to_lowercase().ends_with(".exe") {
return "application/vnd.microsoft.portable-executable";
}
// Use magic signatures to determine mime type
let kind = infer::get_from_path(f.path()).expect("file read successfully");
let mime_type = if let Some(kind) = kind {
kind.mime_type()
@@ -17,7 +14,6 @@ pub fn determine_mime_type(f: &mut NamedTempFile, buf: &[u8], file_name: &str) -
"application/octet-stream"
};
// See if the file is actually just plain Unicode/ASCII text
if mime_type == "application/octet-stream" && simdutf8::basic::from_utf8(buf).is_ok() {
if file_name.to_lowercase().ends_with(".svg") {
return "image/svg+xml";
+7 -7
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-gifbox"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "AGPL-3.0-or-later"
publish = false
@@ -17,19 +17,19 @@ tokio = { version = "1.0", features = ["full"] }
reqwest = { version = "0.12", features = ["json"] }
# Core crates
revolt-config = { version = "0.12.1", path = "../../core/config" }
revolt-models = { version = "0.12.1", path = "../../core/models" }
revolt-result = { version = "0.12.1", path = "../../core/result", features = [
revolt-config = { version = "0.12.0", path = "../../core/config" }
revolt-models = { version = "0.12.0", path = "../../core/models" }
revolt-result = { version = "0.12.0", path = "../../core/result", features = [
"utoipa",
"axum",
] }
revolt-coalesced = { version = "0.12.1", path = "../../core/coalesced", features = [
revolt-coalesced = { version = "0.12.0", path = "../../core/coalesced", features = [
"queue",
] }
revolt-database = { version = "0.12.1", path = "../../core/database", features = [
revolt-database = { version = "0.12.0", path = "../../core/database", features = [
"axum-impl",
] }
revolt-ratelimits = { version = "0.12.1", path = "../../core/ratelimits", features = [
revolt-ratelimits = { version = "0.12.0", path = "../../core/ratelimits", features = [
"axum",
] }
+5 -5
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-january"
version = "0.12.1"
version = "0.12.0"
edition = "2021"
license = "AGPL-3.0-or-later"
publish = false
@@ -33,13 +33,13 @@ tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
# Core crates
revolt-config = { version = "0.12.1", path = "../../core/config" }
revolt-models = { version = "0.12.1", path = "../../core/models" }
revolt-result = { version = "0.12.1", path = "../../core/result", features = [
revolt-config = { version = "0.12.0", path = "../../core/config" }
revolt-models = { version = "0.12.0", path = "../../core/models" }
revolt-result = { version = "0.12.0", path = "../../core/result", features = [
"utoipa",
"axum",
] }
revolt-files = { version = "0.12.1", path = "../../core/files" }
revolt-files = { version = "0.12.0", path = "../../core/files" }
# Axum / web server
axum = { version = "0.7.5" }
+1 -1
View File
@@ -23,7 +23,7 @@ You can contribute translations through [**Weblate**](https://translate.stoat.ch
### 3. Donate
Stoat is not backed by a big company, is not currently monetised (for example, via a subscription service) and does not serve you advertisements; as such, Stoat currently relies entirely on donations.
You can learn more about donating [here](https://ko-fi.com/stoatchat) - if you want to make a larger donation, please consult me first.
You can learn more about donating [here](https://wiki.revolt.chat/notes/project/financial-support/) - if you want to make a larger donation, please consult me first.
### 4. Join the project
+1 -1
View File
@@ -1 +1 @@
0.12.1
0.12.0