forked from jmug/stoatchat
Implement channel permissions.
This commit is contained in:
35
src/database/mutual.rs
Normal file
35
src/database/mutual.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use super::get_collection;
|
||||
|
||||
use bson::{bson, doc};
|
||||
use mongodb::options::FindOneOptions;
|
||||
|
||||
/*pub struct MutualGuild {
|
||||
|
||||
}
|
||||
|
||||
pub fn find_mutual_guilds(user_id: String, target_id: String) -> Vec<> {
|
||||
|
||||
}*/
|
||||
|
||||
pub fn has_mutual_connection(user_id: String, target_id: String) -> bool {
|
||||
let col = get_collection("guilds");
|
||||
if let Ok(result) = col.find_one(
|
||||
doc! {
|
||||
"$and": [
|
||||
{ "members": { "$elemMatch": { "id": user_id } } },
|
||||
{ "members": { "$elemMatch": { "id": target_id } } },
|
||||
]
|
||||
},
|
||||
FindOneOptions::builder()
|
||||
.projection(doc! { "_id": 1 })
|
||||
.build(),
|
||||
) {
|
||||
if result.is_some() {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user