Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43e45aef3f | ||
|
|
c5880596a4 | ||
|
|
59a644891d | ||
|
|
a326cdc736 |
No files matched your search
Generated
+47
-42
@@ -871,12 +871,6 @@ version = "0.15.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dtoa"
|
|
||||||
version = "0.4.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dyn-clone"
|
name = "dyn-clone"
|
||||||
version = "1.0.5"
|
version = "1.0.5"
|
||||||
@@ -1831,6 +1825,27 @@ version = "2.5.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "metrics"
|
||||||
|
version = "0.18.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2e52eb6380b6d2a10eb3434aec0885374490f5b82c8aaf5cd487a183c98be834"
|
||||||
|
dependencies = [
|
||||||
|
"ahash",
|
||||||
|
"metrics-macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "metrics-macros"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "49e30813093f757be5cf21e50389a24dc7dbb22c49f23b7e8f51d69b508a5ffa"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote 1.0.18",
|
||||||
|
"syn 1.0.107",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mime"
|
name = "mime"
|
||||||
version = "0.3.16"
|
version = "0.3.16"
|
||||||
@@ -1897,9 +1912,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mobc"
|
name = "mobc"
|
||||||
version = "0.7.3"
|
version = "0.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7f76d2f2e2dcbb00a8d3b2b09f026a74a82693ea52cd071647aa6cfa7f1ff37e"
|
checksum = "fc79c4a77e312fee9c7bd4b957c12ad1196db73c4a81e5c0b13f02083c4f7f2f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -1908,17 +1923,21 @@ dependencies = [
|
|||||||
"futures-timer",
|
"futures-timer",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"log",
|
"log",
|
||||||
|
"metrics",
|
||||||
|
"thiserror",
|
||||||
"tokio 1.18.2",
|
"tokio 1.18.2",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mobc-redis"
|
name = "mobc-redis"
|
||||||
version = "0.7.0"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e7b5db77b37c9224d5b9949b214041ea3e1c15b6b1e5dd24a5acb8e73975d6d6"
|
checksum = "7bd8e2fd6bf7e35263b86662e663a9496a0352ceddd413b6c33313c36d5068fd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mobc",
|
"mobc",
|
||||||
"redis 0.19.0",
|
"redis 0.22.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2624,57 +2643,55 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redis"
|
name = "redis"
|
||||||
version = "0.19.0"
|
version = "0.22.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/insertish/redis-rs?rev=6575a6b1c09eb8c9cc7f0082d95fe6b8f903c4d7#6575a6b1c09eb8c9cc7f0082d95fe6b8f903c4d7"
|
||||||
checksum = "1a6ddfecac9391fed21cce10e83c65fa4abafd77df05c98b1c647c65374ce9b3"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bytes 1.1.0",
|
"bytes 1.1.0",
|
||||||
"combine",
|
"combine",
|
||||||
"dtoa",
|
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"itoa 0.4.8",
|
"itoa 1.0.2",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pin-project-lite 0.2.9",
|
"pin-project-lite 0.2.9",
|
||||||
"sha1",
|
"ryu",
|
||||||
|
"sha1_smol",
|
||||||
"tokio 1.18.2",
|
"tokio 1.18.2",
|
||||||
"tokio-util 0.6.10",
|
"tokio-util 0.7.2",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redis"
|
name = "redis"
|
||||||
version = "0.21.5"
|
version = "0.23.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1a80b5f38d7f5a020856a0e16e40a9cfabf88ae8f0e4c2dcd8a3114c1e470852"
|
checksum = "3ea8c51b5dc1d8e5fd3350ec8167f464ec0995e79f2e90a075b63371500d557f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bytes 1.1.0",
|
"bytes 1.1.0",
|
||||||
"combine",
|
"combine",
|
||||||
"dtoa",
|
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"itoa 0.4.8",
|
"itoa 1.0.2",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pin-project-lite 0.2.9",
|
"pin-project-lite 0.2.9",
|
||||||
"sha1",
|
"ryu",
|
||||||
"tokio 1.18.2",
|
"tokio 1.18.2",
|
||||||
"tokio-util 0.6.10",
|
"tokio-util 0.7.2",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redis-kiss"
|
name = "redis-kiss"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0d4f2f48fb776a308331c4a1ecb3a7b7b99f4d46c6beb2fc03db2da0f63fcad6"
|
checksum = "58605cfd83a2146161de13bb253f24db25eef6919b35403fc90f508ef89bec92"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"mobc",
|
"mobc",
|
||||||
"mobc-redis",
|
"mobc-redis",
|
||||||
"redis 0.21.5",
|
"redis 0.23.0",
|
||||||
"rmp-serde",
|
"rmp-serde",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -2792,7 +2809,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-bonfire"
|
name = "revolt-bonfire"
|
||||||
version = "0.5.18"
|
version = "0.5.19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
@@ -2808,7 +2825,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-delta"
|
name = "revolt-delta"
|
||||||
version = "0.5.18"
|
version = "0.5.19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-channel",
|
"async-channel",
|
||||||
"async-std",
|
"async-std",
|
||||||
@@ -2823,12 +2840,9 @@ dependencies = [
|
|||||||
"linkify 0.6.0",
|
"linkify 0.6.0",
|
||||||
"log",
|
"log",
|
||||||
"lru",
|
"lru",
|
||||||
"mobc",
|
|
||||||
"mobc-redis",
|
|
||||||
"nanoid",
|
"nanoid",
|
||||||
"num_enum",
|
"num_enum",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"redis 0.21.5",
|
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"revolt-quark",
|
"revolt-quark",
|
||||||
@@ -2847,7 +2861,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revolt-quark"
|
name = "revolt-quark"
|
||||||
version = "0.5.18"
|
version = "0.5.19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-lock",
|
"async-lock",
|
||||||
"async-recursion",
|
"async-recursion",
|
||||||
@@ -3471,15 +3485,6 @@ dependencies = [
|
|||||||
"digest 0.10.3",
|
"digest 0.10.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha1"
|
|
||||||
version = "0.6.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770"
|
|
||||||
dependencies = [
|
|
||||||
"sha1_smol",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha1_smol"
|
name = "sha1_smol"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
|||||||
@@ -1,2 +1,6 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["crates/*"]
|
members = ["crates/*"]
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
# mobc-redis = { git = "https://github.com/insertish/mobc", rev = "8b880bb59f2ba80b4c7bc40c649c113d8857a186" }
|
||||||
|
redis = { git = "https://github.com/insertish/redis-rs", rev = "6575a6b1c09eb8c9cc7f0082d95fe6b8f903c4d7" }
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-bonfire"
|
name = "revolt-bonfire"
|
||||||
version = "0.5.18"
|
version = "0.5.19"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-delta"
|
name = "revolt-delta"
|
||||||
version = "0.5.18"
|
version = "0.5.19"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
authors = ["Paul Makles <paulmakles@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -43,11 +43,6 @@ async-std = { version = "1.8.0", features = ["tokio1", "tokio02", "attributes"]
|
|||||||
# internal util
|
# internal util
|
||||||
lettre = "0.10.0-alpha.4"
|
lettre = "0.10.0-alpha.4"
|
||||||
|
|
||||||
# redis
|
|
||||||
redis = { version = "0.21.2", features = ["async-std-comp"] }
|
|
||||||
mobc = { version = "0.7.3" }
|
|
||||||
mobc-redis = { version = "0.7.0", default-features = false, features = ["async-std-comp"] }
|
|
||||||
|
|
||||||
# web
|
# web
|
||||||
rocket = { version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
rocket = { version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
||||||
rocket_empty = { version = "0.1.1", features = ["schema"] }
|
rocket_empty = { version = "0.1.1", features = ["schema"] }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use revolt_quark::{
|
use revolt_quark::{
|
||||||
models::{Invite, User},
|
models::{Invite, User},
|
||||||
perms, Db, Error, Permission, Ref, Result,
|
perms, Db, Permission, Ref, Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
use rocket::serde::json::Json;
|
use rocket::serde::json::Json;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "revolt-quark"
|
name = "revolt-quark"
|
||||||
version = "0.5.18"
|
version = "0.5.19"
|
||||||
license = "AGPL-3.0-or-later"
|
license = "AGPL-3.0-or-later"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ revolt_okapi = "0.9.1"
|
|||||||
revolt_rocket_okapi = { version = "0.9.1", features = [ "swagger" ] }
|
revolt_rocket_okapi = { version = "0.9.1", features = [ "swagger" ] }
|
||||||
|
|
||||||
# Databases
|
# Databases
|
||||||
redis-kiss = { version = "0.1.3" }
|
redis-kiss = { version = "0.1.4" }
|
||||||
mongodb = { optional = true, version = "2.1.0", default-features = false }
|
mongodb = { optional = true, version = "2.1.0", default-features = false }
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ impl State {
|
|||||||
let mut user = self.clone_user();
|
let mut user = self.clone_user();
|
||||||
|
|
||||||
// Find all relationships to the user.
|
// Find all relationships to the user.
|
||||||
let mut user_ids: Vec<String> = user
|
let mut user_ids: HashSet<String> = user
|
||||||
.relations
|
.relations
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|arr| arr.iter().map(|x| x.id.to_string()).collect())
|
.map(|arr| arr.iter().map(|x| x.id.to_string()).collect())
|
||||||
@@ -128,14 +128,15 @@ impl State {
|
|||||||
for channel in &channels {
|
for channel in &channels {
|
||||||
match channel {
|
match channel {
|
||||||
Channel::DirectMessage { recipients, .. } | Channel::Group { recipients, .. } => {
|
Channel::DirectMessage { recipients, .. } | Channel::Group { recipients, .. } => {
|
||||||
user_ids.append(&mut recipients.clone());
|
user_ids.extend(&mut recipients.clone().into_iter());
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch presence data for known users.
|
// Fetch presence data for known users.
|
||||||
let online_ids = presence_filter_online(&user_ids).await;
|
let online_ids =
|
||||||
|
presence_filter_online(&user_ids.iter().cloned().collect::<Vec<String>>()).await;
|
||||||
user.online = Some(true);
|
user.online = Some(true);
|
||||||
|
|
||||||
// Fetch user data.
|
// Fetch user data.
|
||||||
|
|||||||
@@ -305,12 +305,12 @@ impl IntoUsers for Message {
|
|||||||
|
|
||||||
impl IntoUsers for Vec<Message> {
|
impl IntoUsers for Vec<Message> {
|
||||||
fn get_user_ids(&self) -> Vec<String> {
|
fn get_user_ids(&self) -> Vec<String> {
|
||||||
let mut ids = vec![];
|
let mut ids = HashSet::new();
|
||||||
for message in self {
|
for message in self {
|
||||||
ids.append(&mut message.get_user_ids());
|
ids.extend(&mut message.get_user_ids().into_iter());
|
||||||
}
|
}
|
||||||
|
|
||||||
ids
|
ids.into_iter().collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,3 +10,4 @@ pub static REGION_ID: Lazy<u16> = Lazy::new(|| {
|
|||||||
});
|
});
|
||||||
|
|
||||||
pub static REGION_KEY: Lazy<String> = Lazy::new(|| format!("region{}", &*REGION_ID));
|
pub static REGION_KEY: Lazy<String> = Lazy::new(|| format!("region{}", &*REGION_ID));
|
||||||
|
pub static ONLINE_SET: &str = "online";
|
||||||
@@ -11,7 +11,7 @@ use operations::{
|
|||||||
__get_set_size, __remove_from_set_string, __remove_from_set_u32,
|
__get_set_size, __remove_from_set_string, __remove_from_set_u32,
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::entry::REGION_KEY;
|
use self::entry::{ONLINE_SET, REGION_KEY};
|
||||||
|
|
||||||
/// Create a new presence session, returns the ID of this session
|
/// Create a new presence session, returns the ID of this session
|
||||||
pub async fn presence_create_session(user_id: &str, flags: u8) -> (bool, u32) {
|
pub async fn presence_create_session(user_id: &str, flags: u8) -> (bool, u32) {
|
||||||
@@ -29,6 +29,7 @@ pub async fn presence_create_session(user_id: &str, flags: u8) -> (bool, u32) {
|
|||||||
|
|
||||||
// Add session to user's sessions and to the region
|
// Add session to user's sessions and to the region
|
||||||
__add_to_set_u32(&mut conn, user_id, session_id).await;
|
__add_to_set_u32(&mut conn, user_id, session_id).await;
|
||||||
|
__add_to_set_string(&mut conn, ONLINE_SET, user_id).await;
|
||||||
__add_to_set_string(&mut conn, ®ION_KEY, &format!("{user_id}:{session_id}")).await;
|
__add_to_set_string(&mut conn, ®ION_KEY, &format!("{user_id}:{session_id}")).await;
|
||||||
info!("Created session for {user_id}, assigned them a session ID of {session_id}.");
|
info!("Created session for {user_id}, assigned them a session ID of {session_id}.");
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ async fn presence_delete_session_internal(
|
|||||||
// Return whether this was the last session
|
// Return whether this was the last session
|
||||||
let is_empty = __get_set_size(&mut conn, user_id).await == 0;
|
let is_empty = __get_set_size(&mut conn, user_id).await == 0;
|
||||||
if is_empty {
|
if is_empty {
|
||||||
|
__remove_from_set_string(&mut conn, ONLINE_SET, user_id).await;
|
||||||
info!("User ID {} just went offline.", &user_id);
|
info!("User ID {} just went offline.", &user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,14 +111,19 @@ pub async fn presence_filter_online(user_ids: &'_ [String]) -> HashSet<String> {
|
|||||||
|
|
||||||
// Otherwise, go ahead as normal.
|
// Otherwise, go ahead as normal.
|
||||||
if let Ok(mut conn) = get_connection().await {
|
if let Ok(mut conn) = get_connection().await {
|
||||||
let data: Vec<Option<Vec<u8>>> = conn.get(user_ids).await.unwrap_or_default();
|
// Ok so, if this breaks, that means we've lost the Redis patch which adds SMISMEMBER
|
||||||
|
// Currently it's patched in through a forked repository, investigate what happen to it
|
||||||
|
let data: Vec<bool> = conn
|
||||||
|
.sismember("online", user_ids)
|
||||||
|
.await
|
||||||
|
.expect("this shouldn't happen, please read this code! presence/mod.rs");
|
||||||
if data.is_empty() {
|
if data.is_empty() {
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We filter known values to figure out who is online.
|
// We filter known values to figure out who is online.
|
||||||
for i in 0..user_ids.len() {
|
for i in 0..user_ids.len() {
|
||||||
if data[i].is_some() {
|
if data[i] {
|
||||||
set.insert(user_ids[i].to_string());
|
set.insert(user_ids[i].to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user