Compare commits

..
16 changed files with 61 additions and 32 deletions
Generated
+8 -8
View File
@@ -3452,7 +3452,7 @@ dependencies = [
[[package]]
name = "revolt-bonfire"
version = "0.7.7"
version = "0.7.9"
dependencies = [
"async-channel 2.3.1",
"async-std",
@@ -3482,7 +3482,7 @@ dependencies = [
[[package]]
name = "revolt-config"
version = "0.7.7"
version = "0.7.9"
dependencies = [
"async-std",
"cached",
@@ -3498,7 +3498,7 @@ dependencies = [
[[package]]
name = "revolt-database"
version = "0.7.7"
version = "0.7.9"
dependencies = [
"async-lock",
"async-recursion",
@@ -3544,7 +3544,7 @@ dependencies = [
[[package]]
name = "revolt-delta"
version = "0.7.7"
version = "0.7.9"
dependencies = [
"async-channel 1.6.1",
"async-std",
@@ -3590,7 +3590,7 @@ dependencies = [
[[package]]
name = "revolt-models"
version = "0.7.7"
version = "0.7.9"
dependencies = [
"indexmap",
"iso8601-timestamp 0.2.11",
@@ -3607,7 +3607,7 @@ dependencies = [
[[package]]
name = "revolt-permissions"
version = "0.7.7"
version = "0.7.9"
dependencies = [
"async-std",
"async-trait",
@@ -3622,7 +3622,7 @@ dependencies = [
[[package]]
name = "revolt-presence"
version = "0.7.7"
version = "0.7.9"
dependencies = [
"async-std",
"log",
@@ -3633,7 +3633,7 @@ dependencies = [
[[package]]
name = "revolt-result"
version = "0.7.7"
version = "0.7.9"
dependencies = [
"revolt_okapi",
"revolt_rocket_okapi",
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-bonfire"
version = "0.7.7"
version = "0.7.9"
license = "AGPL-3.0-or-later"
edition = "2021"
@@ -41,7 +41,7 @@ revolt-result = { path = "../core/result" }
revolt-models = { path = "../core/models" }
revolt-config = { path = "../core/config" }
revolt-database = { path = "../core/database" }
revolt-permissions = { version = "0.7.7", path = "../core/permissions" }
revolt-permissions = { version = "0.7.9", path = "../core/permissions" }
revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] }
# redis
+9 -5
View File
@@ -3,6 +3,7 @@ use std::{collections::HashSet, net::SocketAddr, sync::Arc};
use async_tungstenite::WebSocketStream;
use authifier::AuthifierEvent;
use fred::{
error::{RedisError, RedisErrorKind},
interfaces::{ClientLike, EventInterface, PubsubInterface},
types::RedisConfig,
};
@@ -229,11 +230,14 @@ async fn listener(
// Handle Redis connection dropping
let (clean_up_s, clean_up_r) = async_channel::bounded(1);
let clean_up_s = Arc::new(Mutex::new(clean_up_s));
subscriber.on_error(move |_| {
let clean_up_s = clean_up_s.clone();
spawn(async move {
clean_up_s.lock().await.send(()).await.ok();
});
subscriber.on_error(move |err| {
if let RedisErrorKind::Canceled = err.kind() {
let clean_up_s = clean_up_s.clone();
spawn(async move {
clean_up_s.lock().await.send(()).await.ok();
});
}
Ok(())
});
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-config"
version = "0.7.7"
version = "0.7.9"
edition = "2021"
license = "MIT"
authors = ["Paul Makles <me@insrt.uk>"]
+2
View File
@@ -47,6 +47,8 @@ webhooks_enabled = false
[features.limits]
[features.limits.default]
outgoing_friend_requests = 10
group_size = 100
bots = 5
message_length = 2000
+2
View File
@@ -106,6 +106,8 @@ pub struct Api {
#[derive(Deserialize, Debug, Clone)]
pub struct FeaturesLimits {
pub outgoing_friend_requests: usize,
pub group_size: usize,
pub bots: usize,
pub message_length: usize,
+6 -6
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-database"
version = "0.7.7"
version = "0.7.9"
edition = "2021"
license = "AGPL-3.0-or-later"
authors = ["Paul Makles <me@insrt.uk>"]
@@ -23,13 +23,13 @@ default = ["mongodb", "async-std-runtime", "tasks"]
[dependencies]
# Core
revolt-config = { version = "0.7.7", path = "../config" }
revolt-result = { version = "0.7.7", path = "../result" }
revolt-models = { version = "0.7.7", path = "../models", features = [
revolt-config = { version = "0.7.9", path = "../config" }
revolt-result = { version = "0.7.9", path = "../result" }
revolt-models = { version = "0.7.9", path = "../models", features = [
"validator",
] }
revolt-presence = { version = "0.7.7", path = "../presence" }
revolt-permissions = { version = "0.7.7", path = "../permissions", features = [
revolt-presence = { version = "0.7.9", path = "../presence" }
revolt-permissions = { version = "0.7.9", path = "../permissions", features = [
"serde",
"bson",
] }
@@ -470,6 +470,24 @@ impl User {
/// Add another user as a friend
pub async fn add_friend(&mut self, db: &Database, target: &mut User) -> Result<()> {
let count = self
.relations
.as_ref()
.map(|relations| {
relations
.iter()
.filter(|r| matches!(r.status, RelationshipStatus::Outgoing))
.count()
})
.unwrap_or_default();
let config = config().await;
if count >= config.features.limits.default.outgoing_friend_requests {
return Err(create_error!(TooManyPendingFriendRequests {
max: config.features.limits.default.outgoing_friend_requests
}));
}
match self.relationship_with(&target.id) {
RelationshipStatus::User => Err(create_error!(NoEffect)),
RelationshipStatus::Friend => Err(create_error!(AlreadyFriends)),
+3 -3
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-models"
version = "0.7.7"
version = "0.7.9"
edition = "2021"
license = "MIT"
authors = ["Paul Makles <me@insrt.uk>"]
@@ -19,8 +19,8 @@ default = ["serde", "partials", "rocket"]
[dependencies]
# Core
revolt-config = { version = "0.7.7", path = "../config" }
revolt-permissions = { version = "0.7.7", path = "../permissions" }
revolt-config = { version = "0.7.9", path = "../config" }
revolt-permissions = { version = "0.7.9", path = "../permissions" }
# Utility
regex = "1"
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-permissions"
version = "0.7.7"
version = "0.7.9"
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.7.7", path = "../result" }
revolt-result = { version = "0.7.9", path = "../result" }
# Utility
auto_ops = "0.3.0"
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-presence"
version = "0.7.7"
version = "0.7.9"
edition = "2021"
license = "AGPL-3.0-or-later"
authors = ["Paul Makles <me@insrt.uk>"]
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-result"
version = "0.7.7"
version = "0.7.9"
edition = "2021"
license = "MIT"
authors = ["Paul Makles <me@insrt.uk>"]
+3
View File
@@ -60,6 +60,9 @@ pub enum ErrorType {
Blocked,
BlockedByOther,
NotFriends,
TooManyPendingFriendRequests {
max: usize,
},
// ? Channel related errors
UnknownChannel,
+1
View File
@@ -25,6 +25,7 @@ impl<'r> Responder<'r, 'static> for Error {
ErrorType::Blocked => Status::Conflict,
ErrorType::BlockedByOther => Status::Forbidden,
ErrorType::NotFriends => Status::Forbidden,
ErrorType::TooManyPendingFriendRequests { .. } => Status::BadRequest,
ErrorType::UnknownChannel => Status::NotFound,
ErrorType::UnknownMessage => Status::NotFound,
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "revolt-delta"
version = "0.7.7"
version = "0.7.9"
license = "AGPL-3.0-or-later"
authors = ["Paul Makles <paulmakles@gmail.com>"]
edition = "2018"
+1 -2
View File
@@ -47,8 +47,7 @@ pub async fn web() -> Rocket<Build> {
authifier::database::MongoDb(client.database("revolt")),
),
},
config: Default::default(),
// config: authifier_config().await,
config: authifier_config().await,
event_channel: Some(sender),
};