From: Felix Ableitner Date: Wed, 16 Sep 2020 10:25:22 +0000 (+0200) Subject: Move websocket structs into lemmy_structs (ref #1115) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%24%7B%60data:application/%22https:/hacktivis.me/%7Bthis.imageSrc.unwrap%28%29%7D?a=commitdiff_plain;h=98c086abb9d5777381cf2426a36b92321440dc43;p=lemmy.git Move websocket structs into lemmy_structs (ref #1115) --- diff --git a/Cargo.lock b/Cargo.lock index 644c83ac..8fef254f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1820,18 +1820,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lemmy_api_structs" -version = "0.1.0" -dependencies = [ - "actix-web", - "diesel", - "lemmy_db", - "lemmy_utils", - "log", - "serde 1.0.115", -] - [[package]] name = "lemmy_db" version = "0.1.0" @@ -1893,9 +1881,9 @@ dependencies = [ "itertools", "jsonwebtoken", "lazy_static", - "lemmy_api_structs", "lemmy_db", "lemmy_rate_limit", + "lemmy_structs", "lemmy_utils", "log", "openssl", @@ -1907,13 +1895,28 @@ dependencies = [ "serde_json", "sha2", "strum", - "strum_macros", "thiserror", "tokio", "url", "uuid 0.8.1", ] +[[package]] +name = "lemmy_structs" +version = "0.1.0" +dependencies = [ + "actix", + "actix-web", + "chrono", + "diesel", + "lemmy_db", + "lemmy_utils", + "log", + "serde 1.0.115", + "strum", + "strum_macros", +] + [[package]] name = "lemmy_utils" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index f1f490b0..dc411a63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,14 +10,14 @@ lto = true members = [ "lemmy_utils", "lemmy_db", - "lemmy_api_structs", + "lemmy_structs", "lemmy_rate_limit", ] [dependencies] lemmy_utils = { path = "./lemmy_utils" } lemmy_db = { path = "./lemmy_db" } -lemmy_api_structs = { path = "./lemmy_api_structs" } +lemmy_structs = { path = "./lemmy_structs" } lemmy_rate_limit = { path = "./lemmy_rate_limit" } diesel = "1.4.4" diesel_migrations = "1.4.0" @@ -38,7 +38,6 @@ log = "0.4.0" env_logger = "0.7.1" rand = "0.7.3" strum = "0.19.2" -strum_macros = "0.19.2" jsonwebtoken = "7.0.1" lazy_static = "1.3.0" rss = "1.9.0" diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index d9a95c85..17e58fda 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -10,7 +10,7 @@ RUN cargo install --git https://github.com/romac/cargo-build-deps.git WORKDIR /app/server RUN mkdir -p lemmy_db/src/ \ lemmy_utils/src/ \ - lemmy_api_structs/src/ \ + lemmy_structs/src/ \ lemmy_rate_limit/src/ \ lemmy @@ -18,7 +18,7 @@ RUN mkdir -p lemmy_db/src/ \ COPY Cargo.toml Cargo.lock ./ COPY lemmy_db/Cargo.toml ./lemmy_db/ COPY lemmy_utils/Cargo.toml ./lemmy_utils/ -COPY lemmy_api_structs/Cargo.toml ./lemmy_api_structs/ +COPY lemmy_structs/Cargo.toml ./lemmy_structs/ COPY lemmy_rate_limit/Cargo.toml ./lemmy_rate_limit/ # Cache the deps @@ -28,7 +28,7 @@ RUN cargo build-deps COPY src ./src/ COPY lemmy_db/src ./lemmy_db/src/ COPY lemmy_utils/src/ ./lemmy_utils/src/ -COPY lemmy_api_structs/src/ ./lemmy_api_structs/src/ +COPY lemmy_structs/src/ ./lemmy_structs/src/ COPY lemmy_rate_limit/src/ ./lemmy_rate_limit/src/ COPY migrations ./migrations/ diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index 2ba5bca7..20e910a4 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -13,7 +13,7 @@ WORKDIR /app/server COPY Cargo.toml Cargo.lock ./ COPY lemmy_db ./lemmy_db COPY lemmy_utils ./lemmy_utils -COPY lemmy_api_structs ./lemmy_api_structs +COPY lemmy_structs ./lemmy_structs COPY lemmy_rate_limit ./lemmy_rate_limit RUN mkdir -p ./src/bin \ && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs diff --git a/lemmy_api_structs/Cargo.toml b/lemmy_structs/Cargo.toml similarity index 69% rename from lemmy_api_structs/Cargo.toml rename to lemmy_structs/Cargo.toml index b442f697..25e38109 100644 --- a/lemmy_api_structs/Cargo.toml +++ b/lemmy_structs/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "lemmy_api_structs" +name = "lemmy_structs" version = "0.1.0" authors = ["Felix Ableitner "] edition = "2018" [lib] -name = "lemmy_api_structs" +name = "lemmy_structs" path = "src/lib.rs" [dependencies] @@ -15,3 +15,7 @@ serde = { version = "1.0.105", features = ["derive"] } log = "0.4.0" diesel = "1.4.4" actix-web = { version = "3.0.0-beta.3", features = ["rustls"] } +actix = "0.10.0" +strum = "0.19.2" +strum_macros = "0.19.2" +chrono = { version = "0.4.7", features = ["serde"] } \ No newline at end of file diff --git a/lemmy_api_structs/src/comment.rs b/lemmy_structs/src/comment.rs similarity index 100% rename from lemmy_api_structs/src/comment.rs rename to lemmy_structs/src/comment.rs diff --git a/lemmy_api_structs/src/community.rs b/lemmy_structs/src/community.rs similarity index 100% rename from lemmy_api_structs/src/community.rs rename to lemmy_structs/src/community.rs diff --git a/lemmy_api_structs/src/lib.rs b/lemmy_structs/src/lib.rs similarity index 97% rename from lemmy_api_structs/src/lib.rs rename to lemmy_structs/src/lib.rs index dd2a78cd..f7140205 100644 --- a/lemmy_api_structs/src/lib.rs +++ b/lemmy_structs/src/lib.rs @@ -1,13 +1,18 @@ +extern crate actix; extern crate actix_web; extern crate diesel; extern crate log; extern crate serde; +#[macro_use] +extern crate strum_macros; +extern crate chrono; pub mod comment; pub mod community; pub mod post; pub mod site; pub mod user; +pub mod websocket; use diesel::PgConnection; use lemmy_db::{ diff --git a/lemmy_api_structs/src/post.rs b/lemmy_structs/src/post.rs similarity index 100% rename from lemmy_api_structs/src/post.rs rename to lemmy_structs/src/post.rs diff --git a/lemmy_api_structs/src/site.rs b/lemmy_structs/src/site.rs similarity index 100% rename from lemmy_api_structs/src/site.rs rename to lemmy_structs/src/site.rs diff --git a/lemmy_api_structs/src/user.rs b/lemmy_structs/src/user.rs similarity index 100% rename from lemmy_api_structs/src/user.rs rename to lemmy_structs/src/user.rs diff --git a/src/websocket/messages.rs b/lemmy_structs/src/websocket.rs similarity index 70% rename from src/websocket/messages.rs rename to lemmy_structs/src/websocket.rs index 2a0e5fde..c5c6c5d6 100644 --- a/src/websocket/messages.rs +++ b/lemmy_structs/src/websocket.rs @@ -1,9 +1,72 @@ -use crate::websocket::UserOperation; +use crate::{comment::CommentResponse, post::PostResponse}; use actix::{prelude::*, Recipient}; -use lemmy_api_structs::{comment::CommentResponse, post::PostResponse}; use lemmy_utils::{CommunityId, ConnectionId, IPAddr, PostId, UserId}; use serde::{Deserialize, Serialize}; +#[derive(EnumString, ToString, Debug, Clone)] +pub enum UserOperation { + Login, + Register, + GetCaptcha, + CreateCommunity, + CreatePost, + ListCommunities, + ListCategories, + GetPost, + GetCommunity, + CreateComment, + EditComment, + DeleteComment, + RemoveComment, + MarkCommentAsRead, + SaveComment, + CreateCommentLike, + GetPosts, + CreatePostLike, + EditPost, + DeletePost, + RemovePost, + LockPost, + StickyPost, + SavePost, + EditCommunity, + DeleteCommunity, + RemoveCommunity, + FollowCommunity, + GetFollowedCommunities, + GetUserDetails, + GetReplies, + GetUserMentions, + MarkUserMentionAsRead, + GetModlog, + BanFromCommunity, + AddModToCommunity, + CreateSite, + EditSite, + GetSite, + AddAdmin, + BanUser, + Search, + MarkAllAsRead, + SaveUserSettings, + TransferCommunity, + TransferSite, + DeleteAccount, + PasswordReset, + PasswordChange, + CreatePrivateMessage, + EditPrivateMessage, + DeletePrivateMessage, + MarkPrivateMessageAsRead, + GetPrivateMessages, + UserJoin, + GetComments, + GetSiteConfig, + SaveSiteConfig, + PostJoin, + CommunityJoin, +} + /// Chat server sends this messages to session #[derive(Message)] #[rtype(result = "()")] diff --git a/src/api/comment.rs b/src/api/comment.rs index 68481a40..2f6a23b6 100644 --- a/src/api/comment.rs +++ b/src/api/comment.rs @@ -8,11 +8,15 @@ use crate::{ Perform, }, apub::{ApubLikeableType, ApubObjectType}, - websocket::{messages::SendComment, UserOperation}, LemmyContext, }; use actix_web::web::Data; -use lemmy_api_structs::{blocking, comment::*, send_local_notifs}; +use lemmy_structs::{ + blocking, + comment::*, + send_local_notifs, + websocket::{SendComment, UserOperation}, +}; use lemmy_db::{ comment::*, comment_view::*, diff --git a/src/api/community.rs b/src/api/community.rs index 7c8c93f1..e16e7f71 100644 --- a/src/api/community.rs +++ b/src/api/community.rs @@ -1,15 +1,20 @@ use crate::{ api::{get_user_from_jwt, get_user_from_jwt_opt, is_admin, is_mod_or_admin, Perform}, apub::ActorType, - websocket::{ - messages::{GetCommunityUsersOnline, JoinCommunityRoom, SendCommunityRoomMessage}, - UserOperation, - }, LemmyContext, }; use actix_web::web::Data; use anyhow::Context; -use lemmy_api_structs::{blocking, community::*}; +use lemmy_structs::{ + blocking, + community::*, + websocket::{ + GetCommunityUsersOnline, + JoinCommunityRoom, + SendCommunityRoomMessage, + UserOperation, + }, +}; use lemmy_db::{ comment::Comment, comment_view::CommentQueryBuilder, diff --git a/src/api/mod.rs b/src/api/mod.rs index 1aff5d10..0c66e7d7 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,6 +1,6 @@ use crate::{api::claims::Claims, DbPool, LemmyContext}; use actix_web::web::Data; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::{ community::Community, community_view::CommunityUserBanView, diff --git a/src/api/post.rs b/src/api/post.rs index d38c10c9..4cfb3bab 100644 --- a/src/api/post.rs +++ b/src/api/post.rs @@ -2,14 +2,14 @@ use crate::{ api::{check_community_ban, get_user_from_jwt, get_user_from_jwt_opt, is_mod_or_admin, Perform}, apub::{ApubLikeableType, ApubObjectType}, fetch_iframely_and_pictrs_data, - websocket::{ - messages::{GetPostUsersOnline, JoinPostRoom, SendPost}, - UserOperation, - }, LemmyContext, }; use actix_web::web::Data; -use lemmy_api_structs::{blocking, post::*}; +use lemmy_structs::{ + blocking, + post::*, + websocket::{GetPostUsersOnline, JoinPostRoom, SendPost, UserOperation}, +}; use lemmy_db::{ comment_view::*, community_view::*, diff --git a/src/api/site.rs b/src/api/site.rs index 727078e2..e0e2b6ff 100644 --- a/src/api/site.rs +++ b/src/api/site.rs @@ -2,15 +2,16 @@ use crate::{ api::{get_user_from_jwt, get_user_from_jwt_opt, is_admin, Perform}, apub::fetcher::search_by_apub_id, version, - websocket::{ - messages::{GetUsersOnline, SendAllMessage}, - UserOperation, - }, LemmyContext, }; use actix_web::web::Data; use anyhow::Context; -use lemmy_api_structs::{blocking, site::*, user::Register}; +use lemmy_structs::{ + blocking, + site::*, + user::Register, + websocket::{GetUsersOnline, SendAllMessage, UserOperation}, +}; use lemmy_db::{ category::*, comment_view::*, diff --git a/src/api/user.rs b/src/api/user.rs index 195e93dc..3301be9d 100644 --- a/src/api/user.rs +++ b/src/api/user.rs @@ -2,10 +2,6 @@ use crate::{ api::{claims::Claims, get_user_from_jwt, get_user_from_jwt_opt, is_admin, Perform}, apub::ApubObjectType, captcha_espeak_wav_base64, - websocket::{ - messages::{CaptchaItem, CheckCaptcha, JoinUserRoom, SendAllMessage, SendUserRoomMessage}, - UserOperation, - }, LemmyContext, }; use actix_web::web::Data; @@ -13,7 +9,18 @@ use anyhow::Context; use bcrypt::verify; use captcha::{gen, Difficulty}; use chrono::Duration; -use lemmy_api_structs::{blocking, user::*}; +use lemmy_structs::{ + blocking, + user::*, + websocket::{ + CaptchaItem, + CheckCaptcha, + JoinUserRoom, + SendAllMessage, + SendUserRoomMessage, + UserOperation, + }, +}; use lemmy_db::{ comment::*, comment_view::*, diff --git a/src/apub/comment.rs b/src/apub/comment.rs index 78fe6f8a..e71eeacd 100644 --- a/src/apub/comment.rs +++ b/src/apub/comment.rs @@ -40,7 +40,7 @@ use activitystreams::{ use actix_web::{body::Body, web, web::Path, HttpResponse}; use anyhow::Context; use itertools::Itertools; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::{ comment::{Comment, CommentForm}, community::Community, diff --git a/src/apub/community.rs b/src/apub/community.rs index 8f64c671..8a11f570 100644 --- a/src/apub/community.rs +++ b/src/apub/community.rs @@ -38,7 +38,7 @@ use activitystreams_ext::Ext2; use actix_web::{body::Body, web, HttpResponse}; use anyhow::Context; use itertools::Itertools; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::{ community::{Community, CommunityForm}, community_view::{CommunityFollowerView, CommunityModeratorView}, diff --git a/src/apub/fetcher.rs b/src/apub/fetcher.rs index 4891a970..c1caa039 100644 --- a/src/apub/fetcher.rs +++ b/src/apub/fetcher.rs @@ -15,7 +15,7 @@ use activitystreams::{base::BaseExt, collection::OrderedCollection, object::Note use anyhow::{anyhow, Context}; use chrono::NaiveDateTime; use diesel::result::Error::NotFound; -use lemmy_api_structs::{blocking, site::SearchResponse}; +use lemmy_structs::{blocking, site::SearchResponse}; use lemmy_db::{ comment::{Comment, CommentForm}, comment_view::CommentView, diff --git a/src/apub/inbox/activities/create.rs b/src/apub/inbox/activities/create.rs index 66286ce1..d54834e1 100644 --- a/src/apub/inbox/activities/create.rs +++ b/src/apub/inbox/activities/create.rs @@ -9,20 +9,17 @@ use crate::{ FromApub, PageExt, }, - websocket::{ - messages::{SendComment, SendPost}, - UserOperation, - }, LemmyContext, }; use activitystreams::{activity::Create, base::AnyBase, object::Note, prelude::*}; use actix_web::HttpResponse; use anyhow::Context; -use lemmy_api_structs::{ +use lemmy_structs::{ blocking, comment::CommentResponse, post::PostResponse, send_local_notifs, + websocket::{SendComment, SendPost, UserOperation}, }; use lemmy_db::{ comment::{Comment, CommentForm}, diff --git a/src/apub/inbox/activities/delete.rs b/src/apub/inbox/activities/delete.rs index 4adc7c33..41615132 100644 --- a/src/apub/inbox/activities/delete.rs +++ b/src/apub/inbox/activities/delete.rs @@ -11,20 +11,17 @@ use crate::{ GroupExt, PageExt, }, - websocket::{ - messages::{SendComment, SendCommunityRoomMessage, SendPost}, - UserOperation, - }, LemmyContext, }; use activitystreams::{activity::Delete, base::AnyBase, object::Note, prelude::*}; use actix_web::HttpResponse; use anyhow::Context; -use lemmy_api_structs::{ +use lemmy_structs::{ blocking, comment::CommentResponse, community::CommunityResponse, post::PostResponse, + websocket::{SendComment, SendCommunityRoomMessage, SendPost, UserOperation}, }; use lemmy_db::{ comment::{Comment, CommentForm}, diff --git a/src/apub/inbox/activities/dislike.rs b/src/apub/inbox/activities/dislike.rs index 9b63e82d..07bf0815 100644 --- a/src/apub/inbox/activities/dislike.rs +++ b/src/apub/inbox/activities/dislike.rs @@ -9,16 +9,17 @@ use crate::{ FromApub, PageExt, }, - websocket::{ - messages::{SendComment, SendPost}, - UserOperation, - }, LemmyContext, }; use activitystreams::{activity::Dislike, base::AnyBase, object::Note, prelude::*}; use actix_web::HttpResponse; use anyhow::Context; -use lemmy_api_structs::{blocking, comment::CommentResponse, post::PostResponse}; +use lemmy_structs::{ + blocking, + comment::CommentResponse, + post::PostResponse, + websocket::{SendComment, SendPost, UserOperation}, +}; use lemmy_db::{ comment::{CommentForm, CommentLike, CommentLikeForm}, comment_view::CommentView, diff --git a/src/apub/inbox/activities/like.rs b/src/apub/inbox/activities/like.rs index e6f865b9..dbb6363d 100644 --- a/src/apub/inbox/activities/like.rs +++ b/src/apub/inbox/activities/like.rs @@ -9,16 +9,17 @@ use crate::{ FromApub, PageExt, }, - websocket::{ - messages::{SendComment, SendPost}, - UserOperation, - }, LemmyContext, }; use activitystreams::{activity::Like, base::AnyBase, object::Note, prelude::*}; use actix_web::HttpResponse; use anyhow::Context; -use lemmy_api_structs::{blocking, comment::CommentResponse, post::PostResponse}; +use lemmy_structs::{ + blocking, + comment::CommentResponse, + post::PostResponse, + websocket::{SendComment, SendPost, UserOperation}, +}; use lemmy_db::{ comment::{CommentForm, CommentLike, CommentLikeForm}, comment_view::CommentView, diff --git a/src/apub/inbox/activities/remove.rs b/src/apub/inbox/activities/remove.rs index 011f57b9..3299d5cf 100644 --- a/src/apub/inbox/activities/remove.rs +++ b/src/apub/inbox/activities/remove.rs @@ -12,20 +12,17 @@ use crate::{ GroupExt, PageExt, }, - websocket::{ - messages::{SendComment, SendCommunityRoomMessage, SendPost}, - UserOperation, - }, LemmyContext, }; use activitystreams::{activity::Remove, base::AnyBase, object::Note, prelude::*}; use actix_web::HttpResponse; use anyhow::{anyhow, Context}; -use lemmy_api_structs::{ +use lemmy_structs::{ blocking, comment::CommentResponse, community::CommunityResponse, post::PostResponse, + websocket::{SendComment, SendCommunityRoomMessage, SendPost, UserOperation}, }; use lemmy_db::{ comment::{Comment, CommentForm}, diff --git a/src/apub/inbox/activities/undo.rs b/src/apub/inbox/activities/undo.rs index bf207386..c3dad420 100644 --- a/src/apub/inbox/activities/undo.rs +++ b/src/apub/inbox/activities/undo.rs @@ -11,10 +11,6 @@ use crate::{ GroupExt, PageExt, }, - websocket::{ - messages::{SendComment, SendCommunityRoomMessage, SendPost}, - UserOperation, - }, LemmyContext, }; use activitystreams::{ @@ -25,11 +21,12 @@ use activitystreams::{ }; use actix_web::HttpResponse; use anyhow::{anyhow, Context}; -use lemmy_api_structs::{ +use lemmy_structs::{ blocking, comment::CommentResponse, community::CommunityResponse, post::PostResponse, + websocket::{SendComment, SendCommunityRoomMessage, SendPost, UserOperation}, }; use lemmy_db::{ comment::{Comment, CommentForm, CommentLike}, diff --git a/src/apub/inbox/activities/update.rs b/src/apub/inbox/activities/update.rs index f078e67a..137dc061 100644 --- a/src/apub/inbox/activities/update.rs +++ b/src/apub/inbox/activities/update.rs @@ -10,20 +10,17 @@ use crate::{ FromApub, PageExt, }, - websocket::{ - messages::{SendComment, SendPost}, - UserOperation, - }, LemmyContext, }; use activitystreams::{activity::Update, base::AnyBase, object::Note, prelude::*}; use actix_web::HttpResponse; use anyhow::Context; -use lemmy_api_structs::{ +use lemmy_structs::{ blocking, comment::CommentResponse, post::PostResponse, send_local_notifs, + websocket::{SendComment, SendPost, UserOperation}, }; use lemmy_db::{ comment::{Comment, CommentForm}, diff --git a/src/apub/inbox/community_inbox.rs b/src/apub/inbox/community_inbox.rs index b27e6b6a..e60c3fe7 100644 --- a/src/apub/inbox/community_inbox.rs +++ b/src/apub/inbox/community_inbox.rs @@ -15,7 +15,7 @@ use activitystreams::{ }; use actix_web::{web, HttpRequest, HttpResponse}; use anyhow::{anyhow, Context}; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::{ community::{Community, CommunityFollower, CommunityFollowerForm}, user::User_, diff --git a/src/apub/inbox/user_inbox.rs b/src/apub/inbox/user_inbox.rs index ccc4d105..cf47a597 100644 --- a/src/apub/inbox/user_inbox.rs +++ b/src/apub/inbox/user_inbox.rs @@ -6,7 +6,6 @@ use crate::{ insert_activity, FromApub, }, - websocket::{messages::SendUserRoomMessage, UserOperation}, LemmyContext, }; use activitystreams::{ @@ -17,7 +16,11 @@ use activitystreams::{ }; use actix_web::{web, HttpRequest, HttpResponse}; use anyhow::Context; -use lemmy_api_structs::{blocking, user::PrivateMessageResponse}; +use lemmy_structs::{ + blocking, + user::PrivateMessageResponse, + websocket::{SendUserRoomMessage, UserOperation}, +}; use lemmy_db::{ community::{CommunityFollower, CommunityFollowerForm}, naive_now, diff --git a/src/apub/mod.rs b/src/apub/mod.rs index e9184c33..db489622 100644 --- a/src/apub/mod.rs +++ b/src/apub/mod.rs @@ -32,7 +32,7 @@ use activitystreams_ext::{Ext1, Ext2}; use actix_web::{body::Body, HttpResponse}; use anyhow::{anyhow, Context}; use chrono::NaiveDateTime; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::{activity::do_insert_activity, user::User_}; use lemmy_utils::{ apub::get_apub_protocol_string, diff --git a/src/apub/post.rs b/src/apub/post.rs index be9e2304..d2fa7dc5 100644 --- a/src/apub/post.rs +++ b/src/apub/post.rs @@ -35,7 +35,7 @@ use activitystreams::{ use activitystreams_ext::Ext1; use actix_web::{body::Body, web, HttpResponse}; use anyhow::Context; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::{ community::Community, post::{Post, PostForm}, diff --git a/src/apub/private_message.rs b/src/apub/private_message.rs index 6ae30a3f..00196bfd 100644 --- a/src/apub/private_message.rs +++ b/src/apub/private_message.rs @@ -27,7 +27,7 @@ use activitystreams::{ prelude::*, }; use anyhow::Context; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::{ private_message::{PrivateMessage, PrivateMessageForm}, user::User_, diff --git a/src/apub/user.rs b/src/apub/user.rs index 54daadb9..5bd6d257 100644 --- a/src/apub/user.rs +++ b/src/apub/user.rs @@ -27,7 +27,7 @@ use activitystreams::{ use activitystreams_ext::Ext1; use actix_web::{body::Body, web, HttpResponse}; use anyhow::Context; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::{ naive_now, user::{UserForm, User_}, diff --git a/src/lib.rs b/src/lib.rs index 11b8df7c..2bab3552 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,5 @@ #![recursion_limit = "512"] #[macro_use] -extern crate strum_macros; -#[macro_use] extern crate lazy_static; extern crate actix; extern crate actix_web; diff --git a/src/main.rs b/src/main.rs index 6ec2b81e..39ab014d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ use diesel::{ PgConnection, }; use lazy_static::lazy_static; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::get_database_url_from_env; use lemmy_rate_limit::{rate_limiter::RateLimiter, RateLimit}; use lemmy_server::{ diff --git a/src/routes/api.rs b/src/routes/api.rs index 3435b543..fffb7cdf 100644 --- a/src/routes/api.rs +++ b/src/routes/api.rs @@ -1,6 +1,6 @@ use crate::{api::Perform, LemmyContext}; use actix_web::{error::ErrorBadRequest, *}; -use lemmy_api_structs::{comment::*, community::*, post::*, site::*, user::*}; +use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*}; use lemmy_rate_limit::RateLimit; use serde::Deserialize; diff --git a/src/routes/feeds.rs b/src/routes/feeds.rs index 1d864149..c73b8e05 100644 --- a/src/routes/feeds.rs +++ b/src/routes/feeds.rs @@ -3,7 +3,7 @@ use actix_web::{error::ErrorBadRequest, *}; use anyhow::anyhow; use chrono::{DateTime, NaiveDateTime, Utc}; use diesel::PgConnection; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::{ comment_view::{ReplyQueryBuilder, ReplyView}, community::Community, diff --git a/src/routes/nodeinfo.rs b/src/routes/nodeinfo.rs index 2273fae5..20e55cca 100644 --- a/src/routes/nodeinfo.rs +++ b/src/routes/nodeinfo.rs @@ -1,7 +1,7 @@ use crate::{version, LemmyContext}; use actix_web::{body::Body, error::ErrorBadRequest, *}; use anyhow::anyhow; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::site_view::SiteView; use lemmy_utils::{apub::get_apub_protocol_string, settings::Settings, LemmyError}; use serde::{Deserialize, Serialize}; diff --git a/src/routes/webfinger.rs b/src/routes/webfinger.rs index 458fa0f3..1ea38867 100644 --- a/src/routes/webfinger.rs +++ b/src/routes/webfinger.rs @@ -1,7 +1,7 @@ use crate::LemmyContext; use actix_web::{error::ErrorBadRequest, web::Query, *}; use anyhow::anyhow; -use lemmy_api_structs::blocking; +use lemmy_structs::blocking; use lemmy_db::{community::Community, user::User_}; use lemmy_utils::{ settings::Settings, diff --git a/src/routes/websocket.rs b/src/routes/websocket.rs index 540af34f..aaa7ef37 100644 --- a/src/routes/websocket.rs +++ b/src/routes/websocket.rs @@ -1,13 +1,8 @@ -use crate::{ - websocket::{ - chat_server::ChatServer, - messages::{Connect, Disconnect, StandardMessage, WSMessage}, - }, - LemmyContext, -}; +use crate::{websocket::chat_server::ChatServer, LemmyContext}; use actix::prelude::*; use actix_web::*; use actix_web_actors::ws; +use lemmy_structs::websocket::{Connect, Disconnect, StandardMessage, WSMessage}; use lemmy_utils::utils::get_ip; use log::{debug, error, info}; use std::time::{Duration, Instant}; diff --git a/src/websocket/chat_server.rs b/src/websocket/chat_server.rs index 2da10721..13106d9d 100644 --- a/src/websocket/chat_server.rs +++ b/src/websocket/chat_server.rs @@ -1,9 +1,5 @@ use crate::{ - websocket::{ - handlers::{do_user_operation, to_json_string, Args}, - messages::*, - UserOperation, - }, + websocket::handlers::{do_user_operation, to_json_string, Args}, LemmyContext, }; use actix::prelude::*; @@ -13,7 +9,7 @@ use diesel::{ r2d2::{ConnectionManager, Pool}, PgConnection, }; -use lemmy_api_structs::{comment::*, community::*, post::*, site::*, user::*}; +use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*, websocket::*}; use lemmy_rate_limit::RateLimit; use lemmy_utils::{ location_info, diff --git a/src/websocket/handlers.rs b/src/websocket/handlers.rs index a65e88bb..b3c8d541 100644 --- a/src/websocket/handlers.rs +++ b/src/websocket/handlers.rs @@ -1,14 +1,11 @@ use crate::{ api::Perform, - websocket::{ - chat_server::{ChatServer, SessionInfo}, - messages::*, - UserOperation, - }, + websocket::chat_server::{ChatServer, SessionInfo}, LemmyContext, }; use actix::{Actor, Context, Handler, ResponseFuture}; use actix_web::web; +use lemmy_structs::websocket::*; use lemmy_db::naive_now; use lemmy_rate_limit::RateLimit; use lemmy_utils::{ConnectionId, IPAddr, LemmyError}; diff --git a/src/websocket/mod.rs b/src/websocket/mod.rs index 42793a78..e892f78f 100644 --- a/src/websocket/mod.rs +++ b/src/websocket/mod.rs @@ -1,67 +1,2 @@ pub mod chat_server; pub mod handlers; -pub mod messages; - -#[derive(EnumString, ToString, Debug, Clone)] -pub enum UserOperation { - Login, - Register, - GetCaptcha, - CreateCommunity, - CreatePost, - ListCommunities, - ListCategories, - GetPost, - GetCommunity, - CreateComment, - EditComment, - DeleteComment, - RemoveComment, - MarkCommentAsRead, - SaveComment, - CreateCommentLike, - GetPosts, - CreatePostLike, - EditPost, - DeletePost, - RemovePost, - LockPost, - StickyPost, - SavePost, - EditCommunity, - DeleteCommunity, - RemoveCommunity, - FollowCommunity, - GetFollowedCommunities, - GetUserDetails, - GetReplies, - GetUserMentions, - MarkUserMentionAsRead, - GetModlog, - BanFromCommunity, - AddModToCommunity, - CreateSite, - EditSite, - GetSite, - AddAdmin, - BanUser, - Search, - MarkAllAsRead, - SaveUserSettings, - TransferCommunity, - TransferSite, - DeleteAccount, - PasswordReset, - PasswordChange, - CreatePrivateMessage, - EditPrivateMessage, - DeletePrivateMessage, - MarkPrivateMessageAsRead, - GetPrivateMessages, - UserJoin, - GetComments, - GetSiteConfig, - SaveSiteConfig, - PostJoin, - CommunityJoin, -}