Compare commits
No commits in common. "8241196284001839641c0bcfede39b4740c59ed6" and "bcf857d6b2301be4ac6d4d7d434dc0489949c3af" have entirely different histories.
8241196284
...
bcf857d6b2
8 changed files with 0 additions and 89 deletions
|
@ -21,7 +21,6 @@ serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
simple_logger = "5.0.0"
|
simple_logger = "5.0.0"
|
||||||
sqlx = { version = "0.8", features = ["runtime-tokio", "tls-native-tls", "postgres"] }
|
sqlx = { version = "0.8", features = ["runtime-tokio", "tls-native-tls", "postgres"] }
|
||||||
tokio-tungstenite = { version = "0.26", features = ["native-tls", "url"] }
|
|
||||||
toml = "0.8"
|
toml = "0.8"
|
||||||
url = { version = "2.5", features = ["serde"] }
|
url = { version = "2.5", features = ["serde"] }
|
||||||
uuid = { version = "1.16", features = ["serde", "v7"] }
|
uuid = { version = "1.16", features = ["serde", "v7"] }
|
||||||
|
|
|
@ -3,7 +3,6 @@ use actix_web::{Scope, web};
|
||||||
mod auth;
|
mod auth;
|
||||||
mod stats;
|
mod stats;
|
||||||
mod users;
|
mod users;
|
||||||
mod servers;
|
|
||||||
|
|
||||||
pub fn web() -> Scope {
|
pub fn web() -> Scope {
|
||||||
web::scope("/v1")
|
web::scope("/v1")
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
pub fn web() -> Scope {
|
|
||||||
web::scope("/channels")
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
use actix_web::{Error, HttpResponse, error, post, web};
|
|
||||||
use futures::StreamExt;
|
|
||||||
use log::error;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
|
||||||
|
|
||||||
mod uuid;
|
|
||||||
mod channels;
|
|
||||||
|
|
||||||
use crate::Data;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
struct Request {
|
|
||||||
access_token: String,
|
|
||||||
name: String
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
struct Response {
|
|
||||||
refresh_token: String,
|
|
||||||
access_token: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
const MAX_SIZE: usize = 262_144;
|
|
||||||
|
|
||||||
pub fn web() -> Scope {
|
|
||||||
web::scope("/servers")
|
|
||||||
.service(channels::web())
|
|
||||||
.service(uuid::res)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[post("")]
|
|
||||||
pub async fn res(mut payload: web::Payload, data: web::Data<Data>) -> Result<HttpResponse, Error> {
|
|
||||||
let mut body = web::BytesMut::new();
|
|
||||||
while let Some(chunk) = payload.next().await {
|
|
||||||
let chunk = chunk?;
|
|
||||||
// limit max size of in-memory payload
|
|
||||||
if (body.len() + chunk.len()) > MAX_SIZE {
|
|
||||||
return Err(error::ErrorBadRequest("overflow"));
|
|
||||||
}
|
|
||||||
body.extend_from_slice(&chunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
let request = serde_json::from_slice::<Request>(&body)?;
|
|
||||||
|
|
||||||
Ok(HttpResponse::Unauthorized().finish())
|
|
||||||
}
|
|
||||||
|
|
36
src/main.rs
36
src/main.rs
|
@ -71,42 +71,6 @@ async fn main() -> Result<(), Error> {
|
||||||
refresh_token varchar(64) UNIQUE NOT NULL REFERENCES refresh_tokens(token),
|
refresh_token varchar(64) UNIQUE NOT NULL REFERENCES refresh_tokens(token),
|
||||||
uuid uuid NOT NULL REFERENCES users(uuid),
|
uuid uuid NOT NULL REFERENCES users(uuid),
|
||||||
created int8 NOT NULL
|
created int8 NOT NULL
|
||||||
);
|
|
||||||
CREATE TABLE IF NOT EXISTS guilds (
|
|
||||||
uuid uuid PRIMARY KEY NOT NULL,
|
|
||||||
name VARCHAR(100),
|
|
||||||
description VARCHAR(300),
|
|
||||||
created_at int8 NOT NULL
|
|
||||||
);
|
|
||||||
CREATE TABLE IF NOT EXISTS guild_members (
|
|
||||||
guild_uuid uuid NOT NULL REFERENCES guilds(uuid),
|
|
||||||
user_uuid uuid NOT NULL REFERENCES users(uuid),
|
|
||||||
permissions int8 NOT NULL DEFAULT 0,
|
|
||||||
PRIMARY KEY (guild_uuid, user_uuid)
|
|
||||||
);
|
|
||||||
CREATE TABLE IF NOT EXISTS channels (
|
|
||||||
uuid uuid PRIMARY KEY NOT NULL,
|
|
||||||
guild_uuid NOT NULL REFERENCES guilds(uuid),
|
|
||||||
name varchar(32) NOT NULL,
|
|
||||||
description varchar(500) NOT NULL
|
|
||||||
);
|
|
||||||
CREATE TABLE IF NOT EXISTS messages (
|
|
||||||
uuid uuid PRIMARY KEY NOT NULL,
|
|
||||||
channel_uuid uuid NOT NULL REFERENCES channels(uuid),
|
|
||||||
user_uuid uuid NOT NULL REFERENCES users(uuid),
|
|
||||||
message varchar(2000) NOT NULL,
|
|
||||||
created_at int8 NOT NULL
|
|
||||||
);
|
|
||||||
CREATE TABLE IF NOT EXISTS emojis (
|
|
||||||
uuid uuid PRIMARY KEY NOT NULL,
|
|
||||||
name varchar(32) NOT NULL,
|
|
||||||
guild_uuid uuid REFERENCES guilds(uuid)
|
|
||||||
);
|
|
||||||
CREATE TABLE IF NOT EXISTS message_reactions (
|
|
||||||
message_uuid uuid NOT NULL REFERENCES messages(uuid),
|
|
||||||
user_uuid uuid NOT NULL REFERENCES users(uuid),
|
|
||||||
emoji_uuid uuid NOT NULL REFERENCES emojis(uuid),
|
|
||||||
PRIMARY KEY (message_uuid, user_uuid, emoji_uuid)
|
|
||||||
)
|
)
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue