Skip to content
Snippets Groups Projects
Verified Commit 2063eeac authored by insert's avatar insert
Browse files

Delete invites when channel is deleted.

parent b4f471d6
No related merge requests found
...@@ -360,7 +360,28 @@ pub fn delete(user: UserRef, target: ChannelRef) -> Option<Response> { ...@@ -360,7 +360,28 @@ pub fn delete(user: UserRef, target: ChannelRef) -> Option<Response> {
} }
} }
} }
2 => try_delete(), 2 => {
if database::get_collection("guilds")
.update_one(
doc! { "_id": target.guild.unwrap() },
doc! {
"$pull": {
"invites": {
"channel": &target.id
}
}
},
None,
)
.is_ok()
{
try_delete()
} else {
Some(Response::InternalServerError(
json!({ "error": "Failed to remove invites." }),
))
}
}
_ => Some(Response::InternalServerError( _ => Some(Response::InternalServerError(
json!({ "error": "Unknown error has occurred." }), json!({ "error": "Unknown error has occurred." }),
)), )),
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment