Compare commits

...
2 Commits
14 changed files with 51 additions and 25 deletions
Generated
+8 -8
View File
@@ -3452,7 +3452,7 @@ dependencies = [
[[package]] [[package]]
name = "revolt-bonfire" name = "revolt-bonfire"
version = "0.7.8" version = "0.7.9"
dependencies = [ dependencies = [
"async-channel 2.3.1", "async-channel 2.3.1",
"async-std", "async-std",
@@ -3482,7 +3482,7 @@ dependencies = [
[[package]] [[package]]
name = "revolt-config" name = "revolt-config"
version = "0.7.8" version = "0.7.9"
dependencies = [ dependencies = [
"async-std", "async-std",
"cached", "cached",
@@ -3498,7 +3498,7 @@ dependencies = [
[[package]] [[package]]
name = "revolt-database" name = "revolt-database"
version = "0.7.8" version = "0.7.9"
dependencies = [ dependencies = [
"async-lock", "async-lock",
"async-recursion", "async-recursion",
@@ -3544,7 +3544,7 @@ dependencies = [
[[package]] [[package]]
name = "revolt-delta" name = "revolt-delta"
version = "0.7.8" version = "0.7.9"
dependencies = [ dependencies = [
"async-channel 1.6.1", "async-channel 1.6.1",
"async-std", "async-std",
@@ -3590,7 +3590,7 @@ dependencies = [
[[package]] [[package]]
name = "revolt-models" name = "revolt-models"
version = "0.7.8" version = "0.7.9"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"iso8601-timestamp 0.2.11", "iso8601-timestamp 0.2.11",
@@ -3607,7 +3607,7 @@ dependencies = [
[[package]] [[package]]
name = "revolt-permissions" name = "revolt-permissions"
version = "0.7.8" version = "0.7.9"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-trait", "async-trait",
@@ -3622,7 +3622,7 @@ dependencies = [
[[package]] [[package]]
name = "revolt-presence" name = "revolt-presence"
version = "0.7.8" version = "0.7.9"
dependencies = [ dependencies = [
"async-std", "async-std",
"log", "log",
@@ -3633,7 +3633,7 @@ dependencies = [
[[package]] [[package]]
name = "revolt-result" name = "revolt-result"
version = "0.7.8" version = "0.7.9"
dependencies = [ dependencies = [
"revolt_okapi", "revolt_okapi",
"revolt_rocket_okapi", "revolt_rocket_okapi",
+2 -2
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "revolt-bonfire" name = "revolt-bonfire"
version = "0.7.8" version = "0.7.9"
license = "AGPL-3.0-or-later" license = "AGPL-3.0-or-later"
edition = "2021" edition = "2021"
@@ -41,7 +41,7 @@ revolt-result = { path = "../core/result" }
revolt-models = { path = "../core/models" } revolt-models = { path = "../core/models" }
revolt-config = { path = "../core/config" } revolt-config = { path = "../core/config" }
revolt-database = { path = "../core/database" } revolt-database = { path = "../core/database" }
revolt-permissions = { version = "0.7.8", path = "../core/permissions" } revolt-permissions = { version = "0.7.9", path = "../core/permissions" }
revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] } revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] }
# redis # redis
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "revolt-config" name = "revolt-config"
version = "0.7.8" version = "0.7.9"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
authors = ["Paul Makles <me@insrt.uk>"] authors = ["Paul Makles <me@insrt.uk>"]
+2
View File
@@ -47,6 +47,8 @@ webhooks_enabled = false
[features.limits] [features.limits]
[features.limits.default] [features.limits.default]
outgoing_friend_requests = 10
group_size = 100 group_size = 100
bots = 5 bots = 5
message_length = 2000 message_length = 2000
+2
View File
@@ -106,6 +106,8 @@ pub struct Api {
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
pub struct FeaturesLimits { pub struct FeaturesLimits {
pub outgoing_friend_requests: usize,
pub group_size: usize, pub group_size: usize,
pub bots: usize, pub bots: usize,
pub message_length: usize, pub message_length: usize,
+6 -6
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "revolt-database" name = "revolt-database"
version = "0.7.8" version = "0.7.9"
edition = "2021" edition = "2021"
license = "AGPL-3.0-or-later" license = "AGPL-3.0-or-later"
authors = ["Paul Makles <me@insrt.uk>"] authors = ["Paul Makles <me@insrt.uk>"]
@@ -23,13 +23,13 @@ default = ["mongodb", "async-std-runtime", "tasks"]
[dependencies] [dependencies]
# Core # Core
revolt-config = { version = "0.7.8", path = "../config" } revolt-config = { version = "0.7.9", path = "../config" }
revolt-result = { version = "0.7.8", path = "../result" } revolt-result = { version = "0.7.9", path = "../result" }
revolt-models = { version = "0.7.8", path = "../models", features = [ revolt-models = { version = "0.7.9", path = "../models", features = [
"validator", "validator",
] } ] }
revolt-presence = { version = "0.7.8", path = "../presence" } revolt-presence = { version = "0.7.9", path = "../presence" }
revolt-permissions = { version = "0.7.8", path = "../permissions", features = [ revolt-permissions = { version = "0.7.9", path = "../permissions", features = [
"serde", "serde",
"bson", "bson",
] } ] }
@@ -470,6 +470,24 @@ impl User {
/// Add another user as a friend /// Add another user as a friend
pub async fn add_friend(&mut self, db: &Database, target: &mut User) -> Result<()> { 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) { match self.relationship_with(&target.id) {
RelationshipStatus::User => Err(create_error!(NoEffect)), RelationshipStatus::User => Err(create_error!(NoEffect)),
RelationshipStatus::Friend => Err(create_error!(AlreadyFriends)), RelationshipStatus::Friend => Err(create_error!(AlreadyFriends)),
+3 -3
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "revolt-models" name = "revolt-models"
version = "0.7.8" version = "0.7.9"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
authors = ["Paul Makles <me@insrt.uk>"] authors = ["Paul Makles <me@insrt.uk>"]
@@ -19,8 +19,8 @@ default = ["serde", "partials", "rocket"]
[dependencies] [dependencies]
# Core # Core
revolt-config = { version = "0.7.8", path = "../config" } revolt-config = { version = "0.7.9", path = "../config" }
revolt-permissions = { version = "0.7.8", path = "../permissions" } revolt-permissions = { version = "0.7.9", path = "../permissions" }
# Utility # Utility
regex = "1" regex = "1"
+2 -2
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "revolt-permissions" name = "revolt-permissions"
version = "0.7.8" version = "0.7.9"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
authors = ["Paul Makles <me@insrt.uk>"] authors = ["Paul Makles <me@insrt.uk>"]
@@ -21,7 +21,7 @@ async-std = { version = "1.8.0", features = ["attributes"] }
[dependencies] [dependencies]
# Core # Core
revolt-result = { version = "0.7.8", path = "../result" } revolt-result = { version = "0.7.9", path = "../result" }
# Utility # Utility
auto_ops = "0.3.0" auto_ops = "0.3.0"
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "revolt-presence" name = "revolt-presence"
version = "0.7.8" version = "0.7.9"
edition = "2021" edition = "2021"
license = "AGPL-3.0-or-later" license = "AGPL-3.0-or-later"
authors = ["Paul Makles <me@insrt.uk>"] authors = ["Paul Makles <me@insrt.uk>"]
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "revolt-result" name = "revolt-result"
version = "0.7.8" version = "0.7.9"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
authors = ["Paul Makles <me@insrt.uk>"] authors = ["Paul Makles <me@insrt.uk>"]
+3
View File
@@ -60,6 +60,9 @@ pub enum ErrorType {
Blocked, Blocked,
BlockedByOther, BlockedByOther,
NotFriends, NotFriends,
TooManyPendingFriendRequests {
max: usize,
},
// ? Channel related errors // ? Channel related errors
UnknownChannel, UnknownChannel,
+1
View File
@@ -25,6 +25,7 @@ impl<'r> Responder<'r, 'static> for Error {
ErrorType::Blocked => Status::Conflict, ErrorType::Blocked => Status::Conflict,
ErrorType::BlockedByOther => Status::Forbidden, ErrorType::BlockedByOther => Status::Forbidden,
ErrorType::NotFriends => Status::Forbidden, ErrorType::NotFriends => Status::Forbidden,
ErrorType::TooManyPendingFriendRequests { .. } => Status::BadRequest,
ErrorType::UnknownChannel => Status::NotFound, ErrorType::UnknownChannel => Status::NotFound,
ErrorType::UnknownMessage => Status::NotFound, ErrorType::UnknownMessage => Status::NotFound,
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "revolt-delta" name = "revolt-delta"
version = "0.7.8" version = "0.7.9"
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"