Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d52e84c5d3 | ||
|
|
d76a71141f | ||
|
|
6f3441cf4a | ||
|
|
23ad135983 | ||
|
|
d46c7f7f3c | ||
|
|
0719985ac5 | ||
|
|
ab5bd47a39 | ||
|
|
9fd7128f80 | ||
|
|
df276ac40b | ||
|
|
356491e934 | ||
|
|
21d82018cf | ||
|
|
6b41db984b | ||
|
|
5378cd22b4 | ||
|
|
841985d3b9 | ||
|
|
279f5d5fd7 | ||
|
|
e93769786c | ||
|
|
ed4fd5ebfe | ||
|
|
89171e9bd0 | ||
|
|
057f2bb8b3 | ||
|
|
3675ff1a1f | ||
|
|
144e939c6b |
No files matched your search
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
".": "0.12.1"
|
".": "0.13.0"
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,32 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.13.0](https://github.com/stoatchat/stoatchat/compare/v0.12.1...v0.13.0) (2026-05-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add embed support for YouTube Shorts ([#734](https://github.com/stoatchat/stoatchat/issues/734)) ([d46c7f7](https://github.com/stoatchat/stoatchat/commit/d46c7f7f3c04524c0639c3e0a122626f8e0b3bf7))
|
||||||
|
* add emoji rename endpoint ([#714](https://github.com/stoatchat/stoatchat/issues/714)) ([23ad135](https://github.com/stoatchat/stoatchat/commit/23ad1359834bb7d07a460b8678d6a6ebffc73eb0))
|
||||||
|
* add legal links to root payload ([#733](https://github.com/stoatchat/stoatchat/issues/733)) ([21d8201](https://github.com/stoatchat/stoatchat/commit/21d82018cf84ab0fdd10613d254b9562aea8eea3))
|
||||||
|
* add role icon support ([#724](https://github.com/stoatchat/stoatchat/issues/724)) ([841985d](https://github.com/stoatchat/stoatchat/commit/841985d3b994df1c6eefab2fc7ecbd77ab22c493))
|
||||||
|
* Add webhook endpoints for editing and deleting messages ([#682](https://github.com/stoatchat/stoatchat/issues/682)) ([6f3441c](https://github.com/stoatchat/stoatchat/commit/6f3441cf4acac2a8e6e1bf07a279a153b80f7956))
|
||||||
|
* automatically sanitise usernames on create/update ([#689](https://github.com/stoatchat/stoatchat/issues/689)) ([e937697](https://github.com/stoatchat/stoatchat/commit/e93769786c7669485a659ee471630740d3cea702))
|
||||||
|
* blacklist private ip ranges and add january domain blocklist ([#731](https://github.com/stoatchat/stoatchat/issues/731)) ([6b41db9](https://github.com/stoatchat/stoatchat/commit/6b41db984bb491b2e58324309cc70d8c14e0b814))
|
||||||
|
* Rewrite acks ([#741](https://github.com/stoatchat/stoatchat/issues/741)) ([ab5bd47](https://github.com/stoatchat/stoatchat/commit/ab5bd47a39ee889de0b5ae6e7b560620853daead))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add new_user_hours to configuration limits ([#729](https://github.com/stoatchat/stoatchat/issues/729)) ([279f5d5](https://github.com/stoatchat/stoatchat/commit/279f5d5fd7af2df55902c706859ec07f569cdb1e))
|
||||||
|
* add reconnection policy to Redis subscriber to prevent ghost state ([#708](https://github.com/stoatchat/stoatchat/issues/708)) ([057f2bb](https://github.com/stoatchat/stoatchat/commit/057f2bb8b359f8b942741a30ff54eeb8fbe3e0b1))
|
||||||
|
* docker compose file had personal url in it ([#742](https://github.com/stoatchat/stoatchat/issues/742)) ([0719985](https://github.com/stoatchat/stoatchat/commit/0719985ac5636590f91e6f9ec4b68f3eded70c13))
|
||||||
|
* don't strip ICC from exif ([#735](https://github.com/stoatchat/stoatchat/issues/735)) ([d76a711](https://github.com/stoatchat/stoatchat/commit/d76a71141f3e508f6308ba52fa28eaeb56fb3438))
|
||||||
|
* dont send notification in fcm ([#721](https://github.com/stoatchat/stoatchat/issues/721)) ([89171e9](https://github.com/stoatchat/stoatchat/commit/89171e9bd0f15711157e78c6eec0fe7b480de93a))
|
||||||
|
* encode filenames in redirects ([#737](https://github.com/stoatchat/stoatchat/issues/737)) ([9fd7128](https://github.com/stoatchat/stoatchat/commit/9fd7128f800badbd184baf943d4f799e601201e4))
|
||||||
|
* january ip redirects & domain resolver ([#738](https://github.com/stoatchat/stoatchat/issues/738)) ([356491e](https://github.com/stoatchat/stoatchat/commit/356491e934b274f9e895df883dd63ef0b3123510))
|
||||||
|
* update message length validation to remove upper limit ([#723](https://github.com/stoatchat/stoatchat/issues/723)) ([ed4fd5e](https://github.com/stoatchat/stoatchat/commit/ed4fd5ebfe6d0ea534a0898da4afdc1f4e2cd6c5))
|
||||||
|
* use correct response for NoEffect errors ([#732](https://github.com/stoatchat/stoatchat/issues/732)) ([5378cd2](https://github.com/stoatchat/stoatchat/commit/5378cd22b4c7d85f44c31a6af0dda00941b80d5c))
|
||||||
|
|
||||||
## [0.12.1](https://github.com/stoatchat/stoatchat/compare/v0.12.0...v0.12.1) (2026-04-10)
|
## [0.12.1](https://github.com/stoatchat/stoatchat/compare/v0.12.0...v0.12.1) (2026-04-10)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Generated
+2851
-1861
File diff suppressed because it is too large.
Load diff
+163
-9
@@ -1,5 +1,5 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "3"
|
||||||
|
|
||||||
members = [
|
members = [
|
||||||
"crates/delta",
|
"crates/delta",
|
||||||
@@ -20,24 +20,130 @@ lto = true
|
|||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
# Async
|
# Async
|
||||||
async-trait = "0.1.89"
|
async-trait = "0.1.89"
|
||||||
tokio = { version = "1.49.0", features = ["macros", "rt"] }
|
tokio = "1.49.0"
|
||||||
|
async-channel = "2.3.1"
|
||||||
|
futures = "0.3.32"
|
||||||
|
async-std = "1.8.0"
|
||||||
|
async-tungstenite = "0.17.0"
|
||||||
|
futures-locks = "0.7.1"
|
||||||
|
async-lock = "2.8.0"
|
||||||
|
async-recursion = "1.0.4"
|
||||||
|
|
||||||
# Error Handling
|
# Error Handling
|
||||||
anyhow = "1.0.100"
|
anyhow = "1.0.100"
|
||||||
thiserror = "2.0.18"
|
thiserror = "2.0.18"
|
||||||
|
sentry = "0.31.5"
|
||||||
|
sentry-anyhow = "0.38.1"
|
||||||
|
|
||||||
# Other Utilities
|
# Data Validation
|
||||||
uuid = { version = "1.19.0", features = ["v4"] }
|
regex = "1.12.3"
|
||||||
|
validator = "0.16"
|
||||||
|
|
||||||
|
# Data Types
|
||||||
|
uuid = "1.19.0"
|
||||||
|
ulid = "1.2.1"
|
||||||
|
nanoid = "0.4.0"
|
||||||
|
typenum = "1.17.0"
|
||||||
|
num_enum = "0.6.1"
|
||||||
|
bitfield = "0.13.2"
|
||||||
|
|
||||||
|
# Time
|
||||||
|
chrono = "0.4.15"
|
||||||
|
iso8601-timestamp = "0.2.10"
|
||||||
|
|
||||||
|
# Data Collections
|
||||||
|
lru = "0.16.3"
|
||||||
|
indexmap = "2.13.1"
|
||||||
|
dashmap = "5.2.0"
|
||||||
|
moka = "0.12.8"
|
||||||
|
lru_time_cache = "0.11.11"
|
||||||
|
deadqueue = "0.2.4"
|
||||||
|
|
||||||
|
# Web scraping
|
||||||
|
scraper = "0.20.0"
|
||||||
|
encoding_rs = "0.8.34"
|
||||||
|
|
||||||
|
# Mail
|
||||||
|
lettre = "0.10.0-alpha.4"
|
||||||
|
|
||||||
|
# HTTP Requests
|
||||||
|
reqwest = "0.13.2"
|
||||||
|
isahc = "1.7"
|
||||||
|
|
||||||
|
# Notifications
|
||||||
|
fcm_v1 = "0.3.0"
|
||||||
|
web-push = "0.10.0"
|
||||||
|
revolt_a2 = "0.10"
|
||||||
|
|
||||||
|
# Parsing
|
||||||
|
logos = "0.15"
|
||||||
|
|
||||||
|
# SVG rendering
|
||||||
|
usvg = "0.44.0"
|
||||||
|
resvg = "0.44.0"
|
||||||
|
tiny-skia = "0.11.4"
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log = "0.4.29"
|
||||||
|
pretty_env_logger = "0.4.0"
|
||||||
|
|
||||||
|
# Redis
|
||||||
|
redis-kiss = "0.1.4"
|
||||||
|
fred = "8.0.1"
|
||||||
|
|
||||||
|
# Serialisation
|
||||||
|
bincode = "1.3.3"
|
||||||
|
serde_json = "1.0.79"
|
||||||
|
rmp-serde = "1.0.0"
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
strum_macros = "0.26.4"
|
||||||
|
|
||||||
|
# MongoDB
|
||||||
|
bson = { version = "2.1.0" }
|
||||||
|
mongodb = { version = "3.1.0" }
|
||||||
|
|
||||||
|
# S3
|
||||||
|
aws-config = "1.5.5"
|
||||||
|
aws-sdk-s3 = "1.46.0"
|
||||||
|
|
||||||
# Axum (HTTP server)
|
# Axum (HTTP server)
|
||||||
axum-macros = "0.4.1"
|
axum-macros = "0.4.1"
|
||||||
axum_typed_multipart = "0.12.1"
|
axum_typed_multipart = "0.12.1"
|
||||||
axum = { version = "0.7.5", features = ["multipart"] }
|
axum = "0.7.5"
|
||||||
tower-http = { version = "0.5.2", features = ["cors", "trace"] }
|
axum-extra = "0.9"
|
||||||
|
tower-http = "0.5.2"
|
||||||
|
|
||||||
|
# Rocket (HTTP server)
|
||||||
|
rocket = "0.5.1"
|
||||||
|
rocket_empty = "0.1.1"
|
||||||
|
revolt_rocket_okapi = "0.10.0"
|
||||||
|
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", rev = "072d90359b23e9b291df6b672c07c93de9c46011" }
|
||||||
|
rocket_authifier = "1.0.16"
|
||||||
|
rocket_prometheus = "0.10.0-rc.3"
|
||||||
|
|
||||||
|
# Spec Generation
|
||||||
|
utoipa = "4.2.3"
|
||||||
|
revolt_okapi = "0.9.1"
|
||||||
|
schemars = "0.8.8"
|
||||||
|
utoipa-scalar = "0.1.0"
|
||||||
|
|
||||||
# Image Processing
|
# Image Processing
|
||||||
jxl-oxide = { version = "0.12.5", features = ["image"] }
|
jxl-oxide = "0.12.5"
|
||||||
image = "0.25.9"
|
sha2 = "0.10.8"
|
||||||
|
kamadak-exif = "0.5.4"
|
||||||
|
webp = "0.3.0"
|
||||||
|
image = "0.25.2" # avif encode requires dav1d system library: features = ["avif-native"]
|
||||||
|
thumbhash = "0.1.0"
|
||||||
|
lcms2 = "6.1.1" # for color profile processing
|
||||||
|
|
||||||
|
# File processing
|
||||||
|
revolt_clamav-client = "0.1.5"
|
||||||
|
simdutf8 = "0.1.4"
|
||||||
|
|
||||||
|
# Content type processing
|
||||||
|
infer = "0.16.0"
|
||||||
|
ffprobe = "0.4.0"
|
||||||
|
imagesize = "0.13.0"
|
||||||
|
|
||||||
# OpenTelemetry
|
# OpenTelemetry
|
||||||
tracing = "0.1.44"
|
tracing = "0.1.44"
|
||||||
@@ -47,4 +153,52 @@ tracing-subscriber = { version = "0.3.22", features = [
|
|||||||
opentelemetry = { version = "0.31.0", features = ["logs"] }
|
opentelemetry = { version = "0.31.0", features = ["logs"] }
|
||||||
opentelemetry_sdk = { version = "0.31.0", features = ["logs"] }
|
opentelemetry_sdk = { version = "0.31.0", features = ["logs"] }
|
||||||
opentelemetry-otlp = { version = "0.31.0", features = ["logs"] }
|
opentelemetry-otlp = { version = "0.31.0", features = ["logs"] }
|
||||||
opentelemetry-appender-tracing = { version = "0.31.1" }
|
opentelemetry-appender-tracing = "0.31.1"
|
||||||
|
|
||||||
|
# Authifier
|
||||||
|
authifier = "1.0.16"
|
||||||
|
|
||||||
|
# RabbitMQ
|
||||||
|
amqprs = "1.7.0"
|
||||||
|
lapin = "4.7.1"
|
||||||
|
|
||||||
|
# Voice
|
||||||
|
livekit-api = "0.4.4"
|
||||||
|
livekit-protocol = "0.7.4"
|
||||||
|
livekit-runtime = "0.4.0"
|
||||||
|
|
||||||
|
# Other Utilities
|
||||||
|
once_cell = "1.9.0"
|
||||||
|
config = "0.13.3"
|
||||||
|
cached = "0.44.0"
|
||||||
|
rand = "0.8.5"
|
||||||
|
base64 = "0.21.3"
|
||||||
|
decancer = "3.3.3"
|
||||||
|
linkify = "0.8.1"
|
||||||
|
url-escape = "0.1.1"
|
||||||
|
revolt_optional_struct = "0.2.0"
|
||||||
|
unicode-segmentation = "1.10.1"
|
||||||
|
querystring = "1.1.0"
|
||||||
|
tempfile = "3.12.0"
|
||||||
|
aes-gcm = "0.10.3"
|
||||||
|
auto_ops = "0.3.0"
|
||||||
|
url = "2.2.2"
|
||||||
|
impl_ops = "0.1.1"
|
||||||
|
lazy_static = "1.5.0"
|
||||||
|
mime = "0.3.17"
|
||||||
|
futures-lite = "2.6.1"
|
||||||
|
|
||||||
|
# Build Dependencies
|
||||||
|
vergen = "7.5.0"
|
||||||
|
|
||||||
|
# Local packages
|
||||||
|
revolt-coalesced = { version = "0.13.0", path = "crates/core/coalesced" }
|
||||||
|
revolt-config = { version = "0.13.0", path = "crates/core/config" }
|
||||||
|
revolt-database = { version = "0.13.0", path = "crates/core/database" }
|
||||||
|
revolt-files = { version = "0.13.0", path = "crates/core/files" }
|
||||||
|
revolt-models = { version = "0.13.0", path = "crates/core/models" }
|
||||||
|
revolt-parser = { version = "0.13.0", path = "crates/core/parser" }
|
||||||
|
revolt-permissions = { version = "0.13.0", path = "crates/core/permissions" }
|
||||||
|
revolt-presence = { version = "0.13.0", path = "crates/core/presence" }
|
||||||
|
revolt-ratelimits = { version = "0.13.0", path = "crates/core/ratelimits" }
|
||||||
|
revolt-result = { version = "0.13.0", path = "crates/core/result" }
|
||||||
+12
-2
@@ -8,10 +8,20 @@ services:
|
|||||||
# MongoDB
|
# MongoDB
|
||||||
database:
|
database:
|
||||||
image: mongo
|
image: mongo
|
||||||
|
command: mongod --replSet rs0
|
||||||
ports:
|
ports:
|
||||||
- "27017:27017"
|
- "27017:27017"
|
||||||
volumes:
|
volumes:
|
||||||
- ./.data/db:/data/db
|
- ./.data/db:/data/db
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
healthcheck:
|
||||||
|
test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'127.0.0.1:27017'}]}) }" | mongosh --port 27017 --quiet
|
||||||
|
interval: 5s
|
||||||
|
timeout: 30s
|
||||||
|
start_period: 0s
|
||||||
|
start_interval: 1s
|
||||||
|
retries: 30
|
||||||
ulimits:
|
ulimits:
|
||||||
nofile:
|
nofile:
|
||||||
soft: 65536
|
soft: 65536
|
||||||
@@ -19,8 +29,8 @@ services:
|
|||||||
|
|
||||||
# MinIO
|
# MinIO
|
||||||
minio:
|
minio:
|
||||||
image: minio/minio
|
image: firstfinger/minio:latest
|
||||||
command: server /data
|
#command: server /data
|
||||||
environment:
|
environment:
|
||||||
MINIO_ROOT_USER: minioautumn
|
MINIO_ROOT_USER: minioautumn
|
||||||
MINIO_ROOT_PASSWORD: minioautumn
|
MINIO_ROOT_PASSWORD: minioautumn
|
||||||
|
|||||||
+26
-30
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-bonfire"
|
name = "revolt-bonfire"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
@@ -9,42 +9,38 @@ publish = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# util
|
# util
|
||||||
log = "*"
|
log = { workspace = true }
|
||||||
sentry = "0.31.5"
|
sentry = { workspace = true }
|
||||||
lru = "0.7.6"
|
lru = { workspace = true }
|
||||||
ulid = "0.5.0"
|
ulid = { workspace = true }
|
||||||
once_cell = "1.9.0"
|
once_cell = { workspace = true }
|
||||||
redis-kiss = "0.1.4"
|
redis-kiss = { workspace = true }
|
||||||
lru_time_cache = "0.11.11"
|
lru_time_cache = { workspace = true }
|
||||||
async-channel = "2.3.1"
|
async-channel = { workspace = true }
|
||||||
|
|
||||||
# parsing
|
# parsing
|
||||||
querystring = "1.1.0"
|
querystring = { workspace = true }
|
||||||
regex = "1.11.1"
|
regex = { workspace = true }
|
||||||
|
|
||||||
# serde
|
# serde
|
||||||
bincode = "1.3.3"
|
bincode = { workspace = true }
|
||||||
serde_json = "1.0.79"
|
serde_json = { workspace = true }
|
||||||
rmp-serde = "1.0.0"
|
rmp-serde = { workspace = true }
|
||||||
serde = "1.0.136"
|
serde = { workspace = true }
|
||||||
|
|
||||||
# async
|
# async
|
||||||
futures = "0.3.21"
|
futures = { workspace = true }
|
||||||
async-tungstenite = { version = "0.17.0", features = ["async-std-runtime"] }
|
async-tungstenite = { workspace = true, features = ["async-std-runtime"] }
|
||||||
async-std = { version = "1.8.0", features = [
|
async-std = { workspace = true }
|
||||||
"tokio1",
|
|
||||||
"tokio02",
|
|
||||||
"attributes",
|
|
||||||
] }
|
|
||||||
|
|
||||||
# core
|
# core
|
||||||
authifier = { version = "1.0.16" }
|
authifier = { workspace = true }
|
||||||
revolt-result = { path = "../core/result" }
|
revolt-result = { workspace = true }
|
||||||
revolt-models = { path = "../core/models" }
|
revolt-models = { workspace = true }
|
||||||
revolt-config = { path = "../core/config" }
|
revolt-config = { workspace = true }
|
||||||
revolt-database = { path = "../core/database", features = ["voice"] }
|
revolt-database = { workspace = true, features = ["voice"] }
|
||||||
revolt-permissions = { path = "../core/permissions" }
|
revolt-permissions = { workspace = true }
|
||||||
revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] }
|
revolt-presence = { workspace = true, features = ["redis-is-patched"] }
|
||||||
|
|
||||||
# redis
|
# redis
|
||||||
fred = { version = "8.0.1", features = ["subscriber-client"] }
|
fred = { workspace = true, features = ["subscriber-client"] }
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet}, num::NonZeroUsize, sync::Arc, time::Duration
|
||||||
sync::Arc,
|
|
||||||
time::Duration,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use async_std::sync::{Mutex, RwLock};
|
use async_std::sync::{Mutex, RwLock};
|
||||||
@@ -57,7 +55,7 @@ impl Default for Cache {
|
|||||||
members: Default::default(),
|
members: Default::default(),
|
||||||
servers: Default::default(),
|
servers: Default::default(),
|
||||||
|
|
||||||
seen_events: LruCache::new(20),
|
seen_events: LruCache::new(NonZeroUsize::new(20).unwrap()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use authifier::AuthifierEvent;
|
|||||||
use fred::{
|
use fred::{
|
||||||
error::RedisErrorKind,
|
error::RedisErrorKind,
|
||||||
interfaces::{ClientLike, EventInterface, PubsubInterface},
|
interfaces::{ClientLike, EventInterface, PubsubInterface},
|
||||||
types::RedisConfig,
|
types::{ReconnectPolicy, RedisConfig},
|
||||||
};
|
};
|
||||||
use futures::{
|
use futures::{
|
||||||
channel::oneshot,
|
channel::oneshot,
|
||||||
@@ -225,9 +225,9 @@ async fn listener(
|
|||||||
.unwrap_or(REDIS_URI.to_string());
|
.unwrap_or(REDIS_URI.to_string());
|
||||||
|
|
||||||
let redis_config = RedisConfig::from_url(&url).unwrap();
|
let redis_config = RedisConfig::from_url(&url).unwrap();
|
||||||
let subscriber = match report_internal_error!(
|
let mut builder = fred::types::Builder::from_config(redis_config);
|
||||||
fred::types::Builder::from_config(redis_config).build_subscriber_client()
|
builder.set_policy(ReconnectPolicy::new_exponential(8, 100, 30_000, 2));
|
||||||
) {
|
let subscriber = match report_internal_error!(builder.build_subscriber_client()) {
|
||||||
Ok(subscriber) => subscriber,
|
Ok(subscriber) => subscriber,
|
||||||
Err(_) => return,
|
Err(_) => return,
|
||||||
};
|
};
|
||||||
@@ -236,16 +236,21 @@ async fn listener(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Let Fred automatically re-subscribe to tracked channels on reconnect.
|
||||||
|
subscriber.manage_subscriptions();
|
||||||
|
|
||||||
// Handle Redis connection dropping
|
// Handle Redis connection dropping
|
||||||
let (clean_up_s, clean_up_r) = async_channel::bounded(1);
|
let (clean_up_s, clean_up_r) = async_channel::bounded(1);
|
||||||
let clean_up_s = Arc::new(Mutex::new(clean_up_s));
|
let clean_up_s = Arc::new(Mutex::new(clean_up_s));
|
||||||
subscriber.on_error(move |err| {
|
subscriber.on_error(move |err| {
|
||||||
|
warn!("Redis subscriber error: {:?}", err);
|
||||||
if let RedisErrorKind::Canceled = err.kind() {
|
if let RedisErrorKind::Canceled = err.kind() {
|
||||||
let clean_up_s = clean_up_s.clone();
|
let clean_up_s = clean_up_s.clone();
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
clean_up_s.lock().await.send(()).await.ok();
|
clean_up_s.lock().await.send(()).await.ok();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Transient errors (IO, timeout) are handled by the reconnect policy.
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
@@ -522,4 +527,4 @@ async fn worker(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-coalesced"
|
name = "revolt-coalesced"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>", "Zomatree <me@zomatree.live>"]
|
authors = ["Paul Makles <me@insrt.uk>", "Zomatree <me@zomatree.live>"]
|
||||||
@@ -15,12 +15,12 @@ cache = ["dep:lru"]
|
|||||||
default = ["tokio"]
|
default = ["tokio"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1.47.0", features = ["sync"], optional = true }
|
tokio = { workspace = true, features = ["sync"], optional = true }
|
||||||
indexmap = { version = "2.13.0", optional = true }
|
indexmap = { workspace = true, optional = true }
|
||||||
lru = { version = "0.16.3", optional = true }
|
lru = { workspace = true, optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "1.47.0", features = [
|
tokio = { workspace = true, features = [
|
||||||
"rt",
|
"rt",
|
||||||
"rt-multi-thread",
|
"rt-multi-thread",
|
||||||
"macros",
|
"macros",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-config"
|
name = "revolt-config"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -18,24 +18,24 @@ default = ["test", "sentry"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Utility
|
# Utility
|
||||||
config = "0.13.3"
|
config = { workspace = true }
|
||||||
cached = "0.44.0"
|
cached = { workspace = true }
|
||||||
once_cell = "1.18.0"
|
once_cell = { workspace = true }
|
||||||
|
|
||||||
# Serde
|
# Serde
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { workspace = true }
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
futures-locks = "0.7.1"
|
futures-locks = { workspace = true }
|
||||||
async-std = { version = "1.8.0", features = ["attributes"], optional = true }
|
async-std = { workspace = true, features = ["attributes"], optional = true }
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log = "0.4.14"
|
log = { workspace = true }
|
||||||
pretty_env_logger = "0.4.0"
|
pretty_env_logger = { workspace = true }
|
||||||
|
|
||||||
# Sentry
|
# Sentry
|
||||||
sentry = { version = "0.31.5", optional = true }
|
sentry = { workspace = true, optional = true }
|
||||||
sentry-anyhow = { version = "0.38.1", optional = true }
|
sentry-anyhow = { workspace = true, optional = true }
|
||||||
|
|
||||||
# Core
|
# Core
|
||||||
revolt-result = { version = "0.12.1", path = "../result", optional = true }
|
revolt-result = { workspace = true, optional = true }
|
||||||
@@ -30,6 +30,10 @@ host = "rabbit"
|
|||||||
port = 5672
|
port = 5672
|
||||||
username = "rabbituser"
|
username = "rabbituser"
|
||||||
password = "rabbitpass"
|
password = "rabbitpass"
|
||||||
|
default_exchange = "revolt"
|
||||||
|
|
||||||
|
[rabbit.queues]
|
||||||
|
acks = "internal.ack"
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
@@ -78,6 +82,8 @@ call_ring_duration = 30
|
|||||||
[api.livekit.nodes]
|
[api.livekit.nodes]
|
||||||
|
|
||||||
[api.users]
|
[api.users]
|
||||||
|
# Minimum allowed length of usernames
|
||||||
|
min_username_length = 2
|
||||||
|
|
||||||
[pushd]
|
[pushd]
|
||||||
# this changes the names of the queues to not overlap
|
# this changes the names of the queues to not overlap
|
||||||
@@ -130,6 +136,8 @@ pkcs8 = ""
|
|||||||
key_id = ""
|
key_id = ""
|
||||||
team_id = ""
|
team_id = ""
|
||||||
|
|
||||||
|
[january]
|
||||||
|
blocked_domains = []
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
# Encryption key for stored files
|
# Encryption key for stored files
|
||||||
@@ -313,6 +321,12 @@ emojis = 500_000
|
|||||||
# default: 5
|
# default: 5
|
||||||
process_message_delay_limit = 5
|
process_message_delay_limit = 5
|
||||||
|
|
||||||
|
[features.legal_links]
|
||||||
|
# URLs for legal documents
|
||||||
|
terms_of_service = ""
|
||||||
|
privacy_policy = ""
|
||||||
|
guidelines = ""
|
||||||
|
|
||||||
[sentry]
|
[sentry]
|
||||||
# Configuration for Sentry error reporting
|
# Configuration for Sentry error reporting
|
||||||
api = ""
|
api = ""
|
||||||
|
|||||||
@@ -122,12 +122,19 @@ pub struct Database {
|
|||||||
pub redis_pubsub: Option<String>,
|
pub redis_pubsub: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
pub struct RabbitQueues {
|
||||||
|
pub acks: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Rabbit {
|
pub struct Rabbit {
|
||||||
pub host: String,
|
pub host: String,
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub password: String,
|
pub password: String,
|
||||||
|
pub default_exchange: String,
|
||||||
|
pub queues: RabbitQueues,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
@@ -231,6 +238,7 @@ pub struct LiveKitNode {
|
|||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct ApiUsers {
|
pub struct ApiUsers {
|
||||||
pub early_adopter_cutoff: Option<u64>,
|
pub early_adopter_cutoff: Option<u64>,
|
||||||
|
pub min_username_length: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
@@ -301,6 +309,11 @@ impl Pushd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
pub struct January {
|
||||||
|
pub blocked_domains: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct FilesLimit {
|
pub struct FilesLimit {
|
||||||
pub min_file_size: usize,
|
pub min_file_size: usize,
|
||||||
@@ -376,6 +389,16 @@ pub struct FeaturesLimitsCollection {
|
|||||||
pub roles: HashMap<String, FeaturesLimits>,
|
pub roles: HashMap<String, FeaturesLimits>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
|
pub struct LegalLinks {
|
||||||
|
/// Terms of Service URL
|
||||||
|
pub terms_of_service: String,
|
||||||
|
/// Privacy Policy URL
|
||||||
|
pub privacy_policy: String,
|
||||||
|
/// Guidelines URL
|
||||||
|
pub guidelines: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct FeaturesAdvanced {
|
pub struct FeaturesAdvanced {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -393,6 +416,7 @@ impl Default for FeaturesAdvanced {
|
|||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Features {
|
pub struct Features {
|
||||||
pub limits: FeaturesLimitsCollection,
|
pub limits: FeaturesLimitsCollection,
|
||||||
|
pub legal_links: LegalLinks,
|
||||||
pub webhooks_enabled: bool,
|
pub webhooks_enabled: bool,
|
||||||
pub mass_mentions_send_notifications: bool,
|
pub mass_mentions_send_notifications: bool,
|
||||||
pub mass_mentions_enabled: bool,
|
pub mass_mentions_enabled: bool,
|
||||||
@@ -420,6 +444,7 @@ pub struct Settings {
|
|||||||
pub hosts: Hosts,
|
pub hosts: Hosts,
|
||||||
pub api: Api,
|
pub api: Api,
|
||||||
pub pushd: Pushd,
|
pub pushd: Pushd,
|
||||||
|
pub january: January,
|
||||||
pub files: Files,
|
pub files: Files,
|
||||||
pub features: Features,
|
pub features: Features,
|
||||||
pub sentry: Sentry,
|
pub sentry: Sentry,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-database"
|
name = "revolt-database"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -32,80 +32,72 @@ default = ["mongodb", "async-std-runtime", "tasks"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-config = { version = "0.12.1", path = "../config", features = [
|
revolt-config = { workspace = true, features = ["report-macros"] }
|
||||||
"report-macros",
|
revolt-result = { workspace = true }
|
||||||
] }
|
revolt-models = { workspace = true, features = ["validator"] }
|
||||||
revolt-result = { version = "0.12.1", path = "../result" }
|
revolt-presence = { workspace = true }
|
||||||
revolt-models = { version = "0.12.1", path = "../models", features = [
|
revolt-permissions = { workspace = true, features = ["serde", "bson"] }
|
||||||
"validator",
|
revolt-parser = { workspace = true }
|
||||||
] }
|
revolt-coalesced = { workspace = true }
|
||||||
revolt-presence = { version = "0.12.1", path = "../presence" }
|
|
||||||
revolt-permissions = { version = "0.12.1", path = "../permissions", features = [
|
|
||||||
"serde",
|
|
||||||
"bson",
|
|
||||||
] }
|
|
||||||
revolt-parser = { version = "0.12.1", path = "../parser" }
|
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
log = "0.4"
|
log = { workspace = true }
|
||||||
lru = "0.11.0"
|
lru = { workspace = true }
|
||||||
rand = "0.8.5"
|
rand = { workspace = true }
|
||||||
ulid = "1.0.0"
|
ulid = { workspace = true }
|
||||||
nanoid = "0.4.0"
|
nanoid = { workspace = true }
|
||||||
base64 = "0.21.3"
|
base64 = { workspace = true }
|
||||||
once_cell = "1.17"
|
once_cell = { workspace = true }
|
||||||
indexmap = "1.9.1"
|
indexmap = { workspace = true }
|
||||||
decancer = "1.6.2"
|
decancer = { workspace = true }
|
||||||
deadqueue = "0.2.4"
|
deadqueue = { workspace = true }
|
||||||
linkify = { optional = true, version = "0.8.1" }
|
linkify = { workspace = true, optional = true }
|
||||||
url-escape = { optional = true, version = "0.1.1" }
|
url-escape = { workspace = true, optional = true }
|
||||||
validator = { version = "0.16", features = ["derive"] }
|
validator = { workspace = true, features = ["derive"] }
|
||||||
isahc = { optional = true, version = "1.7", features = ["json"] }
|
isahc = { workspace = true, features = ["json"], optional = true }
|
||||||
|
|
||||||
# Serialisation
|
# Serialisation
|
||||||
serde_json = "1"
|
serde_json = { workspace = true }
|
||||||
revolt_optional_struct = "0.2.0"
|
revolt_optional_struct = { workspace = true }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { workspace = true }
|
||||||
iso8601-timestamp = { version = "0.2.10", features = ["serde", "bson"] }
|
iso8601-timestamp = { workspace = true, features = ["serde", "bson"] }
|
||||||
|
|
||||||
# Events
|
# Events
|
||||||
redis-kiss = { version = "0.1.4" }
|
redis-kiss = { workspace = true }
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
bson = { optional = true, version = "2.1.0" }
|
bson = { workspace = true, optional = true }
|
||||||
mongodb = { optional = true, version = "3.1.0" }
|
mongodb = { workspace = true, optional = true }
|
||||||
|
|
||||||
# Database Migration
|
# Database Migration
|
||||||
unicode-segmentation = "1.10.1"
|
unicode-segmentation = { workspace = true }
|
||||||
regex = "1"
|
regex = { workspace = true }
|
||||||
|
|
||||||
# Async Language Features
|
# Async Language Features
|
||||||
futures = "0.3.19"
|
futures = { workspace = true }
|
||||||
async-lock = "2.8.0"
|
async-lock = { workspace = true }
|
||||||
async-trait = "0.1.51"
|
async-trait = { workspace = true }
|
||||||
async-recursion = "1.0.4"
|
async-recursion = { workspace = true }
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
async-std = { version = "1.8.0", features = ["attributes"], optional = true }
|
async-std = { workspace = true, features = ["attributes"], optional = true }
|
||||||
|
|
||||||
# Axum Impl
|
# Axum Impl
|
||||||
axum = { version = "0.7.5", optional = true }
|
axum = { workspace = true, optional = true }
|
||||||
|
|
||||||
# Rocket Impl
|
# Rocket Impl
|
||||||
schemars = { version = "0.8.8", optional = true }
|
schemars = { workspace = true, optional = true }
|
||||||
rocket = { version = "0.5.1", default-features = false, features = [
|
rocket = { workspace = true, features = ["json"], optional = true }
|
||||||
"json",
|
revolt_okapi = { workspace = true, optional = true }
|
||||||
], optional = true }
|
revolt_rocket_okapi = { workspace = true, optional = true }
|
||||||
revolt_okapi = { version = "0.9.1", optional = true }
|
|
||||||
revolt_rocket_okapi = { version = "0.10.0", optional = true }
|
|
||||||
|
|
||||||
# Authifier
|
# Authifier
|
||||||
authifier = { version = "1.0.16" }
|
authifier = { workspace = true }
|
||||||
|
|
||||||
# RabbitMQ
|
# RabbitMQ
|
||||||
amqprs = { version = "1.7.0" }
|
amqprs = { workspace = true }
|
||||||
|
|
||||||
# Voice
|
# Voice
|
||||||
livekit-api = { version = "0.4.4", optional = true }
|
livekit-api = { workspace = true, optional = true }
|
||||||
livekit-protocol = { version = "0.4.0", optional = true }
|
livekit-protocol = { workspace = true, optional = true }
|
||||||
livekit-runtime = { version = "0.3.1", features = ["tokio"], optional = true }
|
livekit-runtime = { workspace = true, features = ["tokio"], optional = true }
|
||||||
@@ -2,7 +2,10 @@ use std::collections::HashSet;
|
|||||||
|
|
||||||
use crate::events::rabbit::*;
|
use crate::events::rabbit::*;
|
||||||
use crate::User;
|
use crate::User;
|
||||||
use amqprs::channel::{BasicPublishArguments, ExchangeDeclareArguments};
|
use amqprs::channel::{
|
||||||
|
BasicPublishArguments, ExchangeDeclareArguments, ExchangeType, QueueBindArguments,
|
||||||
|
QueueDeclareArguments,
|
||||||
|
};
|
||||||
use amqprs::connection::OpenConnectionArguments;
|
use amqprs::connection::OpenConnectionArguments;
|
||||||
use amqprs::{channel::Channel, connection::Connection, error::Error as AMQPError};
|
use amqprs::{channel::Channel, connection::Connection, error::Error as AMQPError};
|
||||||
use amqprs::{BasicProperties, FieldTable};
|
use amqprs::{BasicProperties, FieldTable};
|
||||||
@@ -55,6 +58,43 @@ impl AMQP {
|
|||||||
AMQP::new(connection, channel)
|
AMQP::new(connection, channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn configure_channels(&self) -> revolt_result::Result<()> {
|
||||||
|
let config = revolt_config::config().await;
|
||||||
|
|
||||||
|
self.channel
|
||||||
|
.exchange_declare(
|
||||||
|
ExchangeDeclareArguments::new(
|
||||||
|
&config.rabbit.default_exchange,
|
||||||
|
&ExchangeType::Topic.to_string(),
|
||||||
|
)
|
||||||
|
.durable(true)
|
||||||
|
.finish(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to declare exchange");
|
||||||
|
|
||||||
|
// Configure acks channel & routing
|
||||||
|
self.channel
|
||||||
|
.queue_declare(
|
||||||
|
QueueDeclareArguments::new(&config.rabbit.queues.acks)
|
||||||
|
.durable(true)
|
||||||
|
.no_wait(true)
|
||||||
|
.finish(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to bind queue");
|
||||||
|
|
||||||
|
self.channel
|
||||||
|
.queue_bind(QueueBindArguments::new(
|
||||||
|
&config.rabbit.queues.acks,
|
||||||
|
&config.rabbit.default_exchange,
|
||||||
|
&config.rabbit.queues.acks,
|
||||||
|
))
|
||||||
|
.await
|
||||||
|
.expect("Failed to bind channel");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn friend_request_accepted(
|
pub async fn friend_request_accepted(
|
||||||
&self,
|
&self,
|
||||||
accepted_request_user: &User,
|
accepted_request_user: &User,
|
||||||
@@ -232,7 +272,9 @@ impl AMQP {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn ack_message(
|
/// # Sends an ack to pushd to update badges on iPhones.
|
||||||
|
/// Not to be confused with the process_ack function, which handles sending all acks to crond for processing.
|
||||||
|
pub async fn ack_notification_message(
|
||||||
&self,
|
&self,
|
||||||
user_id: String,
|
user_id: String,
|
||||||
channel_id: String,
|
channel_id: String,
|
||||||
@@ -316,4 +358,41 @@ impl AMQP {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// # Send an ack to crond for processing
|
||||||
|
pub async fn process_ack(
|
||||||
|
&self,
|
||||||
|
user_id: &str,
|
||||||
|
channel_id: Option<&str>,
|
||||||
|
server_id: Option<&str>,
|
||||||
|
) -> Result<(), AMQPError> {
|
||||||
|
let config = revolt_config::config().await;
|
||||||
|
|
||||||
|
let payload = AckEventPayload {
|
||||||
|
user_id: user_id.to_string(),
|
||||||
|
channel_id: channel_id.map(|value| value.to_string()),
|
||||||
|
server_id: server_id.map(|value| value.to_string()),
|
||||||
|
};
|
||||||
|
let payload = to_string(&payload).unwrap();
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"Sending ack processor event on exchange {}, channel {}: {}",
|
||||||
|
config.rabbit.default_exchange, config.rabbit.queues.acks, payload
|
||||||
|
);
|
||||||
|
|
||||||
|
self.channel
|
||||||
|
.basic_publish(
|
||||||
|
BasicProperties::default()
|
||||||
|
.with_content_type("application/json")
|
||||||
|
.with_persistence(true)
|
||||||
|
//.with_headers(headers)
|
||||||
|
.finish(),
|
||||||
|
payload.into(),
|
||||||
|
BasicPublishArguments::new(
|
||||||
|
&config.rabbit.default_exchange,
|
||||||
|
&config.rabbit.queues.acks,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ use revolt_result::Error;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use revolt_models::v0::{
|
use revolt_models::v0::{
|
||||||
AppendMessage, Channel, ChannelUnread, ChannelVoiceState, Emoji, FieldsChannel, FieldsMember, FieldsMessage, FieldsRole, FieldsServer, FieldsUser, FieldsWebhook, Member, MemberCompositeKey, Message, PartialChannel, PartialMember, PartialMessage, PartialRole, PartialServer, PartialUser, PartialUserVoiceState, PartialWebhook, PolicyChange, RemovalIntention, Report, Server, User, UserSettings, UserVoiceState, Webhook
|
AppendMessage, Channel, ChannelUnread, ChannelVoiceState, Emoji, FieldsChannel, FieldsMember, FieldsMessage, FieldsRole, FieldsServer, FieldsUser, FieldsWebhook, Member, MemberCompositeKey, Message, PartialChannel, PartialEmoji, PartialMember, PartialMessage, PartialRole, PartialServer, PartialUser, PartialUserVoiceState, PartialWebhook, PolicyChange, RemovalIntention, Report, Server, User, UserSettings, UserVoiceState, Webhook
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Database;
|
use crate::Database;
|
||||||
@@ -219,6 +219,12 @@ pub enum EventV1 {
|
|||||||
/// New emoji
|
/// New emoji
|
||||||
EmojiCreate(Emoji),
|
EmojiCreate(Emoji),
|
||||||
|
|
||||||
|
/// Update existing emoji
|
||||||
|
EmojiUpdate {
|
||||||
|
id: String,
|
||||||
|
data: PartialEmoji,
|
||||||
|
},
|
||||||
|
|
||||||
/// Delete emoji
|
/// Delete emoji
|
||||||
EmojiDelete { id: String },
|
EmojiDelete { id: String },
|
||||||
|
|
||||||
|
|||||||
@@ -78,3 +78,11 @@ pub struct AckPayload {
|
|||||||
pub channel_id: String,
|
pub channel_id: String,
|
||||||
pub message_id: String,
|
pub message_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This is not the same as the AckPayload above, as the state for this event is stored in redis to allow for state updates while the event is queued.
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct AckEventPayload {
|
||||||
|
pub user_id: String,
|
||||||
|
pub channel_id: Option<String>,
|
||||||
|
pub server_id: Option<String>,
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#![allow(deprecated)]
|
#![allow(deprecated)]
|
||||||
use std::{borrow::Cow, collections::HashMap};
|
use std::{borrow::Cow, collections::HashMap};
|
||||||
|
|
||||||
|
use redis_kiss::get_connection;
|
||||||
use revolt_config::config;
|
use revolt_config::config;
|
||||||
use revolt_models::v0::{self, MessageAuthor};
|
use revolt_models::v0::{self, MessageAuthor};
|
||||||
use revolt_permissions::OverrideField;
|
use revolt_permissions::OverrideField;
|
||||||
@@ -212,7 +213,7 @@ impl Channel {
|
|||||||
role_permissions: HashMap::new(),
|
role_permissions: HashMap::new(),
|
||||||
nsfw: data.nsfw.unwrap_or(false),
|
nsfw: data.nsfw.unwrap_or(false),
|
||||||
voice: data.voice.map(|voice| voice.into()),
|
voice: data.voice.map(|voice| voice.into()),
|
||||||
slowmode: None
|
slowmode: None,
|
||||||
},
|
},
|
||||||
v0::LegacyServerChannelType::Voice => Channel::TextChannel {
|
v0::LegacyServerChannelType::Voice => Channel::TextChannel {
|
||||||
id: id.clone(),
|
id: id.clone(),
|
||||||
@@ -225,7 +226,7 @@ impl Channel {
|
|||||||
role_permissions: HashMap::new(),
|
role_permissions: HashMap::new(),
|
||||||
nsfw: data.nsfw.unwrap_or(false),
|
nsfw: data.nsfw.unwrap_or(false),
|
||||||
voice: Some(data.voice.unwrap_or_default().into()),
|
voice: Some(data.voice.unwrap_or_default().into()),
|
||||||
slowmode: None
|
slowmode: None,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -643,7 +644,7 @@ impl Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Acknowledge a message
|
/// Acknowledge a message
|
||||||
pub async fn ack(&self, user: &str, message: &str) -> Result<()> {
|
pub async fn ack(&self, user: &str, message: &str, amqp: &AMQP) -> Result<()> {
|
||||||
EventV1::ChannelAck {
|
EventV1::ChannelAck {
|
||||||
id: self.id().to_string(),
|
id: self.id().to_string(),
|
||||||
user: user.to_string(),
|
user: user.to_string(),
|
||||||
@@ -652,17 +653,7 @@ impl Channel {
|
|||||||
.private(user.to_string())
|
.private(user.to_string())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
#[cfg(feature = "tasks")]
|
crate::util::acker::ack_channel(user, self.id(), message, amqp).await
|
||||||
crate::tasks::ack::queue_ack(
|
|
||||||
self.id().to_string(),
|
|
||||||
user.to_string(),
|
|
||||||
crate::tasks::ack::AckEvent::AckMessage {
|
|
||||||
id: message.to_string(),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove user from a group
|
/// Remove user from a group
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use std::collections::HashSet;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
use revolt_models::v0;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
use ulid::Ulid;
|
use ulid::Ulid;
|
||||||
|
|
||||||
@@ -41,6 +42,12 @@ auto_derived!(
|
|||||||
Server { id: String },
|
Server { id: String },
|
||||||
Detached,
|
Detached,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Partial representation of an emoji
|
||||||
|
pub struct PartialEmoji {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub name: Option<String>,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
#[allow(clippy::disallowed_methods)]
|
#[allow(clippy::disallowed_methods)]
|
||||||
@@ -75,6 +82,26 @@ impl Emoji {
|
|||||||
db.detach_emoji(&self).await
|
db.detach_emoji(&self).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Update an emoji
|
||||||
|
pub async fn update(&mut self, db: &Database, partial: PartialEmoji) -> Result<()> {
|
||||||
|
if let Some(name) = partial.name.clone() {
|
||||||
|
self.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
db.update_emoji(&self.id, &partial).await?;
|
||||||
|
|
||||||
|
EventV1::EmojiUpdate {
|
||||||
|
id: self.id.clone(),
|
||||||
|
data: v0::PartialEmoji {
|
||||||
|
name: partial.name.clone(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
.p(self.parent().to_string())
|
||||||
|
.await;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Check whether we can use a given emoji
|
/// Check whether we can use a given emoji
|
||||||
pub async fn can_use(db: &Database, emoji: &str) -> Result<bool> {
|
pub async fn can_use(db: &Database, emoji: &str) -> Result<bool> {
|
||||||
if Ulid::from_str(emoji).is_ok() {
|
if Ulid::from_str(emoji).is_ok() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::Emoji;
|
use crate::{Emoji, PartialEmoji};
|
||||||
|
|
||||||
#[cfg(feature = "mongodb")]
|
#[cfg(feature = "mongodb")]
|
||||||
mod mongodb;
|
mod mongodb;
|
||||||
@@ -20,6 +20,9 @@ pub trait AbstractEmojis: Sync + Send {
|
|||||||
/// Fetch emoji by their parent ids
|
/// Fetch emoji by their parent ids
|
||||||
async fn fetch_emoji_by_parent_ids(&self, parent_ids: &[String]) -> Result<Vec<Emoji>>;
|
async fn fetch_emoji_by_parent_ids(&self, parent_ids: &[String]) -> Result<Vec<Emoji>>;
|
||||||
|
|
||||||
|
/// Update emoji with new information
|
||||||
|
async fn update_emoji(&self, emoji_id: &str, partial: &PartialEmoji) -> Result<()>;
|
||||||
|
|
||||||
/// Detach an emoji by its id
|
/// Detach an emoji by its id
|
||||||
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()>;
|
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()>;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
use bson::Document;
|
use bson::Document;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::Emoji;
|
use crate::{Emoji, PartialEmoji};
|
||||||
use crate::MongoDb;
|
use crate::MongoDb;
|
||||||
|
|
||||||
use super::AbstractEmojis;
|
use super::AbstractEmojis;
|
||||||
@@ -46,6 +46,11 @@ impl AbstractEmojis for MongoDb {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Update emoji with new information
|
||||||
|
async fn update_emoji(&self, emoji_id: &str, partial: &PartialEmoji) -> Result<()> {
|
||||||
|
query!(self, update_one_by_id, COL, emoji_id, partial, vec![], None).map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
/// Detach an emoji by its id
|
/// Detach an emoji by its id
|
||||||
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()> {
|
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()> {
|
||||||
self.col::<Document>(COL)
|
self.col::<Document>(COL)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
|
|
||||||
use crate::Emoji;
|
use crate::{Emoji, PartialEmoji};
|
||||||
use crate::EmojiParent;
|
use crate::EmojiParent;
|
||||||
use crate::ReferenceDb;
|
use crate::ReferenceDb;
|
||||||
|
|
||||||
@@ -54,6 +54,19 @@ impl AbstractEmojis for ReferenceDb {
|
|||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Update emoji with new information
|
||||||
|
async fn update_emoji(&self, emoji_id: &str, partial: &PartialEmoji) -> Result<()> {
|
||||||
|
let mut emojis = self.emojis.lock().await;
|
||||||
|
if let Some(emoji) = emojis.get_mut(emoji_id) {
|
||||||
|
if let Some(name) = partial.name.clone() {
|
||||||
|
emoji.name = name;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(create_error!(NotFound))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Detach an emoji by its id
|
/// Detach an emoji by its id
|
||||||
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()> {
|
async fn detach_emoji(&self, emoji: &Emoji) -> Result<()> {
|
||||||
let mut emojis = self.emojis.lock().await;
|
let mut emojis = self.emojis.lock().await;
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -70,6 +70,7 @@ auto_derived!(
|
|||||||
LegacyGroupIcon,
|
LegacyGroupIcon,
|
||||||
ChannelIcon,
|
ChannelIcon,
|
||||||
ServerIcon,
|
ServerIcon,
|
||||||
|
RoleIcon,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information about what the file was used for
|
/// Information about what the file was used for
|
||||||
@@ -239,4 +240,23 @@ impl File {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Use a file for a role icon
|
||||||
|
pub async fn use_role_icon(
|
||||||
|
db: &Database,
|
||||||
|
id: &str,
|
||||||
|
parent: &str,
|
||||||
|
uploader_id: &str,
|
||||||
|
) -> Result<File> {
|
||||||
|
db.find_and_use_attachment(
|
||||||
|
id,
|
||||||
|
"icons",
|
||||||
|
FileUsedFor {
|
||||||
|
id: parent.to_owned(),
|
||||||
|
object_type: FileUsedForType::RoleIcon,
|
||||||
|
},
|
||||||
|
uploader_id.to_owned(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -249,7 +249,7 @@ impl AbstractMessages for ReferenceDb {
|
|||||||
let mut messages = self.messages.lock().await;
|
let mut messages = self.messages.lock().await;
|
||||||
if let Some(message) = messages.get_mut(id) {
|
if let Some(message) = messages.get_mut(id) {
|
||||||
if let Some(users) = message.reactions.get_mut(emoji) {
|
if let Some(users) = message.reactions.get_mut(emoji) {
|
||||||
users.remove(&user.to_string());
|
users.swap_remove(&user.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -262,7 +262,7 @@ impl AbstractMessages for ReferenceDb {
|
|||||||
async fn clear_reaction(&self, id: &str, emoji: &str) -> Result<()> {
|
async fn clear_reaction(&self, id: &str, emoji: &str) -> Result<()> {
|
||||||
let mut messages = self.messages.lock().await;
|
let mut messages = self.messages.lock().await;
|
||||||
if let Some(message) = messages.get_mut(id) {
|
if let Some(message) = messages.get_mut(id) {
|
||||||
message.reactions.remove(emoji);
|
message.reactions.swap_remove(emoji);
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(create_error!(NotFound))
|
Err(create_error!(NotFound))
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ auto_derived_partial!(
|
|||||||
/// Ranking of this role
|
/// Ranking of this role
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub rank: i64,
|
pub rank: i64,
|
||||||
|
/// Custom icon attachment
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub icon: Option<File>,
|
||||||
},
|
},
|
||||||
"PartialRole"
|
"PartialRole"
|
||||||
);
|
);
|
||||||
@@ -129,6 +132,7 @@ auto_derived!(
|
|||||||
/// Optional fields on server object
|
/// Optional fields on server object
|
||||||
pub enum FieldsRole {
|
pub enum FieldsRole {
|
||||||
Colour,
|
Colour,
|
||||||
|
Icon,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -305,6 +309,7 @@ impl Role {
|
|||||||
colour: self.colour,
|
colour: self.colour,
|
||||||
hoist: Some(self.hoist),
|
hoist: Some(self.hoist),
|
||||||
rank: Some(self.rank),
|
rank: Some(self.rank),
|
||||||
|
icon: self.icon,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,6 +323,7 @@ impl Role {
|
|||||||
colour: None,
|
colour: None,
|
||||||
hoist: false,
|
hoist: false,
|
||||||
permissions: Default::default(),
|
permissions: Default::default(),
|
||||||
|
icon: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
db.insert_role(&server.id, &role).await?;
|
db.insert_role(&server.id, &role).await?;
|
||||||
@@ -367,6 +373,7 @@ impl Role {
|
|||||||
pub fn remove_field(&mut self, field: &FieldsRole) {
|
pub fn remove_field(&mut self, field: &FieldsRole) {
|
||||||
match field {
|
match field {
|
||||||
FieldsRole::Colour => self.colour = None,
|
FieldsRole::Colour => self.colour = None,
|
||||||
|
FieldsRole::Icon => self.icon = None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ impl AbstractServers for MongoDb {
|
|||||||
},
|
},
|
||||||
doc! {
|
doc! {
|
||||||
"$set": {
|
"$set": {
|
||||||
"roles.".to_owned() + &role.id: to_document(role)
|
"roles.".to_owned() + role.id.as_str(): to_document(role)
|
||||||
.map_err(|_| create_database_error!("to_document", "role"))?
|
.map_err(|_| create_database_error!("to_document", "role"))?
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -172,6 +172,7 @@ impl IntoDocumentPath for FieldsRole {
|
|||||||
fn as_path(&self) -> Option<&'static str> {
|
fn as_path(&self) -> Option<&'static str> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
FieldsRole::Colour => "colour",
|
FieldsRole::Colour => "colour",
|
||||||
|
FieldsRole::Icon => "icon",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use futures::future::join_all;
|
|||||||
use iso8601_timestamp::Timestamp;
|
use iso8601_timestamp::Timestamp;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
|
use regex::{Regex, RegexBuilder};
|
||||||
use revolt_config::{config, FeaturesLimits};
|
use revolt_config::{config, FeaturesLimits};
|
||||||
use revolt_models::v0::{self, UserBadges, UserFlags};
|
use revolt_models::v0::{self, UserBadges, UserFlags};
|
||||||
use revolt_presence::filter_online;
|
use revolt_presence::filter_online;
|
||||||
@@ -163,6 +164,13 @@ pub static DISCRIMINATOR_SEARCH_SPACE: Lazy<HashSet<String>> = Lazy::new(|| {
|
|||||||
set.into_iter().collect()
|
set.into_iter().collect()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static BLOCKED_USERNAME_PATTERNS: Lazy<Regex> = Lazy::new(|| {
|
||||||
|
RegexBuilder::new("`{3}|(discord|rvlt|guilded|stt)\\.gg|(revolt|stoat)\\.chat|https?:\\/\\/")
|
||||||
|
.case_insensitive(true)
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
});
|
||||||
|
|
||||||
#[allow(clippy::derivable_impls)]
|
#[allow(clippy::derivable_impls)]
|
||||||
impl Default for User {
|
impl Default for User {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -198,11 +206,13 @@ impl User {
|
|||||||
I: Into<Option<String>>,
|
I: Into<Option<String>>,
|
||||||
D: Into<Option<PartialUser>>,
|
D: Into<Option<PartialUser>>,
|
||||||
{
|
{
|
||||||
let username = User::validate_username(username)?;
|
let new_username = User::sanitise_username(&username).await?;
|
||||||
|
User::validate_username(&new_username)?;
|
||||||
|
|
||||||
let mut user = User {
|
let mut user = User {
|
||||||
id: account_id.into().unwrap_or_else(|| Ulid::new().to_string()),
|
id: account_id.into().unwrap_or_else(|| Ulid::new().to_string()),
|
||||||
discriminator: User::find_discriminator(db, &username, None).await?,
|
discriminator: User::find_discriminator(db, &new_username, None).await?,
|
||||||
username,
|
username: new_username.clone(),
|
||||||
last_acknowledged_policy_change: Timestamp::now_utc(),
|
last_acknowledged_policy_change: Timestamp::now_utc(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
@@ -278,39 +288,40 @@ impl User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sanitise and validate a username can be used
|
/// Validate a username
|
||||||
pub fn validate_username(username: String) -> Result<String> {
|
///
|
||||||
// Copy the username for validation
|
/// This will check if the username is a blocked name or contains a blocked pattern.
|
||||||
|
fn validate_username(username: &str) -> Result<()> {
|
||||||
let username_lowercase = username.to_lowercase();
|
let username_lowercase = username.to_lowercase();
|
||||||
|
|
||||||
// Block homoglyphs
|
const BLOCKED_USERNAMES: &[&str] = &["admin", "revolt", "stoat"];
|
||||||
if decancer::cure(&username_lowercase).into_str() != username_lowercase {
|
|
||||||
|
if BLOCKED_USERNAMES.contains(&username_lowercase.as_str())
|
||||||
|
|| BLOCKED_USERNAME_PATTERNS.is_match(username)
|
||||||
|
{
|
||||||
return Err(create_error!(InvalidUsername));
|
return Err(create_error!(InvalidUsername));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the username itself isn't blocked
|
Ok(())
|
||||||
const BLOCKED_USERNAMES: &[&str] = &["admin", "revolt"];
|
}
|
||||||
|
|
||||||
for username in BLOCKED_USERNAMES {
|
/// Sanitise a username
|
||||||
if username_lowercase == *username {
|
///
|
||||||
return Err(create_error!(InvalidUsername));
|
/// This will clean up Unicode homoglyphs and pad to the min username length with underscores.
|
||||||
}
|
async fn sanitise_username(username: &str) -> Result<String> {
|
||||||
}
|
let options = decancer::Options::default().retain_capitalization();
|
||||||
|
let mut username = decancer::cure(username, options)
|
||||||
|
.map_err(|_| create_error!(InvalidUsername))?
|
||||||
|
.to_string();
|
||||||
|
|
||||||
// Ensure none of the following substrings show up in the username
|
let config = revolt_config::config().await;
|
||||||
const BLOCKED_SUBSTRINGS: &[&str] = &[
|
let username_length_diff = config
|
||||||
"```",
|
.api
|
||||||
"discord.gg",
|
.users
|
||||||
"rvlt.gg",
|
.min_username_length
|
||||||
"guilded.gg",
|
.saturating_sub(username.len());
|
||||||
"https://",
|
if username_length_diff > 0 {
|
||||||
"http://",
|
username.push_str(&"_".repeat(username_length_diff))
|
||||||
];
|
|
||||||
|
|
||||||
for substr in BLOCKED_SUBSTRINGS {
|
|
||||||
if username_lowercase.contains(substr) {
|
|
||||||
return Err(create_error!(InvalidUsername));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(username)
|
Ok(username)
|
||||||
@@ -416,12 +427,14 @@ impl User {
|
|||||||
|
|
||||||
/// Update a user's username
|
/// Update a user's username
|
||||||
pub async fn update_username(&mut self, db: &Database, username: String) -> Result<()> {
|
pub async fn update_username(&mut self, db: &Database, username: String) -> Result<()> {
|
||||||
let username = User::validate_username(username)?;
|
let new_username = User::sanitise_username(&username).await?;
|
||||||
if self.username.to_lowercase() == username.to_lowercase() {
|
User::validate_username(&new_username)?;
|
||||||
|
|
||||||
|
if self.username.to_lowercase() == new_username.to_lowercase() {
|
||||||
self.update(
|
self.update(
|
||||||
db,
|
db,
|
||||||
PartialUser {
|
PartialUser {
|
||||||
username: Some(username),
|
username: Some(new_username),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
vec![],
|
vec![],
|
||||||
@@ -434,12 +447,12 @@ impl User {
|
|||||||
discriminator: Some(
|
discriminator: Some(
|
||||||
User::find_discriminator(
|
User::find_discriminator(
|
||||||
db,
|
db,
|
||||||
&username,
|
&new_username,
|
||||||
Some((self.discriminator.to_string(), self.id.clone())),
|
Some((self.discriminator.to_string(), self.id.clone())),
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
),
|
),
|
||||||
username: Some(username),
|
username: Some(new_username),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
vec![],
|
vec![],
|
||||||
@@ -825,3 +838,109 @@ impl User {
|
|||||||
badges
|
badges
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::User;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn username_validation_blocked_names() {
|
||||||
|
let username_admin = "Admin";
|
||||||
|
let username_revolt = "Revolt";
|
||||||
|
let username_stoat = "Stoat";
|
||||||
|
let username_allowed = "Allowed";
|
||||||
|
|
||||||
|
assert!(User::validate_username(username_admin).is_err());
|
||||||
|
assert!(User::validate_username(username_revolt).is_err());
|
||||||
|
assert!(User::validate_username(username_stoat).is_err());
|
||||||
|
assert!(User::validate_username(username_allowed).is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn username_validation_blocked_patterns() {
|
||||||
|
let username_grave = "```_test";
|
||||||
|
let username_discord = "discord.gg_test";
|
||||||
|
let username_rvlt = "rvlt.gg_test";
|
||||||
|
let username_guilded = "guilded.gg_test";
|
||||||
|
let username_stt = "stt.gg_test";
|
||||||
|
let username_revolt = "revolt.chat_test";
|
||||||
|
let username_stoat = "stoat.chat_test";
|
||||||
|
let username_http = "http://_test";
|
||||||
|
let username_https = "https://_test";
|
||||||
|
|
||||||
|
assert!(User::validate_username(username_grave).is_err());
|
||||||
|
assert!(User::validate_username(username_discord).is_err());
|
||||||
|
assert!(User::validate_username(username_rvlt).is_err());
|
||||||
|
assert!(User::validate_username(username_guilded).is_err());
|
||||||
|
assert!(User::validate_username(username_stt).is_err());
|
||||||
|
assert!(User::validate_username(username_revolt).is_err());
|
||||||
|
assert!(User::validate_username(username_stoat).is_err());
|
||||||
|
assert!(User::validate_username(username_http).is_err());
|
||||||
|
assert!(User::validate_username(username_https).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn username_sanitisation_clean() {
|
||||||
|
let username_clean = "Test";
|
||||||
|
|
||||||
|
let username_clean_sanitised = User::sanitise_username(username_clean).await;
|
||||||
|
|
||||||
|
assert!(username_clean_sanitised.is_ok());
|
||||||
|
assert_eq!(username_clean, username_clean_sanitised.unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn username_sanitisation_homoglyphs() {
|
||||||
|
let username_homoglyphs = "𝔽𝕌Ňℕy";
|
||||||
|
|
||||||
|
let username_homoglyphs_sanitised =
|
||||||
|
User::sanitise_username(username_homoglyphs).await.unwrap();
|
||||||
|
|
||||||
|
assert_ne!(username_homoglyphs, username_homoglyphs_sanitised);
|
||||||
|
assert_eq!("funny", username_homoglyphs_sanitised);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn username_sanitisation_padding() {
|
||||||
|
let username_padding = "a";
|
||||||
|
|
||||||
|
let username = User::sanitise_username(username_padding).await.unwrap();
|
||||||
|
|
||||||
|
assert_eq!("a_", username);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn create_user() {
|
||||||
|
use revolt_result::Result;
|
||||||
|
|
||||||
|
database_test!(|db| async move {
|
||||||
|
let mut created_clean = User::create(&db, "Test".to_string(), None, None)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!("Test", created_clean.username);
|
||||||
|
|
||||||
|
created_clean
|
||||||
|
.update_username(&db, "Test2".to_string())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!("Test2", created_clean.username);
|
||||||
|
|
||||||
|
let created_invalid_result: Result<_> =
|
||||||
|
User::create(&db, "stoat.chat".to_string(), None, None).await;
|
||||||
|
|
||||||
|
assert!(created_invalid_result.is_err());
|
||||||
|
|
||||||
|
let mut updated_invalid = User::create(&db, "Test".to_string(), None, None)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let updated_invalid_update_result = updated_invalid
|
||||||
|
.update_username(&db, "http://test".to_string())
|
||||||
|
.await;
|
||||||
|
|
||||||
|
assert!(updated_invalid_update_result.is_err());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -105,7 +105,11 @@ pub async fn handle_ack_event(
|
|||||||
|
|
||||||
if mentions_acked > 0 {
|
if mentions_acked > 0 {
|
||||||
if let Err(err) = amqp
|
if let Err(err) = amqp
|
||||||
.ack_message(user.to_string(), channel.to_string(), id.to_owned())
|
.ack_notification_message(
|
||||||
|
user.to_string(),
|
||||||
|
channel.to_string(),
|
||||||
|
id.to_owned(),
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
revolt_config::capture_error(&err);
|
revolt_config::capture_error(&err);
|
||||||
@@ -192,9 +196,7 @@ pub async fn handle_ack_event(
|
|||||||
.expect("Failed to fetch channel from db");
|
.expect("Failed to fetch channel from db");
|
||||||
|
|
||||||
if let TextChannel { server, .. } = channel {
|
if let TextChannel { server, .. } = channel {
|
||||||
if let Err(err) =
|
if let Err(err) = amqp.mass_mention_message_sent(server, mass_mentions).await {
|
||||||
amqp.mass_mention_message_sent(server, mass_mentions).await
|
|
||||||
{
|
|
||||||
revolt_config::capture_error(&err);
|
revolt_config::capture_error(&err);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
use redis_kiss::{get_connection, AsyncCommands};
|
||||||
|
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||||
|
use revolt_result::{Result, ToRevoltError};
|
||||||
|
|
||||||
|
use crate::{events::client::EventV1, Channel, Database, Server, User, AMQP};
|
||||||
|
|
||||||
|
pub async fn ack_channel(user: &str, channel: &str, message: &str, amqp: &AMQP) -> Result<()> {
|
||||||
|
let mut redis = get_connection()
|
||||||
|
.await
|
||||||
|
.map_err(|_| create_error!(InternalError))?;
|
||||||
|
|
||||||
|
let old: Option<String> = redis
|
||||||
|
.getset(format!("acker:{user}+{channel}"), message)
|
||||||
|
.await
|
||||||
|
.to_internal_error()?;
|
||||||
|
|
||||||
|
if old.is_none() || old.unwrap() == message {
|
||||||
|
amqp.process_ack(user, Some(channel), None)
|
||||||
|
.await
|
||||||
|
.to_internal_error()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn ack_server(user: &User, server: &Server, db: &Database, amqp: &AMQP) -> Result<()> {
|
||||||
|
let mut redis = get_connection()
|
||||||
|
.await
|
||||||
|
.map_err(|_| create_error!(InternalError))?;
|
||||||
|
|
||||||
|
let channels = db.fetch_channels(&server.channels).await?;
|
||||||
|
let query = crate::util::permissions::DatabasePermissionQuery::new(db, user).server(server);
|
||||||
|
|
||||||
|
for channel in channels {
|
||||||
|
let channel_id = channel.id();
|
||||||
|
let mut q = query.clone().channel(&channel);
|
||||||
|
|
||||||
|
if calculate_channel_permissions(&mut q)
|
||||||
|
.await
|
||||||
|
.has_channel_permission(ChannelPermission::ViewChannel)
|
||||||
|
{
|
||||||
|
let channel_last_msg = match &channel {
|
||||||
|
Channel::TextChannel {
|
||||||
|
last_message_id, ..
|
||||||
|
} => last_message_id,
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
if let Some(channel_last_msg) = channel_last_msg {
|
||||||
|
let old: Option<String> = redis
|
||||||
|
.getset(
|
||||||
|
format!("acker:{}+{}", user.id, channel_id),
|
||||||
|
&channel_last_msg,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.to_internal_error()?;
|
||||||
|
|
||||||
|
if old.is_none() || old.unwrap() == channel_last_msg {
|
||||||
|
amqp.process_ack(&user.id, Some(channel_id), Some(&server.id))
|
||||||
|
.await
|
||||||
|
.to_internal_error()?;
|
||||||
|
|
||||||
|
EventV1::ChannelAck {
|
||||||
|
id: channel_id.to_string(),
|
||||||
|
user: user.id.clone(),
|
||||||
|
message_id: channel_last_msg,
|
||||||
|
}
|
||||||
|
.private(user.id.clone())
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -190,7 +190,7 @@ impl From<crate::Channel> for Channel {
|
|||||||
role_permissions,
|
role_permissions,
|
||||||
nsfw,
|
nsfw,
|
||||||
voice,
|
voice,
|
||||||
slowmode
|
slowmode,
|
||||||
} => Channel::TextChannel {
|
} => Channel::TextChannel {
|
||||||
id,
|
id,
|
||||||
server,
|
server,
|
||||||
@@ -202,7 +202,7 @@ impl From<crate::Channel> for Channel {
|
|||||||
role_permissions,
|
role_permissions,
|
||||||
nsfw,
|
nsfw,
|
||||||
voice: voice.map(|voice| voice.into()),
|
voice: voice.map(|voice| voice.into()),
|
||||||
slowmode
|
slowmode,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -256,7 +256,7 @@ impl From<Channel> for crate::Channel {
|
|||||||
role_permissions,
|
role_permissions,
|
||||||
nsfw,
|
nsfw,
|
||||||
voice,
|
voice,
|
||||||
slowmode
|
slowmode,
|
||||||
} => crate::Channel::TextChannel {
|
} => crate::Channel::TextChannel {
|
||||||
id,
|
id,
|
||||||
server,
|
server,
|
||||||
@@ -268,7 +268,7 @@ impl From<Channel> for crate::Channel {
|
|||||||
role_permissions,
|
role_permissions,
|
||||||
nsfw,
|
nsfw,
|
||||||
voice: voice.map(|voice| voice.into()),
|
voice: voice.map(|voice| voice.into()),
|
||||||
slowmode
|
slowmode,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -307,7 +307,7 @@ impl From<PartialChannel> for crate::PartialChannel {
|
|||||||
default_permissions: value.default_permissions,
|
default_permissions: value.default_permissions,
|
||||||
last_message_id: value.last_message_id,
|
last_message_id: value.last_message_id,
|
||||||
voice: value.voice.map(|voice| voice.into()),
|
voice: value.voice.map(|voice| voice.into()),
|
||||||
slowmode: value.slowmode
|
slowmode: value.slowmode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -926,6 +926,7 @@ impl From<crate::Role> for Role {
|
|||||||
colour: value.colour,
|
colour: value.colour,
|
||||||
hoist: value.hoist,
|
hoist: value.hoist,
|
||||||
rank: value.rank,
|
rank: value.rank,
|
||||||
|
icon: value.icon.map(|f| f.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -939,6 +940,7 @@ impl From<Role> for crate::Role {
|
|||||||
colour: value.colour,
|
colour: value.colour,
|
||||||
hoist: value.hoist,
|
hoist: value.hoist,
|
||||||
rank: value.rank,
|
rank: value.rank,
|
||||||
|
icon: value.icon.map(|f| f.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -952,6 +954,7 @@ impl From<crate::PartialRole> for PartialRole {
|
|||||||
colour: value.colour,
|
colour: value.colour,
|
||||||
hoist: value.hoist,
|
hoist: value.hoist,
|
||||||
rank: value.rank,
|
rank: value.rank,
|
||||||
|
icon: value.icon.map(|f| f.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -965,6 +968,7 @@ impl From<PartialRole> for crate::PartialRole {
|
|||||||
colour: value.colour,
|
colour: value.colour,
|
||||||
hoist: value.hoist,
|
hoist: value.hoist,
|
||||||
rank: value.rank,
|
rank: value.rank,
|
||||||
|
icon: value.icon.map(|f| f.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -973,6 +977,7 @@ impl From<crate::FieldsRole> for FieldsRole {
|
|||||||
fn from(value: crate::FieldsRole) -> Self {
|
fn from(value: crate::FieldsRole) -> Self {
|
||||||
match value {
|
match value {
|
||||||
crate::FieldsRole::Colour => FieldsRole::Colour,
|
crate::FieldsRole::Colour => FieldsRole::Colour,
|
||||||
|
crate::FieldsRole::Icon => FieldsRole::Icon,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -981,6 +986,7 @@ impl From<FieldsRole> for crate::FieldsRole {
|
|||||||
fn from(value: FieldsRole) -> Self {
|
fn from(value: FieldsRole) -> Self {
|
||||||
match value {
|
match value {
|
||||||
FieldsRole::Colour => crate::FieldsRole::Colour,
|
FieldsRole::Colour => crate::FieldsRole::Colour,
|
||||||
|
FieldsRole::Icon => crate::FieldsRole::Icon,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
pub mod acker;
|
||||||
pub mod bridge;
|
pub mod bridge;
|
||||||
pub mod bulk_permissions;
|
pub mod bulk_permissions;
|
||||||
mod funcs;
|
mod funcs;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-files"
|
name = "revolt-files"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -16,33 +16,33 @@ tracing = { workspace = true }
|
|||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
async-trait = { workspace = true }
|
async-trait = { workspace = true }
|
||||||
|
|
||||||
ffprobe = "0.4.0"
|
ffprobe = { workspace = true }
|
||||||
imagesize = "0.13.0"
|
imagesize = { workspace = true }
|
||||||
tempfile = "3.12.0"
|
tempfile = { workspace = true }
|
||||||
|
|
||||||
base64 = "0.22.1"
|
base64 = { workspace = true }
|
||||||
aes-gcm = "0.10.3"
|
aes-gcm = { workspace = true }
|
||||||
typenum = "1.17.0"
|
typenum = { workspace = true }
|
||||||
|
|
||||||
aws-config = "1.5.5"
|
aws-config = { workspace = true }
|
||||||
aws-sdk-s3 = { version = "1.46.0", features = ["behavior-version-latest"] }
|
aws-sdk-s3 = { workspace = true, features = ["behavior-version-latest"] }
|
||||||
|
|
||||||
revolt-config = { version = "0.12.1", path = "../config", features = [
|
revolt-config = { workspace = true, features = [
|
||||||
"report-macros",
|
"report-macros",
|
||||||
] }
|
] }
|
||||||
revolt-result = { version = "0.12.1", path = "../result" }
|
revolt-result = { workspace = true }
|
||||||
|
|
||||||
# image processing
|
# image processing
|
||||||
jxl-oxide = { workspace = true }
|
jxl-oxide = { workspace = true, features = ["image"] }
|
||||||
image = { workspace = true }
|
image = { workspace = true }
|
||||||
|
|
||||||
# svg rendering
|
# svg rendering
|
||||||
usvg = "0.44.0"
|
usvg = { workspace = true }
|
||||||
resvg = "0.44.0"
|
resvg = { workspace = true }
|
||||||
tiny-skia = "0.11.4"
|
tiny-skia = { workspace = true }
|
||||||
|
|
||||||
# encoding
|
# encoding
|
||||||
webp = "0.3.0"
|
webp = { workspace = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
uuid = { workspace = true }
|
uuid = { workspace = true, features = ["v4"] }
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-models"
|
name = "revolt-models"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -21,26 +21,26 @@ default = ["serde", "partials", "rocket"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-config = { version = "0.12.1", path = "../config" }
|
revolt-config = { workspace = true }
|
||||||
revolt-permissions = { version = "0.12.1", path = "../permissions" }
|
revolt-permissions = { workspace = true }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
regex = "1.11"
|
regex = { workspace = true }
|
||||||
indexmap = "1.9.3"
|
indexmap = { workspace = true }
|
||||||
once_cell = "1.17.1"
|
once_cell = { workspace = true }
|
||||||
num_enum = "0.6.1"
|
num_enum = { workspace = true }
|
||||||
|
|
||||||
# Rocket
|
# Rocket
|
||||||
rocket = { optional = true, version = "0.5.0-rc.2", default-features = false }
|
rocket = { workspace = true, optional = true }
|
||||||
|
|
||||||
# Serialisation
|
# Serialisation
|
||||||
revolt_optional_struct = { version = "0.2.0", optional = true }
|
revolt_optional_struct = { workspace = true, optional = true }
|
||||||
serde = { version = "1", features = ["derive"], optional = true }
|
serde = { workspace = true, optional = true }
|
||||||
iso8601-timestamp = { version = "0.2.11", features = ["schema", "bson"] }
|
iso8601-timestamp = { workspace = true, features = ["schema", "bson"] }
|
||||||
|
|
||||||
# Spec Generation
|
# Spec Generation
|
||||||
schemars = { version = "0.8.8", optional = true, features = ["indexmap1"] }
|
schemars = { workspace = true, features = ["indexmap2"], optional = true }
|
||||||
utoipa = { version = "4.2.3", optional = true }
|
utoipa = { workspace = true, optional = true }
|
||||||
|
|
||||||
# Validation
|
# Validation
|
||||||
validator = { version = "0.16.0", optional = true, features = ["derive"] }
|
validator = { workspace = true, features = ["derive"], optional = true }
|
||||||
@@ -54,4 +54,22 @@ auto_derived!(
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub nsfw: bool,
|
pub nsfw: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Partial emoji representation
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct PartialEmoji {
|
||||||
|
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
|
pub name: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Edit emoji information
|
||||||
|
#[cfg_attr(feature = "validator", derive(Validate))]
|
||||||
|
pub struct DataEditEmoji {
|
||||||
|
/// Emoji name
|
||||||
|
#[cfg_attr(
|
||||||
|
feature = "validator",
|
||||||
|
validate(length(min = 1, max = 32), regex = "RE_EMOJI")
|
||||||
|
)]
|
||||||
|
pub name: Option<String>,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
@@ -261,7 +261,7 @@ auto_derived!(
|
|||||||
pub nonce: Option<String>,
|
pub nonce: Option<String>,
|
||||||
|
|
||||||
/// Message content to send
|
/// Message content to send
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 0, max = 2000)))]
|
#[cfg_attr(feature = "validator", validate(length(min = 0)))]
|
||||||
pub content: Option<String>,
|
pub content: Option<String>,
|
||||||
/// Attachments to include in message
|
/// Attachments to include in message
|
||||||
pub attachments: Option<Vec<String>>,
|
pub attachments: Option<Vec<String>>,
|
||||||
@@ -345,7 +345,7 @@ auto_derived!(
|
|||||||
#[cfg_attr(feature = "validator", derive(Validate))]
|
#[cfg_attr(feature = "validator", derive(Validate))]
|
||||||
pub struct DataEditMessage {
|
pub struct DataEditMessage {
|
||||||
/// New message content
|
/// New message content
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 1, max = 2000)))]
|
#[cfg_attr(feature = "validator", validate(length(min = 1)))]
|
||||||
pub content: Option<String>,
|
pub content: Option<String>,
|
||||||
/// Embeds to include in the message
|
/// Embeds to include in the message
|
||||||
#[cfg_attr(feature = "validator", validate(length(min = 0, max = 10)))]
|
#[cfg_attr(feature = "validator", validate(length(min = 0, max = 10)))]
|
||||||
|
|||||||
@@ -106,6 +106,9 @@ auto_derived_partial!(
|
|||||||
/// Ranking of this role
|
/// Ranking of this role
|
||||||
#[cfg_attr(feature = "serde", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub rank: i64,
|
pub rank: i64,
|
||||||
|
/// Role icon
|
||||||
|
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
|
pub icon: Option<File>,
|
||||||
},
|
},
|
||||||
"PartialRole"
|
"PartialRole"
|
||||||
);
|
);
|
||||||
@@ -123,6 +126,7 @@ auto_derived!(
|
|||||||
/// Optional fields on server object
|
/// Optional fields on server object
|
||||||
pub enum FieldsRole {
|
pub enum FieldsRole {
|
||||||
Colour,
|
Colour,
|
||||||
|
Icon,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Channel category
|
/// Channel category
|
||||||
@@ -278,6 +282,11 @@ auto_derived!(
|
|||||||
///
|
///
|
||||||
/// **Removed** - no effect, use the edit server role positions route
|
/// **Removed** - no effect, use the edit server role positions route
|
||||||
pub rank: Option<i64>,
|
pub rank: Option<i64>,
|
||||||
|
/// Role icon
|
||||||
|
///
|
||||||
|
/// Provide an Autumn attachment Id.
|
||||||
|
#[cfg_attr(feature = "validator", validate(length(min = 1, max = 128)))]
|
||||||
|
pub icon: Option<String>,
|
||||||
/// Fields to remove from role object
|
/// Fields to remove from role object
|
||||||
#[cfg_attr(feature = "serde", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub remove: Vec<FieldsRole>,
|
pub remove: Vec<FieldsRole>,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-parser"
|
name = "revolt-parser"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
||||||
@@ -8,4 +8,4 @@ description = "Revolt Backend: Message Parser"
|
|||||||
repository = "https://github.com/stoatchat/stoatchat"
|
repository = "https://github.com/stoatchat/stoatchat"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
logos = { version = "0.15" }
|
logos = { workspace = true }
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-permissions"
|
name = "revolt-permissions"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -18,23 +18,23 @@ try-from-primitive = ["dep:num_enum"]
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
# Async
|
# Async
|
||||||
async-std = { version = "1.8.0", features = ["attributes"] }
|
async-std = { workspace = true, features = ["attributes"] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Core
|
# Core
|
||||||
revolt-result = { version = "0.12.1", path = "../result" }
|
revolt-result = { workspace = true }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
auto_ops = "0.3.0"
|
auto_ops = { workspace = true }
|
||||||
once_cell = "1.17"
|
once_cell = { workspace = true }
|
||||||
num_enum = { version = "0.6.1", optional = true }
|
num_enum = { workspace = true, optional = true }
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
async-trait = "0.1.51"
|
async-trait = { workspace = true }
|
||||||
|
|
||||||
# Serialisation
|
# Serialisation
|
||||||
serde = { version = "1", features = ["derive"], optional = true }
|
serde = { workspace = true, optional = true }
|
||||||
bson = { version = "2.1.0", optional = true }
|
bson = { workspace = true, optional = true }
|
||||||
|
|
||||||
# Spec Generation
|
# Spec Generation
|
||||||
schemars = { version = "0.8.8", optional = true }
|
schemars = { workspace = true, optional = true }
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-presence"
|
name = "revolt-presence"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -14,16 +14,16 @@ redis-is-patched = []
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
# Async
|
# Async
|
||||||
async-std = { version = "1.8.0", features = ["attributes"] }
|
async-std = { workspace = true, features = ["attributes"] }
|
||||||
|
|
||||||
# Config for loading Redis URI
|
# Config for loading Redis URI
|
||||||
revolt-config = { version = "0.12.1", path = "../config" }
|
revolt-config = { workspace = true }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Utility
|
# Utility
|
||||||
log = "0.4.17"
|
log = { workspace = true }
|
||||||
rand = "0.8.5"
|
rand = { workspace = true }
|
||||||
once_cell = "1.17.1"
|
once_cell = { workspace = true }
|
||||||
|
|
||||||
# Redis
|
# Redis
|
||||||
redis-kiss = "0.1.4"
|
redis-kiss = { workspace = true }
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-ratelimits"
|
name = "revolt-ratelimits"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
authors = ["Zomatree <me@zomatree.live>", "Paul Makles <me@insrt.uk>"]
|
||||||
@@ -18,17 +18,17 @@ axum = ["dep:axum", "revolt-database/axum-impl"]
|
|||||||
default = ["rocket", "axum"]
|
default = ["rocket", "axum"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
revolt-database = { version = "0.12.1", path = "../database" }
|
revolt-database = { workspace = true }
|
||||||
revolt-result = { version = "0.12.1", path = "../result" }
|
revolt-result = { workspace = true }
|
||||||
revolt-config = { version = "0.12.1", path = "../config" }
|
revolt-config = { workspace = true }
|
||||||
|
|
||||||
rocket = { version = "0.5.1", optional = true }
|
rocket = { workspace = true, optional = true }
|
||||||
revolt_rocket_okapi = { version = "0.10.0", optional = true }
|
revolt_rocket_okapi = { workspace = true, optional = true }
|
||||||
|
|
||||||
axum = { version = "0.7.5", optional = true, features = ["macros"] }
|
axum = { workspace = true, optional = true, features = ["macros"] }
|
||||||
|
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { workspace = true }
|
||||||
authifier = { version = "1.0.16" }
|
authifier = { workspace = true }
|
||||||
dashmap = "5.2.0"
|
dashmap = { workspace = true }
|
||||||
async-trait = "0.1.81"
|
async-trait = { workspace = true }
|
||||||
log = "0.4"
|
log = { workspace = true }
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-result"
|
name = "revolt-result"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
@@ -22,21 +22,21 @@ default = ["serde", "sentry"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Serialisation
|
# Serialisation
|
||||||
serde_json = { version = "1", optional = true }
|
serde_json = { workspace = true, optional = true }
|
||||||
serde = { version = "1", features = ["derive"], optional = true }
|
serde = { workspace = true, optional = true }
|
||||||
|
|
||||||
# Spec Generation
|
# Spec Generation
|
||||||
schemars = { version = "0.8.8", optional = true }
|
schemars = { workspace = true, optional = true }
|
||||||
utoipa = { version = "4.2.3", optional = true }
|
utoipa = { workspace = true, optional = true }
|
||||||
|
|
||||||
# Rocket
|
# Rocket
|
||||||
rocket = { optional = true, version = "0.5.0-rc.2", default-features = false }
|
rocket = { workspace = true, optional = true }
|
||||||
revolt_rocket_okapi = { version = "0.10.0", optional = true }
|
revolt_rocket_okapi = { workspace = true, optional = true }
|
||||||
revolt_okapi = { version = "0.9.1", optional = true }
|
revolt_okapi = { workspace = true, optional = true }
|
||||||
|
|
||||||
# utilities
|
# utilities
|
||||||
log = "0.4"
|
log = { workspace = true }
|
||||||
# Axum
|
# Axum
|
||||||
axum = { version = "0.7.5", optional = true }
|
axum = { workspace = true, optional = true }
|
||||||
|
|
||||||
sentry = { version = "0.31.5", optional = true }
|
sentry = { workspace = true, optional = true }
|
||||||
@@ -24,6 +24,7 @@ impl IntoResponse for Error {
|
|||||||
ErrorType::UnknownChannel => StatusCode::NOT_FOUND,
|
ErrorType::UnknownChannel => StatusCode::NOT_FOUND,
|
||||||
ErrorType::UnknownMessage => StatusCode::NOT_FOUND,
|
ErrorType::UnknownMessage => StatusCode::NOT_FOUND,
|
||||||
ErrorType::UnknownAttachment => StatusCode::BAD_REQUEST,
|
ErrorType::UnknownAttachment => StatusCode::BAD_REQUEST,
|
||||||
|
ErrorType::CannotDeleteMessage => StatusCode::FORBIDDEN,
|
||||||
ErrorType::CannotEditMessage => StatusCode::FORBIDDEN,
|
ErrorType::CannotEditMessage => StatusCode::FORBIDDEN,
|
||||||
ErrorType::CannotJoinCall => StatusCode::BAD_REQUEST,
|
ErrorType::CannotJoinCall => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::TooManyAttachments { .. } => StatusCode::BAD_REQUEST,
|
ErrorType::TooManyAttachments { .. } => StatusCode::BAD_REQUEST,
|
||||||
@@ -36,9 +37,7 @@ impl IntoResponse for Error {
|
|||||||
ErrorType::NotInGroup => StatusCode::NOT_FOUND,
|
ErrorType::NotInGroup => StatusCode::NOT_FOUND,
|
||||||
ErrorType::AlreadyPinned => StatusCode::BAD_REQUEST,
|
ErrorType::AlreadyPinned => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::NotPinned => StatusCode::BAD_REQUEST,
|
ErrorType::NotPinned => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::InSlowmode {
|
ErrorType::InSlowmode { retry_after: _ } => StatusCode::TOO_MANY_REQUESTS,
|
||||||
retry_after: _,
|
|
||||||
} => StatusCode::TOO_MANY_REQUESTS,
|
|
||||||
|
|
||||||
ErrorType::CantCreateServers => StatusCode::FORBIDDEN,
|
ErrorType::CantCreateServers => StatusCode::FORBIDDEN,
|
||||||
ErrorType::UnknownServer => StatusCode::NOT_FOUND,
|
ErrorType::UnknownServer => StatusCode::NOT_FOUND,
|
||||||
@@ -78,7 +77,7 @@ impl IntoResponse for Error {
|
|||||||
ErrorType::DuplicateNonce => StatusCode::CONFLICT,
|
ErrorType::DuplicateNonce => StatusCode::CONFLICT,
|
||||||
ErrorType::VosoUnavailable => StatusCode::BAD_REQUEST,
|
ErrorType::VosoUnavailable => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::NotFound => StatusCode::NOT_FOUND,
|
ErrorType::NotFound => StatusCode::NOT_FOUND,
|
||||||
ErrorType::NoEffect => StatusCode::OK,
|
ErrorType::NoEffect => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::FailedValidation { .. } => StatusCode::BAD_REQUEST,
|
ErrorType::FailedValidation { .. } => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::LiveKitUnavailable => StatusCode::BAD_REQUEST,
|
ErrorType::LiveKitUnavailable => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::NotConnected => StatusCode::BAD_REQUEST,
|
ErrorType::NotConnected => StatusCode::BAD_REQUEST,
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ pub enum ErrorType {
|
|||||||
UnknownChannel,
|
UnknownChannel,
|
||||||
UnknownAttachment,
|
UnknownAttachment,
|
||||||
UnknownMessage,
|
UnknownMessage,
|
||||||
|
CannotDeleteMessage,
|
||||||
CannotEditMessage,
|
CannotEditMessage,
|
||||||
CannotJoinCall,
|
CannotJoinCall,
|
||||||
TooManyAttachments {
|
TooManyAttachments {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ impl<'r> Responder<'r, 'static> for Error {
|
|||||||
ErrorType::UnknownChannel => Status::NotFound,
|
ErrorType::UnknownChannel => Status::NotFound,
|
||||||
ErrorType::UnknownMessage => Status::NotFound,
|
ErrorType::UnknownMessage => Status::NotFound,
|
||||||
ErrorType::UnknownAttachment => Status::BadRequest,
|
ErrorType::UnknownAttachment => Status::BadRequest,
|
||||||
|
ErrorType::CannotDeleteMessage => Status::Forbidden,
|
||||||
ErrorType::CannotEditMessage => Status::Forbidden,
|
ErrorType::CannotEditMessage => Status::Forbidden,
|
||||||
ErrorType::CannotJoinCall => Status::BadRequest,
|
ErrorType::CannotJoinCall => Status::BadRequest,
|
||||||
ErrorType::TooManyAttachments { .. } => Status::BadRequest,
|
ErrorType::TooManyAttachments { .. } => Status::BadRequest,
|
||||||
@@ -42,9 +43,7 @@ impl<'r> Responder<'r, 'static> for Error {
|
|||||||
ErrorType::NotInGroup => Status::NotFound,
|
ErrorType::NotInGroup => Status::NotFound,
|
||||||
ErrorType::AlreadyPinned => Status::BadRequest,
|
ErrorType::AlreadyPinned => Status::BadRequest,
|
||||||
ErrorType::NotPinned => Status::BadRequest,
|
ErrorType::NotPinned => Status::BadRequest,
|
||||||
ErrorType::InSlowmode {
|
ErrorType::InSlowmode { retry_after: _ } => Status::TooManyRequests,
|
||||||
retry_after: _,
|
|
||||||
} => Status::TooManyRequests,
|
|
||||||
ErrorType::InvalidFlagValue => Status::BadRequest,
|
ErrorType::InvalidFlagValue => Status::BadRequest,
|
||||||
|
|
||||||
ErrorType::CantCreateServers => Status::Forbidden,
|
ErrorType::CantCreateServers => Status::Forbidden,
|
||||||
@@ -84,7 +83,7 @@ impl<'r> Responder<'r, 'static> for Error {
|
|||||||
ErrorType::NotAuthenticated => Status::Unauthorized,
|
ErrorType::NotAuthenticated => Status::Unauthorized,
|
||||||
ErrorType::DuplicateNonce => Status::Conflict,
|
ErrorType::DuplicateNonce => Status::Conflict,
|
||||||
ErrorType::NotFound => Status::NotFound,
|
ErrorType::NotFound => Status::NotFound,
|
||||||
ErrorType::NoEffect => Status::Ok,
|
ErrorType::NoEffect => Status::BadRequest,
|
||||||
ErrorType::FailedValidation { .. } => Status::BadRequest,
|
ErrorType::FailedValidation { .. } => Status::BadRequest,
|
||||||
ErrorType::LiveKitUnavailable => Status::BadRequest,
|
ErrorType::LiveKitUnavailable => Status::BadRequest,
|
||||||
ErrorType::NotAVoiceChannel => Status::BadRequest,
|
ErrorType::NotAVoiceChannel => Status::BadRequest,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-crond"
|
name = "revolt-crond"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <me@insrt.uk>"]
|
authors = ["Paul Makles <me@insrt.uk>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -11,13 +11,27 @@ publish = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Utility
|
# Utility
|
||||||
log = "0.4"
|
log = { workspace = true }
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
tokio = { version = "1" }
|
tokio = { workspace = true }
|
||||||
|
|
||||||
|
# Redis
|
||||||
|
redis-kiss = { workspace = true }
|
||||||
|
|
||||||
|
# RabbitMQ
|
||||||
|
lapin = { workspace = true }
|
||||||
|
futures-lite = { workspace = true }
|
||||||
|
|
||||||
|
# Processing
|
||||||
|
serde_json = { workspace = true }
|
||||||
|
revolt_optional_struct = { workspace = true }
|
||||||
|
serde = { workspace = true }
|
||||||
|
iso8601-timestamp = { workspace = true, features = ["serde", "bson"] }
|
||||||
|
|
||||||
# Core
|
# Core
|
||||||
revolt-database = { version = "0.12.1", path = "../../core/database" }
|
revolt-database = { workspace = true }
|
||||||
revolt-result = { version = "0.12.1", path = "../../core/result" }
|
revolt-result = { workspace = true }
|
||||||
revolt-config = { version = "0.12.1", path = "../../core/config" }
|
revolt-config = { workspace = true }
|
||||||
revolt-files = { version = "0.12.1", path = "../../core/files" }
|
revolt-files = { workspace = true }
|
||||||
|
revolt-permissions = { workspace = true }
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
use revolt_config::configure;
|
use revolt_config::configure;
|
||||||
use revolt_database::DatabaseInfo;
|
use revolt_database::DatabaseInfo;
|
||||||
use revolt_result::Result;
|
use revolt_result::Result;
|
||||||
use tasks::{file_deletion, prune_dangling_files, prune_members};
|
use tasks::{acks, file_deletion, prune_dangling_files, prune_members};
|
||||||
use tokio::try_join;
|
use tokio::try_join;
|
||||||
|
|
||||||
pub mod tasks;
|
pub mod tasks;
|
||||||
@@ -14,7 +14,8 @@ async fn main() -> Result<()> {
|
|||||||
try_join!(
|
try_join!(
|
||||||
file_deletion::task(db.clone()),
|
file_deletion::task(db.clone()),
|
||||||
prune_dangling_files::task(db.clone()),
|
prune_dangling_files::task(db.clone()),
|
||||||
prune_members::task(db.clone())
|
prune_members::task(db.clone()),
|
||||||
|
acks::task(db.clone())
|
||||||
)
|
)
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
use futures_lite::stream::StreamExt;
|
||||||
|
use lapin::{
|
||||||
|
options::*,
|
||||||
|
types::FieldTable,
|
||||||
|
uri::{AMQPAuthority, AMQPQueryString, AMQPUri, AMQPUserInfo},
|
||||||
|
ConnectionBuilder, ConnectionProperties,
|
||||||
|
};
|
||||||
|
use log::info;
|
||||||
|
use redis_kiss::{get_connection, AsyncCommands, Conn as RedisConnection};
|
||||||
|
use revolt_config::config;
|
||||||
|
use revolt_database::{events::rabbit::AckEventPayload, Database};
|
||||||
|
use revolt_result::{Result, ToRevoltError};
|
||||||
|
use serde_json;
|
||||||
|
|
||||||
|
pub async fn task(db: Database) -> Result<()> {
|
||||||
|
let config = config().await;
|
||||||
|
|
||||||
|
let mut redis = get_connection()
|
||||||
|
.await
|
||||||
|
.expect("Failed to get redis connection");
|
||||||
|
|
||||||
|
let uri = AMQPUri {
|
||||||
|
scheme: lapin::uri::AMQPScheme::AMQP,
|
||||||
|
authority: AMQPAuthority {
|
||||||
|
userinfo: AMQPUserInfo {
|
||||||
|
username: config.rabbit.username,
|
||||||
|
password: config.rabbit.password,
|
||||||
|
},
|
||||||
|
host: config.rabbit.host,
|
||||||
|
port: config.rabbit.port,
|
||||||
|
},
|
||||||
|
vhost: "/".to_string(),
|
||||||
|
query: AMQPQueryString::default(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let connection = ConnectionBuilder::new()
|
||||||
|
.expect("Builder")
|
||||||
|
.with_uri(uri)
|
||||||
|
.with_properties(ConnectionProperties::default())
|
||||||
|
.connect()
|
||||||
|
.await
|
||||||
|
.expect("Failed to connect to rabbitmq");
|
||||||
|
|
||||||
|
let reader_channel = connection
|
||||||
|
.create_channel()
|
||||||
|
.await
|
||||||
|
.expect("Failed to create channel");
|
||||||
|
|
||||||
|
let mut consumer = reader_channel
|
||||||
|
.basic_consume(
|
||||||
|
config.rabbit.queues.acks.into(),
|
||||||
|
"crond-ack-consumer".into(),
|
||||||
|
BasicConsumeOptions::default(),
|
||||||
|
FieldTable::default(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("Failed to create consumer");
|
||||||
|
|
||||||
|
while let Some(delivery) = consumer.next().await {
|
||||||
|
if let Ok(delivery) = delivery {
|
||||||
|
let payload: std::result::Result<AckEventPayload, _> =
|
||||||
|
serde_json::from_slice(&delivery.data);
|
||||||
|
if let Ok(payload) = payload {
|
||||||
|
info!("{:?}", payload);
|
||||||
|
if let Err(e) = process_channel_ack(
|
||||||
|
&db,
|
||||||
|
payload.user_id,
|
||||||
|
payload.channel_id.unwrap(),
|
||||||
|
&mut redis,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
revolt_config::capture_error(&e);
|
||||||
|
_ = delivery.reject(BasicRejectOptions { requeue: false }).await;
|
||||||
|
} else {
|
||||||
|
_ = delivery.ack(BasicAckOptions { multiple: false }).await;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
revolt_config::capture_message(
|
||||||
|
format!("Failed to decode ack data: {:?}", delivery.data).as_str(),
|
||||||
|
revolt_config::Level::Error,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::disallowed_methods)]
|
||||||
|
async fn process_channel_ack(
|
||||||
|
db: &Database,
|
||||||
|
user: String,
|
||||||
|
channel: String,
|
||||||
|
redis: &mut RedisConnection,
|
||||||
|
) -> Result<()> {
|
||||||
|
let message_id: Option<String> = redis
|
||||||
|
.get_del(format!("acker:{user}+{channel}"))
|
||||||
|
.await
|
||||||
|
.to_internal_error()?;
|
||||||
|
|
||||||
|
if let Some(message_id) = message_id {
|
||||||
|
// This will be uncommented eventually, but we need to sort out the transition to lapin first. For now we'll simply disable the badge update logic.
|
||||||
|
// We also drop a db request as a bonus.
|
||||||
|
|
||||||
|
//let unread = db.fetch_unread(&user, &channel).await?;
|
||||||
|
let _updated = db.acknowledge_message(&channel, &user, &message_id).await?;
|
||||||
|
info!("Set new state for ack: {}:{}:{}", channel, user, message_id);
|
||||||
|
|
||||||
|
// if let (Some(before), Some(after)) = (unread, updated) {
|
||||||
|
// let before_mentions = before.mentions.unwrap_or_default().len();
|
||||||
|
// let after_mentions = after.mentions.unwrap_or_default().len();
|
||||||
|
|
||||||
|
// let mentions_acked = before_mentions - after_mentions;
|
||||||
|
|
||||||
|
// if mentions_acked > 0 {
|
||||||
|
// if let Err(err) = amqp
|
||||||
|
// .ack_message(user.to_string(), channel.to_string(), payload.message_id)
|
||||||
|
// .await
|
||||||
|
// {
|
||||||
|
// revolt_config::capture_error(&err);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(message_id.to_internal_error().expect_err("no err"))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
pub mod acks;
|
||||||
pub mod file_deletion;
|
pub mod file_deletion;
|
||||||
pub mod prune_dangling_files;
|
pub mod prune_dangling_files;
|
||||||
pub mod prune_members;
|
pub mod prune_members;
|
||||||
@@ -1,47 +1,40 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-pushd"
|
name = "revolt-pushd"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
revolt-result = { version = "0.12.1", path = "../../core/result" }
|
revolt-result = { workspace = true }
|
||||||
revolt-config = { version = "0.12.1", path = "../../core/config", features = [
|
revolt-config = { workspace = true, features = ["report-macros", "anyhow"] }
|
||||||
"report-macros",
|
revolt-database = { workspace = true }
|
||||||
"anyhow",
|
revolt-models = { workspace = true, features = ["validator"] }
|
||||||
] }
|
revolt-presence = { workspace = true, features = ["redis-is-patched"] }
|
||||||
revolt-database = { version = "0.12.1", path = "../../core/database" }
|
revolt-parser = { workspace = true }
|
||||||
revolt-models = { version = "0.12.1", path = "../../core/models", features = [
|
|
||||||
"validator",
|
|
||||||
] }
|
|
||||||
revolt-presence = { version = "0.12.1", path = "../../core/presence", features = [
|
|
||||||
"redis-is-patched",
|
|
||||||
] }
|
|
||||||
revolt-parser = { version = "0.12.1", path = "../../core/parser" }
|
|
||||||
|
|
||||||
anyhow = { version = "1.0.98" }
|
anyhow = { workspace = true }
|
||||||
|
|
||||||
amqprs = { version = "1.7.0" }
|
amqprs = { workspace = true }
|
||||||
fcm_v1 = "0.3.0"
|
fcm_v1 = { workspace = true }
|
||||||
web-push = "0.10.0"
|
web-push = { workspace = true }
|
||||||
isahc = { optional = true, version = "1.7", features = ["json"] }
|
isahc = { workspace = true, features = ["json"], optional = true }
|
||||||
revolt_a2 = { version = "0.10", default-features = false, features = ["ring"] }
|
revolt_a2 = { workspace = true, features = ["ring"] }
|
||||||
redis-kiss = "0.1.4"
|
redis-kiss = { workspace = true }
|
||||||
tokio = "1.39.2"
|
tokio = { workspace = true }
|
||||||
async-trait = "0.1.81"
|
async-trait = { workspace = true }
|
||||||
ulid = "1.0.0"
|
ulid = { workspace = true }
|
||||||
|
|
||||||
authifier = "1.0.16"
|
authifier = { workspace = true }
|
||||||
|
|
||||||
log = "0.4.11"
|
log = { workspace = true }
|
||||||
pretty_env_logger = "0.4.0"
|
pretty_env_logger = { workspace = true }
|
||||||
|
|
||||||
regex = "1.12.3"
|
regex = { workspace = true }
|
||||||
|
|
||||||
#serialization
|
#serialization
|
||||||
serde_json = "1"
|
serde_json = { workspace = true }
|
||||||
revolt_optional_struct = "0.2.0"
|
revolt_optional_struct = { workspace = true }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { workspace = true }
|
||||||
iso8601-timestamp = { version = "0.2.10", features = ["serde", "bson"] }
|
iso8601-timestamp = { workspace = true, features = ["serde", "bson"] }
|
||||||
base64 = "0.22.1"
|
base64 = { workspace = true }
|
||||||
@@ -5,9 +5,8 @@ use amqprs::{channel::Channel as AmqpChannel, consumer::AsyncConsumer, BasicProp
|
|||||||
use anyhow::{anyhow, bail, Result};
|
use anyhow::{anyhow, bail, Result};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use fcm_v1::{
|
use fcm_v1::{
|
||||||
android::{AndroidConfig, AndroidMessagePriority},
|
|
||||||
auth::{Authenticator, ServiceAccountKey},
|
auth::{Authenticator, ServiceAccountKey},
|
||||||
message::{Message, Notification},
|
message::Message,
|
||||||
Client, Error as FcmError,
|
Client, Error as FcmError,
|
||||||
};
|
};
|
||||||
use revolt_config::config;
|
use revolt_config::config;
|
||||||
@@ -15,6 +14,102 @@ use revolt_database::{events::rabbit::*, Database};
|
|||||||
use revolt_models::v0::{Channel, PushNotification};
|
use revolt_models::v0::{Channel, PushNotification};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
|
/// Custom notification data
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub enum NotificationData {
|
||||||
|
FRReceived {
|
||||||
|
id: String,
|
||||||
|
username: String,
|
||||||
|
},
|
||||||
|
FRAccepted {
|
||||||
|
id: String,
|
||||||
|
username: String,
|
||||||
|
},
|
||||||
|
Generic {
|
||||||
|
title: String,
|
||||||
|
body: String,
|
||||||
|
image: Option<String>,
|
||||||
|
},
|
||||||
|
Message {
|
||||||
|
title: String,
|
||||||
|
body: String,
|
||||||
|
image: String,
|
||||||
|
tag: String,
|
||||||
|
},
|
||||||
|
DmCallStartEnd {
|
||||||
|
initiator_id: String,
|
||||||
|
channel_id: String,
|
||||||
|
started_at: String,
|
||||||
|
ended: bool,
|
||||||
|
duration: usize,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NotificationData {
|
||||||
|
pub fn get_type(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
NotificationData::FRReceived { .. } => "push.fr.receive",
|
||||||
|
NotificationData::FRAccepted { .. } => "push.fr.accept",
|
||||||
|
NotificationData::Generic { .. } => "push.generic",
|
||||||
|
NotificationData::Message { .. } => "push.message",
|
||||||
|
NotificationData::DmCallStartEnd { .. } => "push.dm.call",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_payload(self) -> HashMap<String, Value> {
|
||||||
|
let mut data = HashMap::new();
|
||||||
|
data.insert(
|
||||||
|
"type".to_string(),
|
||||||
|
Value::String(self.get_type().to_string()),
|
||||||
|
);
|
||||||
|
|
||||||
|
match self {
|
||||||
|
NotificationData::FRReceived { id, username } => {
|
||||||
|
data.insert("id".to_string(), Value::String(id));
|
||||||
|
data.insert("username".to_string(), Value::String(username));
|
||||||
|
}
|
||||||
|
NotificationData::FRAccepted { id, username } => {
|
||||||
|
data.insert("id".to_string(), Value::String(id));
|
||||||
|
data.insert("username".to_string(), Value::String(username));
|
||||||
|
}
|
||||||
|
NotificationData::Generic { title, body, image } => {
|
||||||
|
data.insert("title".to_string(), Value::String(title));
|
||||||
|
data.insert("body".to_string(), Value::String(body));
|
||||||
|
|
||||||
|
if let Some(image) = image {
|
||||||
|
data.insert("image".to_string(), Value::String(image));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NotificationData::Message {
|
||||||
|
title,
|
||||||
|
body,
|
||||||
|
image,
|
||||||
|
tag,
|
||||||
|
} => {
|
||||||
|
data.insert("title".to_string(), Value::String(title));
|
||||||
|
data.insert("body".to_string(), Value::String(body));
|
||||||
|
data.insert("image".to_string(), Value::String(image));
|
||||||
|
data.insert("tag".to_string(), Value::String(tag));
|
||||||
|
}
|
||||||
|
NotificationData::DmCallStartEnd {
|
||||||
|
initiator_id,
|
||||||
|
channel_id,
|
||||||
|
started_at,
|
||||||
|
ended,
|
||||||
|
duration,
|
||||||
|
} => {
|
||||||
|
data.insert("initiator_id".to_string(), Value::String(initiator_id));
|
||||||
|
data.insert("channel_id".to_string(), Value::String(channel_id));
|
||||||
|
data.insert("started_at".to_string(), Value::String(started_at));
|
||||||
|
data.insert("ended".to_string(), Value::Bool(ended));
|
||||||
|
data.insert("duration".to_string(), Value::Number(duration.into()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct FcmOutboundConsumer {
|
pub struct FcmOutboundConsumer {
|
||||||
db: Database,
|
db: Database,
|
||||||
client: Client,
|
client: Client,
|
||||||
@@ -93,17 +188,14 @@ impl FcmOutboundConsumer {
|
|||||||
.clone()
|
.clone()
|
||||||
.ok_or_else(|| anyhow!("missing name"))?;
|
.ok_or_else(|| anyhow!("missing name"))?;
|
||||||
|
|
||||||
let mut data = HashMap::new();
|
let data = NotificationData::FRReceived {
|
||||||
data.insert(
|
id: alert.from_user.id,
|
||||||
"type".to_string(),
|
username: name,
|
||||||
Value::String("push.fr.receive".to_string()),
|
};
|
||||||
);
|
|
||||||
data.insert("id".to_string(), Value::String(alert.from_user.id));
|
|
||||||
data.insert("username".to_string(), Value::String(name));
|
|
||||||
|
|
||||||
let msg = Message {
|
let msg = Message {
|
||||||
token: Some(payload.token),
|
token: Some(payload.token),
|
||||||
data: Some(data),
|
data: Some(data.into_payload()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -121,30 +213,29 @@ impl FcmOutboundConsumer {
|
|||||||
.clone()
|
.clone()
|
||||||
.ok_or_else(|| anyhow!("missing name"))?;
|
.ok_or_else(|| anyhow!("missing name"))?;
|
||||||
|
|
||||||
let mut data: HashMap<String, Value> = HashMap::new();
|
let data = NotificationData::FRAccepted {
|
||||||
data.insert(
|
id: alert.accepted_user.id,
|
||||||
"type".to_string(),
|
username: name,
|
||||||
Value::String("push.fr.accept".to_string()),
|
};
|
||||||
);
|
|
||||||
data.insert("id".to_string(), Value::String(alert.accepted_user.id));
|
|
||||||
data.insert("username".to_string(), Value::String(name));
|
|
||||||
|
|
||||||
let msg = Message {
|
let msg = Message {
|
||||||
token: Some(payload.token),
|
token: Some(payload.token),
|
||||||
data: Some(data),
|
data: Some(data.into_payload()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
resp = self.client.send(&msg).await;
|
resp = self.client.send(&msg).await;
|
||||||
}
|
}
|
||||||
PayloadKind::Generic(alert) => {
|
PayloadKind::Generic(alert) => {
|
||||||
|
let data = NotificationData::Generic {
|
||||||
|
title: alert.title,
|
||||||
|
body: alert.body,
|
||||||
|
image: alert.icon,
|
||||||
|
};
|
||||||
|
|
||||||
let msg = Message {
|
let msg = Message {
|
||||||
token: Some(payload.token),
|
token: Some(payload.token),
|
||||||
notification: Some(Notification {
|
data: Some(data.into_payload()),
|
||||||
title: Some(alert.title),
|
|
||||||
body: Some(alert.body),
|
|
||||||
image: alert.icon,
|
|
||||||
}),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -152,19 +243,16 @@ impl FcmOutboundConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PayloadKind::MessageNotification(alert) => {
|
PayloadKind::MessageNotification(alert) => {
|
||||||
let title = self.format_title(&alert);
|
let data = NotificationData::Message {
|
||||||
|
title: self.format_title(&alert),
|
||||||
|
body: alert.body,
|
||||||
|
image: alert.icon,
|
||||||
|
tag: alert.tag,
|
||||||
|
};
|
||||||
|
|
||||||
let msg = Message {
|
let msg = Message {
|
||||||
token: Some(payload.token),
|
token: Some(payload.token),
|
||||||
notification: Some(Notification {
|
data: Some(data.into_payload()),
|
||||||
title: Some(title),
|
|
||||||
body: Some(alert.body),
|
|
||||||
image: Some(alert.icon),
|
|
||||||
}),
|
|
||||||
android: Some(AndroidConfig {
|
|
||||||
collapse_key: Some(alert.tag),
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -172,30 +260,17 @@ impl FcmOutboundConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PayloadKind::DmCallStartEnd(alert) => {
|
PayloadKind::DmCallStartEnd(alert) => {
|
||||||
let mut data: HashMap<String, Value> = HashMap::new();
|
let data = NotificationData::DmCallStartEnd {
|
||||||
data.insert(
|
initiator_id: alert.initiator_id,
|
||||||
"initiator_id".to_string(),
|
channel_id: alert.channel_id,
|
||||||
Value::String(alert.initiator_id),
|
started_at: alert.started_at.unwrap_or_else(|| "".to_string()),
|
||||||
);
|
ended: alert.ended,
|
||||||
data.insert("channel_id".to_string(), Value::String(alert.channel_id));
|
duration: config().await.api.livekit.call_ring_duration,
|
||||||
data.insert(
|
};
|
||||||
"started_at".to_string(),
|
|
||||||
Value::String(alert.started_at.unwrap_or_else(|| "".to_string())),
|
|
||||||
);
|
|
||||||
data.insert("ended".to_string(), Value::Bool(alert.ended));
|
|
||||||
|
|
||||||
let msg = Message {
|
let msg = Message {
|
||||||
token: Some(payload.token),
|
token: Some(payload.token),
|
||||||
notification: None,
|
data: Some(data.into_payload()),
|
||||||
data: Some(data),
|
|
||||||
android: Some(AndroidConfig {
|
|
||||||
priority: Some(AndroidMessagePriority::High),
|
|
||||||
ttl: Some(format!(
|
|
||||||
"{}s",
|
|
||||||
config().await.api.livekit.call_ring_duration
|
|
||||||
)),
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-voice-ingress"
|
name = "revolt-voice-ingress"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
@@ -9,41 +9,41 @@ publish = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# util
|
# util
|
||||||
log = "*"
|
log = { workspace = true }
|
||||||
sentry = "0.31.5"
|
sentry = { workspace = true }
|
||||||
lru = "0.7.6"
|
lru = { workspace = true }
|
||||||
ulid = "0.5.0"
|
ulid = { workspace = true }
|
||||||
redis-kiss = "0.1.4"
|
redis-kiss = { workspace = true }
|
||||||
chrono = "0.4.15"
|
chrono = { workspace = true }
|
||||||
|
|
||||||
# Serde
|
# Serde
|
||||||
serde_json = "1.0.79"
|
serde_json = { workspace = true }
|
||||||
rmp-serde = "1.0.0"
|
rmp-serde = { workspace = true }
|
||||||
serde = "1.0.136"
|
serde = { workspace = true }
|
||||||
|
|
||||||
# Http
|
# Http
|
||||||
rocket = { version = "0.5.0-rc.2", features = ["json"] }
|
rocket = { workspace = true, features = ["json"] }
|
||||||
rocket_empty = "0.1.1"
|
rocket_empty = { workspace = true }
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
futures = "0.3.21"
|
futures = { workspace = true }
|
||||||
async-std = { version = "1.8.0", features = [
|
async-std = { workspace = true, features = [
|
||||||
"tokio1",
|
"tokio1",
|
||||||
"tokio02",
|
"tokio02",
|
||||||
"attributes",
|
"attributes",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
# Core
|
# Core
|
||||||
revolt-result = { path = "../../core/result" }
|
revolt-result = { workspace = true, features = ["rocket"] }
|
||||||
revolt-models = { path = "../../core/models" }
|
revolt-models = { workspace = true }
|
||||||
revolt-config = { path = "../../core/config" }
|
revolt-config = { workspace = true }
|
||||||
revolt-database = { path = "../../core/database", features = ["voice"] }
|
revolt-database = { workspace = true, features = ["voice"] }
|
||||||
revolt-permissions = { path = "../../core/permissions" }
|
revolt-permissions = { workspace = true }
|
||||||
|
|
||||||
# Voice
|
# Voice
|
||||||
livekit-api = "0.4.4"
|
livekit-api = { workspace = true }
|
||||||
livekit-protocol = "0.4.0"
|
livekit-protocol = { workspace = true }
|
||||||
livekit-runtime = { version = "0.3.1", features = ["tokio"] }
|
livekit-runtime = { workspace = true, features = ["tokio"] }
|
||||||
|
|
||||||
# RabbitMQ
|
# RabbitMQ
|
||||||
amqprs = { version = "1.7.0" }
|
amqprs = { workspace = true }
|
||||||
+44
-45
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-delta"
|
name = "revolt-delta"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -10,84 +10,83 @@ publish = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Test
|
# Test
|
||||||
rand = "0.8.5"
|
rand = { workspace = true }
|
||||||
redis-kiss = "0.1.4"
|
redis-kiss = { workspace = true }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
lru = "0.7.0"
|
lru = { workspace = true }
|
||||||
url = "2.2.2"
|
url = { workspace = true }
|
||||||
log = "0.4.11"
|
log = { workspace = true }
|
||||||
dashmap = "5.2.0"
|
dashmap = { workspace = true }
|
||||||
linkify = "0.6.0"
|
linkify = { workspace = true }
|
||||||
once_cell = "1.17.1"
|
once_cell = { workspace = true }
|
||||||
env_logger = "0.7.1"
|
|
||||||
|
|
||||||
# Lang. Utilities
|
# Lang. Utilities
|
||||||
regex = "1"
|
regex = { workspace = true }
|
||||||
num_enum = "0.5.1"
|
num_enum = { workspace = true }
|
||||||
impl_ops = "0.1.1"
|
impl_ops = { workspace = true }
|
||||||
bitfield = "0.13.2"
|
bitfield = { workspace = true }
|
||||||
|
|
||||||
# ID / key generation
|
# ID / key generation
|
||||||
ulid = "0.4.1"
|
ulid = { workspace = true }
|
||||||
nanoid = "0.4.0"
|
nanoid = { workspace = true }
|
||||||
|
|
||||||
# serde
|
# serde
|
||||||
serde_json = "1.0.57"
|
serde_json = { workspace = true }
|
||||||
serde = { version = "1.0.115", features = ["derive"] }
|
serde = { workspace = true }
|
||||||
validator = { version = "0.16", features = ["derive"] }
|
validator = { workspace = true, features = ["derive"] }
|
||||||
iso8601-timestamp = { version = "0.2.11", features = [] }
|
iso8601-timestamp = { workspace = true }
|
||||||
|
|
||||||
# async
|
# async
|
||||||
futures = "0.3.8"
|
futures = { workspace = true }
|
||||||
chrono = "0.4.15"
|
chrono = { workspace = true }
|
||||||
async-channel = "1.6.1"
|
async-channel = { workspace = true }
|
||||||
reqwest = { version = "0.11.4", features = ["json"] }
|
reqwest = { workspace = true, features = ["json"] }
|
||||||
async-std = { version = "1.8.0", features = [
|
async-std = { workspace = true, features = [
|
||||||
"tokio1",
|
"tokio1",
|
||||||
"tokio02",
|
"tokio02",
|
||||||
"attributes",
|
"attributes",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
# internal util
|
# internal util
|
||||||
lettre = "0.10.0-alpha.4"
|
lettre = { workspace = true }
|
||||||
|
|
||||||
# web
|
# web
|
||||||
|
|
||||||
rocket = { version = "0.5.1", default-features = false, features = ["json"] }
|
rocket = { workspace = true, features = ["json"] }
|
||||||
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", rev = "072d90359b23e9b291df6b672c07c93de9c46011" }
|
rocket_cors = { workspace = true }
|
||||||
rocket_empty = { version = "0.1.1", features = ["schema"] }
|
rocket_empty = { workspace = true, features = ["schema"] }
|
||||||
rocket_authifier = { version = "1.0.16" }
|
rocket_authifier = { workspace = true }
|
||||||
rocket_prometheus = "0.10.0-rc.3"
|
rocket_prometheus = { workspace = true }
|
||||||
|
|
||||||
# spec generation
|
# spec generation
|
||||||
schemars = "0.8.8"
|
schemars = { workspace = true }
|
||||||
revolt_rocket_okapi = { version = "0.10.0", features = ["swagger"] }
|
revolt_rocket_okapi = { workspace = true, features = ["swagger"] }
|
||||||
|
|
||||||
# rabbit
|
# rabbit
|
||||||
amqprs = { version = "1.7.0" }
|
amqprs = { workspace = true }
|
||||||
|
|
||||||
# core
|
# core
|
||||||
authifier = "1.0.16"
|
authifier = { workspace = true }
|
||||||
revolt-config = { path = "../core/config" }
|
revolt-config = { workspace = true }
|
||||||
revolt-database = { path = "../core/database", features = [
|
revolt-database = { workspace = true, features = [
|
||||||
"rocket-impl",
|
"rocket-impl",
|
||||||
"redis-is-patched",
|
"redis-is-patched",
|
||||||
"voice",
|
"voice",
|
||||||
] }
|
] }
|
||||||
revolt-models = { path = "../core/models", features = [
|
revolt-models = { workspace = true, features = [
|
||||||
"schemas",
|
"schemas",
|
||||||
"validator",
|
"validator",
|
||||||
"rocket",
|
"rocket",
|
||||||
] }
|
] }
|
||||||
revolt-presence = { path = "../core/presence" }
|
revolt-presence = { workspace = true }
|
||||||
revolt-result = { path = "../core/result", features = ["rocket", "okapi"] }
|
revolt-result = { workspace = true, features = ["rocket", "okapi"] }
|
||||||
revolt-permissions = { path = "../core/permissions", features = ["schemas"] }
|
revolt-permissions = { workspace = true, features = ["schemas"] }
|
||||||
revolt-ratelimits = { path = "../core/ratelimits", features = ["rocket"] }
|
revolt-ratelimits = { workspace = true, features = ["rocket"] }
|
||||||
|
|
||||||
# voice
|
# voice
|
||||||
livekit-api = "0.4.4"
|
livekit-api = { workspace = true }
|
||||||
livekit-protocol = "0.4.0"
|
livekit-protocol = { workspace = true }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
vergen = "7.5.0"
|
vergen = { workspace = true }
|
||||||
@@ -24,8 +24,8 @@ use amqprs::{
|
|||||||
};
|
};
|
||||||
use async_std::channel::unbounded;
|
use async_std::channel::unbounded;
|
||||||
use authifier::AuthifierEvent;
|
use authifier::AuthifierEvent;
|
||||||
use rocket::data::ToByteUnit;
|
|
||||||
use revolt_database::voice::VoiceClient;
|
use revolt_database::voice::VoiceClient;
|
||||||
|
use rocket::data::ToByteUnit;
|
||||||
|
|
||||||
pub async fn web() -> Rocket<Build> {
|
pub async fn web() -> Rocket<Build> {
|
||||||
// Get settings
|
// Get settings
|
||||||
@@ -93,22 +93,6 @@ pub async fn web() -> Rocket<Build> {
|
|||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
let swagger_0_8 = revolt_rocket_okapi::swagger_ui::make_swagger_ui(
|
|
||||||
&revolt_rocket_okapi::swagger_ui::SwaggerUIConfig {
|
|
||||||
url: "/0.8/openapi.json".to_owned(),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.into();
|
|
||||||
|
|
||||||
let swagger_0_8 = revolt_rocket_okapi::swagger_ui::make_swagger_ui(
|
|
||||||
&revolt_rocket_okapi::swagger_ui::SwaggerUIConfig {
|
|
||||||
url: "/0.8/openapi.json".to_owned(),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.into();
|
|
||||||
|
|
||||||
// Voice handler
|
// Voice handler
|
||||||
let voice_client = VoiceClient::new(config.api.livekit.nodes.clone());
|
let voice_client = VoiceClient::new(config.api.livekit.nodes.clone());
|
||||||
// Configure Rabbit
|
// Configure Rabbit
|
||||||
@@ -136,6 +120,9 @@ pub async fn web() -> Rocket<Build> {
|
|||||||
.expect("Failed to declare exchange");
|
.expect("Failed to declare exchange");
|
||||||
|
|
||||||
let amqp = AMQP::new(connection, channel);
|
let amqp = AMQP::new(connection, channel);
|
||||||
|
amqp.configure_channels()
|
||||||
|
.await
|
||||||
|
.expect("Failed to configure channels");
|
||||||
|
|
||||||
// Launch background task workers
|
// Launch background task workers
|
||||||
revolt_database::tasks::start_workers(db.clone(), amqp.clone());
|
revolt_database::tasks::start_workers(db.clone(), amqp.clone());
|
||||||
@@ -153,7 +140,6 @@ pub async fn web() -> Rocket<Build> {
|
|||||||
.mount("/", rocket_cors::catch_all_options_routes())
|
.mount("/", rocket_cors::catch_all_options_routes())
|
||||||
.mount("/", ratelimiter::routes())
|
.mount("/", ratelimiter::routes())
|
||||||
.mount("/swagger/", swagger)
|
.mount("/swagger/", swagger)
|
||||||
.mount("/0.8/swagger/", swagger_0_8)
|
|
||||||
.manage(authifier)
|
.manage(authifier)
|
||||||
.manage(db)
|
.manage(db)
|
||||||
.manage(amqp)
|
.manage(amqp)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use revolt_database::{
|
use revolt_database::{
|
||||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||||
Database, User,
|
Database, User, AMQP,
|
||||||
};
|
};
|
||||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||||
use revolt_result::{create_error, Result};
|
use revolt_result::{create_error, Result};
|
||||||
@@ -14,6 +14,7 @@ use rocket_empty::EmptyResponse;
|
|||||||
#[put("/<target>/ack/<message>")]
|
#[put("/<target>/ack/<message>")]
|
||||||
pub async fn ack(
|
pub async fn ack(
|
||||||
db: &State<Database>,
|
db: &State<Database>,
|
||||||
|
amqp: &State<AMQP>,
|
||||||
user: User,
|
user: User,
|
||||||
target: Reference<'_>,
|
target: Reference<'_>,
|
||||||
message: Reference<'_>,
|
message: Reference<'_>,
|
||||||
@@ -29,7 +30,7 @@ pub async fn ack(
|
|||||||
.throw_if_lacking_channel_permission(ChannelPermission::ViewChannel)?;
|
.throw_if_lacking_channel_permission(ChannelPermission::ViewChannel)?;
|
||||||
|
|
||||||
channel
|
channel
|
||||||
.ack(&user.id, message.id)
|
.ack(&user.id, message.id, amqp)
|
||||||
.await
|
.await
|
||||||
.map(|_| EmptyResponse)
|
.map(|_| EmptyResponse)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use chrono::Utc;
|
use std::time::Duration;
|
||||||
|
|
||||||
use revolt_database::{
|
use revolt_database::{
|
||||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||||
Database, Message, User,
|
Database, Message, User,
|
||||||
@@ -36,10 +37,9 @@ pub async fn bulk_delete_messages(
|
|||||||
if ulid::Ulid::from_string(id)
|
if ulid::Ulid::from_string(id)
|
||||||
.map_err(|_| create_error!(InvalidOperation))?
|
.map_err(|_| create_error!(InvalidOperation))?
|
||||||
.datetime()
|
.datetime()
|
||||||
.signed_duration_since(Utc::now())
|
.elapsed()
|
||||||
.num_days()
|
.expect("Time went backwards")
|
||||||
.abs()
|
> Duration::from_hours(7 * 24) // 7 days
|
||||||
> 7
|
|
||||||
{
|
{
|
||||||
return Err(create_error!(InvalidOperation));
|
return Err(create_error!(InvalidOperation));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use chrono::{Duration, Utc};
|
use std::time::Duration;
|
||||||
|
|
||||||
use redis_kiss::{get_connection, redis, AsyncCommands};
|
use redis_kiss::{get_connection, redis, AsyncCommands};
|
||||||
use revolt_database::util::permissions::DatabasePermissionQuery;
|
use revolt_database::util::permissions::DatabasePermissionQuery;
|
||||||
use revolt_database::{
|
use revolt_database::{
|
||||||
@@ -111,8 +112,12 @@ pub async fn message_send(
|
|||||||
// Disallow mentions for new users (TRUST-0: <12 hours age) in public servers
|
// Disallow mentions for new users (TRUST-0: <12 hours age) in public servers
|
||||||
let allow_mentions = if let Some(server) = query.server_ref() {
|
let allow_mentions = if let Some(server) = query.server_ref() {
|
||||||
if server.discoverable {
|
if server.discoverable {
|
||||||
(Utc::now() - ulid::Ulid::from_string(&user.id).unwrap().datetime())
|
(ulid::Ulid::from_string(&user.id)
|
||||||
>= Duration::hours(12)
|
.unwrap()
|
||||||
|
.datetime()
|
||||||
|
.elapsed()
|
||||||
|
.expect("Time went backwards"))
|
||||||
|
>= Duration::from_hours(12)
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,212 @@
|
|||||||
|
use revolt_database::{
|
||||||
|
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||||
|
Database, EmojiParent, PartialEmoji, User,
|
||||||
|
};
|
||||||
|
use revolt_models::v0;
|
||||||
|
use revolt_permissions::{calculate_server_permissions, ChannelPermission};
|
||||||
|
use revolt_result::{create_error, Result};
|
||||||
|
use rocket::{serde::json::Json, State};
|
||||||
|
use validator::Validate;
|
||||||
|
|
||||||
|
/// # Edit Emoji
|
||||||
|
///
|
||||||
|
/// Edit an emoji by its id.
|
||||||
|
#[openapi(tag = "Emojis")]
|
||||||
|
#[patch("/emoji/<emoji_id>", data = "<data>")]
|
||||||
|
pub async fn edit_emoji(
|
||||||
|
db: &State<Database>,
|
||||||
|
user: User,
|
||||||
|
emoji_id: Reference<'_>,
|
||||||
|
data: Json<v0::DataEditEmoji>,
|
||||||
|
) -> Result<Json<v0::Emoji>> {
|
||||||
|
let data = data.into_inner();
|
||||||
|
data.validate().map_err(|error| {
|
||||||
|
create_error!(FailedValidation {
|
||||||
|
error: error.to_string()
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let mut emoji = emoji_id.as_emoji(db).await?;
|
||||||
|
|
||||||
|
match &emoji.parent {
|
||||||
|
EmojiParent::Server { id } => {
|
||||||
|
let server = db.fetch_server(id.as_str()).await?;
|
||||||
|
|
||||||
|
let mut query = DatabasePermissionQuery::new(db, &user).server(&server);
|
||||||
|
calculate_server_permissions(&mut query)
|
||||||
|
.await
|
||||||
|
.throw_if_lacking_channel_permission(ChannelPermission::ManageCustomisation)?;
|
||||||
|
}
|
||||||
|
EmojiParent::Detached => return Err(create_error!(NotAuthenticated)),
|
||||||
|
}
|
||||||
|
|
||||||
|
if data.name.is_none() {
|
||||||
|
return Ok(Json(emoji.into()));
|
||||||
|
}
|
||||||
|
|
||||||
|
let partial = PartialEmoji { name: data.name };
|
||||||
|
emoji.update(db, partial).await?;
|
||||||
|
|
||||||
|
Ok(Json(emoji.into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use crate::util::test::TestHarness;
|
||||||
|
use revolt_database::{Emoji, EmojiParent, Member};
|
||||||
|
use revolt_models::v0;
|
||||||
|
use rocket::http::{ContentType, Header, Status};
|
||||||
|
use ulid::Ulid;
|
||||||
|
|
||||||
|
#[rocket::async_test]
|
||||||
|
async fn edit_emoji_name_as_creator() {
|
||||||
|
let harness = TestHarness::new().await;
|
||||||
|
let (_, session, user) = harness.new_user().await;
|
||||||
|
let (server, _) = harness.new_server(&user).await;
|
||||||
|
|
||||||
|
let emoji_id = Ulid::new().to_string();
|
||||||
|
let emoji = Emoji {
|
||||||
|
id: emoji_id.clone(),
|
||||||
|
parent: EmojiParent::Server {
|
||||||
|
id: server.id.clone(),
|
||||||
|
},
|
||||||
|
creator_id: user.id.clone(),
|
||||||
|
name: "initial_name".to_string(),
|
||||||
|
animated: false,
|
||||||
|
nsfw: false,
|
||||||
|
};
|
||||||
|
emoji.create(&harness.db).await.expect("`Emoji` created");
|
||||||
|
|
||||||
|
let response = harness
|
||||||
|
.client
|
||||||
|
.patch(format!("/custom/emoji/{emoji_id}"))
|
||||||
|
.header(Header::new("x-session-token", session.token.to_string()))
|
||||||
|
.header(ContentType::JSON)
|
||||||
|
.body(
|
||||||
|
json!(v0::DataEditEmoji {
|
||||||
|
name: Some("renamed_emoji".to_string()),
|
||||||
|
})
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
.dispatch()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::Ok);
|
||||||
|
|
||||||
|
let edited: v0::Emoji = response.into_json().await.expect("`Emoji`");
|
||||||
|
assert_eq!(edited.name, "renamed_emoji");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[rocket::async_test]
|
||||||
|
async fn reject_invalid_emoji_name() {
|
||||||
|
let harness = TestHarness::new().await;
|
||||||
|
let (_, session, user) = harness.new_user().await;
|
||||||
|
let (server, _) = harness.new_server(&user).await;
|
||||||
|
|
||||||
|
let emoji_id = Ulid::new().to_string();
|
||||||
|
let emoji = Emoji {
|
||||||
|
id: emoji_id.clone(),
|
||||||
|
parent: EmojiParent::Server {
|
||||||
|
id: server.id.clone(),
|
||||||
|
},
|
||||||
|
creator_id: user.id.clone(),
|
||||||
|
name: "valid_name".to_string(),
|
||||||
|
animated: false,
|
||||||
|
nsfw: false,
|
||||||
|
};
|
||||||
|
emoji.create(&harness.db).await.expect("`Emoji` created");
|
||||||
|
|
||||||
|
let response = harness
|
||||||
|
.client
|
||||||
|
.patch(format!("/custom/emoji/{emoji_id}"))
|
||||||
|
.header(Header::new("x-session-token", session.token.to_string()))
|
||||||
|
.header(ContentType::JSON)
|
||||||
|
.body(
|
||||||
|
json!(v0::DataEditEmoji {
|
||||||
|
name: Some("Invalid Name".to_string()),
|
||||||
|
})
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
.dispatch()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::BadRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[rocket::async_test]
|
||||||
|
async fn reject_edit_for_detached_emoji() {
|
||||||
|
let harness = TestHarness::new().await;
|
||||||
|
let (_, session, user) = harness.new_user().await;
|
||||||
|
|
||||||
|
let emoji_id = Ulid::new().to_string();
|
||||||
|
let emoji = Emoji {
|
||||||
|
id: emoji_id.clone(),
|
||||||
|
parent: EmojiParent::Detached,
|
||||||
|
creator_id: user.id.clone(),
|
||||||
|
name: "detached_name".to_string(),
|
||||||
|
animated: false,
|
||||||
|
nsfw: false,
|
||||||
|
};
|
||||||
|
emoji.create(&harness.db).await.expect("`Emoji` created");
|
||||||
|
|
||||||
|
let response = harness
|
||||||
|
.client
|
||||||
|
.patch(format!("/custom/emoji/{emoji_id}"))
|
||||||
|
.header(Header::new("x-session-token", session.token.to_string()))
|
||||||
|
.header(ContentType::JSON)
|
||||||
|
.body(
|
||||||
|
json!(v0::DataEditEmoji {
|
||||||
|
name: Some("should_not_apply".to_string()),
|
||||||
|
})
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
.dispatch()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::Unauthorized);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[rocket::async_test]
|
||||||
|
async fn reject_edit_for_creator_without_manage_customisation() {
|
||||||
|
let harness = TestHarness::new().await;
|
||||||
|
let (_, _, owner) = harness.new_user().await;
|
||||||
|
let (_, creator_session, creator) = harness.new_user().await;
|
||||||
|
let (server, _) = harness.new_server(&owner).await;
|
||||||
|
|
||||||
|
Member::create(&harness.db, &server, &creator, None)
|
||||||
|
.await
|
||||||
|
.expect("`Member` created");
|
||||||
|
|
||||||
|
let emoji_id = Ulid::new().to_string();
|
||||||
|
let emoji = Emoji {
|
||||||
|
id: emoji_id.clone(),
|
||||||
|
parent: EmojiParent::Server {
|
||||||
|
id: server.id.clone(),
|
||||||
|
},
|
||||||
|
creator_id: creator.id.clone(),
|
||||||
|
name: "member_uploaded_name".to_string(),
|
||||||
|
animated: false,
|
||||||
|
nsfw: false,
|
||||||
|
};
|
||||||
|
emoji.create(&harness.db).await.expect("`Emoji` created");
|
||||||
|
|
||||||
|
let response = harness
|
||||||
|
.client
|
||||||
|
.patch(format!("/custom/emoji/{emoji_id}"))
|
||||||
|
.header(Header::new(
|
||||||
|
"x-session-token",
|
||||||
|
creator_session.token.to_string(),
|
||||||
|
))
|
||||||
|
.header(ContentType::JSON)
|
||||||
|
.body(
|
||||||
|
json!(v0::DataEditEmoji {
|
||||||
|
name: Some("renamed_without_permission".to_string()),
|
||||||
|
})
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
.dispatch()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::Forbidden);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,12 +3,14 @@ use rocket::Route;
|
|||||||
|
|
||||||
mod emoji_create;
|
mod emoji_create;
|
||||||
mod emoji_delete;
|
mod emoji_delete;
|
||||||
|
mod emoji_edit;
|
||||||
mod emoji_fetch;
|
mod emoji_fetch;
|
||||||
|
|
||||||
pub fn routes() -> (Vec<Route>, OpenApi) {
|
pub fn routes() -> (Vec<Route>, OpenApi) {
|
||||||
openapi_get_routes_spec![
|
openapi_get_routes_spec![
|
||||||
emoji_create::create_emoji,
|
emoji_create::create_emoji,
|
||||||
emoji_delete::delete_emoji,
|
emoji_delete::delete_emoji,
|
||||||
|
emoji_edit::edit_emoji,
|
||||||
emoji_fetch::fetch_emoji
|
emoji_fetch::fetch_emoji
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,8 @@ pub struct RevoltFeatures {
|
|||||||
pub livekit: VoiceFeature,
|
pub livekit: VoiceFeature,
|
||||||
/// Limits
|
/// Limits
|
||||||
pub limits: LimitsConfig,
|
pub limits: LimitsConfig,
|
||||||
|
/// Legal links
|
||||||
|
pub legal_links: LegalLinks,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Limits For Users
|
/// # Limits For Users
|
||||||
@@ -70,6 +72,17 @@ pub struct LimitsConfig {
|
|||||||
pub default: UserLimits,
|
pub default: UserLimits,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// # Legal links
|
||||||
|
#[derive(Serialize, JsonSchema, Debug)]
|
||||||
|
pub struct LegalLinks {
|
||||||
|
/// Terms of Service URL
|
||||||
|
pub terms_of_service: String,
|
||||||
|
/// Privacy Policy URL
|
||||||
|
pub privacy_policy: String,
|
||||||
|
/// Guidelines URL
|
||||||
|
pub guidelines: String,
|
||||||
|
}
|
||||||
|
|
||||||
/// # Global limits
|
/// # Global limits
|
||||||
#[derive(Serialize, JsonSchema, Debug)]
|
#[derive(Serialize, JsonSchema, Debug)]
|
||||||
pub struct GlobalLimits {
|
pub struct GlobalLimits {
|
||||||
@@ -92,6 +105,8 @@ pub struct GlobalLimits {
|
|||||||
/// restrict server creation to these users.
|
/// restrict server creation to these users.
|
||||||
/// if blank, all users can create servers
|
/// if blank, all users can create servers
|
||||||
pub restrict_server_creation: Vec<String>,
|
pub restrict_server_creation: Vec<String>,
|
||||||
|
/// New user hours
|
||||||
|
new_user_hours: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # User Limits
|
/// # User Limits
|
||||||
@@ -231,10 +246,16 @@ pub async fn root() -> Result<Json<RevoltConfig>> {
|
|||||||
.limits
|
.limits
|
||||||
.global
|
.global
|
||||||
.restrict_server_creation,
|
.restrict_server_creation,
|
||||||
|
new_user_hours: config.features.limits.global.new_user_hours as i64,
|
||||||
},
|
},
|
||||||
new_user: UserLimits::from_feature_limits(config.features.limits.new_user),
|
new_user: UserLimits::from_feature_limits(config.features.limits.new_user),
|
||||||
default: UserLimits::from_feature_limits(config.features.limits.default),
|
default: UserLimits::from_feature_limits(config.features.limits.default),
|
||||||
},
|
},
|
||||||
|
legal_links: LegalLinks {
|
||||||
|
terms_of_service: config.features.legal_links.terms_of_service,
|
||||||
|
privacy_policy: config.features.legal_links.privacy_policy,
|
||||||
|
guidelines: config.features.legal_links.guidelines,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ws: config.hosts.events,
|
ws: config.hosts.events,
|
||||||
app: config.hosts.app,
|
app: config.hosts.app,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use revolt_database::{
|
use revolt_database::{
|
||||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||||
voice::{sync_voice_permissions, VoiceClient},
|
voice::{sync_voice_permissions, VoiceClient},
|
||||||
Database, PartialRole, User
|
Database, File, PartialRole, User,
|
||||||
};
|
};
|
||||||
use revolt_models::v0;
|
use revolt_models::v0;
|
||||||
use revolt_permissions::{calculate_server_permissions, ChannelPermission};
|
use revolt_permissions::{calculate_server_permissions, ChannelPermission};
|
||||||
@@ -47,14 +47,27 @@ pub async fn edit(
|
|||||||
name,
|
name,
|
||||||
colour,
|
colour,
|
||||||
hoist,
|
hoist,
|
||||||
|
icon,
|
||||||
remove,
|
remove,
|
||||||
..
|
..
|
||||||
} = data;
|
} = data;
|
||||||
|
|
||||||
|
if remove.contains(&v0::FieldsRole::Icon) {
|
||||||
|
if let Some(existing_icon) = &role.icon {
|
||||||
|
db.mark_attachment_as_deleted(&existing_icon.id).await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut final_icon = None;
|
||||||
|
if let Some(icon_id) = icon {
|
||||||
|
final_icon = Some(File::use_role_icon(db, &icon_id, &role_id, &user.id).await?);
|
||||||
|
}
|
||||||
|
|
||||||
let partial = PartialRole {
|
let partial = PartialRole {
|
||||||
name,
|
name,
|
||||||
colour,
|
colour,
|
||||||
hoist,
|
hoist,
|
||||||
|
icon: final_icon,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,8 +82,9 @@ pub async fn edit(
|
|||||||
for channel_id in &server.channels {
|
for channel_id in &server.channels {
|
||||||
let channel = Reference::from_unchecked(channel_id).as_channel(db).await?;
|
let channel = Reference::from_unchecked(channel_id).as_channel(db).await?;
|
||||||
|
|
||||||
sync_voice_permissions(db, voice_client, &channel, Some(&server), Some(&role_id)).await?;
|
sync_voice_permissions(db, voice_client, &channel, Some(&server), Some(&role_id))
|
||||||
};
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(Json(role.into()))
|
Ok(Json(role.into()))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use revolt_database::{
|
use revolt_database::{
|
||||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
util::{acker, permissions::DatabasePermissionQuery, reference::Reference},
|
||||||
Database, User,
|
Database, User, AMQP,
|
||||||
};
|
};
|
||||||
use revolt_permissions::PermissionQuery;
|
use revolt_permissions::PermissionQuery;
|
||||||
use revolt_result::{create_error, Result};
|
use revolt_result::{create_error, Result};
|
||||||
@@ -12,7 +12,12 @@ use rocket_empty::EmptyResponse;
|
|||||||
/// Mark all channels in a server as read.
|
/// Mark all channels in a server as read.
|
||||||
#[openapi(tag = "Server Information")]
|
#[openapi(tag = "Server Information")]
|
||||||
#[put("/<target>/ack")]
|
#[put("/<target>/ack")]
|
||||||
pub async fn ack(db: &State<Database>, user: User, target: Reference<'_>) -> Result<EmptyResponse> {
|
pub async fn ack(
|
||||||
|
db: &State<Database>,
|
||||||
|
amqp: &State<AMQP>,
|
||||||
|
user: User,
|
||||||
|
target: Reference<'_>,
|
||||||
|
) -> Result<EmptyResponse> {
|
||||||
if user.bot.is_some() {
|
if user.bot.is_some() {
|
||||||
return Err(create_error!(IsBot));
|
return Err(create_error!(IsBot));
|
||||||
}
|
}
|
||||||
@@ -23,7 +28,6 @@ pub async fn ack(db: &State<Database>, user: User, target: Reference<'_>) -> Res
|
|||||||
return Err(create_error!(NotFound));
|
return Err(create_error!(NotFound));
|
||||||
}
|
}
|
||||||
|
|
||||||
db.acknowledge_channels(&user.id, &server.channels)
|
acker::ack_server(&user, &server, db, amqp).await?;
|
||||||
.await
|
Ok(EmptyResponse)
|
||||||
.map(|_| EmptyResponse)
|
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,23 @@
|
|||||||
use rocket::Route;
|
|
||||||
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
||||||
|
use rocket::Route;
|
||||||
|
|
||||||
mod webhook_delete;
|
mod webhook_delete;
|
||||||
|
mod webhook_delete_message;
|
||||||
mod webhook_delete_token;
|
mod webhook_delete_token;
|
||||||
mod webhook_edit;
|
mod webhook_edit;
|
||||||
|
mod webhook_edit_message;
|
||||||
mod webhook_edit_token;
|
mod webhook_edit_token;
|
||||||
mod webhook_execute;
|
mod webhook_execute;
|
||||||
mod webhook_fetch_token;
|
|
||||||
mod webhook_fetch;
|
|
||||||
mod webhook_execute_github;
|
mod webhook_execute_github;
|
||||||
|
mod webhook_fetch;
|
||||||
|
mod webhook_fetch_token;
|
||||||
|
|
||||||
pub fn routes() -> (Vec<Route>, OpenApi) {
|
pub fn routes() -> (Vec<Route>, OpenApi) {
|
||||||
openapi_get_routes_spec![
|
openapi_get_routes_spec![
|
||||||
|
webhook_delete_message::webhook_delete_message,
|
||||||
webhook_delete_token::webhook_delete_token,
|
webhook_delete_token::webhook_delete_token,
|
||||||
webhook_delete::webhook_delete,
|
webhook_delete::webhook_delete,
|
||||||
|
webhook_edit_message::webhook_edit_message,
|
||||||
webhook_edit_token::webhook_edit_token,
|
webhook_edit_token::webhook_edit_token,
|
||||||
webhook_edit::webhook_edit,
|
webhook_edit::webhook_edit,
|
||||||
webhook_execute_github::webhook_execute_github,
|
webhook_execute_github::webhook_execute_github,
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
use revolt_database::{util::reference::Reference, Database};
|
||||||
|
use revolt_result::{create_error, Result};
|
||||||
|
use rocket::State;
|
||||||
|
use rocket_empty::EmptyResponse;
|
||||||
|
|
||||||
|
/// # Deletes a webhook message
|
||||||
|
///
|
||||||
|
/// Deletes a message sent by a webhook
|
||||||
|
#[openapi(tag = "Webhooks")]
|
||||||
|
#[delete("/<webhook_id>/<token>/<message_id>")]
|
||||||
|
pub async fn webhook_delete_message(
|
||||||
|
db: &State<Database>,
|
||||||
|
webhook_id: Reference<'_>,
|
||||||
|
token: String,
|
||||||
|
message_id: Reference<'_>,
|
||||||
|
) -> Result<EmptyResponse> {
|
||||||
|
let webhook = webhook_id.as_webhook(db).await?;
|
||||||
|
webhook.assert_token(&token)?;
|
||||||
|
|
||||||
|
let message = message_id.as_message(db).await?;
|
||||||
|
|
||||||
|
if message.author != webhook.id {
|
||||||
|
return Err(create_error!(CannotDeleteMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
message.delete(db).await.map(|_| EmptyResponse)
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
use iso8601_timestamp::Timestamp;
|
||||||
|
use revolt_config::config;
|
||||||
|
use revolt_database::{
|
||||||
|
tasks::process_embeds::queue, util::reference::Reference, Database, Message, PartialMessage,
|
||||||
|
};
|
||||||
|
use revolt_models::v0::{self, DataEditMessage, Embed};
|
||||||
|
use revolt_models::validator::Validate;
|
||||||
|
use revolt_result::{create_error, Result};
|
||||||
|
use rocket::{serde::json::Json, State};
|
||||||
|
|
||||||
|
/// # Edits a webhook message
|
||||||
|
///
|
||||||
|
/// Edits a message sent by a webhook
|
||||||
|
#[openapi(tag = "Webhooks")]
|
||||||
|
#[patch("/<webhook_id>/<token>/<message_id>", data = "<data>")]
|
||||||
|
pub async fn webhook_edit_message(
|
||||||
|
db: &State<Database>,
|
||||||
|
webhook_id: Reference<'_>,
|
||||||
|
token: String,
|
||||||
|
message_id: Reference<'_>,
|
||||||
|
data: Json<DataEditMessage>,
|
||||||
|
) -> Result<Json<v0::Message>> {
|
||||||
|
let edit = data.into_inner();
|
||||||
|
edit.validate().map_err(|error| {
|
||||||
|
create_error!(FailedValidation {
|
||||||
|
error: error.to_string()
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Message::validate_sum(
|
||||||
|
&edit.content,
|
||||||
|
edit.embeds.as_deref().unwrap_or_default(),
|
||||||
|
config().await.features.limits.default.message_length,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let webhook = webhook_id.as_webhook(db).await?;
|
||||||
|
webhook.assert_token(&token)?;
|
||||||
|
|
||||||
|
let mut message = message_id.as_message(db).await?;
|
||||||
|
if message.author != webhook.id {
|
||||||
|
return Err(create_error!(CannotEditMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
message.edited = Some(Timestamp::now_utc());
|
||||||
|
let mut partial = PartialMessage {
|
||||||
|
edited: message.edited,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1. Handle content update
|
||||||
|
if let Some(content) = &edit.content {
|
||||||
|
partial.content = Some(content.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Clear any auto generated embeds
|
||||||
|
let mut new_embeds = vec![];
|
||||||
|
if let Some(embeds) = &message.embeds {
|
||||||
|
for embed in embeds {
|
||||||
|
if let Embed::Text(embed) = embed {
|
||||||
|
new_embeds.push(Embed::Text(embed.clone()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Replace if we are given new embeds
|
||||||
|
if let Some(embeds) = edit.embeds {
|
||||||
|
new_embeds.clear();
|
||||||
|
|
||||||
|
for embed in embeds {
|
||||||
|
new_embeds.push(message.create_embed(db, embed).await?);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
partial.embeds = Some(new_embeds);
|
||||||
|
|
||||||
|
message.update(db, partial, vec![]).await?;
|
||||||
|
|
||||||
|
// Queue up a task for processing embeds
|
||||||
|
if let Some(content) = edit.content {
|
||||||
|
queue(message.channel.to_string(), message.id.to_string(), content).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Json(message.into_model(None, None)))
|
||||||
|
}
|
||||||
@@ -1,68 +1,64 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-autumn"
|
name = "revolt-autumn"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# ID generation
|
# ID generation
|
||||||
ulid = "1.1.3"
|
ulid = { workspace = true }
|
||||||
nanoid = "0.4.0"
|
nanoid = { workspace = true }
|
||||||
|
|
||||||
# Media processing
|
# Media processing
|
||||||
webp = "0.3.0"
|
webp = { workspace = true }
|
||||||
sha2 = "0.10.8"
|
sha2 = { workspace = true }
|
||||||
jxl-oxide = "0.8.1"
|
jxl-oxide = { workspace = true }
|
||||||
kamadak-exif = "0.5.4"
|
kamadak-exif = { workspace = true }
|
||||||
# revolt_little_exif = "0.5.1"
|
# revolt_little_exif = "0.5.1"
|
||||||
image = { version = "0.25.2" } # avif encode requires dav1d system library: features = ["avif-native"]
|
image = { workspace = true }
|
||||||
thumbhash = "0.1.0"
|
thumbhash = { workspace = true }
|
||||||
|
lcms2 = { workspace = true }
|
||||||
|
|
||||||
# File processing
|
# File processing
|
||||||
revolt_clamav-client = { version = "0.1.5" }
|
revolt_clamav-client = { workspace = true }
|
||||||
simdutf8 = { version = "0.1.4", features = ["aarch64_neon"] }
|
simdutf8 = { workspace = true, features = ["aarch64_neon"] }
|
||||||
|
|
||||||
# Content type processing
|
# Content type processing
|
||||||
infer = "0.16.0"
|
infer = { workspace = true }
|
||||||
ffprobe = "0.4.0"
|
ffprobe = { workspace = true }
|
||||||
imagesize = "0.13.0"
|
imagesize = { workspace = true }
|
||||||
|
|
||||||
# Utility
|
# Utility
|
||||||
lazy_static = "1.5.0"
|
lazy_static = { workspace = true }
|
||||||
moka = { version = "0.12.8", features = ["future"] }
|
moka = { workspace = true, features = ["future"] }
|
||||||
|
url-escape = { workspace = true }
|
||||||
# Serialisation
|
# Serialisation
|
||||||
strum_macros = "0.26.4"
|
strum_macros = { workspace = true }
|
||||||
serde_json = "1.0.68"
|
serde_json = { workspace = true }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { workspace = true }
|
||||||
|
|
||||||
# Async runtime
|
# Async runtime
|
||||||
tokio = { version = "1.0", features = ["full"] }
|
tokio = { workspace = true, features = ["full"] }
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
tracing = "0.1"
|
tracing = { workspace = true }
|
||||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
tracing-subscriber = { workspace = true }
|
||||||
|
|
||||||
# Core crates
|
# Core crates
|
||||||
revolt-files = { version = "0.12.1", path = "../../core/files" }
|
revolt-files = { workspace = true }
|
||||||
revolt-config = { version = "0.12.1", path = "../../core/config" }
|
revolt-config = { workspace = true }
|
||||||
revolt-database = { version = "0.12.1", path = "../../core/database", features = [
|
revolt-database = { workspace = true, features = ["axum-impl"] }
|
||||||
"axum-impl",
|
revolt-result = { workspace = true, features = ["utoipa", "axum"] }
|
||||||
] }
|
revolt-ratelimits = { workspace = true, features = ["axum"] }
|
||||||
revolt-result = { version = "0.12.1", path = "../../core/result", features = [
|
|
||||||
"utoipa",
|
|
||||||
"axum",
|
|
||||||
] }
|
|
||||||
revolt-ratelimits = { version = "0.12.1", path = "../../core/ratelimits", features = ["axum"] }
|
|
||||||
|
|
||||||
# Axum / web server
|
# Axum / web server
|
||||||
tempfile = "3.12.0"
|
tempfile = { workspace = true }
|
||||||
axum-macros = "0.4.1"
|
axum-macros = { workspace = true }
|
||||||
axum_typed_multipart = "0.12.1"
|
axum_typed_multipart = { workspace = true }
|
||||||
axum = { version = "0.7.5", features = ["multipart"] }
|
axum = { workspace = true, features = ["multipart"] }
|
||||||
tower-http = { version = "0.5.2", features = ["cors"] }
|
tower-http = { workspace = true, features = ["cors"] }
|
||||||
|
|
||||||
# OpenAPI & documentation generation
|
# OpenAPI & documentation generation
|
||||||
utoipa-scalar = { version = "0.1.0", features = ["axum"] }
|
utoipa-scalar = { workspace = true, features = ["axum"] }
|
||||||
utoipa = { version = "4.2.3", features = ["axum_extras", "ulid"] }
|
utoipa = { workspace = true, features = ["axum_extras", "ulid"] }
|
||||||
@@ -24,6 +24,7 @@ use sha2::Digest;
|
|||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
use tokio::time::Instant;
|
use tokio::time::Instant;
|
||||||
use tower_http::cors::{AllowHeaders, Any, CorsLayer};
|
use tower_http::cors::{AllowHeaders, Any, CorsLayer};
|
||||||
|
use url_escape::encode_component;
|
||||||
use utoipa::ToSchema;
|
use utoipa::ToSchema;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -479,8 +480,10 @@ async fn fetch_file(
|
|||||||
// Ensure filename is correct
|
// Ensure filename is correct
|
||||||
if file_name != file.filename {
|
if file_name != file.filename {
|
||||||
if file_name == "original" {
|
if file_name == "original" {
|
||||||
|
let safe_filename = encode_component(&file.filename);
|
||||||
|
|
||||||
return Ok(
|
return Ok(
|
||||||
Redirect::permanent(&format!("/{tag}/{file_id}/{}", file.filename)).into_response(),
|
Redirect::permanent(&format!("/{tag}/{file_id}/{}", safe_filename)).into_response(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,24 @@
|
|||||||
use std::io::{Cursor, Read};
|
use std::io::{Cursor, Read};
|
||||||
|
|
||||||
|
use crate::utils::apply_icc_profile;
|
||||||
use exif::Reader;
|
use exif::Reader;
|
||||||
use image::{ImageFormat, ImageReader};
|
use image::{ImageEncoder, ImageReader};
|
||||||
use revolt_config::report_internal_error;
|
use revolt_config::report_internal_error;
|
||||||
use revolt_database::Metadata;
|
use revolt_database::Metadata;
|
||||||
use revolt_result::{create_error, Result};
|
use revolt_result::{create_error, Result};
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
|
|
||||||
|
macro_rules! encode_with_icc {
|
||||||
|
($encoder:expr, $icc:expr, $image:expr, $width:expr, $height:expr, $color:expr) => {{
|
||||||
|
let mut encoder = $encoder;
|
||||||
|
if let Some(icc) = $icc {
|
||||||
|
let _ = encoder.set_icc_profile(icc.clone());
|
||||||
|
}
|
||||||
|
encoder.write_image($image, $width, $height, $color)
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
/// Strip EXIF data from given file and produce new file and metadata
|
/// Strip EXIF data from given file and produce new file and metadata
|
||||||
pub async fn strip_metadata(
|
pub async fn strip_metadata(
|
||||||
file: NamedTempFile,
|
file: NamedTempFile,
|
||||||
@@ -17,8 +28,8 @@ pub async fn strip_metadata(
|
|||||||
) -> Result<(Vec<u8>, Metadata)> {
|
) -> Result<(Vec<u8>, Metadata)> {
|
||||||
match &metadata {
|
match &metadata {
|
||||||
Metadata::Image {
|
Metadata::Image {
|
||||||
width,
|
width: _,
|
||||||
height,
|
height: _,
|
||||||
thumbhash,
|
thumbhash,
|
||||||
animated,
|
animated,
|
||||||
} => match mime {
|
} => match mime {
|
||||||
@@ -46,11 +57,12 @@ pub async fn strip_metadata(
|
|||||||
let mut cursor = Cursor::new(buf);
|
let mut cursor = Cursor::new(buf);
|
||||||
|
|
||||||
// Decode the image
|
// Decode the image
|
||||||
let image = report_internal_error!(report_internal_error!(ImageReader::new(
|
let reader =
|
||||||
&mut cursor
|
report_internal_error!(ImageReader::new(&mut cursor).with_guessed_format())?;
|
||||||
)
|
let mut decoder = report_internal_error!(reader.into_decoder())?;
|
||||||
.with_guessed_format())?
|
let mut icc_profile =
|
||||||
.decode());
|
report_internal_error!(image::ImageDecoder::icc_profile(&mut decoder))?;
|
||||||
|
let mut image = report_internal_error!(image::DynamicImage::from_decoder(decoder))?;
|
||||||
|
|
||||||
// Reset read position
|
// Reset read position
|
||||||
cursor.set_position(0);
|
cursor.set_position(0);
|
||||||
@@ -71,38 +83,68 @@ pub async fn strip_metadata(
|
|||||||
|
|
||||||
// Apply the EXIF rotation
|
// Apply the EXIF rotation
|
||||||
// See https://jdhao.github.io/2019/07/31/image_rotation_exif_info/
|
// See https://jdhao.github.io/2019/07/31/image_rotation_exif_info/
|
||||||
report_internal_error!(match &rotation {
|
image = match &rotation {
|
||||||
2 => image?.fliph(),
|
2 => image.fliph(),
|
||||||
3 => image?.rotate180(),
|
3 => image.rotate180(),
|
||||||
4 => image?.rotate180().fliph(),
|
4 => image.rotate180().fliph(),
|
||||||
5 => image?.rotate90().fliph(),
|
5 => image.rotate90().fliph(),
|
||||||
6 => image?.rotate90(),
|
6 => image.rotate90(),
|
||||||
7 => image?.rotate270().fliph(),
|
7 => image.rotate270().fliph(),
|
||||||
8 => image?.rotate270(),
|
8 => image.rotate270(),
|
||||||
_ => image?,
|
_ => image,
|
||||||
}
|
|
||||||
.write_to(
|
|
||||||
&mut writer,
|
|
||||||
match mime {
|
|
||||||
"image/jpeg" => ImageFormat::Jpeg,
|
|
||||||
"image/png" => ImageFormat::Png,
|
|
||||||
"image/avif" => ImageFormat::Avif,
|
|
||||||
"image/tiff" => ImageFormat::Tiff,
|
|
||||||
_ => todo!(),
|
|
||||||
},
|
|
||||||
))?;
|
|
||||||
|
|
||||||
// Calculate dimensions after rotation.
|
|
||||||
let (width, height) = match &rotation {
|
|
||||||
2 | 4 | 5 | 7 => (*height, *width),
|
|
||||||
_ => (*width, *height),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(icc) = &icc_profile {
|
||||||
|
image = apply_icc_profile(image, icc);
|
||||||
|
icc_profile = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let color_type = image.color();
|
||||||
|
let width = image.width();
|
||||||
|
let height = image.height();
|
||||||
|
|
||||||
|
report_internal_error!(match mime {
|
||||||
|
"image/jpeg" => encode_with_icc!(
|
||||||
|
image::codecs::jpeg::JpegEncoder::new(&mut writer),
|
||||||
|
&icc_profile,
|
||||||
|
image.as_bytes(),
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
color_type.into()
|
||||||
|
),
|
||||||
|
"image/png" => encode_with_icc!(
|
||||||
|
image::codecs::png::PngEncoder::new(&mut writer),
|
||||||
|
&icc_profile,
|
||||||
|
image.as_bytes(),
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
color_type.into()
|
||||||
|
),
|
||||||
|
"image/avif" => {
|
||||||
|
// avif encoder doesn't implement set_icc_profile currently
|
||||||
|
image::codecs::avif::AvifEncoder::new(&mut writer).write_image(
|
||||||
|
image.as_bytes(),
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
color_type.into(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
"image/tiff" => encode_with_icc!(
|
||||||
|
image::codecs::tiff::TiffEncoder::new(&mut writer),
|
||||||
|
&icc_profile,
|
||||||
|
image.as_bytes(),
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
color_type.into()
|
||||||
|
),
|
||||||
|
_ => unreachable!(),
|
||||||
|
})?;
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
bytes,
|
bytes,
|
||||||
Metadata::Image {
|
Metadata::Image {
|
||||||
width,
|
width: width as isize,
|
||||||
height,
|
height: height as isize,
|
||||||
thumbhash: thumbhash.clone(),
|
thumbhash: thumbhash.clone(),
|
||||||
animated: *animated,
|
animated: *animated,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ pub mod exif;
|
|||||||
pub mod metadata;
|
pub mod metadata;
|
||||||
pub mod mime_type;
|
pub mod mime_type;
|
||||||
mod ratelimits;
|
mod ratelimits;
|
||||||
|
mod utils;
|
||||||
|
|
||||||
#[derive(FromRef, Clone)]
|
#[derive(FromRef, Clone)]
|
||||||
struct AppState {
|
struct AppState {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
|
||||||
|
use crate::utils::apply_icc_profile;
|
||||||
use image::{GenericImageView, ImageError, ImageReader};
|
use image::{GenericImageView, ImageError, ImageReader};
|
||||||
use revolt_database::Metadata;
|
use revolt_database::Metadata;
|
||||||
use revolt_files::{image_size, is_animated, video_size};
|
use revolt_files::{image_size, is_animated, video_size};
|
||||||
@@ -27,16 +28,26 @@ pub fn generate_metadata(f: &NamedTempFile, mime_type: &str) -> Metadata {
|
|||||||
.map(|(width, height)| Metadata::Image {
|
.map(|(width, height)| Metadata::Image {
|
||||||
width: width as isize,
|
width: width as isize,
|
||||||
height: height as isize,
|
height: height as isize,
|
||||||
thumbhash: ImageReader::open(f)
|
thumbhash: (|| {
|
||||||
.and_then(|r| r.with_guessed_format())
|
let reader = ImageReader::open(f).ok()?.with_guessed_format().ok()?;
|
||||||
.map_err(ImageError::from)
|
let mut decoder = reader.into_decoder().ok()?;
|
||||||
.and_then(|r| r.decode())
|
let icc_profile = image::ImageDecoder::icc_profile(&mut decoder)
|
||||||
.map(|img| img.thumbnail(100, 100))
|
.ok()
|
||||||
.map(|img| (img.dimensions(), img.to_rgba8().into_raw()))
|
.flatten();
|
||||||
.map(|((width, height), rgba)| {
|
let mut img = image::DynamicImage::from_decoder(decoder).ok()?;
|
||||||
thumbhash::rgba_to_thumb_hash(width as usize, height as usize, &rgba)
|
|
||||||
})
|
if let Some(icc) = icc_profile {
|
||||||
.ok(),
|
img = apply_icc_profile(img, &icc);
|
||||||
|
}
|
||||||
|
|
||||||
|
let img = img.thumbnail(100, 100);
|
||||||
|
let (width, height) = img.dimensions();
|
||||||
|
Some(thumbhash::rgba_to_thumb_hash(
|
||||||
|
width as usize,
|
||||||
|
height as usize,
|
||||||
|
&img.into_rgba8().into_raw(),
|
||||||
|
))
|
||||||
|
})(),
|
||||||
animated: is_animated(f, mime_type).or(Some(false)),
|
animated: is_animated(f, mime_type).or(Some(false)),
|
||||||
})
|
})
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/// Convert image to sRGB using the provided ICC profile.
|
||||||
|
/// Returns the converted image, or the original if conversion fails.
|
||||||
|
pub fn apply_icc_profile(image: image::DynamicImage, icc: &[u8]) -> image::DynamicImage {
|
||||||
|
let Ok(src_profile) = lcms2::Profile::new_icc(icc) else {
|
||||||
|
return image;
|
||||||
|
};
|
||||||
|
let dst_profile = lcms2::Profile::new_srgb();
|
||||||
|
let format = if image.color().has_alpha() {
|
||||||
|
lcms2::PixelFormat::RGBA_8
|
||||||
|
} else {
|
||||||
|
lcms2::PixelFormat::RGB_8
|
||||||
|
};
|
||||||
|
let Ok(t) = lcms2::Transform::new(
|
||||||
|
&src_profile,
|
||||||
|
format,
|
||||||
|
&dst_profile,
|
||||||
|
format,
|
||||||
|
lcms2::Intent::Perceptual,
|
||||||
|
) else {
|
||||||
|
return image;
|
||||||
|
};
|
||||||
|
if image.color().has_alpha() {
|
||||||
|
let mut rgba_image = image.into_rgba8();
|
||||||
|
t.transform_in_place(rgba_image.as_mut());
|
||||||
|
image::DynamicImage::ImageRgba8(rgba_image)
|
||||||
|
} else {
|
||||||
|
let mut rgb_image = image.into_rgb8();
|
||||||
|
t.transform_in_place(rgb_image.as_mut());
|
||||||
|
image::DynamicImage::ImageRgb8(rgb_image)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,49 +1,40 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-gifbox"
|
name = "revolt-gifbox"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Serialisation
|
# Serialisation
|
||||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
serde = { workspace = true, features = ["rc"] }
|
||||||
serde_json = "1.0.68"
|
serde_json = { workspace = true }
|
||||||
|
|
||||||
# Async runtime
|
# Async runtime
|
||||||
tokio = { version = "1.0", features = ["full"] }
|
tokio = { workspace = true, features = [] }
|
||||||
|
|
||||||
# Web requests
|
# Web requests
|
||||||
reqwest = { version = "0.12", features = ["json"] }
|
reqwest = { workspace = true, features = ["json", "query"] }
|
||||||
|
|
||||||
# Core crates
|
# Core crates
|
||||||
revolt-config = { version = "0.12.1", path = "../../core/config" }
|
revolt-config = { workspace = true }
|
||||||
revolt-models = { version = "0.12.1", path = "../../core/models" }
|
revolt-models = { workspace = true }
|
||||||
revolt-result = { version = "0.12.1", path = "../../core/result", features = [
|
revolt-result = { workspace = true, features = ["utoipa", "axum"] }
|
||||||
"utoipa",
|
revolt-coalesced = { workspace = true, features = ["queue"] }
|
||||||
"axum",
|
revolt-database = { workspace = true, features = ["axum-impl"] }
|
||||||
] }
|
revolt-ratelimits = { workspace = true, features = ["axum"] }
|
||||||
revolt-coalesced = { version = "0.12.1", path = "../../core/coalesced", features = [
|
|
||||||
"queue",
|
|
||||||
] }
|
|
||||||
revolt-database = { version = "0.12.1", path = "../../core/database", features = [
|
|
||||||
"axum-impl",
|
|
||||||
] }
|
|
||||||
revolt-ratelimits = { version = "0.12.1", path = "../../core/ratelimits", features = [
|
|
||||||
"axum",
|
|
||||||
] }
|
|
||||||
|
|
||||||
# Axum / web server
|
# Axum / web server
|
||||||
axum = { version = "0.7.5" }
|
axum = { workspace = true }
|
||||||
axum-extra = { version = "0.9", features = ["typed-header"] }
|
axum-extra = { workspace = true, features = ["typed-header"] }
|
||||||
tower-http = { version = "0.5.2", features = ["cors"] }
|
tower-http = { workspace = true, features = ["cors"] }
|
||||||
|
|
||||||
# OpenAPI & documentation generation
|
# OpenAPI & documentation generation
|
||||||
utoipa-scalar = { version = "0.1.0", features = ["axum"] }
|
utoipa-scalar = { workspace = true, features = ["axum"] }
|
||||||
utoipa = { version = "4.2.3", features = ["axum_extras", "ulid"] }
|
utoipa = { workspace = true, features = ["axum_extras", "ulid"] }
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
tracing = "0.1"
|
tracing = { workspace = true }
|
||||||
|
|
||||||
# Utils
|
# Utils
|
||||||
lru_time_cache = "0.11.11"
|
lru_time_cache = { workspace = true }
|
||||||
@@ -1,50 +1,49 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-january"
|
name = "revolt-january"
|
||||||
version = "0.12.1"
|
version = "0.13.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Utility
|
# Utility
|
||||||
mime = "0.3.17"
|
mime = { workspace = true }
|
||||||
regex = "1.11.0"
|
regex = { workspace = true }
|
||||||
tempfile = "3.13.0"
|
tempfile = { workspace = true }
|
||||||
lazy_static = "1.5.0"
|
lazy_static = { workspace = true }
|
||||||
moka = { version = "0.12.8", features = ["future"] }
|
moka = { workspace = true, features = ["future"] }
|
||||||
|
|
||||||
# Web scraping
|
# Web scraping
|
||||||
scraper = "0.20.0"
|
scraper = { workspace = true }
|
||||||
encoding_rs = "0.8.34"
|
encoding_rs = { workspace = true }
|
||||||
|
|
||||||
# Serialisation
|
# Serialisation
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { workspace = true }
|
||||||
serde_json = "1.0.68"
|
serde_json = { workspace = true }
|
||||||
|
|
||||||
# Async runtime
|
# Async runtime
|
||||||
async-recursion = "1.1.1"
|
async-recursion = { workspace = true }
|
||||||
tokio = { version = "1.0", features = ["full"] }
|
tokio = { workspace = true, features = [] }
|
||||||
|
|
||||||
# Web requests
|
# Web requests
|
||||||
reqwest = { version = "0.12", features = ["json"] }
|
reqwest = { workspace = true, features = ["json"] }
|
||||||
|
pdk-ip-filter-lib = "1.8.0"
|
||||||
|
url = { workspace = true }
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
tracing = "0.1"
|
tracing = { workspace = true }
|
||||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
tracing-subscriber = { workspace = true, features = ["env-filter"] }
|
||||||
|
|
||||||
# Core crates
|
# Core crates
|
||||||
revolt-config = { version = "0.12.1", path = "../../core/config" }
|
revolt-config = { workspace = true }
|
||||||
revolt-models = { version = "0.12.1", path = "../../core/models" }
|
revolt-models = { workspace = true }
|
||||||
revolt-result = { version = "0.12.1", path = "../../core/result", features = [
|
revolt-result = { workspace = true, features = ["utoipa", "axum"] }
|
||||||
"utoipa",
|
revolt-files = { workspace = true }
|
||||||
"axum",
|
|
||||||
] }
|
|
||||||
revolt-files = { version = "0.12.1", path = "../../core/files" }
|
|
||||||
|
|
||||||
# Axum / web server
|
# Axum / web server
|
||||||
axum = { version = "0.7.5" }
|
axum = { workspace = true }
|
||||||
axum-extra = { version = "0.9", features = ["typed-header"] }
|
axum-extra = { workspace = true, features = ["typed-header"] }
|
||||||
|
|
||||||
# OpenAPI & documentation generation
|
# OpenAPI & documentation generation
|
||||||
utoipa-scalar = { version = "0.1.0", features = ["axum"] }
|
utoipa-scalar = { workspace = true, features = ["axum"] }
|
||||||
utoipa = { version = "4.2.3", features = ["axum_extras", "ulid"] }
|
utoipa = { workspace = true, features = ["axum_extras", "ulid"] }
|
||||||
@@ -1,42 +1,40 @@
|
|||||||
use encoding_rs::{Encoding, UTF_8_INIT};
|
use encoding_rs::{Encoding, UTF_8_INIT};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
|
use pdk_ip_filter_lib::IpFilter;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use reqwest::{
|
use reqwest::{
|
||||||
header::{self, CONTENT_TYPE},
|
header::{self, CONTENT_TYPE},
|
||||||
redirect, Client, Response,
|
redirect, Client, Response,
|
||||||
};
|
};
|
||||||
use revolt_config::report_internal_error;
|
use revolt_config::{config, report_internal_error};
|
||||||
use revolt_files::{create_thumbnail, decode_image, image_size_vec, is_valid_image, video_size};
|
use revolt_files::{create_thumbnail, decode_image, image_size_vec, is_valid_image, video_size};
|
||||||
use revolt_models::v0::{Embed, Image, ImageSize, Video};
|
use revolt_models::v0::{Embed, Image, ImageSize, Video};
|
||||||
use revolt_result::{create_error, Error, Result};
|
use revolt_result::{create_error, Error, Result, ToRevoltError};
|
||||||
use std::{
|
use std::{
|
||||||
io::{Cursor, Write},
|
io::{Cursor, Write},
|
||||||
|
str::FromStr,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
use url::{Host, Url};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Request client
|
/// Request client
|
||||||
static ref CLIENT: Client = reqwest::Client::builder()
|
static ref CLIENT: Client = reqwest::Client::builder()
|
||||||
.timeout(Duration::from_secs(10)) // TODO config
|
.timeout(Duration::from_secs(10)) // TODO config
|
||||||
.connect_timeout(Duration::from_secs(5)) // TODO config
|
.connect_timeout(Duration::from_secs(5)) // TODO config
|
||||||
.redirect(redirect::Policy::custom(|attempt| {
|
.redirect(redirect::Policy::none())
|
||||||
if attempt.previous().len() > 5 { // TODO config
|
|
||||||
attempt.error("too many redirects")
|
|
||||||
} else if attempt.url().host_str() == Some("jan.revolt.chat") { // TODO config
|
|
||||||
attempt.stop()
|
|
||||||
} else {
|
|
||||||
attempt.follow()
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
.build()
|
.build()
|
||||||
.expect("reqwest Client");
|
.expect("reqwest Client");
|
||||||
|
|
||||||
/// Spoof User Agent as Discord
|
/// Spoof User Agent as Discord
|
||||||
static ref RE_USER_AGENT_SPOOFING_AS_DISCORD: Regex = Regex::new("^(?:(?:https?:)?//)?(?:(?:vx|fx)?twitter|(?:fixv|fixup)?x|(?:old\\.|new\\.|www\\.)reddit).com").expect("valid regex");
|
static ref RE_USER_AGENT_SPOOFING_AS_DISCORD: Regex = Regex::new("^(?:(?:vx|fx)?twitter|(?:fixv|fixup)?x|(?:old\\.|new\\.|www\\.)reddit).com").expect("valid regex");
|
||||||
|
|
||||||
/// Regex for matching new Reddit URLs
|
/// Regex for matching new Reddit URLs
|
||||||
static ref RE_URL_NEW_REDDIT: Regex = Regex::new("^(?:(?:https?:)?//)?(?:(?:new\\.|www\\.)?reddit).com").expect("valid regex");
|
static ref RE_URL_NEW_REDDIT: Regex = Regex::new("^(?:(?:new\\.|www\\.)?reddit).com").expect("valid regex");
|
||||||
|
|
||||||
|
/// Regex for matching YouTube Shorts URLs
|
||||||
|
static ref RE_URL_YOUTUBE_SHORTS: Regex = Regex::new("^(?:(?:https?:)?//)?(?:(?:www\\.)?youtube\\.com)/shorts/([a-zA-Z0-9_-]+)").expect("valid regex");
|
||||||
|
|
||||||
/// Cache for proxy results
|
/// Cache for proxy results
|
||||||
static ref PROXY_CACHE: moka::future::Cache<String, Result<(String, Vec<u8>)>> = moka::future::Cache::builder()
|
static ref PROXY_CACHE: moka::future::Cache<String, Result<(String, Vec<u8>)>> = moka::future::Cache::builder()
|
||||||
@@ -59,6 +57,17 @@ lazy_static! {
|
|||||||
.max_capacity(10_000) // Cache up to 10k embeds
|
.max_capacity(10_000) // Cache up to 10k embeds
|
||||||
.time_to_live(Duration::from_secs(60)) // For up to 1 minute
|
.time_to_live(Duration::from_secs(60)) // For up to 1 minute
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
static ref IP_BLOCKLIST: IpFilter = IpFilter::block(&[
|
||||||
|
"10.0.0.0/8",
|
||||||
|
"192.168.0.0/16",
|
||||||
|
"127.0.0.0/8",
|
||||||
|
"172.16.0.0/12",
|
||||||
|
"169.254.0.0/16",
|
||||||
|
"::1",
|
||||||
|
"fc00::/7"
|
||||||
|
]
|
||||||
|
).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information about a successful request
|
/// Information about a successful request
|
||||||
@@ -73,7 +82,7 @@ impl Request {
|
|||||||
if let Some(hit) = PROXY_CACHE.get(url).await {
|
if let Some(hit) = PROXY_CACHE.get(url).await {
|
||||||
hit
|
hit
|
||||||
} else {
|
} else {
|
||||||
let Request { response, mime } = Request::new(url).await?;
|
let Request { response, mime } = Request::new_from_str(url).await?;
|
||||||
|
|
||||||
if matches!(mime.type_(), mime::IMAGE | mime::VIDEO) {
|
if matches!(mime.type_(), mime::IMAGE | mime::VIDEO) {
|
||||||
let bytes = report_internal_error!(response.bytes().await);
|
let bytes = report_internal_error!(response.bytes().await);
|
||||||
@@ -135,7 +144,7 @@ impl Request {
|
|||||||
let request = if let Some(request) = request {
|
let request = if let Some(request) = request {
|
||||||
request
|
request
|
||||||
} else {
|
} else {
|
||||||
let request = Request::new(url).await?;
|
let request = Request::new_from_str(url).await?;
|
||||||
if matches!(request.mime.type_(), mime::IMAGE) {
|
if matches!(request.mime.type_(), mime::IMAGE) {
|
||||||
request
|
request
|
||||||
} else {
|
} else {
|
||||||
@@ -173,7 +182,7 @@ impl Request {
|
|||||||
let response = if let Some(Request { response, .. }) = request {
|
let response = if let Some(Request { response, .. }) = request {
|
||||||
response
|
response
|
||||||
} else {
|
} else {
|
||||||
let Request { response, mime } = Request::new(url).await?;
|
let Request { response, mime } = Request::new_from_str(url).await?;
|
||||||
if matches!(mime.type_(), mime::VIDEO) {
|
if matches!(mime.type_(), mime::VIDEO) {
|
||||||
response
|
response
|
||||||
} else {
|
} else {
|
||||||
@@ -208,11 +217,18 @@ impl Request {
|
|||||||
.to_string();
|
.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-map Youtube Shorts to regular Youtube links
|
||||||
|
if let Some(captures) = RE_URL_YOUTUBE_SHORTS.captures(&url) {
|
||||||
|
if let Some(video_id) = captures.get(1) {
|
||||||
|
url = format!("https://youtube.com/watch?v={}", video_id.as_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generate the actual embed
|
// Generate the actual embed
|
||||||
if let Some(hit) = EMBED_CACHE.get(&url).await {
|
if let Some(hit) = EMBED_CACHE.get(&url).await {
|
||||||
Ok(hit)
|
Ok(hit)
|
||||||
} else {
|
} else {
|
||||||
let request = Request::new(&url).await?;
|
let request = Request::new_from_str(&url).await?;
|
||||||
let embed = match (request.mime.type_(), request.mime.subtype()) {
|
let embed = match (request.mime.type_(), request.mime.subtype()) {
|
||||||
(_, mime::HTML) => {
|
(_, mime::HTML) => {
|
||||||
let content_type = request
|
let content_type = request
|
||||||
@@ -255,15 +271,22 @@ impl Request {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Send a new request to a service
|
/// Send a new request to a service
|
||||||
pub async fn new(url: &str) -> Result<Request> {
|
pub async fn new(url: Url) -> Result<Request> {
|
||||||
let response = CLIENT
|
let mut url = url;
|
||||||
|
let url_host_str = url.host_str().ok_or(create_error!(ProxyError))?.to_string();
|
||||||
|
|
||||||
|
Request::url_is_blacklisted(&url).await?;
|
||||||
|
let mut redirect_count = 0;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let response = CLIENT
|
||||||
.get(url)
|
.get(url)
|
||||||
.header(
|
.header(
|
||||||
"User-Agent",
|
"User-Agent",
|
||||||
if RE_USER_AGENT_SPOOFING_AS_DISCORD.is_match(url) {
|
if RE_USER_AGENT_SPOOFING_AS_DISCORD.is_match(&url_host_str) {
|
||||||
"Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)"
|
"Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)"
|
||||||
} else {
|
} else {
|
||||||
"Mozilla/5.0 (compatible; January/2.0; +https://github.com/revoltchat/backend)"
|
"Mozilla/5.0 (compatible; January/2.0; +https://github.com/stoatchat/stoatchat)"
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.header("Accept-Language", "en-US,en;q=0.5")
|
.header("Accept-Language", "en-US,en;q=0.5")
|
||||||
@@ -271,31 +294,105 @@ impl Request {
|
|||||||
.await
|
.await
|
||||||
.map_err(|_| create_error!(ProxyError))?;
|
.map_err(|_| create_error!(ProxyError))?;
|
||||||
|
|
||||||
if !response.status().is_success() {
|
if response.status().is_redirection() {
|
||||||
tracing::error!("{:?}", response);
|
redirect_count += 1;
|
||||||
return Err(create_error!(ProxyError));
|
|
||||||
|
if redirect_count > 5 {
|
||||||
|
return Err(create_error!(ProxyError));
|
||||||
|
}
|
||||||
|
if let Some(location) = response.headers().get("location") {
|
||||||
|
let location = location.to_str().map_err(|_| create_error!(ProxyError))?;
|
||||||
|
url = Url::from_str(location).to_internal_error()?;
|
||||||
|
|
||||||
|
if !Request::url_is_blacklisted(&url).await? {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Err(create_error!(ProxyError));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !response.status().is_success() {
|
||||||
|
tracing::error!("{:?}", response);
|
||||||
|
return Err(create_error!(ProxyError));
|
||||||
|
}
|
||||||
|
|
||||||
|
let content_type = response
|
||||||
|
.headers()
|
||||||
|
.get(CONTENT_TYPE)
|
||||||
|
.ok_or(create_error!(ProxyError))?
|
||||||
|
.to_str()
|
||||||
|
.map_err(|_| create_error!(ProxyError))?;
|
||||||
|
|
||||||
|
let mime: mime::Mime = content_type
|
||||||
|
.parse()
|
||||||
|
.map_err(|_| create_error!(ProxyError))?;
|
||||||
|
|
||||||
|
return Ok(Request { response, mime });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let content_type = response
|
pub async fn new_from_str(url: &str) -> Result<Request> {
|
||||||
.headers()
|
let proper_url = Url::parse(url).map_err(|_| create_error!(ProxyError))?;
|
||||||
.get(CONTENT_TYPE)
|
Request::new(proper_url).await
|
||||||
.ok_or(create_error!(ProxyError))?
|
|
||||||
.to_str()
|
|
||||||
.map_err(|_| create_error!(ProxyError))?;
|
|
||||||
|
|
||||||
let mime: mime::Mime = content_type
|
|
||||||
.parse()
|
|
||||||
.map_err(|_| create_error!(ProxyError))?;
|
|
||||||
|
|
||||||
Ok(Request { response, mime })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if something exists
|
/// Check if something exists
|
||||||
pub async fn exists(url: &str) -> bool {
|
pub async fn exists(url: Url) -> bool {
|
||||||
if let Ok(response) = CLIENT.head(url).send().await {
|
if let Ok(response) = CLIENT.head(url).send().await {
|
||||||
response.status().is_success()
|
response.status().is_success()
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn exists_from_str(url: &str) -> Result<bool> {
|
||||||
|
let proper_url = Url::parse(url).map_err(|_| create_error!(ProxyError))?;
|
||||||
|
Ok(Request::exists(proper_url).await)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn url_is_blacklisted(url: &Url) -> Result<bool> {
|
||||||
|
if let Some(host) = url.host() {
|
||||||
|
match host {
|
||||||
|
Host::Ipv4(ipv4) => {
|
||||||
|
let url_str = ipv4.to_string();
|
||||||
|
if !IP_BLOCKLIST.is_allowed(&url_str) {
|
||||||
|
return Err(create_error!(InvalidOperation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Host::Domain(domain) => {
|
||||||
|
let mut domain = domain.to_string();
|
||||||
|
|
||||||
|
let config = config().await;
|
||||||
|
|
||||||
|
// First step: TLDs and blocked domains
|
||||||
|
if !domain.contains(".") // lazily block TLDs
|
||||||
|
|| config.january.blocked_domains.iter().any(|x| x == &domain)
|
||||||
|
{
|
||||||
|
return Err(create_error!(InvalidOperation));
|
||||||
|
}
|
||||||
|
|
||||||
|
if !domain.contains(":") {
|
||||||
|
domain += ":80";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Second step: resolve the IP and check the blocklist
|
||||||
|
if let Ok(mut resolved_ip) = tokio::net::lookup_host(domain.clone()).await {
|
||||||
|
if let Some(resolved_ip) = resolved_ip.next() {
|
||||||
|
if !IP_BLOCKLIST.is_allowed(&resolved_ip.ip().to_string()) {
|
||||||
|
return Err(create_error!(InvalidOperation));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Err(create_error!(InvalidOperation));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Err(create_error!(ProxyError));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ pub async fn create_website_embed(original_url: &str, document: &str) -> Option<
|
|||||||
|
|
||||||
pub async fn populate_special(original_url: String, metadata: &mut WebsiteMetadata) {
|
pub async fn populate_special(original_url: String, metadata: &mut WebsiteMetadata) {
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref RE_YOUTUBE: Regex = Regex::new("^(?:(?:https?:)?//)?(?:(?:www|m)\\.)?(?:(?:youtube\\.com|youtu.be))(?:/(?:[\\w\\-]+\\?v=|embed/|v/)?)([\\w\\-]+)(?:\\S+)?$").unwrap();
|
static ref RE_YOUTUBE: Regex = Regex::new("^(?:(?:https?:)?//)?(?:(?:www|m)\\.)?(?:(?:youtube\\.com|youtu.be))(?:/(?:[\\w\\-]+\\?v=|embed/|v/|shorts/)?)([\\w\\-]+)(?:\\S+)?$").unwrap();
|
||||||
|
|
||||||
static ref RE_LIGHTSPEED: Regex = Regex::new("^(?:https?://)?(?:[\\w]+\\.)?lightspeed\\.tv/([a-z0-9_]{4,25})").unwrap();
|
static ref RE_LIGHTSPEED: Regex = Regex::new("^(?:https?://)?(?:[\\w]+\\.)?lightspeed\\.tv/([a-z0-9_]{4,25})").unwrap();
|
||||||
|
|
||||||
@@ -236,11 +236,12 @@ pub async fn populate_special(original_url: String, metadata: &mut WebsiteMetada
|
|||||||
metadata.site_name.take();
|
metadata.site_name.take();
|
||||||
|
|
||||||
// Verify the video exists
|
// Verify the video exists
|
||||||
if !crate::requests::Request::exists(&format!(
|
if !crate::requests::Request::exists_from_str(&format!(
|
||||||
"http://img.youtube.com/vi/{}/sddefault.jpg",
|
"http://img.youtube.com/vi/{}/sddefault.jpg",
|
||||||
id
|
id
|
||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ sidebar_position: 1
|
|||||||
|
|
||||||
# Endpoints
|
# Endpoints
|
||||||
|
|
||||||
|
[](https://yaak.app/button/run?name=Stoat+API&url=https%3A%2F%2Fstoat.chat%2Fapi%2Fopenapi.json)
|
||||||
|
|
||||||
**We are moving stuff around currently following the rebrand, guidance will follow soon!**
|
**We are moving stuff around currently following the rebrand, guidance will follow soon!**
|
||||||
|
|
||||||
You can connect to the API on the following URLs:
|
You can connect to the API on the following URLs:
|
||||||
|
|||||||
@@ -539,6 +539,22 @@ Emoji created, the event object has the same schema as the Emoji object in the A
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### EmojiUpdate
|
||||||
|
|
||||||
|
Emoji has been updated.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"type": "EmojiUpdate",
|
||||||
|
"id": "{emoji_id}",
|
||||||
|
"data": {
|
||||||
|
"name"?: "{emoji_name}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- `data` field contains a partial Emoji object.
|
||||||
|
|
||||||
### EmojiDelete
|
### EmojiDelete
|
||||||
|
|
||||||
Emoji has been deleted.
|
Emoji has been deleted.
|
||||||
|
|||||||
+38
-193
@@ -30,76 +30,21 @@
|
|||||||
"path": "crates/core/config/Cargo.toml",
|
"path": "crates/core/config/Cargo.toml",
|
||||||
"jsonpath": "$.package.version"
|
"jsonpath": "$.package.version"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/config/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-result'].version"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/core/database/Cargo.toml",
|
"path": "crates/core/database/Cargo.toml",
|
||||||
"jsonpath": "$.package.version"
|
"jsonpath": "$.package.version"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/database/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-config'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/database/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-result'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/database/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-models'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/database/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-presence'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/database/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-permissions'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/database/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-parser'].version"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/core/files/Cargo.toml",
|
"path": "crates/core/files/Cargo.toml",
|
||||||
"jsonpath": "$.package.version"
|
"jsonpath": "$.package.version"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/files/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-config'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/files/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-result'].version"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/core/models/Cargo.toml",
|
"path": "crates/core/models/Cargo.toml",
|
||||||
"jsonpath": "$.package.version"
|
"jsonpath": "$.package.version"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/models/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-config'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/models/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-permissions'].version"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/core/parser/Cargo.toml",
|
"path": "crates/core/parser/Cargo.toml",
|
||||||
@@ -110,41 +55,16 @@
|
|||||||
"path": "crates/core/permissions/Cargo.toml",
|
"path": "crates/core/permissions/Cargo.toml",
|
||||||
"jsonpath": "$.package.version"
|
"jsonpath": "$.package.version"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/permissions/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-result'].version"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/core/presence/Cargo.toml",
|
"path": "crates/core/presence/Cargo.toml",
|
||||||
"jsonpath": "$.package.version"
|
"jsonpath": "$.package.version"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/presence/Cargo.toml",
|
|
||||||
"jsonpath": "$['dev-dependencies']['revolt-config'].version"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/core/ratelimits/Cargo.toml",
|
"path": "crates/core/ratelimits/Cargo.toml",
|
||||||
"jsonpath": "$.package.version"
|
"jsonpath": "$.package.version"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/ratelimits/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-database'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/ratelimits/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-result'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/core/ratelimits/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-config'].version"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/core/result/Cargo.toml",
|
"path": "crates/core/result/Cargo.toml",
|
||||||
@@ -155,61 +75,11 @@
|
|||||||
"path": "crates/daemons/crond/Cargo.toml",
|
"path": "crates/daemons/crond/Cargo.toml",
|
||||||
"jsonpath": "$.package.version"
|
"jsonpath": "$.package.version"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/daemons/crond/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-database'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/daemons/crond/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-result'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/daemons/crond/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-config'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/daemons/crond/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-files'].version"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/daemons/pushd/Cargo.toml",
|
"path": "crates/daemons/pushd/Cargo.toml",
|
||||||
"jsonpath": "$.package.version"
|
"jsonpath": "$.package.version"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/daemons/pushd/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-result'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/daemons/pushd/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-config'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/daemons/pushd/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-database'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/daemons/pushd/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-models'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/daemons/pushd/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-presence'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/daemons/pushd/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-parser'].version"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/daemons/voice-ingress/Cargo.toml",
|
"path": "crates/daemons/voice-ingress/Cargo.toml",
|
||||||
@@ -220,66 +90,11 @@
|
|||||||
"path": "crates/services/autumn/Cargo.toml",
|
"path": "crates/services/autumn/Cargo.toml",
|
||||||
"jsonpath": "$.package.version"
|
"jsonpath": "$.package.version"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/services/autumn/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-files'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/services/autumn/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-config'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/services/autumn/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-database'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/services/autumn/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-result'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/services/autumn/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-ratelimits'].version"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/services/gifbox/Cargo.toml",
|
"path": "crates/services/gifbox/Cargo.toml",
|
||||||
"jsonpath": "$.package.version"
|
"jsonpath": "$.package.version"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/services/gifbox/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-config'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/services/gifbox/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-models'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/services/gifbox/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-result'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/services/gifbox/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-coalesced'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/services/gifbox/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-database'].version"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "toml",
|
|
||||||
"path": "crates/services/gifbox/Cargo.toml",
|
|
||||||
"jsonpath": "$.dependencies['revolt-ratelimits'].version"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/services/january/Cargo.toml",
|
"path": "crates/services/january/Cargo.toml",
|
||||||
@@ -287,23 +102,53 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/services/january/Cargo.toml",
|
"path": "Cargo.toml",
|
||||||
"jsonpath": "$.dependencies['revolt-config'].version"
|
"jsonpath": "$.workspace.dependencies['revolt-coalesced'].version"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/services/january/Cargo.toml",
|
"path": "Cargo.toml",
|
||||||
"jsonpath": "$.dependencies['revolt-models'].version"
|
"jsonpath": "$.workspace.dependencies['revolt-config'].version"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/services/january/Cargo.toml",
|
"path": "Cargo.toml",
|
||||||
"jsonpath": "$.dependencies['revolt-result'].version"
|
"jsonpath": "$.workspace.dependencies['revolt-database'].version"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "toml",
|
"type": "toml",
|
||||||
"path": "crates/services/january/Cargo.toml",
|
"path": "Cargo.toml",
|
||||||
"jsonpath": "$.dependencies['revolt-files'].version"
|
"jsonpath": "$.workspace.dependencies['revolt-files'].version"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "toml",
|
||||||
|
"path": "Cargo.toml",
|
||||||
|
"jsonpath": "$.workspace.dependencies['revolt-models'].version"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "toml",
|
||||||
|
"path": "Cargo.toml",
|
||||||
|
"jsonpath": "$.workspace.dependencies['revolt-parser'].version"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "toml",
|
||||||
|
"path": "Cargo.toml",
|
||||||
|
"jsonpath": "$.workspace.dependencies['revolt-permissions'].version"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "toml",
|
||||||
|
"path": "Cargo.toml",
|
||||||
|
"jsonpath": "$.workspace.dependencies['revolt-presence'].version"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "toml",
|
||||||
|
"path": "Cargo.toml",
|
||||||
|
"jsonpath": "$.workspace.dependencies['revolt-ratelimits'].version"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "toml",
|
||||||
|
"path": "Cargo.toml",
|
||||||
|
"jsonpath": "$.workspace.dependencies['revolt-result'].version"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
0.12.1
|
0.13.0
|
||||||
Reference in new issue
Block a user