chore(thanos): strip down codebase to just API routes
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use crate::database::*;
|
||||
use crate::util::result::{Error, Result};
|
||||
use revolt_quark::{Error, Result};
|
||||
|
||||
use futures::StreamExt;
|
||||
use mongodb::bson::{doc, from_document};
|
||||
@@ -15,39 +14,6 @@ pub struct ServerInvite {
|
||||
}
|
||||
|
||||
#[get("/<target>/invites")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let target = target.fetch_server().await?;
|
||||
|
||||
let perm = permissions::PermissionCalculator::new(&user)
|
||||
.with_server(&target)
|
||||
.for_server()
|
||||
.await?;
|
||||
|
||||
if !perm.get_manage_server() {
|
||||
Err(Error::MissingPermission)?
|
||||
}
|
||||
|
||||
let mut cursor = get_collection("channel_invites")
|
||||
.find(
|
||||
doc! {
|
||||
"server": target.id
|
||||
},
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
operation: "find",
|
||||
with: "channel_invites",
|
||||
})?;
|
||||
|
||||
let mut invites = vec![];
|
||||
while let Some(result) = cursor.next().await {
|
||||
if let Ok(doc) = result {
|
||||
if let Ok(invite) = from_document::<Invite>(doc) {
|
||||
invites.push(invite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(json!(invites))
|
||||
pub async fn req(/*user: UserRef, target: Ref*/ target: String) -> Result<Value> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user