mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 05:26:59 +00:00
fix: ensure bot invite route runs correct group member checks
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -3098,7 +3098,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "revolt-quark"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/revoltchat/quark?rev=1eb92e3b5893075de1c11332bab76bffd88d4fa8#1eb92e3b5893075de1c11332bab76bffd88d4fa8"
|
||||
source = "git+https://github.com/revoltchat/quark?rev=2e914015d56dcedead3a7e9ed2b9ff0696a5135e#2e914015d56dcedead3a7e9ed2b9ff0696a5135e"
|
||||
dependencies = [
|
||||
"async-recursion",
|
||||
"async-std",
|
||||
|
||||
@@ -69,5 +69,5 @@ schemars = "0.8.8"
|
||||
rocket_okapi = { git = "https://github.com/insertish/okapi", rev = "dcf0df115596ee07a587a7a543cddf3d7944645b", features = [ "swagger" ] }
|
||||
|
||||
# quark
|
||||
revolt-quark = { git = "https://github.com/revoltchat/quark", rev = "1eb92e3b5893075de1c11332bab76bffd88d4fa8" }
|
||||
revolt-quark = { git = "https://github.com/revoltchat/quark", rev = "2e914015d56dcedead3a7e9ed2b9ff0696a5135e" }
|
||||
# revolt-quark = { path = "../quark" }
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
use revolt_quark::{
|
||||
models::{Channel, User},
|
||||
perms, Db, EmptyResponse, Error, Permission, Ref, Result,
|
||||
};
|
||||
use revolt_quark::{models::User, perms, Db, EmptyResponse, Error, Permission, Ref, Result};
|
||||
|
||||
use rocket::serde::json::Json;
|
||||
use serde::Deserialize;
|
||||
@@ -58,20 +55,17 @@ pub async fn invite_bot(
|
||||
.map(|_| EmptyResponse)
|
||||
}
|
||||
InviteBotDestination::Group { group } => {
|
||||
let channel = db.fetch_channel(&group).await?;
|
||||
let mut channel = db.fetch_channel(&group).await?;
|
||||
|
||||
perms(&user)
|
||||
.channel(&channel)
|
||||
.throw_permission_and_view_channel(db, Permission::InviteOthers)
|
||||
.await?;
|
||||
|
||||
if let Channel::Group { id, .. } = channel {
|
||||
db.add_user_to_group(&id, &bot.id)
|
||||
.await
|
||||
.map(|_| EmptyResponse)
|
||||
} else {
|
||||
Err(Error::InvalidOperation)
|
||||
}
|
||||
channel
|
||||
.add_user_to_group(db, &bot.id, &user.id)
|
||||
.await
|
||||
.map(|_| EmptyResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ pub async fn req(db: &Db, user: User, target: Ref) -> Result<EmptyResponse> {
|
||||
.await
|
||||
.map(|_| EmptyResponse),
|
||||
Channel::Group { .. } => channel
|
||||
.remove_user_from_group(db, &user.id)
|
||||
.remove_user_from_group(db, &user.id, None)
|
||||
.await
|
||||
.map(|_| EmptyResponse),
|
||||
Channel::TextChannel { .. } | Channel::VoiceChannel { .. } => {
|
||||
|
||||
@@ -29,7 +29,7 @@ pub async fn req(db: &Db, user: User, target: Ref, member: Ref) -> Result<EmptyR
|
||||
}
|
||||
|
||||
channel
|
||||
.remove_user_from_group(db, &member.id)
|
||||
.remove_user_from_group(db, &member.id, Some(&user.id))
|
||||
.await
|
||||
.map(|_| EmptyResponse)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user