mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
New perm concept, reference, and adding routes.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
/*#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct LastMessage {
|
||||
id: String,
|
||||
user_id: String,
|
||||
@@ -28,4 +28,23 @@ pub struct Channel {
|
||||
pub name: Option<String>,
|
||||
// GUILD + GDM: channel description
|
||||
pub description: Option<String>,
|
||||
}*/
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum Channel {
|
||||
DirectMessage {
|
||||
#[serde(rename = "_id")]
|
||||
id: String,
|
||||
active: bool,
|
||||
recipients: Vec<String>,
|
||||
},
|
||||
Group {
|
||||
#[serde(rename = "_id")]
|
||||
id: String,
|
||||
name: String,
|
||||
owner: String,
|
||||
description: String,
|
||||
recipients: Vec<String>,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
// use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
/*#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct MemberCompositeKey {
|
||||
pub guild: String,
|
||||
pub user: String,
|
||||
@@ -40,4 +40,4 @@ pub struct Guild {
|
||||
pub bans: Vec<Ban>,
|
||||
|
||||
pub default_permissions: u32,
|
||||
}
|
||||
}*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use mongodb::bson::DateTime;
|
||||
use serde::{Deserialize, Serialize};
|
||||
// use mongodb::bson::DateTime;
|
||||
// use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
/*#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct PreviousEntry {
|
||||
pub content: String,
|
||||
pub time: DateTime,
|
||||
@@ -19,4 +19,4 @@ pub struct Message {
|
||||
pub edited: Option<DateTime>,
|
||||
|
||||
pub previous_content: Vec<PreviousEntry>,
|
||||
}
|
||||
}*/
|
||||
|
||||
@@ -5,17 +5,18 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::database::get_collection;
|
||||
use rocket::request::{self, FromRequest, Outcome, Request};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Relationship {
|
||||
pub id: String,
|
||||
pub status: u8,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct User {
|
||||
#[serde(rename = "_id")]
|
||||
pub id: String,
|
||||
pub username: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub relations: Option<Vec<Relationship>>,
|
||||
}
|
||||
|
||||
@@ -43,35 +44,5 @@ impl<'a, 'r> FromRequest<'a, 'r> for User {
|
||||
} else {
|
||||
Outcome::Failure((Status::InternalServerError, rauth::util::Error::DatabaseError))
|
||||
}
|
||||
|
||||
/*Outcome::Success(
|
||||
User {
|
||||
id: "gaming".to_string(),
|
||||
username: None,
|
||||
relations: None
|
||||
}
|
||||
)*/
|
||||
|
||||
/*match (
|
||||
request.managed_state::<Auth>(),
|
||||
header_user_id,
|
||||
header_session_token,
|
||||
) {
|
||||
(Some(auth), Some(user_id), Some(session_token)) => {
|
||||
let session = Session {
|
||||
id: None,
|
||||
user_id,
|
||||
session_token,
|
||||
};
|
||||
|
||||
if let Ok(session) = auth.verify_session(session).await {
|
||||
Outcome::Success(session)
|
||||
} else {
|
||||
Outcome::Failure((Status::Forbidden, Error::InvalidSession))
|
||||
}
|
||||
}
|
||||
(None, _, _) => Outcome::Failure((Status::InternalServerError, Error::InternalError)),
|
||||
(_, _, _) => Outcome::Failure((Status::Forbidden, Error::MissingHeaders)),
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user