All DB functions, Admin starter, Need auth
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use chrono::{DateTime, TimeZone, Utc};
|
||||
use tarpc::serde::{Deserialize, Serialize};
|
||||
|
||||
#[tarpc::service]
|
||||
@@ -11,16 +12,20 @@ pub trait RealmChat {
|
||||
async fn keep_typing() -> ErrorCode; //NOTE: If a keep alive hasn't been received in 5 seconds, stop typing
|
||||
|
||||
//NOTE: Any user can call, if they are in the server
|
||||
async fn get_message_from_guid(guid: String) -> Result<Message, ErrorCode>;
|
||||
async fn get_messages_since(time: u64) -> Result<Vec<Message>, ErrorCode>;
|
||||
async fn get_message_from_id(id: u32) -> Result<Message, ErrorCode>;
|
||||
async fn get_messages_since(time: DateTime<Utc>) -> Result<Vec<Message>, ErrorCode>;
|
||||
async fn get_rooms() -> Result<Vec<Room>, ErrorCode>;
|
||||
async fn get_room(roomid: String) -> Result<Room, ErrorCode>;
|
||||
async fn get_user(userid: String) -> Result<User, ErrorCode>;
|
||||
async fn get_joined_users() -> Result<Vec<User>, ErrorCode>;
|
||||
async fn get_online_users() -> Result<Vec<User>, ErrorCode>;
|
||||
async fn get_users(get_only_online: bool) -> Result<Vec<User>, ErrorCode>;
|
||||
|
||||
//TODO: Admin access only!
|
||||
// async fn create_room() -> Result<Room, ErrorCode>;
|
||||
// delete room
|
||||
// delete any message
|
||||
// kick user
|
||||
// ban user
|
||||
// unban user
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -29,12 +34,13 @@ pub enum ErrorCode {
|
||||
Error,
|
||||
Unauthorized,
|
||||
NotFound,
|
||||
FailedToUnwrapDB,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Message {
|
||||
pub id: u32,
|
||||
pub timestamp: u64, //TODO: Change to a real time for SQL
|
||||
pub timestamp: DateTime<Utc>, //TODO: Does the database already have timestamps for us?
|
||||
pub user: User,
|
||||
pub room: Room,
|
||||
pub data: MessageData,
|
||||
@@ -48,7 +54,7 @@ pub enum MessageData {
|
||||
Reply(Reply),
|
||||
Edit(Edit), //NOTE: Have to be the owner of the referencing_guid
|
||||
Reaction(Reaction),
|
||||
Redaction(Redaction),
|
||||
Redaction(Redaction), //NOTE: Have to be the owner of the referencing_guid
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -85,7 +91,8 @@ pub struct User {
|
||||
pub userid: String,
|
||||
pub name: String,
|
||||
pub online: bool,
|
||||
//TODO
|
||||
pub admin: bool,
|
||||
//TODO: auth stuff needed, should be Option
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -93,6 +100,7 @@ pub struct Room {
|
||||
pub id: u32,
|
||||
pub roomid: String,
|
||||
pub name: String,
|
||||
//TODO
|
||||
pub admin_only_send: bool,
|
||||
pub admin_only_view: bool,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user