Re-structure Permissions; add perm to view users from mutual groups.

This commit is contained in:
Paul Makles
2021-01-26 21:12:23 +00:00
parent 23ec2d61f1
commit f42480886b
17 changed files with 210 additions and 58 deletions

View File

@@ -1,7 +1,7 @@
use crate::database::*;
use crate::notifications::events::ClientboundNotification;
use crate::util::result::{Error, Result};
use mongodb::bson::{doc, to_document};
use mongodb::bson::{doc, from_document, to_document};
use rocket_contrib::json::JsonValue;
use serde::{Deserialize, Serialize};
@@ -52,6 +52,20 @@ impl Channel {
}
}
pub async fn get(id: &str) -> Result<Channel> {
let doc = get_collection("channels")
.find_one(
doc! { "_id": id },
None
)
.await
.map_err(|_| Error::DatabaseError { operation: "find_one", with: "channel" })?
.ok_or_else(|| Error::UnknownChannel)?;
from_document::<Channel>(doc)
.map_err(|_| Error::DatabaseError { operation: "from_document", with: "channel" })
}
pub async fn publish(self) -> Result<()> {
get_collection("channels")
.insert_one(

View File

@@ -44,7 +44,7 @@ impl Message {
with: "message",
})?;
// ! temp code
// ! FIXME: temp code
let channels = get_collection("channels");
match channel {
Channel::DirectMessage { id, .. } => {