fix(invites): account for server bans

This commit is contained in:
Paul Makles
2022-02-11 12:52:34 +00:00
parent f0eb228b19
commit 7a9adb45f7

View File

@@ -19,11 +19,14 @@ pub async fn req(db: &Db, user: User, target: Ref) -> Result<Value> {
let invite = target.as_invite(db).await?;
match &invite {
Invite::Server { channel, server, .. } => {
let channel = db.fetch_channel(channel).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?;
Ok(json!({
"type": "Server",
"channel": channel,