forked from jmug/stoatchat
fix(invites): account for server bans
This commit is contained in:
@@ -19,11 +19,14 @@ pub async fn req(db: &Db, user: User, target: Ref) -> Result<Value> {
|
|||||||
let invite = target.as_invite(db).await?;
|
let invite = target.as_invite(db).await?;
|
||||||
match &invite {
|
match &invite {
|
||||||
Invite::Server { channel, server, .. } => {
|
Invite::Server { channel, server, .. } => {
|
||||||
let channel = db.fetch_channel(channel).await?;
|
|
||||||
let server = db.fetch_server(server).await?;
|
let server = db.fetch_server(server).await?;
|
||||||
|
if db.fetch_ban(&server.id, &user.id).await.is_ok() {
|
||||||
|
return Err(Error::Banned)
|
||||||
|
}
|
||||||
|
|
||||||
|
let channel = db.fetch_channel(channel).await?;
|
||||||
db.insert_member(&server.id, &user.id).await?;
|
db.insert_member(&server.id, &user.id).await?;
|
||||||
|
|
||||||
Ok(json!({
|
Ok(json!({
|
||||||
"type": "Server",
|
"type": "Server",
|
||||||
"channel": channel,
|
"channel": channel,
|
||||||
|
|||||||
Reference in New Issue
Block a user