mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-09 04:26:53 +00:00
Compare commits
10 Commits
20250510-1
...
stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4728c696d | ||
|
|
8153f5f17a | ||
|
|
99a80f723d | ||
|
|
4f13f5899b | ||
|
|
5362e84730 | ||
|
|
be89e62d54 | ||
|
|
a72134f4ad | ||
|
|
69ae767175 | ||
|
|
2aff76c369 | ||
|
|
01e0f9e558 |
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"editor.formatOnSave": true,
|
||||
"rust-analyzer.checkOnSave.command": "clippy",
|
||||
"rust-analyzer.check.command": "clippy",
|
||||
"nixEnvSelector.suggestion": false,
|
||||
"nixEnvSelector.nixFile": "${workspaceFolder}/default.nix"
|
||||
}
|
||||
}
|
||||
|
||||
218
Cargo.lock
generated
218
Cargo.lock
generated
@@ -58,7 +58,7 @@ version = "0.7.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.2.15",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
]
|
||||
@@ -70,7 +70,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"getrandom",
|
||||
"getrandom 0.2.15",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
"zerocopy",
|
||||
@@ -139,9 +139,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.95"
|
||||
version = "1.0.98"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
|
||||
checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
@@ -443,9 +446,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "authifier"
|
||||
version = "1.0.13"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca26cb6b5ab776a1de5a8122fe6cc77fadd84fed30704c496f2aca451637877b"
|
||||
checksum = "b1a03b810b342b4c584cdc1cfc40d1ec763b1d653ef4086f7494740f35d9e1f0"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"async-trait",
|
||||
@@ -2056,7 +2059,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9b3460f44bea8cd47f45a0c70892f1eff856d97cd55358b2f73f663789f6190"
|
||||
dependencies = [
|
||||
"ct-codecs",
|
||||
"getrandom",
|
||||
"getrandom 0.2.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2675,10 +2678,22 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"wasi 0.14.2+wasi-0.2.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getset"
|
||||
version = "0.1.3"
|
||||
@@ -4313,7 +4328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
@@ -4933,7 +4948,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"thiserror 2.0.9",
|
||||
"thiserror 2.0.12",
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
@@ -5386,7 +5401,7 @@ dependencies = [
|
||||
"libc",
|
||||
"once_cell",
|
||||
"raw-cpuid",
|
||||
"wasi",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"web-sys",
|
||||
"winapi",
|
||||
]
|
||||
@@ -5430,6 +5445,12 @@ version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a3866219251662ec3b26fc217e3e05bf9c4f84325234dfb96bf0bf840889e49"
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "5.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
|
||||
|
||||
[[package]]
|
||||
name = "radium"
|
||||
version = "0.7.0"
|
||||
@@ -5466,6 +5487,16 @@ dependencies = [
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97"
|
||||
dependencies = [
|
||||
"rand_chacha 0.9.0",
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.1.1"
|
||||
@@ -5486,6 +5517,16 @@ dependencies = [
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
@@ -5507,7 +5548,16 @@ version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.2.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||
dependencies = [
|
||||
"getrandom 0.3.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5904,7 +5954,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-autumn"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"axum-macros",
|
||||
@@ -5941,7 +5991,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-bonfire"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"async-channel 2.3.1",
|
||||
"async-std",
|
||||
@@ -5971,7 +6021,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-config"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"cached",
|
||||
@@ -5982,12 +6032,13 @@ dependencies = [
|
||||
"pretty_env_logger",
|
||||
"revolt-result",
|
||||
"sentry",
|
||||
"sentry-anyhow",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "revolt-crond"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"log",
|
||||
"revolt-config",
|
||||
@@ -5999,7 +6050,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-database"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"amqprs",
|
||||
"async-lock 2.8.0",
|
||||
@@ -6049,7 +6100,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-delta"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"amqprs",
|
||||
"async-channel 1.9.0",
|
||||
@@ -6096,7 +6147,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-files"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"aws-config",
|
||||
@@ -6119,7 +6170,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-january"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"async-recursion",
|
||||
"axum",
|
||||
@@ -6147,7 +6198,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-models"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"indexmap 1.9.3",
|
||||
"iso8601-timestamp",
|
||||
@@ -6166,14 +6217,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-parser"
|
||||
version = "0.1.1"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"logos",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "revolt-permissions"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"async-trait",
|
||||
@@ -6188,7 +6239,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-presence"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"log",
|
||||
@@ -6199,9 +6250,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-pushd"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"amqprs",
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"authifier",
|
||||
"base64 0.22.1",
|
||||
@@ -6214,6 +6266,7 @@ dependencies = [
|
||||
"revolt-database",
|
||||
"revolt-models",
|
||||
"revolt-presence",
|
||||
"revolt-result",
|
||||
"revolt_a2",
|
||||
"revolt_optional_struct",
|
||||
"serde",
|
||||
@@ -6225,7 +6278,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "revolt-result"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"revolt_okapi",
|
||||
@@ -6356,7 +6409,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"getrandom",
|
||||
"getrandom 0.2.15",
|
||||
"libc",
|
||||
"spin",
|
||||
"untrusted",
|
||||
@@ -6425,9 +6478,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rocket_authifier"
|
||||
version = "1.0.13"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0490f4a6f0a359a9ffff9acbdf4eddf49890ec94941b8ddd88163c16f6159f5a"
|
||||
checksum = "c1f98a5be96ac4144ee1adc809c1594e8212032b8a08d9bc4cef70735dfd976e"
|
||||
dependencies = [
|
||||
"authifier",
|
||||
"iso8601-timestamp",
|
||||
@@ -6918,9 +6971,9 @@ dependencies = [
|
||||
"httpdate",
|
||||
"native-tls",
|
||||
"reqwest 0.11.27",
|
||||
"sentry-backtrace",
|
||||
"sentry-backtrace 0.31.8",
|
||||
"sentry-contexts",
|
||||
"sentry-core",
|
||||
"sentry-core 0.31.8",
|
||||
"sentry-debug-images",
|
||||
"sentry-panic",
|
||||
"sentry-tracing",
|
||||
@@ -6928,6 +6981,17 @@ dependencies = [
|
||||
"ureq",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sentry-anyhow"
|
||||
version = "0.38.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c93cfb800654dc846ccbeb35254a2f6f194aaf7e187223fd90aeb7afafe722c"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"sentry-backtrace 0.38.1",
|
||||
"sentry-core 0.38.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sentry-backtrace"
|
||||
version = "0.31.8"
|
||||
@@ -6937,7 +7001,18 @@ dependencies = [
|
||||
"backtrace",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"sentry-core",
|
||||
"sentry-core 0.31.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sentry-backtrace"
|
||||
version = "0.38.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8dace796060e4ad10e3d1405b122ae184a8b2e71dce05ae450e4f81b7686b0d9"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"regex",
|
||||
"sentry-core 0.38.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6950,7 +7025,7 @@ dependencies = [
|
||||
"libc",
|
||||
"os_info",
|
||||
"rustc_version",
|
||||
"sentry-core",
|
||||
"sentry-core 0.31.8",
|
||||
"uname",
|
||||
]
|
||||
|
||||
@@ -6962,7 +7037,18 @@ checksum = "901f761681f97db3db836ef9e094acdd8756c40215326c194201941947164ef1"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"rand 0.8.5",
|
||||
"sentry-types",
|
||||
"sentry-types 0.31.8",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sentry-core"
|
||||
version = "0.38.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7426d4beec270cfdbb50f85f0bb2ce176ea57eed0b11741182a163055a558187"
|
||||
dependencies = [
|
||||
"sentry-types 0.38.1",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
@@ -6975,7 +7061,7 @@ checksum = "afdb263e73d22f39946f6022ed455b7561b22ff5553aca9be3c6a047fa39c328"
|
||||
dependencies = [
|
||||
"findshlibs",
|
||||
"once_cell",
|
||||
"sentry-core",
|
||||
"sentry-core 0.31.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6984,8 +7070,8 @@ version = "0.31.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74fbf1c163f8b6a9d05912e1b272afa27c652e8b47ea60cb9a57ad5e481eea99"
|
||||
dependencies = [
|
||||
"sentry-backtrace",
|
||||
"sentry-core",
|
||||
"sentry-backtrace 0.31.8",
|
||||
"sentry-core 0.31.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6994,8 +7080,8 @@ version = "0.31.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82eabcab0a047040befd44599a1da73d3adb228ff53b5ed9795ae04535577704"
|
||||
dependencies = [
|
||||
"sentry-backtrace",
|
||||
"sentry-core",
|
||||
"sentry-backtrace 0.31.8",
|
||||
"sentry-core 0.31.8",
|
||||
"tracing-core",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
@@ -7017,6 +7103,23 @@ dependencies = [
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sentry-types"
|
||||
version = "0.38.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04b6c9287202294685cb1f749b944dbbce8160b81a1061ecddc073025fed129f"
|
||||
dependencies = [
|
||||
"debugid",
|
||||
"hex",
|
||||
"rand 0.9.1",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.12",
|
||||
"time",
|
||||
"url",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.217"
|
||||
@@ -7647,7 +7750,7 @@ checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand 2.3.0",
|
||||
"getrandom",
|
||||
"getrandom 0.2.15",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys 0.59.0",
|
||||
@@ -7684,11 +7787,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.9"
|
||||
version = "2.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc"
|
||||
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
|
||||
dependencies = [
|
||||
"thiserror-impl 2.0.9",
|
||||
"thiserror-impl 2.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7704,9 +7807,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.9"
|
||||
version = "2.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4"
|
||||
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote 1.0.38",
|
||||
@@ -8191,6 +8294,7 @@ checksum = "220b18413e1fe5e85a5580b22f44241f82404a66c792c9f3c9eda74c52d9a22e"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -8199,7 +8303,7 @@ version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04f903f293d11f31c0c29e4148f6dc0d033a7f80cebc0282bea147611667d289"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.2.15",
|
||||
"rand 0.8.5",
|
||||
"web-time",
|
||||
]
|
||||
@@ -8459,7 +8563,7 @@ version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.2.15",
|
||||
"serde",
|
||||
]
|
||||
|
||||
@@ -8606,13 +8710,22 @@ version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.14.2+wasi-0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
|
||||
dependencies = [
|
||||
"wit-bindgen-rt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasix"
|
||||
version = "0.12.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1fbb4ef9bbca0c1170e0b00dd28abc9e3b68669821600cad1caaed606583c6d"
|
||||
dependencies = [
|
||||
"wasi",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9061,6 +9174,15 @@ dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rt"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "write16"
|
||||
version = "1.0.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-bonfire"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
license = "AGPL-3.0-or-later"
|
||||
edition = "2021"
|
||||
|
||||
@@ -36,12 +36,12 @@ async-std = { version = "1.8.0", features = [
|
||||
] }
|
||||
|
||||
# core
|
||||
authifier = { version = "1.0.13" }
|
||||
authifier = { version = "1.0.15" }
|
||||
revolt-result = { path = "../core/result" }
|
||||
revolt-models = { path = "../core/models" }
|
||||
revolt-config = { path = "../core/config" }
|
||||
revolt-database = { path = "../core/database" }
|
||||
revolt-permissions = { version = "0.8.5", path = "../core/permissions" }
|
||||
revolt-permissions = { version = "0.8.7", path = "../core/permissions" }
|
||||
revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] }
|
||||
|
||||
# redis
|
||||
|
||||
@@ -100,6 +100,18 @@ impl State {
|
||||
let user = self.clone_user();
|
||||
self.cache.is_bot = user.bot.is_some();
|
||||
|
||||
// Fetch pending policy changes.
|
||||
let policy_changes = if user.bot.is_some() {
|
||||
vec![]
|
||||
} else {
|
||||
db.fetch_policy_changes()
|
||||
.await?
|
||||
.into_iter()
|
||||
.filter(|policy| policy.created_time > user.last_acknowledged_policy_change)
|
||||
.map(Into::into)
|
||||
.collect()
|
||||
};
|
||||
|
||||
// Find all relationships to the user.
|
||||
let mut user_ids: HashSet<String> = user
|
||||
.relations
|
||||
@@ -175,7 +187,7 @@ impl State {
|
||||
.iter()
|
||||
.find(|e| matches!(e, ReadyPayloadFields::UserSettings(_)))
|
||||
{
|
||||
Some(db.fetch_user_settings(&user.id, &keys).await?)
|
||||
Some(db.fetch_user_settings(&user.id, keys).await?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -199,12 +211,11 @@ impl State {
|
||||
.collect();
|
||||
|
||||
// Make all users appear from our perspective.
|
||||
let mut users: Vec<v0::User> = join_all(users
|
||||
.into_iter()
|
||||
.map(|other_user| async {
|
||||
let is_online = online_ids.contains(&other_user.id);
|
||||
other_user.into_known(&user, is_online).await
|
||||
})).await;
|
||||
let mut users: Vec<v0::User> = join_all(users.into_iter().map(|other_user| async {
|
||||
let is_online = online_ids.contains(&other_user.id);
|
||||
other_user.into_known(&user, is_online).await
|
||||
}))
|
||||
.await;
|
||||
|
||||
// Make sure we see our own user correctly.
|
||||
users.push(user.into_self(true).await);
|
||||
@@ -228,6 +239,7 @@ impl State {
|
||||
for channel in &channels {
|
||||
self.insert_subscription(channel.id().to_string()).await;
|
||||
}
|
||||
|
||||
Ok(EventV1::Ready {
|
||||
users: if fields.contains(&ReadyPayloadFields::Users) {
|
||||
Some(users)
|
||||
@@ -253,6 +265,8 @@ impl State {
|
||||
|
||||
user_settings,
|
||||
channel_unreads: channel_unreads.map(|vec| vec.into_iter().map(Into::into).collect()),
|
||||
|
||||
policy_changes,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{collections::HashSet, net::SocketAddr, sync::Arc};
|
||||
use async_tungstenite::WebSocketStream;
|
||||
use authifier::AuthifierEvent;
|
||||
use fred::{
|
||||
error::{RedisError, RedisErrorKind},
|
||||
error::RedisErrorKind,
|
||||
interfaces::{ClientLike, EventInterface, PubsubInterface},
|
||||
types::RedisConfig,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-config"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
authors = ["Paul Makles <me@insrt.uk>"]
|
||||
@@ -9,9 +9,10 @@ description = "Revolt Backend: Configuration"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[features]
|
||||
anyhow = ["dep:sentry-anyhow"]
|
||||
report-macros = ["revolt-result"]
|
||||
test = ["async-std"]
|
||||
default = ["test"]
|
||||
default = ["test", "anyhow"]
|
||||
|
||||
[dependencies]
|
||||
# Utility
|
||||
@@ -32,6 +33,7 @@ pretty_env_logger = "0.4.0"
|
||||
|
||||
# Sentry
|
||||
sentry = "0.31.5"
|
||||
sentry-anyhow = { version = "0.38.1", optional = true }
|
||||
|
||||
# Core
|
||||
revolt-result = { version = "0.8.5", path = "../result", optional = true }
|
||||
revolt-result = { version = "0.8.7", path = "../result", optional = true }
|
||||
|
||||
@@ -275,4 +275,5 @@ api = ""
|
||||
events = ""
|
||||
files = ""
|
||||
proxy = ""
|
||||
pushd = ""
|
||||
crond = ""
|
||||
|
||||
@@ -7,6 +7,7 @@ use once_cell::sync::Lazy;
|
||||
use serde::Deserialize;
|
||||
|
||||
pub use sentry::{capture_error, capture_message, Level};
|
||||
pub use sentry_anyhow::capture_anyhow;
|
||||
|
||||
#[cfg(feature = "report-macros")]
|
||||
#[macro_export]
|
||||
@@ -343,6 +344,7 @@ pub struct Sentry {
|
||||
pub events: String,
|
||||
pub files: String,
|
||||
pub proxy: String,
|
||||
pub pushd: String,
|
||||
pub crond: String,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-database"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-or-later"
|
||||
authors = ["Paul Makles <me@insrt.uk>"]
|
||||
@@ -24,19 +24,19 @@ default = ["mongodb", "async-std-runtime", "tasks"]
|
||||
|
||||
[dependencies]
|
||||
# Core
|
||||
revolt-config = { version = "0.8.5", path = "../config", features = [
|
||||
revolt-config = { version = "0.8.7", path = "../config", features = [
|
||||
"report-macros",
|
||||
] }
|
||||
revolt-result = { version = "0.8.5", path = "../result" }
|
||||
revolt-models = { version = "0.8.5", path = "../models", features = [
|
||||
revolt-result = { version = "0.8.7", path = "../result" }
|
||||
revolt-models = { version = "0.8.7", path = "../models", features = [
|
||||
"validator",
|
||||
] }
|
||||
revolt-presence = { version = "0.8.5", path = "../presence" }
|
||||
revolt-permissions = { version = "0.8.5", path = "../permissions", features = [
|
||||
revolt-presence = { version = "0.8.7", path = "../presence" }
|
||||
revolt-permissions = { version = "0.8.7", path = "../permissions", features = [
|
||||
"serde",
|
||||
"bson",
|
||||
] }
|
||||
revolt-parser = { version = "0.1.1", path = "../parser" }
|
||||
revolt-parser = { version = "0.8.7", path = "../parser" }
|
||||
|
||||
# Utility
|
||||
log = "0.4"
|
||||
@@ -97,7 +97,7 @@ web-push = "0.10.0"
|
||||
revolt_a2 = { version = "0.10", default-features = false, features = ["ring"] }
|
||||
|
||||
# Authifier
|
||||
authifier = { version = "1.0.13", features = ["rocket_impl"] }
|
||||
authifier = { version = "1.0.15", features = ["rocket_impl"] }
|
||||
|
||||
# RabbitMQ
|
||||
amqprs = { version = "1.7.0" }
|
||||
|
||||
@@ -4,8 +4,8 @@ use futures::lock::Mutex;
|
||||
|
||||
use crate::{
|
||||
Bot, Channel, ChannelCompositeKey, ChannelUnread, Emoji, File, FileHash, Invite, Member,
|
||||
MemberCompositeKey, Message, RatelimitEvent, Report, Server, ServerBan, Snapshot, User,
|
||||
UserSettings, Webhook,
|
||||
MemberCompositeKey, Message, PolicyChange, RatelimitEvent, Report, Server, ServerBan, Snapshot,
|
||||
User, UserSettings, Webhook,
|
||||
};
|
||||
|
||||
database_derived!(
|
||||
@@ -21,6 +21,7 @@ database_derived!(
|
||||
pub file_hashes: Arc<Mutex<HashMap<String, FileHash>>>,
|
||||
pub files: Arc<Mutex<HashMap<String, File>>>,
|
||||
pub messages: Arc<Mutex<HashMap<String, Message>>>,
|
||||
pub policy_changes: Arc<Mutex<HashMap<String, PolicyChange>>>,
|
||||
pub ratelimit_events: Arc<Mutex<HashMap<String, RatelimitEvent>>>,
|
||||
pub user_settings: Arc<Mutex<HashMap<String, UserSettings>>>,
|
||||
pub users: Arc<Mutex<HashMap<String, User>>>,
|
||||
|
||||
@@ -6,7 +6,7 @@ use revolt_models::v0::{
|
||||
AppendMessage, Channel, ChannelUnread, Emoji, FieldsChannel, FieldsMember, FieldsMessage,
|
||||
FieldsRole, FieldsServer, FieldsUser, FieldsWebhook, Member, MemberCompositeKey, Message,
|
||||
PartialChannel, PartialMember, PartialMessage, PartialRole, PartialServer, PartialUser,
|
||||
PartialWebhook, RemovalIntention, Report, Server, User, UserSettings, Webhook,
|
||||
PartialWebhook, PolicyChange, RemovalIntention, Report, Server, User, UserSettings, Webhook,
|
||||
};
|
||||
|
||||
use crate::Database;
|
||||
@@ -62,6 +62,8 @@ pub enum EventV1 {
|
||||
user_settings: Option<UserSettings>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
channel_unreads: Option<Vec<ChannelUnread>>,
|
||||
|
||||
policy_changes: Vec<PolicyChange>,
|
||||
},
|
||||
|
||||
/// Ping response
|
||||
|
||||
@@ -64,6 +64,10 @@ pub async fn create_database(db: &MongoDb) {
|
||||
.await
|
||||
.expect("Failed to create user_settings collection.");
|
||||
|
||||
db.create_collection("policy_changes")
|
||||
.await
|
||||
.expect("Failed to create policy_changes collection.");
|
||||
|
||||
db.create_collection("safety_reports")
|
||||
.await
|
||||
.expect("Failed to create safety_reports collection.");
|
||||
|
||||
@@ -5,10 +5,11 @@ use crate::{
|
||||
bson::{doc, from_bson, from_document, to_document, Bson, DateTime, Document},
|
||||
options::FindOptions,
|
||||
},
|
||||
AbstractChannels, AbstractServers, Channel, Invite, MongoDb, DISCRIMINATOR_SEARCH_SPACE,
|
||||
AbstractChannels, AbstractServers, Channel, Invite, MongoDb, User, DISCRIMINATOR_SEARCH_SPACE,
|
||||
};
|
||||
use bson::oid::ObjectId;
|
||||
use bson::{oid::ObjectId, to_bson};
|
||||
use futures::StreamExt;
|
||||
use iso8601_timestamp::Timestamp;
|
||||
use rand::seq::SliceRandom;
|
||||
use revolt_permissions::DEFAULT_WEBHOOK_PERMISSIONS;
|
||||
use revolt_result::{Error, ErrorType};
|
||||
@@ -21,7 +22,7 @@ struct MigrationInfo {
|
||||
revision: i32,
|
||||
}
|
||||
|
||||
pub const LATEST_REVISION: i32 = 31;
|
||||
pub const LATEST_REVISION: i32 = 41; // MUST BE +1 to last migration
|
||||
|
||||
pub async fn migrate_database(db: &MongoDb) {
|
||||
let migrations = db.col::<Document>("migrations");
|
||||
@@ -1128,6 +1129,42 @@ pub async fn run_migrations(db: &MongoDb, revision: i32) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
if revision <= 32 {
|
||||
info!(
|
||||
"Running migration [revision 32 / 12-05-2025]: (Authifier) Add last_seen to sessions."
|
||||
);
|
||||
|
||||
let db = authifier::Database::MongoDb(authifier::database::MongoDb(db.db()));
|
||||
db.run_migration(authifier::Migration::M2025_02_20AddLastSeenToSession)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
if revision <= 40 {
|
||||
info!(
|
||||
"Running migration [revision |> 40 / 30-05-2025]: Set last policy acknowlegement date to now and create policy changes collection."
|
||||
);
|
||||
|
||||
db.db()
|
||||
.create_collection("policy_changes")
|
||||
.await
|
||||
.expect("Failed to create policy_changes collection.");
|
||||
|
||||
db.db()
|
||||
.collection::<User>("users")
|
||||
.update_many(
|
||||
doc! {},
|
||||
doc! {
|
||||
"$set": {
|
||||
"last_acknowledged_policy_change": to_bson(&Timestamp::now_utc())
|
||||
.expect("failed to serialise timestamp")
|
||||
}
|
||||
},
|
||||
)
|
||||
.await
|
||||
.expect("failed to update users");
|
||||
}
|
||||
|
||||
// Reminder to update LATEST_REVISION when adding new migrations.
|
||||
LATEST_REVISION.max(revision)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use revolt_config::config;
|
||||
use revolt_result::Result;
|
||||
use ulid::Ulid;
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ mod tests {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
db.insert_webhook(&webhook).await.unwrap();
|
||||
webhook.create(&db).await.unwrap();
|
||||
|
||||
let mut updated_webhook = webhook.clone();
|
||||
updated_webhook
|
||||
|
||||
@@ -328,13 +328,10 @@ impl Channel {
|
||||
|
||||
db.insert_channel(&channel).await?;
|
||||
|
||||
match &channel {
|
||||
Channel::DirectMessage { .. } => {
|
||||
let event = EventV1::ChannelCreate(channel.clone().into());
|
||||
event.clone().private(user_a.id.clone()).await;
|
||||
event.private(user_b.id.clone()).await;
|
||||
}
|
||||
_ => {}
|
||||
if let Channel::DirectMessage { .. } = &channel {
|
||||
let event = EventV1::ChannelCreate(channel.clone().into());
|
||||
event.clone().private(user_a.id.clone()).await;
|
||||
event.private(user_b.id.clone()).await;
|
||||
};
|
||||
|
||||
Ok(channel)
|
||||
|
||||
@@ -28,7 +28,7 @@ auto_derived_partial!(
|
||||
/// Size of this file (in bytes)
|
||||
pub size: isize,
|
||||
},
|
||||
"PartialFile"
|
||||
"PartialFileHash"
|
||||
);
|
||||
|
||||
auto_derived!(
|
||||
|
||||
@@ -5,7 +5,7 @@ use iso8601_timestamp::Timestamp;
|
||||
use revolt_config::{config, FeaturesLimits};
|
||||
use revolt_models::v0::{
|
||||
self, BulkMessageResponse, DataMessageSend, Embed, MessageAuthor, MessageFlags, MessageSort,
|
||||
MessageWebhook, PushNotification, ReplyIntent, SendableEmbed, Text
|
||||
MessageWebhook, PushNotification, ReplyIntent, SendableEmbed, Text,
|
||||
};
|
||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission, PermissionValue};
|
||||
use revolt_result::{ErrorType, Result};
|
||||
@@ -286,9 +286,9 @@ impl Message {
|
||||
.map_err(|_| create_error!(InvalidOperation))?;
|
||||
|
||||
// Check the message is not empty
|
||||
if (data.content.as_ref().map_or(true, |v| v.is_empty()))
|
||||
&& (data.attachments.as_ref().map_or(true, |v| v.is_empty()))
|
||||
&& (data.embeds.as_ref().map_or(true, |v| v.is_empty()))
|
||||
if (data.content.as_ref().is_none_or(|v| v.is_empty()))
|
||||
&& (data.attachments.as_ref().is_none_or(|v| v.is_empty()))
|
||||
&& (data.embeds.as_ref().is_none_or(|v| v.is_empty()))
|
||||
{
|
||||
return Err(create_error!(EmptyMessage));
|
||||
}
|
||||
@@ -382,7 +382,7 @@ impl Message {
|
||||
mut user_mentions,
|
||||
mut role_mentions,
|
||||
mut mentions_everyone,
|
||||
mut mentions_online
|
||||
mut mentions_online,
|
||||
} = message_mentions;
|
||||
|
||||
if allow_mass_mentions && server_id.is_some() && !role_mentions.is_empty() {
|
||||
@@ -489,7 +489,9 @@ impl Message {
|
||||
|
||||
let valid_members = db.fetch_members(server.as_str(), &mentions_vec[..]).await;
|
||||
if let Ok(valid_members) = valid_members {
|
||||
let valid_mentions = HashSet::<&String, RandomState>::from_iter(valid_members.iter().map(|m| &m.id.user));
|
||||
let valid_mentions = HashSet::<&String, RandomState>::from_iter(
|
||||
valid_members.iter().map(|m| &m.id.user),
|
||||
);
|
||||
|
||||
user_mentions.retain(|m| valid_mentions.contains(m)); // quick pass, validate mentions are in the server
|
||||
|
||||
@@ -503,7 +505,8 @@ impl Message {
|
||||
.members_can_see_channel()
|
||||
.await;
|
||||
|
||||
user_mentions.retain(|m| *member_channel_view_perms.get(m).unwrap_or(&false));
|
||||
user_mentions
|
||||
.retain(|m| *member_channel_view_perms.get(m).unwrap_or(&false));
|
||||
}
|
||||
} else {
|
||||
revolt_config::capture_error(&valid_members.unwrap_err());
|
||||
@@ -517,7 +520,9 @@ impl Message {
|
||||
}
|
||||
|
||||
if !user_mentions.is_empty() {
|
||||
message.mentions.replace(user_mentions.into_iter().collect());
|
||||
message
|
||||
.mentions
|
||||
.replace(user_mentions.into_iter().collect());
|
||||
}
|
||||
|
||||
if !role_mentions.is_empty() {
|
||||
@@ -651,7 +656,7 @@ impl Message {
|
||||
pub async fn send(
|
||||
&mut self,
|
||||
db: &Database,
|
||||
amqp: Option<&AMQP>, // this is optional mostly for tests.
|
||||
_amqp: Option<&AMQP>, // this is optional mostly for tests.
|
||||
author: MessageAuthor<'_>,
|
||||
user: Option<v0::User>,
|
||||
member: Option<v0::Member>,
|
||||
|
||||
@@ -8,6 +8,7 @@ mod emojis;
|
||||
mod file_hashes;
|
||||
mod files;
|
||||
mod messages;
|
||||
mod policy_changes;
|
||||
mod ratelimit_events;
|
||||
mod safety_reports;
|
||||
mod safety_snapshots;
|
||||
@@ -27,6 +28,7 @@ pub use emojis::*;
|
||||
pub use file_hashes::*;
|
||||
pub use files::*;
|
||||
pub use messages::*;
|
||||
pub use policy_changes::*;
|
||||
pub use ratelimit_events::*;
|
||||
pub use safety_reports::*;
|
||||
pub use safety_snapshots::*;
|
||||
@@ -51,6 +53,7 @@ pub trait AbstractDatabase:
|
||||
+ file_hashes::AbstractAttachmentHashes
|
||||
+ files::AbstractAttachments
|
||||
+ messages::AbstractMessages
|
||||
+ policy_changes::AbstractPolicyChange
|
||||
+ ratelimit_events::AbstractRatelimitEvents
|
||||
+ safety_reports::AbstractReport
|
||||
+ safety_snapshots::AbstractSnapshot
|
||||
|
||||
5
crates/core/database/src/models/policy_changes/mod.rs
Normal file
5
crates/core/database/src/models/policy_changes/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
mod model;
|
||||
mod ops;
|
||||
|
||||
pub use model::*;
|
||||
pub use ops::*;
|
||||
20
crates/core/database/src/models/policy_changes/model.rs
Normal file
20
crates/core/database/src/models/policy_changes/model.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use iso8601_timestamp::Timestamp;
|
||||
|
||||
auto_derived!(
|
||||
/// Platform policy change
|
||||
pub struct PolicyChange {
|
||||
/// Unique Id
|
||||
#[serde(rename = "_id")]
|
||||
pub id: String,
|
||||
|
||||
/// Time at which this policy was created
|
||||
pub created_time: Timestamp,
|
||||
/// Time at which this policy is effective
|
||||
pub effective_time: Timestamp,
|
||||
|
||||
/// Message shown to users
|
||||
pub description: String,
|
||||
/// URL with details about changes
|
||||
pub url: String,
|
||||
}
|
||||
);
|
||||
15
crates/core/database/src/models/policy_changes/ops.rs
Normal file
15
crates/core/database/src/models/policy_changes/ops.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use revolt_result::Result;
|
||||
|
||||
use crate::PolicyChange;
|
||||
|
||||
mod mongodb;
|
||||
mod reference;
|
||||
|
||||
#[async_trait]
|
||||
pub trait AbstractPolicyChange: Sync + Send {
|
||||
/// Fetch all policy changes
|
||||
async fn fetch_policy_changes(&self) -> Result<Vec<PolicyChange>>;
|
||||
|
||||
/// Acknowledge policy changes
|
||||
async fn acknowledge_policy_changes(&self, user_id: &str) -> Result<()>;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
use bson::to_bson;
|
||||
use iso8601_timestamp::Timestamp;
|
||||
use revolt_result::Result;
|
||||
|
||||
use crate::MongoDb;
|
||||
use crate::PolicyChange;
|
||||
use crate::User;
|
||||
|
||||
use super::AbstractPolicyChange;
|
||||
|
||||
static COL: &str = "policy_changes";
|
||||
|
||||
#[async_trait]
|
||||
impl AbstractPolicyChange for MongoDb {
|
||||
/// Fetch all policy changes
|
||||
async fn fetch_policy_changes(&self) -> Result<Vec<PolicyChange>> {
|
||||
query!(self, find, COL, doc! {})
|
||||
}
|
||||
|
||||
/// Acknowledge policy changes
|
||||
async fn acknowledge_policy_changes(&self, user_id: &str) -> Result<()> {
|
||||
let latest_policy = self
|
||||
.fetch_policy_changes()
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|policy| policy.created_time)
|
||||
.max()
|
||||
.unwrap_or(Timestamp::UNIX_EPOCH);
|
||||
|
||||
self.col::<User>("users")
|
||||
.update_one(
|
||||
doc! {
|
||||
"_id": user_id
|
||||
},
|
||||
doc! {
|
||||
"$set": {
|
||||
"last_acknowledged_policy_change": to_bson(&latest_policy)
|
||||
.map_err(|_| create_database_error!("to_bson", "timestamp"))?
|
||||
}
|
||||
},
|
||||
)
|
||||
.await
|
||||
.map(|_| ())
|
||||
.map_err(|_| create_database_error!("update_one", COL))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
use iso8601_timestamp::Timestamp;
|
||||
use revolt_result::Result;
|
||||
|
||||
use crate::PolicyChange;
|
||||
use crate::ReferenceDb;
|
||||
|
||||
use super::AbstractPolicyChange;
|
||||
|
||||
#[async_trait]
|
||||
impl AbstractPolicyChange for ReferenceDb {
|
||||
/// Fetch all policy changes
|
||||
async fn fetch_policy_changes(&self) -> Result<Vec<PolicyChange>> {
|
||||
let policy_changes = self.policy_changes.lock().await;
|
||||
Ok(policy_changes.values().cloned().collect())
|
||||
}
|
||||
|
||||
/// Acknowledge policy changes
|
||||
async fn acknowledge_policy_changes(&self, user_id: &str) -> Result<()> {
|
||||
let mut users = self.users.lock().await;
|
||||
let user = users.get_mut(user_id).expect("user doesn't exist");
|
||||
user.last_acknowledged_policy_change = self
|
||||
.fetch_policy_changes()
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|policy| policy.created_time)
|
||||
.max()
|
||||
.unwrap_or(Timestamp::UNIX_EPOCH);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -85,8 +85,8 @@ impl SnapshotContent {
|
||||
Ok((
|
||||
SnapshotContent::Message {
|
||||
message,
|
||||
prior_context: prior_context.into_iter().map(Into::into).collect(),
|
||||
leading_context: leading_context.into_iter().map(Into::into).collect(),
|
||||
prior_context: prior_context.into_iter().collect(),
|
||||
leading_context: leading_context.into_iter().collect(),
|
||||
},
|
||||
files,
|
||||
))
|
||||
|
||||
@@ -13,6 +13,7 @@ auto_derived!(
|
||||
}
|
||||
);
|
||||
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
impl ServerBan {
|
||||
/// Create ban
|
||||
pub async fn create(
|
||||
|
||||
@@ -159,7 +159,7 @@ impl Member {
|
||||
}
|
||||
|
||||
/// Update member data
|
||||
pub async fn update<'a>(
|
||||
pub async fn update(
|
||||
&mut self,
|
||||
db: &Database,
|
||||
partial: PartialMember,
|
||||
|
||||
@@ -285,7 +285,7 @@ impl Role {
|
||||
}
|
||||
|
||||
/// Update server data
|
||||
pub async fn update<'a>(
|
||||
pub async fn update(
|
||||
&mut self,
|
||||
db: &Database,
|
||||
server_id: &str,
|
||||
|
||||
@@ -8,7 +8,7 @@ use iso8601_timestamp::Timestamp;
|
||||
use once_cell::sync::Lazy;
|
||||
use rand::seq::SliceRandom;
|
||||
use revolt_config::{config, FeaturesLimits};
|
||||
use revolt_models::v0::{self, UserFlags, UserBadges};
|
||||
use revolt_models::v0::{self, UserBadges, UserFlags};
|
||||
use revolt_presence::filter_online;
|
||||
use revolt_result::{create_error, Result};
|
||||
use serde_json::json;
|
||||
@@ -57,6 +57,8 @@ auto_derived_partial!(
|
||||
/// Time until user is unsuspended
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub suspended_until: Option<Timestamp>,
|
||||
/// Last acknowledged policy change
|
||||
pub last_acknowledged_policy_change: Timestamp,
|
||||
},
|
||||
"PartialUser"
|
||||
);
|
||||
@@ -178,6 +180,7 @@ impl Default for User {
|
||||
privileged: Default::default(),
|
||||
bot: Default::default(),
|
||||
suspended_until: Default::default(),
|
||||
last_acknowledged_policy_change: Timestamp::UNIX_EPOCH,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,6 +203,7 @@ impl User {
|
||||
id: account_id.into().unwrap_or_else(|| Ulid::new().to_string()),
|
||||
discriminator: User::find_discriminator(db, &username, None).await?,
|
||||
username,
|
||||
last_acknowledged_policy_change: Timestamp::now_utc(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -349,16 +353,13 @@ impl User {
|
||||
) -> Result<Vec<v0::User>> {
|
||||
let online_ids = filter_online(ids).await;
|
||||
|
||||
Ok(join_all(
|
||||
db
|
||||
.fetch_users(ids)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|user| async {
|
||||
Ok(
|
||||
join_all(db.fetch_users(ids).await?.into_iter().map(|user| async {
|
||||
let is_online = online_ids.contains(&user.id);
|
||||
user.into_known(perspective, is_online).await
|
||||
})
|
||||
).await)
|
||||
}))
|
||||
.await,
|
||||
)
|
||||
}
|
||||
|
||||
/// Find a free discriminator for a given username
|
||||
@@ -639,7 +640,7 @@ impl User {
|
||||
}
|
||||
|
||||
/// Update user data
|
||||
pub async fn update<'a>(
|
||||
pub async fn update(
|
||||
&mut self,
|
||||
db: &Database,
|
||||
partial: PartialUser,
|
||||
@@ -817,7 +818,7 @@ impl User {
|
||||
|
||||
if let Some(cutoff) = config.api.users.early_adopter_cutoff {
|
||||
if Ulid::from_string(&self.id).unwrap().timestamp_ms() < cutoff {
|
||||
return badges + UserBadges::EarlyAdopter as u32
|
||||
return badges + UserBadges::EarlyAdopter as u32;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use revolt_rocket_okapi::{
|
||||
|
||||
use crate::User;
|
||||
|
||||
impl<'r> OpenApiFromRequest<'r> for User {
|
||||
impl OpenApiFromRequest<'_> for User {
|
||||
fn from_request_input(
|
||||
_gen: &mut OpenApiGenerator,
|
||||
_name: String,
|
||||
|
||||
@@ -3,8 +3,8 @@ use crate::{Database, Message, AMQP};
|
||||
|
||||
use deadqueue::limited::Queue;
|
||||
use once_cell::sync::Lazy;
|
||||
use revolt_config::capture_message;
|
||||
use revolt_models::v0::PushNotification;
|
||||
use rocket::form::validate::Contains;
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
time::Duration,
|
||||
@@ -65,6 +65,7 @@ pub async fn queue_ack(channel: String, user: String, event: AckEvent) {
|
||||
);
|
||||
}
|
||||
|
||||
/// Do not add more than one message per event.
|
||||
pub async fn queue_message(channel: String, event: AckEvent) {
|
||||
Q.try_push(Data {
|
||||
channel,
|
||||
@@ -114,7 +115,7 @@ pub async fn handle_ack_event(
|
||||
}
|
||||
AckEvent::ProcessMessage { messages } => {
|
||||
let mut users: HashSet<&String> = HashSet::new();
|
||||
debug!(
|
||||
info!(
|
||||
"Processing {} messages from channel {}",
|
||||
messages.len(),
|
||||
messages[0].1.channel
|
||||
@@ -125,7 +126,7 @@ pub async fn handle_ack_event(
|
||||
users.extend(recipents.iter());
|
||||
});
|
||||
|
||||
debug!("Found {} users to notify.", users.len());
|
||||
info!("Found {} users to notify.", users.len());
|
||||
|
||||
for user in users {
|
||||
let message_ids: Vec<String> = messages
|
||||
@@ -143,7 +144,7 @@ pub async fn handle_ack_event(
|
||||
db.add_mention_to_unread(channel, user, &message_ids)
|
||||
.await?;
|
||||
}
|
||||
debug!("Added {} mentions for user {}", message_ids.len(), &user);
|
||||
info!("Added {} mentions for user {}", message_ids.len(), &user);
|
||||
}
|
||||
|
||||
let mut mass_mentions = vec![];
|
||||
@@ -232,7 +233,7 @@ pub async fn worker(db: Database, amqp: AMQP) {
|
||||
revolt_config::capture_error(&err);
|
||||
error!("{err:?} for {event:?}. ({user:?}, {channel})");
|
||||
} else {
|
||||
debug!("User {user:?} ack in {channel} with {event:?}");
|
||||
info!("User {user:?} ack in {channel} with {event:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,6 +248,8 @@ pub async fn worker(db: Database, amqp: AMQP) {
|
||||
mut event,
|
||||
}) = Q.try_pop()
|
||||
{
|
||||
info!("Took next ack from queue, now {} remaining", Q.len());
|
||||
|
||||
let key: (Option<String>, String, u8) = (
|
||||
user,
|
||||
channel,
|
||||
@@ -261,24 +264,31 @@ pub async fn worker(db: Database, amqp: AMQP) {
|
||||
if let AckEvent::ProcessMessage { messages: existing } =
|
||||
&mut task.data.event
|
||||
{
|
||||
// add the new message to the list of messages to be processed.
|
||||
existing.append(new_data);
|
||||
if let Some(new_event) = new_data.pop() {
|
||||
// if the message contains a mass mention, do not delay it any further.
|
||||
if new_event.1.contains_mass_push_mention() {
|
||||
// add the new message to the list of messages to be processed.
|
||||
existing.push(new_event);
|
||||
task.run_immediately();
|
||||
continue;
|
||||
}
|
||||
|
||||
// if the message contains a mass mention, do not delay it any further.
|
||||
if new_data[0].1.contains_mass_push_mention() {
|
||||
task.run_immediately();
|
||||
continue;
|
||||
}
|
||||
existing.push(new_event);
|
||||
|
||||
// put a cap on the amount of messages that can be queued, for particularly active channels
|
||||
if (existing.length() as u16)
|
||||
< revolt_config::config()
|
||||
.await
|
||||
.features
|
||||
.advanced
|
||||
.process_message_delay_limit
|
||||
{
|
||||
task.delay();
|
||||
// put a cap on the amount of messages that can be queued, for particularly active channels
|
||||
if (existing.length() as u16)
|
||||
< revolt_config::config()
|
||||
.await
|
||||
.features
|
||||
.advanced
|
||||
.process_message_delay_limit
|
||||
{
|
||||
task.delay();
|
||||
}
|
||||
} else {
|
||||
let err_msg = format!("Got zero-length message event: {event:?}");
|
||||
capture_message(&err_msg, revolt_config::Level::Warning);
|
||||
info!("{err_msg}")
|
||||
}
|
||||
} else {
|
||||
panic!("Somehow got an ack message in the add mention arm");
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use iso8601_timestamp::Timestamp;
|
||||
use revolt_models::v0::*;
|
||||
use revolt_permissions::{calculate_user_permissions, UserPermission};
|
||||
|
||||
use crate::{util::permissions::DatabasePermissionQuery, Database, FileUsedFor};
|
||||
use crate::{util::permissions::DatabasePermissionQuery, Database};
|
||||
|
||||
impl crate::Bot {
|
||||
pub fn into_public_bot(self, user: crate::User) -> PublicBot {
|
||||
@@ -488,7 +489,7 @@ impl crate::Message {
|
||||
reactions: self.reactions,
|
||||
interactions: self.interactions.into(),
|
||||
masquerade: self.masquerade.map(Into::into),
|
||||
flags: self.flags.map(|flags| flags as u32).unwrap_or_default(),
|
||||
flags: self.flags.unwrap_or_default(),
|
||||
pinned: self.pinned,
|
||||
}
|
||||
}
|
||||
@@ -517,7 +518,7 @@ impl From<crate::PartialMessage> for PartialMessage {
|
||||
reactions: value.reactions,
|
||||
interactions: value.interactions.map(Into::into),
|
||||
masquerade: value.masquerade.map(Into::into),
|
||||
flags: value.flags.map(|flags| flags as u32),
|
||||
flags: value.flags,
|
||||
pinned: value.pinned,
|
||||
}
|
||||
}
|
||||
@@ -597,6 +598,17 @@ impl From<Masquerade> for crate::Masquerade {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::PolicyChange> for PolicyChange {
|
||||
fn from(value: crate::PolicyChange) -> Self {
|
||||
PolicyChange {
|
||||
created_time: value.created_time,
|
||||
effective_time: value.effective_time,
|
||||
description: value.description,
|
||||
url: value.url,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::Report> for Report {
|
||||
fn from(value: crate::Report) -> Self {
|
||||
Report {
|
||||
@@ -1188,6 +1200,7 @@ impl From<User> for crate::User {
|
||||
privileged: value.privileged,
|
||||
bot: value.bot.map(Into::into),
|
||||
suspended_until: None,
|
||||
last_acknowledged_policy_change: Timestamp::UNIX_EPOCH,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ impl<'z> BulkDatabasePermissionQuery<'z> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn channel(self, channel: &'z Channel) -> BulkDatabasePermissionQuery {
|
||||
pub fn channel(self, channel: &'z Channel) -> BulkDatabasePermissionQuery<'z> {
|
||||
BulkDatabasePermissionQuery {
|
||||
channel: Some(channel.clone()),
|
||||
..self
|
||||
@@ -109,7 +109,7 @@ impl<'z> BulkDatabasePermissionQuery<'z> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn members(self, members: &'z [Member]) -> BulkDatabasePermissionQuery {
|
||||
pub fn members(self, members: &'z [Member]) -> BulkDatabasePermissionQuery<'z> {
|
||||
BulkDatabasePermissionQuery {
|
||||
members: Some(members.to_owned()),
|
||||
cached_member_perms: None,
|
||||
@@ -120,7 +120,7 @@ impl<'z> BulkDatabasePermissionQuery<'z> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn users(self, users: &'z [User]) -> BulkDatabasePermissionQuery {
|
||||
pub fn users(self, users: &'z [User]) -> BulkDatabasePermissionQuery<'z> {
|
||||
BulkDatabasePermissionQuery {
|
||||
users: Some(users.to_owned()),
|
||||
cached_member_perms: None,
|
||||
|
||||
@@ -305,16 +305,14 @@ impl PermissionQuery for DatabasePermissionQuery<'_> {
|
||||
|
||||
/// Are we a recipient of this channel?
|
||||
async fn are_we_part_of_the_channel(&mut self) -> bool {
|
||||
if let Some(channel) = &self.channel {
|
||||
match channel {
|
||||
Cow::Borrowed(Channel::DirectMessage { recipients, .. })
|
||||
| Cow::Owned(Channel::DirectMessage { recipients, .. })
|
||||
| Cow::Borrowed(Channel::Group { recipients, .. })
|
||||
| Cow::Owned(Channel::Group { recipients, .. }) => {
|
||||
recipients.contains(&self.perspective.id)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
if let Some(
|
||||
Cow::Borrowed(Channel::DirectMessage { recipients, .. })
|
||||
| Cow::Owned(Channel::DirectMessage { recipients, .. })
|
||||
| Cow::Borrowed(Channel::Group { recipients, .. })
|
||||
| Cow::Owned(Channel::Group { recipients, .. }),
|
||||
) = &self.channel
|
||||
{
|
||||
recipients.contains(&self.perspective.id)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
@@ -420,7 +418,7 @@ impl<'a> DatabasePermissionQuery<'a> {
|
||||
}
|
||||
|
||||
/// Use user
|
||||
pub fn user(self, user: &'a User) -> DatabasePermissionQuery {
|
||||
pub fn user(self, user: &'a User) -> DatabasePermissionQuery<'a> {
|
||||
DatabasePermissionQuery {
|
||||
user: Some(Cow::Borrowed(user)),
|
||||
..self
|
||||
@@ -428,7 +426,7 @@ impl<'a> DatabasePermissionQuery<'a> {
|
||||
}
|
||||
|
||||
/// Use channel
|
||||
pub fn channel(self, channel: &'a Channel) -> DatabasePermissionQuery {
|
||||
pub fn channel(self, channel: &'a Channel) -> DatabasePermissionQuery<'a> {
|
||||
DatabasePermissionQuery {
|
||||
channel: Some(Cow::Borrowed(channel)),
|
||||
..self
|
||||
@@ -436,7 +434,7 @@ impl<'a> DatabasePermissionQuery<'a> {
|
||||
}
|
||||
|
||||
/// Use server
|
||||
pub fn server(self, server: &'a Server) -> DatabasePermissionQuery {
|
||||
pub fn server(self, server: &'a Server) -> DatabasePermissionQuery<'a> {
|
||||
DatabasePermissionQuery {
|
||||
server: Some(Cow::Borrowed(server)),
|
||||
..self
|
||||
@@ -444,7 +442,7 @@ impl<'a> DatabasePermissionQuery<'a> {
|
||||
}
|
||||
|
||||
/// Use member
|
||||
pub fn member(self, member: &'a Member) -> DatabasePermissionQuery {
|
||||
pub fn member(self, member: &'a Member) -> DatabasePermissionQuery<'a> {
|
||||
DatabasePermissionQuery {
|
||||
member: Some(Cow::Borrowed(member)),
|
||||
..self
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-files"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-or-later"
|
||||
authors = ["Paul Makles <me@insrt.uk>"]
|
||||
@@ -20,10 +20,10 @@ typenum = "1.17.0"
|
||||
aws-config = "1.5.5"
|
||||
aws-sdk-s3 = { version = "1.46.0", features = ["behavior-version-latest"] }
|
||||
|
||||
revolt-config = { version = "0.8.5", path = "../config", features = [
|
||||
revolt-config = { version = "0.8.7", path = "../config", features = [
|
||||
"report-macros",
|
||||
] }
|
||||
revolt-result = { version = "0.8.5", path = "../result" }
|
||||
revolt-result = { version = "0.8.7", path = "../result" }
|
||||
|
||||
# image processing
|
||||
jxl-oxide = "0.8.1"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-models"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
authors = ["Paul Makles <me@insrt.uk>"]
|
||||
@@ -20,8 +20,8 @@ default = ["serde", "partials", "rocket"]
|
||||
|
||||
[dependencies]
|
||||
# Core
|
||||
revolt-config = { version = "0.8.5", path = "../config" }
|
||||
revolt-permissions = { version = "0.8.5", path = "../permissions" }
|
||||
revolt-config = { version = "0.8.7", path = "../config" }
|
||||
revolt-permissions = { version = "0.8.7", path = "../permissions" }
|
||||
|
||||
# Utility
|
||||
regex = "1.11"
|
||||
|
||||
@@ -399,7 +399,7 @@ impl Interactions {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> MessageAuthor<'a> {
|
||||
impl MessageAuthor<'_> {
|
||||
pub fn id(&self) -> &str {
|
||||
match self {
|
||||
MessageAuthor::User(user) => &user.id,
|
||||
|
||||
@@ -7,6 +7,7 @@ mod embeds;
|
||||
mod emojis;
|
||||
mod files;
|
||||
mod messages;
|
||||
mod policy_changes;
|
||||
mod safety_reports;
|
||||
mod server_bans;
|
||||
mod server_members;
|
||||
@@ -23,6 +24,7 @@ pub use embeds::*;
|
||||
pub use emojis::*;
|
||||
pub use files::*;
|
||||
pub use messages::*;
|
||||
pub use policy_changes::*;
|
||||
pub use safety_reports::*;
|
||||
pub use server_bans::*;
|
||||
pub use server_members::*;
|
||||
|
||||
16
crates/core/models/src/v0/policy_changes.rs
Normal file
16
crates/core/models/src/v0/policy_changes.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use iso8601_timestamp::Timestamp;
|
||||
|
||||
auto_derived!(
|
||||
/// Platform policy change
|
||||
pub struct PolicyChange {
|
||||
/// Time at which this policy was created
|
||||
pub created_time: Timestamp,
|
||||
/// Time at which this policy is effective
|
||||
pub effective_time: Timestamp,
|
||||
|
||||
/// Message shown to users
|
||||
pub description: String,
|
||||
/// URL with details about changes
|
||||
pub url: String,
|
||||
}
|
||||
);
|
||||
@@ -1,7 +1,9 @@
|
||||
[package]
|
||||
name = "revolt-parser"
|
||||
version = "0.1.1"
|
||||
version = "0.8.7"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-or-later"
|
||||
description = "Revolt Backend: Message Parser"
|
||||
|
||||
[dependencies]
|
||||
logos = { version = "*" }
|
||||
logos = { version = "0.15" }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-permissions"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
authors = ["Paul Makles <me@insrt.uk>"]
|
||||
@@ -21,7 +21,7 @@ async-std = { version = "1.8.0", features = ["attributes"] }
|
||||
|
||||
[dependencies]
|
||||
# Core
|
||||
revolt-result = { version = "0.8.5", path = "../result" }
|
||||
revolt-result = { version = "0.8.7", path = "../result" }
|
||||
|
||||
# Utility
|
||||
auto_ops = "0.3.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-presence"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-or-later"
|
||||
authors = ["Paul Makles <me@insrt.uk>"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-result"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
authors = ["Paul Makles <me@insrt.uk>"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-crond"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
license = "AGPL-3.0-or-later"
|
||||
authors = ["Paul Makles <me@insrt.uk>"]
|
||||
edition = "2021"
|
||||
@@ -16,7 +16,7 @@ log = "0.4"
|
||||
tokio = { version = "1" }
|
||||
|
||||
# Core
|
||||
revolt-database = { version = "0.8.5", path = "../../core/database" }
|
||||
revolt-result = { version = "0.8.5", path = "../../core/result" }
|
||||
revolt-config = { version = "0.8.5", path = "../../core/config" }
|
||||
revolt-files = { version = "0.8.5", path = "../../core/files" }
|
||||
revolt-database = { version = "0.8.7", path = "../../core/database" }
|
||||
revolt-result = { version = "0.8.7", path = "../../core/result" }
|
||||
revolt-config = { version = "0.8.7", path = "../../core/config" }
|
||||
revolt-files = { version = "0.8.7", path = "../../core/files" }
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
[package]
|
||||
name = "revolt-pushd"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-or-later"
|
||||
|
||||
[dependencies]
|
||||
revolt-config = { version = "0.8.5", path = "../../core/config" }
|
||||
revolt-database = { version = "0.8.5", path = "../../core/database" }
|
||||
revolt-models = { version = "0.8.5", path = "../../core/models", features = [
|
||||
revolt-result = { version = "0.8.7", path = "../../core/result" }
|
||||
revolt-config = { version = "0.8.7", path = "../../core/config", features = [
|
||||
"report-macros",
|
||||
] }
|
||||
revolt-database = { version = "0.8.7", path = "../../core/database" }
|
||||
revolt-models = { version = "0.8.7", path = "../../core/models", features = [
|
||||
"validator",
|
||||
] }
|
||||
revolt-presence = { version = "0.8.5", path = "../../core/presence", features = [
|
||||
revolt-presence = { version = "0.8.7", path = "../../core/presence", features = [
|
||||
"redis-is-patched",
|
||||
] }
|
||||
|
||||
anyhow = { version = "1.0.98" }
|
||||
|
||||
amqprs = { version = "1.7.0" }
|
||||
fcm_v1 = "0.3.0"
|
||||
web-push = "0.10.0"
|
||||
@@ -23,7 +28,7 @@ tokio = "1.39.2"
|
||||
async-trait = "0.1.81"
|
||||
ulid = "1.0.0"
|
||||
|
||||
authifier = "1.0.10"
|
||||
authifier = "1.0.15"
|
||||
|
||||
log = "0.4.11"
|
||||
pretty_env_logger = "0.4.0"
|
||||
|
||||
@@ -7,6 +7,7 @@ use amqprs::{
|
||||
consumer::AsyncConsumer,
|
||||
BasicProperties, Deliver,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use log::debug;
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
@@ -54,21 +55,16 @@ impl FRAcceptedConsumer {
|
||||
channel: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for FRAcceptedConsumer {
|
||||
/// This consumer handles delegating messages into their respective platform queues.
|
||||
async fn consume(
|
||||
async fn consume_event(
|
||||
&mut self,
|
||||
channel: &Channel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
_channel: &Channel,
|
||||
_deliver: Deliver,
|
||||
_basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
let content = String::from_utf8(content).unwrap();
|
||||
let payload: FRAcceptedPayload = serde_json::from_str(content.as_str()).unwrap();
|
||||
) -> Result<()> {
|
||||
let content = String::from_utf8(content)?;
|
||||
let payload: FRAcceptedPayload = serde_json::from_str(content.as_str())?;
|
||||
|
||||
debug!("Received FR accept event");
|
||||
|
||||
@@ -111,11 +107,34 @@ impl AsyncConsumer for FRAcceptedConsumer {
|
||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||
}
|
||||
|
||||
let payload = serde_json::to_string(&sendable).unwrap();
|
||||
let payload = serde_json::to_string(&sendable)?;
|
||||
|
||||
publish_message(self, payload.into(), args).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for FRAcceptedConsumer {
|
||||
/// This consumer handles delegating messages into their respective platform queues.
|
||||
async fn consume(
|
||||
&mut self,
|
||||
channel: &Channel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
if let Err(err) = self
|
||||
.consume_event(channel, deliver, basic_properties, content)
|
||||
.await
|
||||
{
|
||||
revolt_config::capture_anyhow(&err);
|
||||
eprintln!("Failed to process friend request accepted event: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use amqprs::{
|
||||
consumer::AsyncConsumer,
|
||||
BasicProperties, Deliver,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use log::debug;
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
@@ -54,21 +55,16 @@ impl FRReceivedConsumer {
|
||||
channel: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for FRReceivedConsumer {
|
||||
/// This consumer handles delegating messages into their respective platform queues.
|
||||
async fn consume(
|
||||
async fn consume_event(
|
||||
&mut self,
|
||||
channel: &Channel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
_channel: &Channel,
|
||||
_deliver: Deliver,
|
||||
_basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
let content = String::from_utf8(content).unwrap();
|
||||
let payload: FRReceivedPayload = serde_json::from_str(content.as_str()).unwrap();
|
||||
) -> Result<()> {
|
||||
let content = String::from_utf8(content)?;
|
||||
let payload: FRReceivedPayload = serde_json::from_str(content.as_str())?;
|
||||
|
||||
debug!("Received FR received event");
|
||||
|
||||
@@ -111,11 +107,34 @@ impl AsyncConsumer for FRReceivedConsumer {
|
||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||
}
|
||||
|
||||
let payload = serde_json::to_string(&sendable).unwrap();
|
||||
let payload = serde_json::to_string(&sendable)?;
|
||||
|
||||
publish_message(self, payload.into(), args).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for FRReceivedConsumer {
|
||||
/// This consumer handles delegating messages into their respective platform queues.
|
||||
async fn consume(
|
||||
&mut self,
|
||||
channel: &Channel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
if let Err(err) = self
|
||||
.consume_event(channel, deliver, basic_properties, content)
|
||||
.await
|
||||
{
|
||||
revolt_config::capture_anyhow(&err);
|
||||
eprintln!("Failed to process friend request received event: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use amqprs::{
|
||||
consumer::AsyncConsumer,
|
||||
BasicProperties, Deliver,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use log::debug;
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
@@ -54,21 +55,16 @@ impl GenericConsumer {
|
||||
channel: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for GenericConsumer {
|
||||
/// This consumer handles delegating messages into their respective platform queues.
|
||||
async fn consume(
|
||||
async fn consume_event(
|
||||
&mut self,
|
||||
channel: &Channel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
_channel: &Channel,
|
||||
_deliver: Deliver,
|
||||
_basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
let content = String::from_utf8(content).unwrap();
|
||||
let payload: MessageSentPayload = serde_json::from_str(content.as_str()).unwrap();
|
||||
) -> Result<()> {
|
||||
let content = String::from_utf8(content)?;
|
||||
let payload: MessageSentPayload = serde_json::from_str(content.as_str())?;
|
||||
|
||||
debug!("Received message event on origin");
|
||||
|
||||
@@ -117,11 +113,34 @@ impl AsyncConsumer for GenericConsumer {
|
||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||
}
|
||||
|
||||
let payload = serde_json::to_string(&sendable).unwrap();
|
||||
let payload = serde_json::to_string(&sendable)?;
|
||||
|
||||
publish_message(self, payload.into(), args).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for GenericConsumer {
|
||||
/// This consumer handles delegating messages into their respective platform queues.
|
||||
async fn consume(
|
||||
&mut self,
|
||||
channel: &Channel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
if let Err(err) = self
|
||||
.consume_event(channel, deliver, basic_properties, content)
|
||||
.await
|
||||
{
|
||||
revolt_config::capture_anyhow(&err);
|
||||
eprintln!("Failed to process generic event: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use amqprs::{
|
||||
consumer::AsyncConsumer,
|
||||
BasicProperties, Deliver,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use revolt_database::{
|
||||
events::rabbit::*, util::bulk_permissions::BulkDatabasePermissionQuery, Database, Member,
|
||||
@@ -61,7 +62,11 @@ impl MassMessageConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
async fn fire_notification_for_users(&mut self, push: &PushNotification, users: &[String]) {
|
||||
async fn fire_notification_for_users(
|
||||
&mut self,
|
||||
push: &PushNotification,
|
||||
users: &[String],
|
||||
) -> Result<()> {
|
||||
if let Ok(sessions) = self
|
||||
.authifier_db
|
||||
.find_sessions_with_subscription(users)
|
||||
@@ -105,29 +110,26 @@ impl MassMessageConsumer {
|
||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||
}
|
||||
|
||||
let payload = serde_json::to_string(&sendable).unwrap();
|
||||
let payload = serde_json::to_string(&sendable)?;
|
||||
|
||||
publish_message(self, payload.into(), args).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for MassMessageConsumer {
|
||||
/// This consumer handles adding mentions for all the users affected by a mass mention ping, and then sends out push notifications
|
||||
async fn consume(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn consume_event(
|
||||
&mut self,
|
||||
channel: &Channel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
_channel: &Channel,
|
||||
_deliver: Deliver,
|
||||
_basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
) -> Result<()> {
|
||||
let config = revolt_config::config().await;
|
||||
let content = String::from_utf8(content).unwrap();
|
||||
let payload: MassMessageSentPayload = serde_json::from_str(content.as_str()).unwrap();
|
||||
let content = String::from_utf8(content)?;
|
||||
let payload: MassMessageSentPayload = serde_json::from_str(content.as_str())?;
|
||||
|
||||
debug!("Received mass message event");
|
||||
|
||||
@@ -159,8 +161,7 @@ impl AsyncConsumer for MassMessageConsumer {
|
||||
let mut db_query = self
|
||||
.db
|
||||
.fetch_all_members_chunked(&payload.server_id)
|
||||
.await
|
||||
.expect("Failed to fetch members from database");
|
||||
.await?;
|
||||
|
||||
let mut exhausted = false;
|
||||
let ack_chnl = vec![push.channel.id().to_string()];
|
||||
@@ -203,7 +204,8 @@ impl AsyncConsumer for MassMessageConsumer {
|
||||
target_users, online_users
|
||||
);
|
||||
|
||||
self.fire_notification_for_users(&push, &target_users).await;
|
||||
self.fire_notification_for_users(&push, &target_users)
|
||||
.await?;
|
||||
|
||||
if exhausted {
|
||||
break;
|
||||
@@ -211,19 +213,11 @@ impl AsyncConsumer for MassMessageConsumer {
|
||||
}
|
||||
} else if let Some(roles) = &push.message.role_mentions {
|
||||
// role mentions
|
||||
let _role_members = self
|
||||
let mut role_members = self
|
||||
.db
|
||||
.fetch_all_members_with_roles_chunked(&payload.server_id, roles)
|
||||
.await;
|
||||
.await?;
|
||||
|
||||
debug!("role members: {:?}", _role_members);
|
||||
|
||||
if _role_members.is_err() {
|
||||
revolt_config::capture_error(&_role_members.err().unwrap());
|
||||
return;
|
||||
}
|
||||
|
||||
let mut role_members = _role_members.unwrap();
|
||||
let mut chunk = vec![];
|
||||
let mut exhausted = false;
|
||||
|
||||
@@ -266,10 +260,33 @@ impl AsyncConsumer for MassMessageConsumer {
|
||||
|
||||
debug!("targets: {:?}", targets);
|
||||
|
||||
self.fire_notification_for_users(&push, &targets).await;
|
||||
self.fire_notification_for_users(&push, &targets).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for MassMessageConsumer {
|
||||
/// This consumer handles adding mentions for all the users affected by a mass mention ping, and then sends out push notifications
|
||||
async fn consume(
|
||||
&mut self,
|
||||
channel: &Channel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
if let Err(err) = self
|
||||
.consume_event(channel, deliver, basic_properties, content)
|
||||
.await
|
||||
{
|
||||
revolt_config::capture_anyhow(&err);
|
||||
eprintln!("Failed to process mass message event: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use amqprs::{
|
||||
consumer::AsyncConsumer,
|
||||
BasicProperties, Deliver,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use log::debug;
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
@@ -54,21 +55,16 @@ impl MessageConsumer {
|
||||
channel: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for MessageConsumer {
|
||||
/// This consumer handles delegating messages into their respective platform queues.
|
||||
async fn consume(
|
||||
async fn consume_event(
|
||||
&mut self,
|
||||
channel: &Channel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
_channel: &Channel,
|
||||
_deliver: Deliver,
|
||||
_basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
let content = String::from_utf8(content).unwrap();
|
||||
let payload: MessageSentPayload = serde_json::from_str(content.as_str()).unwrap();
|
||||
) -> Result<()> {
|
||||
let content = String::from_utf8(content)?;
|
||||
let payload: MessageSentPayload = serde_json::from_str(content.as_str())?;
|
||||
|
||||
debug!("Received message event on origin");
|
||||
|
||||
@@ -117,11 +113,34 @@ impl AsyncConsumer for MessageConsumer {
|
||||
.insert("endpoint".to_string(), sub.endpoint.clone());
|
||||
}
|
||||
|
||||
let payload = serde_json::to_string(&sendable).unwrap();
|
||||
let payload = serde_json::to_string(&sendable)?;
|
||||
|
||||
publish_message(self, payload.into(), args).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for MessageConsumer {
|
||||
/// This consumer handles delegating messages into their respective platform queues.
|
||||
async fn consume(
|
||||
&mut self,
|
||||
channel: &Channel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
if let Err(err) = self
|
||||
.consume_event(channel, deliver, basic_properties, content)
|
||||
.await
|
||||
{
|
||||
revolt_config::capture_anyhow(&err);
|
||||
eprintln!("Failed to process message event: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::{borrow::Cow, collections::BTreeMap, io::Cursor};
|
||||
|
||||
use amqprs::{channel::Channel as AmqpChannel, consumer::AsyncConsumer, BasicProperties, Deliver};
|
||||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use base64::{
|
||||
engine::{self},
|
||||
@@ -122,20 +123,16 @@ impl ApnsOutboundConsumer {
|
||||
|
||||
Ok(ApnsOutboundConsumer { db, client })
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for ApnsOutboundConsumer {
|
||||
async fn consume(
|
||||
async fn consume_event(
|
||||
&mut self,
|
||||
channel: &AmqpChannel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
_channel: &AmqpChannel,
|
||||
_deliver: Deliver,
|
||||
_basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
let content = String::from_utf8(content).unwrap();
|
||||
let payload: PayloadToService = serde_json::from_str(content.as_str()).unwrap();
|
||||
) -> Result<()> {
|
||||
let content = String::from_utf8(content)?;
|
||||
let payload: PayloadToService = serde_json::from_str(content.as_str())?;
|
||||
|
||||
let payload_options = NotificationOptions {
|
||||
apns_id: None,
|
||||
@@ -159,7 +156,7 @@ impl AsyncConsumer for ApnsOutboundConsumer {
|
||||
alert.from_user.username, alert.from_user.discriminator
|
||||
)))
|
||||
.clone()
|
||||
.unwrap(),
|
||||
.ok_or_else(|| anyhow!("missing name"))?,
|
||||
)];
|
||||
|
||||
let apn_payload = Payload {
|
||||
@@ -205,7 +202,7 @@ impl AsyncConsumer for ApnsOutboundConsumer {
|
||||
alert.accepted_user.username, alert.accepted_user.discriminator
|
||||
)))
|
||||
.clone()
|
||||
.unwrap(),
|
||||
.ok_or_else(|| anyhow!("missing name"))?,
|
||||
)];
|
||||
|
||||
let apn_payload = Payload {
|
||||
@@ -355,5 +352,27 @@ impl AsyncConsumer for ApnsOutboundConsumer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for ApnsOutboundConsumer {
|
||||
async fn consume(
|
||||
&mut self,
|
||||
channel: &AmqpChannel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
if let Err(err) = self
|
||||
.consume_event(channel, deliver, basic_properties, content)
|
||||
.await
|
||||
{
|
||||
revolt_config::capture_anyhow(&err);
|
||||
eprintln!("Failed to process APN event: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::{collections::HashMap, time::Duration};
|
||||
|
||||
use amqprs::{channel::Channel as AmqpChannel, consumer::AsyncConsumer, BasicProperties, Deliver};
|
||||
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use async_trait::async_trait;
|
||||
use fcm_v1::{
|
||||
android::AndroidConfig,
|
||||
@@ -64,22 +65,16 @@ impl FcmOutboundConsumer {
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for FcmOutboundConsumer {
|
||||
async fn consume(
|
||||
async fn consume_event(
|
||||
&mut self,
|
||||
channel: &AmqpChannel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
_channel: &AmqpChannel,
|
||||
_deliver: Deliver,
|
||||
_basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
let content = String::from_utf8(content).unwrap();
|
||||
let payload: PayloadToService = serde_json::from_str(content.as_str()).unwrap();
|
||||
|
||||
let config = revolt_config::config().await;
|
||||
) -> Result<()> {
|
||||
let content = String::from_utf8(content)?;
|
||||
let payload: PayloadToService = serde_json::from_str(content.as_str())?;
|
||||
|
||||
#[allow(clippy::needless_late_init)]
|
||||
let resp: Result<Message, FcmError>;
|
||||
@@ -94,7 +89,7 @@ impl AsyncConsumer for FcmOutboundConsumer {
|
||||
alert.from_user.username, alert.from_user.discriminator
|
||||
)))
|
||||
.clone()
|
||||
.unwrap();
|
||||
.ok_or_else(|| anyhow!("missing name"))?;
|
||||
|
||||
let mut data = HashMap::new();
|
||||
data.insert(
|
||||
@@ -122,7 +117,7 @@ impl AsyncConsumer for FcmOutboundConsumer {
|
||||
alert.accepted_user.username, alert.accepted_user.discriminator
|
||||
)))
|
||||
.clone()
|
||||
.unwrap();
|
||||
.ok_or_else(|| anyhow!("missing name"))?;
|
||||
|
||||
let mut data: HashMap<String, Value> = HashMap::new();
|
||||
data.insert(
|
||||
@@ -175,7 +170,7 @@ impl AsyncConsumer for FcmOutboundConsumer {
|
||||
}
|
||||
|
||||
PayloadKind::BadgeUpdate(_) => {
|
||||
panic!("FCM cannot handle badge updates, and they should not be sent here.")
|
||||
bail!("FCM cannot handle badge updates and they should not be sent here.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,5 +190,27 @@ impl AsyncConsumer for FcmOutboundConsumer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for FcmOutboundConsumer {
|
||||
async fn consume(
|
||||
&mut self,
|
||||
channel: &AmqpChannel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
if let Err(err) = self
|
||||
.consume_event(channel, deliver, basic_properties, content)
|
||||
.await
|
||||
{
|
||||
revolt_config::capture_anyhow(&err);
|
||||
eprintln!("Failed to process FCM event: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ use std::collections::HashMap;
|
||||
|
||||
use amqprs::{channel::Channel as AmqpChannel, consumer::AsyncConsumer, BasicProperties, Deliver};
|
||||
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use async_trait::async_trait;
|
||||
use base64::{
|
||||
engine::{self},
|
||||
Engine as _,
|
||||
};
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
// use revolt_models::v0::{Channel, PushNotification};
|
||||
use web_push::{
|
||||
ContentEncoding, IsahcWebPushClient, SubscriptionInfo, SubscriptionKeys, VapidSignatureBuilder,
|
||||
WebPushClient, WebPushError, WebPushMessageBuilder,
|
||||
@@ -21,11 +21,11 @@ pub struct VapidOutboundConsumer {
|
||||
}
|
||||
|
||||
impl VapidOutboundConsumer {
|
||||
pub async fn new(db: Database) -> Result<VapidOutboundConsumer, &'static str> {
|
||||
pub async fn new(db: Database) -> Result<VapidOutboundConsumer> {
|
||||
let config = revolt_config::config().await;
|
||||
|
||||
if config.pushd.vapid.private_key.is_empty() | config.pushd.vapid.public_key.is_empty() {
|
||||
return Err("No Vapid keys present");
|
||||
bail!("no Vapid keys present");
|
||||
}
|
||||
|
||||
let web_push_private_key = engine::general_purpose::URL_SAFE_NO_PAD
|
||||
@@ -38,28 +38,30 @@ impl VapidOutboundConsumer {
|
||||
pkey: web_push_private_key,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for VapidOutboundConsumer {
|
||||
async fn consume(
|
||||
async fn consume_event(
|
||||
&mut self,
|
||||
channel: &AmqpChannel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
_channel: &AmqpChannel,
|
||||
_deliver: Deliver,
|
||||
_basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
let content = String::from_utf8(content).unwrap();
|
||||
let payload: PayloadToService = serde_json::from_str(content.as_str()).unwrap();
|
||||
|
||||
let config = revolt_config::config().await;
|
||||
) -> Result<()> {
|
||||
let content = String::from_utf8(content)?;
|
||||
let payload: PayloadToService = serde_json::from_str(content.as_str())?;
|
||||
|
||||
let subscription = SubscriptionInfo {
|
||||
endpoint: payload.extras.get("endpoint").unwrap().clone(),
|
||||
endpoint: payload
|
||||
.extras
|
||||
.get("endpoint")
|
||||
.ok_or_else(|| anyhow!("missing endpoint"))?
|
||||
.clone(),
|
||||
keys: SubscriptionKeys {
|
||||
auth: payload.token,
|
||||
p256dh: payload.extras.get("p256dh").unwrap().clone(),
|
||||
p256dh: payload
|
||||
.extras
|
||||
.get("p256dh")
|
||||
.ok_or_else(|| anyhow!("missing p256dh"))?
|
||||
.clone(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -76,12 +78,12 @@ impl AsyncConsumer for VapidOutboundConsumer {
|
||||
alert.from_user.username, alert.from_user.discriminator
|
||||
)))
|
||||
.clone()
|
||||
.unwrap();
|
||||
.ok_or_else(|| anyhow!("missing name"))?;
|
||||
|
||||
let mut body = HashMap::new();
|
||||
body.insert("body", format!("{} sent you a friend request", name));
|
||||
|
||||
payload_body = serde_json::to_string(&body).unwrap();
|
||||
payload_body = serde_json::to_string(&body)?;
|
||||
}
|
||||
PayloadKind::FRAccepted(alert) => {
|
||||
let name = alert
|
||||
@@ -92,21 +94,21 @@ impl AsyncConsumer for VapidOutboundConsumer {
|
||||
alert.accepted_user.username, alert.accepted_user.discriminator
|
||||
)))
|
||||
.clone()
|
||||
.unwrap();
|
||||
.ok_or_else(|| anyhow!("missing name"))?;
|
||||
|
||||
let mut body = HashMap::new();
|
||||
body.insert("body", format!("{} accepted your friend request", name));
|
||||
|
||||
payload_body = serde_json::to_string(&body).unwrap();
|
||||
payload_body = serde_json::to_string(&body)?;
|
||||
}
|
||||
PayloadKind::Generic(alert) => {
|
||||
payload_body = serde_json::to_string(&alert).unwrap();
|
||||
payload_body = serde_json::to_string(&alert)?;
|
||||
}
|
||||
PayloadKind::MessageNotification(alert) => {
|
||||
payload_body = serde_json::to_string(&alert).unwrap();
|
||||
payload_body = serde_json::to_string(&alert)?;
|
||||
}
|
||||
PayloadKind::BadgeUpdate(_) => {
|
||||
panic!("Vapid cannot handle badge updates, and they should not be sent here.")
|
||||
bail!("Vapid cannot handle badge updates and they should not be sent here.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,28 +124,40 @@ impl AsyncConsumer for VapidOutboundConsumer {
|
||||
Ok(msg) => {
|
||||
if let Err(err) = self.client.send(msg).await {
|
||||
if err == WebPushError::Unauthorized {
|
||||
if let Err(err) = self
|
||||
.db
|
||||
self.db
|
||||
.remove_push_subscription_by_session_id(&payload.session_id)
|
||||
.await
|
||||
{
|
||||
revolt_config::capture_error(&err);
|
||||
}
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Err(err) => {
|
||||
revolt_config::capture_error(&err);
|
||||
}
|
||||
Err(err) => Err(err.into()),
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
revolt_config::capture_error(&err);
|
||||
}
|
||||
Err(err) => Err(err.into()),
|
||||
},
|
||||
Err(err) => {
|
||||
revolt_config::capture_error(&err);
|
||||
}
|
||||
Err(err) => Err(err.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[async_trait]
|
||||
impl AsyncConsumer for VapidOutboundConsumer {
|
||||
async fn consume(
|
||||
&mut self,
|
||||
channel: &AmqpChannel,
|
||||
deliver: Deliver,
|
||||
basic_properties: BasicProperties,
|
||||
content: Vec<u8>,
|
||||
) {
|
||||
if let Err(err) = self
|
||||
.consume_event(channel, deliver, basic_properties, content)
|
||||
.await
|
||||
{
|
||||
revolt_config::capture_anyhow(&err);
|
||||
eprintln!("Failed to process Vapid event: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ use consumers::{
|
||||
|
||||
#[tokio::main(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn main() {
|
||||
let config = config().await;
|
||||
pretty_env_logger::init();
|
||||
// Configure logging and environment
|
||||
revolt_config::configure!(pushd);
|
||||
|
||||
// Setup database
|
||||
let db = revolt_database::DatabaseInfo::Auto.connect().await.unwrap();
|
||||
@@ -52,6 +52,8 @@ async fn main() {
|
||||
// This'll require some interesting shimming if we need to add more events once this is in prod (different payloads between prod and test),
|
||||
// but that sounds like a problem for future us.
|
||||
|
||||
let config = config().await;
|
||||
|
||||
// inbound: generic
|
||||
connections.push(
|
||||
make_queue_and_consume(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-delta"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
license = "AGPL-3.0-or-later"
|
||||
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
||||
edition = "2018"
|
||||
@@ -56,7 +56,7 @@ lettre = "0.10.0-alpha.4"
|
||||
rocket = { version = "0.5.1", default-features = false, features = ["json"] }
|
||||
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", rev = "072d90359b23e9b291df6b672c07c93de9c46011" }
|
||||
rocket_empty = { version = "0.1.1", features = ["schema"] }
|
||||
rocket_authifier = { version = "1.0.13" }
|
||||
rocket_authifier = { version = "1.0.15" }
|
||||
rocket_prometheus = "0.10.0-rc.3"
|
||||
|
||||
# spec generation
|
||||
@@ -67,7 +67,7 @@ revolt_rocket_okapi = { version = "0.10.0", features = ["swagger"] }
|
||||
amqprs = { version = "1.7.0" }
|
||||
|
||||
# core
|
||||
authifier = "1.0.13"
|
||||
authifier = "1.0.15"
|
||||
revolt-config = { path = "../core/config" }
|
||||
revolt-database = { path = "../core/database", features = [
|
||||
"rocket-impl",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use futures::future::join_all;
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Channel, Database, User,
|
||||
|
||||
@@ -8,7 +8,6 @@ use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::{serde::json::Json, State};
|
||||
use rocket_empty::EmptyResponse;
|
||||
use serde::Deserialize;
|
||||
use validator::Validate;
|
||||
|
||||
/// # Bulk Delete Messages
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use iso8601_timestamp::Timestamp;
|
||||
use revolt_config::config;
|
||||
use revolt_database::{
|
||||
tasks,
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Channel, Database, User,
|
||||
Database, User,
|
||||
};
|
||||
use revolt_models::v0;
|
||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission, Override};
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::{serde::json::Json, State};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// # Set Role Permission
|
||||
///
|
||||
|
||||
@@ -3,7 +3,7 @@ use revolt_database::{
|
||||
Database, EmojiParent, User,
|
||||
};
|
||||
use revolt_permissions::{calculate_server_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
use revolt_result::Result;
|
||||
|
||||
use rocket::State;
|
||||
use rocket_empty::EmptyResponse;
|
||||
@@ -18,7 +18,6 @@ pub async fn delete_emoji(
|
||||
user: User,
|
||||
emoji_id: Reference,
|
||||
) -> Result<EmptyResponse> {
|
||||
|
||||
// Fetch the emoji
|
||||
let emoji = emoji_id.as_emoji(db).await?;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use revolt_config::{config, Settings};
|
||||
use revolt_config::Settings;
|
||||
use revolt_rocket_okapi::{revolt_okapi::openapi3::OpenApi, settings::OpenApiSettings};
|
||||
pub use rocket::http::Status;
|
||||
pub use rocket::response::Redirect;
|
||||
@@ -9,6 +9,7 @@ mod channels;
|
||||
mod customisation;
|
||||
mod invites;
|
||||
mod onboard;
|
||||
mod policy;
|
||||
mod push;
|
||||
mod root;
|
||||
mod safety;
|
||||
@@ -36,6 +37,7 @@ pub fn mount(config: Settings, mut rocket: Rocket<Build>) -> Rocket<Build> {
|
||||
"/auth/session" => rocket_authifier::routes::session::routes(),
|
||||
"/auth/mfa" => rocket_authifier::routes::mfa::routes(),
|
||||
"/onboard" => onboard::routes(),
|
||||
"/policy" => policy::routes(),
|
||||
"/push" => push::routes(),
|
||||
"/sync" => sync::routes(),
|
||||
"/webhooks" => webhooks::routes()
|
||||
@@ -56,6 +58,7 @@ pub fn mount(config: Settings, mut rocket: Rocket<Build>) -> Rocket<Build> {
|
||||
"/auth/session" => rocket_authifier::routes::session::routes(),
|
||||
"/auth/mfa" => rocket_authifier::routes::mfa::routes(),
|
||||
"/onboard" => onboard::routes(),
|
||||
"/policy" => policy::routes(),
|
||||
"/push" => push::routes(),
|
||||
"/sync" => sync::routes()
|
||||
};
|
||||
|
||||
17
crates/delta/src/routes/policy/acknowledge_policy_changes.rs
Normal file
17
crates/delta/src/routes/policy/acknowledge_policy_changes.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use revolt_database::{events::client::EventV1, Database, Report, Snapshot, SnapshotContent, User};
|
||||
use revolt_models::v0::{ReportStatus, ReportedContent};
|
||||
use revolt_result::{create_error, Result};
|
||||
use serde::Deserialize;
|
||||
use ulid::Ulid;
|
||||
use validator::Validate;
|
||||
|
||||
use rocket::{serde::json::Json, State};
|
||||
|
||||
/// # Acknowledge Policy Changes
|
||||
///
|
||||
/// Accept/acknowledge changes to platform policy.
|
||||
#[openapi(tag = "Policy")]
|
||||
#[post("/acknowledge")]
|
||||
pub async fn acknowledge_policy_changes(db: &State<Database>, user: User) -> Result<()> {
|
||||
db.acknowledge_policy_changes(&user.id).await
|
||||
}
|
||||
11
crates/delta/src/routes/policy/mod.rs
Normal file
11
crates/delta/src/routes/policy/mod.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use revolt_rocket_okapi::revolt_okapi::openapi3::OpenApi;
|
||||
use rocket::Route;
|
||||
|
||||
mod acknowledge_policy_changes;
|
||||
|
||||
pub fn routes() -> (Vec<Route>, OpenApi) {
|
||||
openapi_get_routes_spec![
|
||||
// Policy
|
||||
acknowledge_policy_changes::acknowledge_policy_changes,
|
||||
]
|
||||
}
|
||||
@@ -4,12 +4,9 @@ use revolt_database::{
|
||||
};
|
||||
use revolt_models::v0;
|
||||
|
||||
use revolt_permissions::{
|
||||
calculate_channel_permissions, calculate_server_permissions, ChannelPermission,
|
||||
};
|
||||
use revolt_permissions::{calculate_server_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::{serde::json::Json, State};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
/// # Ban User
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Database, PartialServer, Server, User,
|
||||
Database, PartialServer, User,
|
||||
};
|
||||
use revolt_models::v0;
|
||||
use revolt_permissions::{
|
||||
|
||||
@@ -6,7 +6,6 @@ use revolt_models::v0;
|
||||
use revolt_permissions::{calculate_server_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::{serde::json::Json, State};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
/// # Edit Role
|
||||
|
||||
@@ -2,7 +2,6 @@ use revolt_database::{util::reference::Reference, Database};
|
||||
use revolt_models::v0;
|
||||
use revolt_result::Result;
|
||||
use rocket::{serde::json::Json, State};
|
||||
use serde::Serialize;
|
||||
|
||||
/// # Fetch User Flags
|
||||
///
|
||||
|
||||
@@ -588,6 +588,7 @@ pub enum PullRequestEvent {
|
||||
#[derive(Debug)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum BaseEvent {
|
||||
#[allow(dead_code)]
|
||||
Star(StarEvent),
|
||||
Ping,
|
||||
Push(PushEvent),
|
||||
@@ -829,7 +830,7 @@ pub async fn webhook_execute_github(
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n"),
|
||||
1000
|
||||
1000,
|
||||
);
|
||||
|
||||
SendableEmbed {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-autumn"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-or-later"
|
||||
|
||||
@@ -43,12 +43,12 @@ tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
|
||||
# Core crates
|
||||
revolt-files = { version = "0.8.5", path = "../../core/files" }
|
||||
revolt-config = { version = "0.8.5", path = "../../core/config" }
|
||||
revolt-database = { version = "0.8.5", path = "../../core/database", features = [
|
||||
revolt-files = { version = "0.8.7", path = "../../core/files" }
|
||||
revolt-config = { version = "0.8.7", path = "../../core/config" }
|
||||
revolt-database = { version = "0.8.7", path = "../../core/database", features = [
|
||||
"axum-impl",
|
||||
] }
|
||||
revolt-result = { version = "0.8.5", path = "../../core/result", features = [
|
||||
revolt-result = { version = "0.8.7", path = "../../core/result", features = [
|
||||
"utoipa",
|
||||
"axum",
|
||||
] }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-january"
|
||||
version = "0.8.5"
|
||||
version = "0.8.7"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-or-later"
|
||||
|
||||
@@ -32,13 +32,13 @@ tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
|
||||
# Core crates
|
||||
revolt-config = { version = "0.8.5", path = "../../core/config" }
|
||||
revolt-models = { version = "0.8.5", path = "../../core/models" }
|
||||
revolt-result = { version = "0.8.5", path = "../../core/result", features = [
|
||||
revolt-config = { version = "0.8.7", path = "../../core/config" }
|
||||
revolt-models = { version = "0.8.7", path = "../../core/models" }
|
||||
revolt-result = { version = "0.8.7", path = "../../core/result", features = [
|
||||
"utoipa",
|
||||
"axum",
|
||||
] }
|
||||
revolt-files = { version = "0.8.5", path = "../../core/files" }
|
||||
revolt-files = { version = "0.8.7", path = "../../core/files" }
|
||||
|
||||
# Axum / web server
|
||||
axum = { version = "0.7.5" }
|
||||
|
||||
Reference in New Issue
Block a user