Attempt to move websocket into workspace
This commit is contained in:
parent
353e2e027a
commit
02e0363fd2
10 changed files with 84 additions and 14 deletions
26
server/Cargo.lock
generated
vendored
26
server/Cargo.lock
generated
vendored
|
@ -1798,7 +1798,10 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
name = "lemmy_api_structs"
|
name = "lemmy_api_structs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"actix-web",
|
||||||
|
"async-trait",
|
||||||
"lemmy_db",
|
"lemmy_db",
|
||||||
|
"lemmy_utils",
|
||||||
"serde 1.0.114",
|
"serde 1.0.114",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
@ -1868,6 +1871,7 @@ dependencies = [
|
||||||
"lemmy_db",
|
"lemmy_db",
|
||||||
"lemmy_rate_limit",
|
"lemmy_rate_limit",
|
||||||
"lemmy_utils",
|
"lemmy_utils",
|
||||||
|
"lemmy_websocket",
|
||||||
"log",
|
"log",
|
||||||
"openssl",
|
"openssl",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
|
@ -1907,6 +1911,28 @@ dependencies = [
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lemmy_websocket"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"actix",
|
||||||
|
"actix-web",
|
||||||
|
"anyhow",
|
||||||
|
"chrono",
|
||||||
|
"diesel",
|
||||||
|
"lemmy_api_structs",
|
||||||
|
"lemmy_db",
|
||||||
|
"lemmy_rate_limit",
|
||||||
|
"lemmy_utils",
|
||||||
|
"log",
|
||||||
|
"rand 0.7.3",
|
||||||
|
"reqwest",
|
||||||
|
"serde 1.0.114",
|
||||||
|
"serde_json",
|
||||||
|
"strum",
|
||||||
|
"strum_macros",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lettre"
|
name = "lettre"
|
||||||
version = "0.9.3"
|
version = "0.9.3"
|
||||||
|
|
2
server/Cargo.toml
vendored
2
server/Cargo.toml
vendored
|
@ -11,6 +11,7 @@ members = [
|
||||||
"lemmy_utils",
|
"lemmy_utils",
|
||||||
"lemmy_db",
|
"lemmy_db",
|
||||||
"lemmy_api_structs",
|
"lemmy_api_structs",
|
||||||
|
"lemmy_websocket",
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -18,6 +19,7 @@ lemmy_utils = { path = "./lemmy_utils" }
|
||||||
lemmy_db = { path = "./lemmy_db" }
|
lemmy_db = { path = "./lemmy_db" }
|
||||||
lemmy_api_structs = { path = "./lemmy_api_structs" }
|
lemmy_api_structs = { path = "./lemmy_api_structs" }
|
||||||
lemmy_rate_limit = { path = "./lemmy_rate_limit" }
|
lemmy_rate_limit = { path = "./lemmy_rate_limit" }
|
||||||
|
lemmy_websocket = { path = "./lemmy_websocket" }
|
||||||
diesel = "1.4.4"
|
diesel = "1.4.4"
|
||||||
diesel_migrations = "1.4.0"
|
diesel_migrations = "1.4.0"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
|
|
3
server/lemmy_api_structs/Cargo.toml
vendored
3
server/lemmy_api_structs/Cargo.toml
vendored
|
@ -6,5 +6,8 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lemmy_db = { path = "../lemmy_db" }
|
lemmy_db = { path = "../lemmy_db" }
|
||||||
|
lemmy_utils = { path = "../lemmy_utils" }
|
||||||
serde = { version = "1.0.105", features = ["derive"] }
|
serde = { version = "1.0.105", features = ["derive"] }
|
||||||
thiserror = "1.0.20"
|
thiserror = "1.0.20"
|
||||||
|
async-trait = "0.1.36"
|
||||||
|
actix-web = "3.0.0-alpha.3"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
pub extern crate serde;
|
pub extern crate serde;
|
||||||
pub extern crate thiserror;
|
pub extern crate thiserror;
|
||||||
|
pub extern crate actix_web;
|
||||||
|
|
||||||
pub mod comment;
|
pub mod comment;
|
||||||
pub mod community;
|
pub mod community;
|
||||||
|
@ -8,6 +9,8 @@ pub mod site;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
use actix_web::web::Data;
|
||||||
|
use lemmy_utils::{ConnectionId, LemmyError};
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
#[error("{{\"error\":\"{message}\"}}")]
|
#[error("{{\"error\":\"{message}\"}}")]
|
||||||
|
@ -22,3 +25,14 @@ impl APIError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait(?Send)]
|
||||||
|
pub trait Perform {
|
||||||
|
type Response: serde::ser::Serialize + Send;
|
||||||
|
|
||||||
|
async fn perform(
|
||||||
|
&self,
|
||||||
|
context: &Data<LemmyContext>,
|
||||||
|
websocket_id: Option<ConnectionId>,
|
||||||
|
) -> Result<Self::Response, LemmyError>;
|
||||||
|
}
|
23
server/lemmy_websocket/Cargo.toml
vendored
Normal file
23
server/lemmy_websocket/Cargo.toml
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
[package]
|
||||||
|
name = "lemmy_websocket"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Felix Ableitner <me@nutomic.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
lemmy_api_structs = { path = "../lemmy_api_structs" }
|
||||||
|
lemmy_rate_limit = { path = "../lemmy_rate_limit" }
|
||||||
|
lemmy_utils = { path = "../lemmy_utils" }
|
||||||
|
lemmy_db = { path = "../lemmy_db" }
|
||||||
|
log = "0.4.0"
|
||||||
|
actix = "0.10.0-alpha.2"
|
||||||
|
actix-web = { version = "3.0.0-alpha.3", features = ["rustls"] }
|
||||||
|
anyhow = "1.0.32"
|
||||||
|
diesel = "1.4.4"
|
||||||
|
rand = "0.7.3"
|
||||||
|
serde = { version = "1.0.105", features = ["derive"] }
|
||||||
|
serde_json = { version = "1.0.52", features = ["preserve_order"]}
|
||||||
|
chrono = { version = "0.4.7", features = ["serde"] }
|
||||||
|
reqwest = { version = "0.10", features = ["json"] }
|
||||||
|
strum = "0.18.0"
|
||||||
|
strum_macros = "0.18.0"
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
websocket::{
|
{
|
||||||
handlers::{do_user_operation, to_json_string, Args},
|
handlers::{do_user_operation, to_json_string, Args},
|
||||||
messages::*,
|
messages::*,
|
||||||
UserOperation,
|
UserOperation,
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
api::Perform,
|
api::Perform,
|
||||||
websocket::{
|
{
|
||||||
chat_server::{ChatServer, SessionInfo},
|
chat_server::{ChatServer, SessionInfo},
|
||||||
messages::*,
|
messages::*,
|
||||||
UserOperation,
|
UserOperation,
|
|
@ -1,3 +1,16 @@
|
||||||
|
pub extern crate actix;
|
||||||
|
pub extern crate actix_web;
|
||||||
|
pub extern crate anyhow;
|
||||||
|
pub extern crate diesel;
|
||||||
|
pub extern crate rand;
|
||||||
|
pub extern crate serde;
|
||||||
|
pub extern crate serde_json;
|
||||||
|
pub extern crate chrono;
|
||||||
|
pub extern crate reqwest;
|
||||||
|
pub extern crate log;
|
||||||
|
#[macro_use]
|
||||||
|
pub extern crate strum_macros;
|
||||||
|
|
||||||
pub mod chat_server;
|
pub mod chat_server;
|
||||||
pub mod handlers;
|
pub mod handlers;
|
||||||
pub mod messages;
|
pub mod messages;
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::websocket::UserOperation;
|
use crate::UserOperation;
|
||||||
use actix::{prelude::*, Recipient};
|
use actix::{prelude::*, Recipient};
|
||||||
use lemmy_api_structs::{comment::CommentResponse, post::PostResponse};
|
use lemmy_api_structs::{comment::CommentResponse, post::PostResponse};
|
||||||
use lemmy_utils::{CommunityId, ConnectionId, IPAddr, PostId, UserId};
|
use lemmy_utils::{CommunityId, ConnectionId, IPAddr, PostId, UserId};
|
|
@ -17,17 +17,6 @@ pub mod post;
|
||||||
pub mod site;
|
pub mod site;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
#[async_trait::async_trait(?Send)]
|
|
||||||
pub trait Perform {
|
|
||||||
type Response: serde::ser::Serialize + Send;
|
|
||||||
|
|
||||||
async fn perform(
|
|
||||||
&self,
|
|
||||||
context: &Data<LemmyContext>,
|
|
||||||
websocket_id: Option<ConnectionId>,
|
|
||||||
) -> Result<Self::Response, LemmyError>;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(in crate::api) async fn is_mod_or_admin(
|
pub(in crate::api) async fn is_mod_or_admin(
|
||||||
pool: &DbPool,
|
pool: &DbPool,
|
||||||
user_id: i32,
|
user_id: i32,
|
||||||
|
|
Loading…
Reference in a new issue