From: Felix Ableitner Date: Sat, 26 Nov 2022 02:04:46 +0000 (+0100) Subject: Merge websocket crate into api_common X-Git-Url: http://these/git/readmes/%7BimageSrc%7D?a=commitdiff_plain;h=030afbc2e78a91b1a302ca59c4ea0ccef9057019;p=lemmy.git Merge websocket crate into api_common --- diff --git a/Cargo.lock b/Cargo.lock index c083fba9..95475492 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2050,7 +2050,6 @@ dependencies = [ "lemmy_db_views_actor", "lemmy_db_views_moderator", "lemmy_utils", - "lemmy_websocket", "serde", "serde_json", "serial_test", @@ -2063,8 +2062,12 @@ dependencies = [ name = "lemmy_api_common" version = "0.16.5" dependencies = [ + "actix", "actix-rt", "actix-web", + "actix-web-actors", + "anyhow", + "background-jobs", "chrono", "diesel", "encoding", @@ -2073,13 +2076,20 @@ dependencies = [ "lemmy_db_views_actor", "lemmy_db_views_moderator", "lemmy_utils", + "opentelemetry 0.17.0", "percent-encoding", + "rand 0.8.5", "regex", "reqwest", "reqwest-middleware", "rosetta-i18n", "serde", + "serde_json", + "strum", + "strum_macros", + "tokio", "tracing", + "tracing-opentelemetry 0.17.4", "url", "webpage", ] @@ -2098,7 +2108,6 @@ dependencies = [ "lemmy_db_views", "lemmy_db_views_actor", "lemmy_utils", - "lemmy_websocket", "serde", "serde_json", "tracing", @@ -2131,7 +2140,6 @@ dependencies = [ "lemmy_db_views", "lemmy_db_views_actor", "lemmy_utils", - "lemmy_websocket", "once_cell", "reqwest", "reqwest-middleware", @@ -2228,7 +2236,6 @@ dependencies = [ "lemmy_db_views", "lemmy_db_views_actor", "lemmy_utils", - "lemmy_websocket", "once_cell", "reqwest", "reqwest-middleware", @@ -2260,7 +2267,6 @@ dependencies = [ "lemmy_db_schema", "lemmy_routes", "lemmy_utils", - "lemmy_websocket", "opentelemetry 0.17.0", "opentelemetry-otlp", "parking_lot", @@ -2317,34 +2323,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "lemmy_websocket" -version = "0.16.5" -dependencies = [ - "actix", - "actix-web", - "actix-web-actors", - "anyhow", - "background-jobs", - "chrono", - "diesel", - "lemmy_api_common", - "lemmy_db_schema", - "lemmy_db_views", - "lemmy_db_views_actor", - "lemmy_utils", - "opentelemetry 0.17.0", - "rand 0.8.5", - "reqwest-middleware", - "serde", - "serde_json", - "strum", - "strum_macros", - "tokio", - "tracing", - "tracing-opentelemetry 0.17.4", -] - [[package]] name = "lettre" version = "0.10.1" diff --git a/Cargo.toml b/Cargo.toml index 67e85b27..16ca864f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,6 @@ members = [ "crates/db_views", "crates/db_views_actor", "crates/db_views_actor", - "crates/websocket", "crates/routes" ] @@ -56,7 +55,6 @@ lemmy_apub = { version = "=0.16.5", path = "./crates/apub" } lemmy_utils = { version = "=0.16.5", path = "./crates/utils" } lemmy_db_schema = { version = "=0.16.5", path = "./crates/db_schema" } lemmy_api_common = { version = "=0.16.5", path = "./crates/api_common" } -lemmy_websocket = { version = "=0.16.5", path = "./crates/websocket" } lemmy_routes = { version = "=0.16.5", path = "./crates/routes" } lemmy_db_views = { version = "=0.16.5", path = "./crates/db_views" } lemmy_db_views_actor = { version = "=0.16.5", path = "./crates/db_views_actor" } @@ -116,7 +114,6 @@ lemmy_apub = { workspace = true } lemmy_utils = { workspace = true } lemmy_db_schema = { workspace = true } lemmy_api_common = { workspace = true } -lemmy_websocket = { workspace = true } lemmy_routes = { workspace = true } activitypub_federation = { workspace = true } diesel = { workspace = true } diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index b707545b..17c0127b 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -21,7 +21,6 @@ lemmy_db_views = { workspace = true, features = ["full"] } lemmy_db_views_moderator = { workspace = true, features = ["full"] } lemmy_db_views_actor = { workspace = true, features = ["full"] } lemmy_api_common = { workspace = true, features = ["full"] } -lemmy_websocket = { workspace = true } activitypub_federation = { workspace = true } diesel = { workspace = true } bcrypt = { workspace = true } diff --git a/crates/api/src/comment/like.rs b/crates/api/src/comment/like.rs index 6ca87f3c..1ba6ec79 100644 --- a/crates/api/src/comment/like.rs +++ b/crates/api/src/comment/like.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ comment::{CommentResponse, CreateCommentLike}, utils::{check_community_ban, check_downvotes_enabled, get_local_user_view_from_jwt}, + websocket::{send::send_comment_ws_message, UserOperation}, + LemmyContext, }; use lemmy_apub::{ fetcher::post_or_comment::PostOrComment, @@ -22,7 +24,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::{CommentView, LocalUserView}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperation}; use std::convert::TryInto; #[async_trait::async_trait(?Send)] diff --git a/crates/api/src/comment/save.rs b/crates/api/src/comment/save.rs index 647f0ed5..cc6955de 100644 --- a/crates/api/src/comment/save.rs +++ b/crates/api/src/comment/save.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ comment::{CommentResponse, SaveComment}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_schema::{ source::comment::{CommentSaved, CommentSavedForm}, @@ -10,7 +11,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::CommentView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for SaveComment { diff --git a/crates/api/src/comment_report/create.rs b/crates/api/src/comment_report/create.rs index 2533aba1..99c653e2 100644 --- a/crates/api/src/comment_report/create.rs +++ b/crates/api/src/comment_report/create.rs @@ -4,6 +4,8 @@ use actix_web::web::Data; use lemmy_api_common::{ comment::{CommentReportResponse, CreateCommentReport}, utils::{check_community_ban, get_local_user_view_from_jwt}, + websocket::{messages::SendModRoomMessage, UserOperation}, + LemmyContext, }; use lemmy_apub::protocol::activities::community::report::Report; use lemmy_db_schema::{ @@ -15,7 +17,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::{CommentReportView, CommentView}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; /// Creates a comment report and notifies the moderators of the community #[async_trait::async_trait(?Send)] diff --git a/crates/api/src/comment_report/list.rs b/crates/api/src/comment_report/list.rs index 4a9041e9..b99716e8 100644 --- a/crates/api/src/comment_report/list.rs +++ b/crates/api/src/comment_report/list.rs @@ -3,10 +3,10 @@ use actix_web::web::Data; use lemmy_api_common::{ comment::{ListCommentReports, ListCommentReportsResponse}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_views::comment_report_view::CommentReportQuery; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; /// Lists comment reports for a community if an id is supplied /// or returns all comment reports for communities a user moderates diff --git a/crates/api/src/comment_report/resolve.rs b/crates/api/src/comment_report/resolve.rs index 8055e948..16598ffa 100644 --- a/crates/api/src/comment_report/resolve.rs +++ b/crates/api/src/comment_report/resolve.rs @@ -3,11 +3,12 @@ use actix_web::web::Data; use lemmy_api_common::{ comment::{CommentReportResponse, ResolveCommentReport}, utils::{get_local_user_view_from_jwt, is_mod_or_admin}, + websocket::{messages::SendModRoomMessage, UserOperation}, + LemmyContext, }; use lemmy_db_schema::{source::comment_report::CommentReport, traits::Reportable}; use lemmy_db_views::structs::CommentReportView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; /// Resolves or unresolves a comment report and notifies the moderators of the community #[async_trait::async_trait(?Send)] diff --git a/crates/api/src/community/add_mod.rs b/crates/api/src/community/add_mod.rs index ff54edda..d307a672 100644 --- a/crates/api/src/community/add_mod.rs +++ b/crates/api/src/community/add_mod.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ community::{AddModToCommunity, AddModToCommunityResponse}, utils::{get_local_user_view_from_jwt, is_mod_or_admin}, + websocket::{messages::SendCommunityRoomMessage, UserOperation}, + LemmyContext, }; use lemmy_apub::{ objects::{community::ApubCommunity, person::ApubPerson}, @@ -18,7 +20,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::CommunityModeratorView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext, UserOperation}; #[async_trait::async_trait(?Send)] impl Perform for AddModToCommunity { diff --git a/crates/api/src/community/ban.rs b/crates/api/src/community/ban.rs index 7b0897ad..018ccd01 100644 --- a/crates/api/src/community/ban.rs +++ b/crates/api/src/community/ban.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ community::{BanFromCommunity, BanFromCommunityResponse}, utils::{get_local_user_view_from_jwt, is_mod_or_admin, remove_user_data_in_community}, + websocket::{messages::SendCommunityRoomMessage, UserOperation}, + LemmyContext, }; use lemmy_apub::{ activities::block::SiteOrCommunity, @@ -25,7 +27,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_utils::{error::LemmyError, utils::naive_from_unix, ConnectionId}; -use lemmy_websocket::{messages::SendCommunityRoomMessage, LemmyContext, UserOperation}; #[async_trait::async_trait(?Send)] impl Perform for BanFromCommunity { diff --git a/crates/api/src/community/block.rs b/crates/api/src/community/block.rs index 840d1766..6c6efc21 100644 --- a/crates/api/src/community/block.rs +++ b/crates/api/src/community/block.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ community::{BlockCommunity, BlockCommunityResponse}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_apub::protocol::activities::following::undo_follow::UndoFollow; use lemmy_db_schema::{ @@ -14,7 +15,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::CommunityView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for BlockCommunity { diff --git a/crates/api/src/community/follow.rs b/crates/api/src/community/follow.rs index fbabebc2..51d5ad9b 100644 --- a/crates/api/src/community/follow.rs +++ b/crates/api/src/community/follow.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ community::{CommunityResponse, FollowCommunity}, utils::{check_community_ban, check_community_deleted_or_removed, get_local_user_view_from_jwt}, + LemmyContext, }; use lemmy_apub::{ objects::community::ApubCommunity, @@ -17,7 +18,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::CommunityView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for FollowCommunity { diff --git a/crates/api/src/community/hide.rs b/crates/api/src/community/hide.rs index 111a89d0..54a08135 100644 --- a/crates/api/src/community/hide.rs +++ b/crates/api/src/community/hide.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ community::{CommunityResponse, HideCommunity}, utils::{get_local_user_view_from_jwt, is_admin}, + websocket::{send::send_community_ws_message, UserOperationCrud}, + LemmyContext, }; use lemmy_apub::protocol::activities::community::update::UpdateCommunity; use lemmy_db_schema::{ @@ -13,7 +15,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud}; #[async_trait::async_trait(?Send)] impl Perform for HideCommunity { diff --git a/crates/api/src/community/transfer.rs b/crates/api/src/community/transfer.rs index 5da0d8e3..bb69de09 100644 --- a/crates/api/src/community/transfer.rs +++ b/crates/api/src/community/transfer.rs @@ -4,6 +4,7 @@ use anyhow::Context; use lemmy_api_common::{ community::{GetCommunityResponse, TransferCommunity}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_schema::{ source::{ @@ -14,7 +15,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView, PersonViewSafe}; use lemmy_utils::{error::LemmyError, location_info, ConnectionId}; -use lemmy_websocket::LemmyContext; // TODO: we dont do anything for federation here, it should be updated the next time the community // gets fetched. i hope we can get rid of the community creator role soon. diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index dbff533e..0473f1e8 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -66,11 +66,15 @@ use lemmy_api_common::{ Search, }, utils::local_site_to_slur_regex, - websocket::{CommunityJoin, ModJoin, PostJoin, UserJoin}, + websocket::{ + serialize_websocket_message, + structs::{CommunityJoin, ModJoin, PostJoin, UserJoin}, + UserOperation, + }, + LemmyContext, }; use lemmy_db_schema::source::local_site::LocalSite; use lemmy_utils::{error::LemmyError, utils::check_slurs, ConnectionId}; -use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation}; use serde::Deserialize; mod comment; diff --git a/crates/api/src/local_user/add_admin.rs b/crates/api/src/local_user/add_admin.rs index ceca80f9..8091f97e 100644 --- a/crates/api/src/local_user/add_admin.rs +++ b/crates/api/src/local_user/add_admin.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{AddAdmin, AddAdminResponse}, utils::{get_local_user_view_from_jwt, is_admin}, + websocket::{messages::SendAllMessage, UserOperation}, + LemmyContext, }; use lemmy_db_schema::{ source::{ @@ -13,7 +15,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{messages::SendAllMessage, LemmyContext, UserOperation}; #[async_trait::async_trait(?Send)] impl Perform for AddAdmin { diff --git a/crates/api/src/local_user/ban_person.rs b/crates/api/src/local_user/ban_person.rs index 2482e408..a848175e 100644 --- a/crates/api/src/local_user/ban_person.rs +++ b/crates/api/src/local_user/ban_person.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{BanPerson, BanPersonResponse}, utils::{get_local_user_view_from_jwt, is_admin, remove_user_data}, + websocket::{messages::SendAllMessage, UserOperation}, + LemmyContext, }; use lemmy_apub::{ activities::block::SiteOrCommunity, @@ -18,7 +20,6 @@ use lemmy_db_schema::{ use lemmy_db_views::structs::SiteView; use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_utils::{error::LemmyError, utils::naive_from_unix, ConnectionId}; -use lemmy_websocket::{messages::SendAllMessage, LemmyContext, UserOperation}; #[async_trait::async_trait(?Send)] impl Perform for BanPerson { diff --git a/crates/api/src/local_user/block.rs b/crates/api/src/local_user/block.rs index 44bd668f..798d3677 100644 --- a/crates/api/src/local_user/block.rs +++ b/crates/api/src/local_user/block.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{BlockPerson, BlockPersonResponse}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_schema::{ source::person_block::{PersonBlock, PersonBlockForm}, @@ -10,7 +11,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for BlockPerson { diff --git a/crates/api/src/local_user/change_password.rs b/crates/api/src/local_user/change_password.rs index 38fac32b..e4e9004e 100644 --- a/crates/api/src/local_user/change_password.rs +++ b/crates/api/src/local_user/change_password.rs @@ -4,10 +4,10 @@ use bcrypt::verify; use lemmy_api_common::{ person::{ChangePassword, LoginResponse}, utils::{get_local_user_view_from_jwt, password_length_check}, + LemmyContext, }; use lemmy_db_schema::source::local_user::LocalUser; use lemmy_utils::{claims::Claims, error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for ChangePassword { diff --git a/crates/api/src/local_user/change_password_after_reset.rs b/crates/api/src/local_user/change_password_after_reset.rs index 3ac48252..f9556b53 100644 --- a/crates/api/src/local_user/change_password_after_reset.rs +++ b/crates/api/src/local_user/change_password_after_reset.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{LoginResponse, PasswordChangeAfterReset}, utils::password_length_check, + LemmyContext, }; use lemmy_db_schema::source::{ local_user::LocalUser, @@ -10,7 +11,6 @@ use lemmy_db_schema::source::{ }; use lemmy_db_views::structs::SiteView; use lemmy_utils::{claims::Claims, error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for PasswordChangeAfterReset { diff --git a/crates/api/src/local_user/get_captcha.rs b/crates/api/src/local_user/get_captcha.rs index 3d1b8884..5eacc4fd 100644 --- a/crates/api/src/local_user/get_captcha.rs +++ b/crates/api/src/local_user/get_captcha.rs @@ -2,10 +2,13 @@ use crate::{captcha_as_wav_base64, Perform}; use actix_web::web::Data; use captcha::{gen, Difficulty}; use chrono::Duration; -use lemmy_api_common::person::{CaptchaResponse, GetCaptcha, GetCaptchaResponse}; +use lemmy_api_common::{ + person::{CaptchaResponse, GetCaptcha, GetCaptchaResponse}, + websocket::messages::CaptchaItem, + LemmyContext, +}; use lemmy_db_schema::{source::local_site::LocalSite, utils::naive_now}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{messages::CaptchaItem, LemmyContext}; #[async_trait::async_trait(?Send)] impl Perform for GetCaptcha { diff --git a/crates/api/src/local_user/list_banned.rs b/crates/api/src/local_user/list_banned.rs index 16df72cc..31d4e3be 100644 --- a/crates/api/src/local_user/list_banned.rs +++ b/crates/api/src/local_user/list_banned.rs @@ -3,10 +3,10 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{BannedPersonsResponse, GetBannedPersons}, utils::{get_local_user_view_from_jwt, is_admin}, + LemmyContext, }; use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for GetBannedPersons { diff --git a/crates/api/src/local_user/login.rs b/crates/api/src/local_user/login.rs index 61354387..dac0d9bf 100644 --- a/crates/api/src/local_user/login.rs +++ b/crates/api/src/local_user/login.rs @@ -4,11 +4,11 @@ use bcrypt::verify; use lemmy_api_common::{ person::{Login, LoginResponse}, utils::{check_registration_application, check_user_valid}, + LemmyContext, }; use lemmy_db_schema::source::local_site::LocalSite; use lemmy_db_views::structs::LocalUserView; use lemmy_utils::{claims::Claims, error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for Login { diff --git a/crates/api/src/local_user/notifications/list_mentions.rs b/crates/api/src/local_user/notifications/list_mentions.rs index d231f718..5e3b63e7 100644 --- a/crates/api/src/local_user/notifications/list_mentions.rs +++ b/crates/api/src/local_user/notifications/list_mentions.rs @@ -3,10 +3,10 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{GetPersonMentions, GetPersonMentionsResponse}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_views_actor::person_mention_view::PersonMentionQuery; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for GetPersonMentions { diff --git a/crates/api/src/local_user/notifications/list_replies.rs b/crates/api/src/local_user/notifications/list_replies.rs index 10222998..375864b5 100644 --- a/crates/api/src/local_user/notifications/list_replies.rs +++ b/crates/api/src/local_user/notifications/list_replies.rs @@ -3,10 +3,10 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{GetReplies, GetRepliesResponse}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_views_actor::comment_reply_view::CommentReplyQuery; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for GetReplies { diff --git a/crates/api/src/local_user/notifications/mark_all_read.rs b/crates/api/src/local_user/notifications/mark_all_read.rs index 3b8ad0f4..9f8926dc 100644 --- a/crates/api/src/local_user/notifications/mark_all_read.rs +++ b/crates/api/src/local_user/notifications/mark_all_read.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{GetRepliesResponse, MarkAllAsRead}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_schema::source::{ comment_reply::CommentReply, @@ -10,7 +11,6 @@ use lemmy_db_schema::source::{ private_message::PrivateMessage, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for MarkAllAsRead { diff --git a/crates/api/src/local_user/notifications/mark_mention_read.rs b/crates/api/src/local_user/notifications/mark_mention_read.rs index c42e294a..655f7884 100644 --- a/crates/api/src/local_user/notifications/mark_mention_read.rs +++ b/crates/api/src/local_user/notifications/mark_mention_read.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{MarkPersonMentionAsRead, PersonMentionResponse}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_schema::{ source::person_mention::{PersonMention, PersonMentionUpdateForm}, @@ -10,7 +11,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::PersonMentionView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for MarkPersonMentionAsRead { diff --git a/crates/api/src/local_user/notifications/mark_reply_read.rs b/crates/api/src/local_user/notifications/mark_reply_read.rs index 2ec5fd80..fa3367e3 100644 --- a/crates/api/src/local_user/notifications/mark_reply_read.rs +++ b/crates/api/src/local_user/notifications/mark_reply_read.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{CommentReplyResponse, MarkCommentReplyAsRead}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_schema::{ source::comment_reply::{CommentReply, CommentReplyUpdateForm}, @@ -10,7 +11,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::CommentReplyView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for MarkCommentReplyAsRead { diff --git a/crates/api/src/local_user/notifications/unread_count.rs b/crates/api/src/local_user/notifications/unread_count.rs index 47d826fd..442977a2 100644 --- a/crates/api/src/local_user/notifications/unread_count.rs +++ b/crates/api/src/local_user/notifications/unread_count.rs @@ -3,11 +3,11 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{GetUnreadCount, GetUnreadCountResponse}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_views::structs::PrivateMessageView; use lemmy_db_views_actor::structs::{CommentReplyView, PersonMentionView}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for GetUnreadCount { diff --git a/crates/api/src/local_user/report_count.rs b/crates/api/src/local_user/report_count.rs index 1372e4ca..7dd63b7a 100644 --- a/crates/api/src/local_user/report_count.rs +++ b/crates/api/src/local_user/report_count.rs @@ -3,10 +3,10 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{GetReportCount, GetReportCountResponse}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_views::structs::{CommentReportView, PostReportView, PrivateMessageReportView}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for GetReportCount { diff --git a/crates/api/src/local_user/reset_password.rs b/crates/api/src/local_user/reset_password.rs index 078d55ec..8def6d3c 100644 --- a/crates/api/src/local_user/reset_password.rs +++ b/crates/api/src/local_user/reset_password.rs @@ -3,10 +3,10 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{PasswordReset, PasswordResetResponse}, utils::send_password_reset_email, + LemmyContext, }; use lemmy_db_views::structs::LocalUserView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for PasswordReset { diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index 4aa3a743..807e8262 100644 --- a/crates/api/src/local_user/save_settings.rs +++ b/crates/api/src/local_user/save_settings.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{LoginResponse, SaveUserSettings}, utils::{get_local_user_view_from_jwt, send_verification_email}, + LemmyContext, }; use lemmy_db_schema::{ source::{ @@ -20,7 +21,6 @@ use lemmy_utils::{ utils::{is_valid_display_name, is_valid_matrix_id}, ConnectionId, }; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for SaveUserSettings { diff --git a/crates/api/src/local_user/verify_email.rs b/crates/api/src/local_user/verify_email.rs index 73db4bea..238692ff 100644 --- a/crates/api/src/local_user/verify_email.rs +++ b/crates/api/src/local_user/verify_email.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{VerifyEmail, VerifyEmailResponse}, utils::send_email_verification_success, + LemmyContext, }; use lemmy_db_schema::{ source::{ @@ -13,7 +14,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::LocalUserView; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for VerifyEmail { diff --git a/crates/api/src/post/get_link_metadata.rs b/crates/api/src/post/get_link_metadata.rs index 54e2cfe7..aae211a5 100644 --- a/crates/api/src/post/get_link_metadata.rs +++ b/crates/api/src/post/get_link_metadata.rs @@ -3,9 +3,9 @@ use actix_web::web::Data; use lemmy_api_common::{ post::{GetSiteMetadata, GetSiteMetadataResponse}, request::fetch_site_metadata, + LemmyContext, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for GetSiteMetadata { diff --git a/crates/api/src/post/like.rs b/crates/api/src/post/like.rs index ec2edc33..d15e649b 100644 --- a/crates/api/src/post/like.rs +++ b/crates/api/src/post/like.rs @@ -9,6 +9,8 @@ use lemmy_api_common::{ get_local_user_view_from_jwt, mark_post_as_read, }, + websocket::{send::send_post_ws_message, UserOperation}, + LemmyContext, }; use lemmy_apub::{ fetcher::post_or_comment::PostOrComment, @@ -26,7 +28,6 @@ use lemmy_db_schema::{ traits::{Crud, Likeable}, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation}; #[async_trait::async_trait(?Send)] impl Perform for CreatePostLike { diff --git a/crates/api/src/post/lock.rs b/crates/api/src/post/lock.rs index ae726ee9..4348971f 100644 --- a/crates/api/src/post/lock.rs +++ b/crates/api/src/post/lock.rs @@ -8,6 +8,8 @@ use lemmy_api_common::{ get_local_user_view_from_jwt, is_mod_or_admin, }, + websocket::{send::send_post_ws_message, UserOperation}, + LemmyContext, }; use lemmy_apub::{ objects::post::ApubPost, @@ -21,7 +23,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation}; #[async_trait::async_trait(?Send)] impl Perform for LockPost { diff --git a/crates/api/src/post/mark_read.rs b/crates/api/src/post/mark_read.rs index 18f86521..228fdac0 100644 --- a/crates/api/src/post/mark_read.rs +++ b/crates/api/src/post/mark_read.rs @@ -3,10 +3,10 @@ use actix_web::web::Data; use lemmy_api_common::{ post::{MarkPostAsRead, PostResponse}, utils::{get_local_user_view_from_jwt, mark_post_as_read, mark_post_as_unread}, + LemmyContext, }; use lemmy_db_views::structs::PostView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for MarkPostAsRead { diff --git a/crates/api/src/post/save.rs b/crates/api/src/post/save.rs index 0a240f9e..9e8ca9ce 100644 --- a/crates/api/src/post/save.rs +++ b/crates/api/src/post/save.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ post::{PostResponse, SavePost}, utils::{get_local_user_view_from_jwt, mark_post_as_read}, + LemmyContext, }; use lemmy_db_schema::{ source::post::{PostSaved, PostSavedForm}, @@ -10,7 +11,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::PostView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for SavePost { diff --git a/crates/api/src/post/sticky.rs b/crates/api/src/post/sticky.rs index 384ba52d..ccba5f2c 100644 --- a/crates/api/src/post/sticky.rs +++ b/crates/api/src/post/sticky.rs @@ -8,6 +8,8 @@ use lemmy_api_common::{ get_local_user_view_from_jwt, is_mod_or_admin, }, + websocket::{send::send_post_ws_message, UserOperation}, + LemmyContext, }; use lemmy_apub::{ objects::post::ApubPost, @@ -21,7 +23,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation}; #[async_trait::async_trait(?Send)] impl Perform for StickyPost { diff --git a/crates/api/src/post_report/create.rs b/crates/api/src/post_report/create.rs index ca4113a3..2fd2d08b 100644 --- a/crates/api/src/post_report/create.rs +++ b/crates/api/src/post_report/create.rs @@ -4,6 +4,8 @@ use actix_web::web::Data; use lemmy_api_common::{ post::{CreatePostReport, PostReportResponse}, utils::{check_community_ban, get_local_user_view_from_jwt}, + websocket::{messages::SendModRoomMessage, UserOperation}, + LemmyContext, }; use lemmy_apub::protocol::activities::community::report::Report; use lemmy_db_schema::{ @@ -15,7 +17,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::{PostReportView, PostView}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; /// Creates a post report and notifies the moderators of the community #[async_trait::async_trait(?Send)] diff --git a/crates/api/src/post_report/list.rs b/crates/api/src/post_report/list.rs index 7a79f04b..188a722f 100644 --- a/crates/api/src/post_report/list.rs +++ b/crates/api/src/post_report/list.rs @@ -3,10 +3,10 @@ use actix_web::web::Data; use lemmy_api_common::{ post::{ListPostReports, ListPostReportsResponse}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_views::post_report_view::PostReportQuery; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; /// Lists post reports for a community if an id is supplied /// or returns all post reports for communities a user moderates diff --git a/crates/api/src/post_report/resolve.rs b/crates/api/src/post_report/resolve.rs index 687bdcce..6c3d62f1 100644 --- a/crates/api/src/post_report/resolve.rs +++ b/crates/api/src/post_report/resolve.rs @@ -3,11 +3,12 @@ use actix_web::web::Data; use lemmy_api_common::{ post::{PostReportResponse, ResolvePostReport}, utils::{get_local_user_view_from_jwt, is_mod_or_admin}, + websocket::{messages::SendModRoomMessage, UserOperation}, + LemmyContext, }; use lemmy_db_schema::{source::post_report::PostReport, traits::Reportable}; use lemmy_db_views::structs::PostReportView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; /// Resolves or unresolves a post report and notifies the moderators of the community #[async_trait::async_trait(?Send)] diff --git a/crates/api/src/private_message/mark_read.rs b/crates/api/src/private_message/mark_read.rs index 0b7bb676..ba0e70d5 100644 --- a/crates/api/src/private_message/mark_read.rs +++ b/crates/api/src/private_message/mark_read.rs @@ -3,13 +3,14 @@ use actix_web::web::Data; use lemmy_api_common::{ private_message::{MarkPrivateMessageAsRead, PrivateMessageResponse}, utils::get_local_user_view_from_jwt, + websocket::{send::send_pm_ws_message, UserOperation}, + LemmyContext, }; use lemmy_db_schema::{ source::private_message::{PrivateMessage, PrivateMessageUpdateForm}, traits::Crud, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperation}; #[async_trait::async_trait(?Send)] impl Perform for MarkPrivateMessageAsRead { diff --git a/crates/api/src/private_message_report/create.rs b/crates/api/src/private_message_report/create.rs index 490fd55b..6b923c10 100644 --- a/crates/api/src/private_message_report/create.rs +++ b/crates/api/src/private_message_report/create.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ private_message::{CreatePrivateMessageReport, PrivateMessageReportResponse}, utils::get_local_user_view_from_jwt, + websocket::{messages::SendModRoomMessage, UserOperation}, + LemmyContext, }; use lemmy_db_schema::{ newtypes::CommunityId, @@ -15,7 +17,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::PrivateMessageReportView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; #[async_trait::async_trait(?Send)] impl Perform for CreatePrivateMessageReport { diff --git a/crates/api/src/private_message_report/list.rs b/crates/api/src/private_message_report/list.rs index 0279cb83..17fc438f 100644 --- a/crates/api/src/private_message_report/list.rs +++ b/crates/api/src/private_message_report/list.rs @@ -3,10 +3,10 @@ use actix_web::web::Data; use lemmy_api_common::{ private_message::{ListPrivateMessageReports, ListPrivateMessageReportsResponse}, utils::{get_local_user_view_from_jwt, is_admin}, + LemmyContext, }; use lemmy_db_views::private_message_report_view::PrivateMessageReportQuery; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for ListPrivateMessageReports { diff --git a/crates/api/src/private_message_report/resolve.rs b/crates/api/src/private_message_report/resolve.rs index a7af798a..eeda4ed4 100644 --- a/crates/api/src/private_message_report/resolve.rs +++ b/crates/api/src/private_message_report/resolve.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ private_message::{PrivateMessageReportResponse, ResolvePrivateMessageReport}, utils::{get_local_user_view_from_jwt, is_admin}, + websocket::{messages::SendModRoomMessage, UserOperation}, + LemmyContext, }; use lemmy_db_schema::{ newtypes::CommunityId, @@ -11,7 +13,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::PrivateMessageReportView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; #[async_trait::async_trait(?Send)] impl Perform for ResolvePrivateMessageReport { diff --git a/crates/api/src/site/leave_admin.rs b/crates/api/src/site/leave_admin.rs index 4a6687b3..4674f43b 100644 --- a/crates/api/src/site/leave_admin.rs +++ b/crates/api/src/site/leave_admin.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ site::{GetSiteResponse, LeaveAdmin}, utils::{get_local_user_view_from_jwt, is_admin}, + LemmyContext, }; use lemmy_db_schema::{ source::{ @@ -17,7 +18,6 @@ use lemmy_db_schema::{ use lemmy_db_views::structs::SiteView; use lemmy_db_views_actor::structs::PersonViewSafe; use lemmy_utils::{error::LemmyError, version, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for LeaveAdmin { diff --git a/crates/api/src/site/mod_log.rs b/crates/api/src/site/mod_log.rs index f1ab9f45..85bfc40c 100644 --- a/crates/api/src/site/mod_log.rs +++ b/crates/api/src/site/mod_log.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ site::{GetModlog, GetModlogResponse}, utils::{check_private_instance, get_local_user_view_from_jwt_opt, is_admin, is_mod_or_admin}, + LemmyContext, }; use lemmy_db_schema::{ newtypes::{CommunityId, PersonId}, @@ -28,7 +29,6 @@ use lemmy_db_views_moderator::structs::{ ModlogListParams, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; use ModlogActionType::*; #[async_trait::async_trait(?Send)] diff --git a/crates/api/src/site/purge/comment.rs b/crates/api/src/site/purge/comment.rs index d5a11216..54f3c0ed 100644 --- a/crates/api/src/site/purge/comment.rs +++ b/crates/api/src/site/purge/comment.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ site::{PurgeComment, PurgeItemResponse}, utils::{get_local_user_view_from_jwt, is_admin}, + LemmyContext, }; use lemmy_db_schema::{ source::{ @@ -12,7 +13,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for PurgeComment { diff --git a/crates/api/src/site/purge/community.rs b/crates/api/src/site/purge/community.rs index 74373d81..c70c8c0a 100644 --- a/crates/api/src/site/purge/community.rs +++ b/crates/api/src/site/purge/community.rs @@ -4,6 +4,7 @@ use lemmy_api_common::{ request::purge_image_from_pictrs, site::{PurgeCommunity, PurgeItemResponse}, utils::{get_local_user_view_from_jwt, is_admin, purge_image_posts_for_community}, + LemmyContext, }; use lemmy_db_schema::{ source::{ @@ -13,7 +14,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for PurgeCommunity { diff --git a/crates/api/src/site/purge/person.rs b/crates/api/src/site/purge/person.rs index f5aad6e1..8a5f6ac0 100644 --- a/crates/api/src/site/purge/person.rs +++ b/crates/api/src/site/purge/person.rs @@ -4,6 +4,7 @@ use lemmy_api_common::{ request::purge_image_from_pictrs, site::{PurgeItemResponse, PurgePerson}, utils::{get_local_user_view_from_jwt, is_admin, purge_image_posts_for_person}, + LemmyContext, }; use lemmy_db_schema::{ source::{ @@ -13,7 +14,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for PurgePerson { diff --git a/crates/api/src/site/purge/post.rs b/crates/api/src/site/purge/post.rs index ee5adf72..b3ec28ea 100644 --- a/crates/api/src/site/purge/post.rs +++ b/crates/api/src/site/purge/post.rs @@ -4,6 +4,7 @@ use lemmy_api_common::{ request::purge_image_from_pictrs, site::{PurgeItemResponse, PurgePost}, utils::{get_local_user_view_from_jwt, is_admin}, + LemmyContext, }; use lemmy_db_schema::{ source::{ @@ -13,7 +14,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for PurgePost { diff --git a/crates/api/src/site/registration_applications/approve.rs b/crates/api/src/site/registration_applications/approve.rs index bb125259..c5089b5d 100644 --- a/crates/api/src/site/registration_applications/approve.rs +++ b/crates/api/src/site/registration_applications/approve.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ site::{ApproveRegistrationApplication, RegistrationApplicationResponse}, utils::{get_local_user_view_from_jwt, is_admin, send_application_approved_email}, + LemmyContext, }; use lemmy_db_schema::{ source::{ @@ -14,7 +15,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::{LocalUserView, RegistrationApplicationView}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for ApproveRegistrationApplication { diff --git a/crates/api/src/site/registration_applications/list.rs b/crates/api/src/site/registration_applications/list.rs index 3d9ed326..1ce709b3 100644 --- a/crates/api/src/site/registration_applications/list.rs +++ b/crates/api/src/site/registration_applications/list.rs @@ -3,11 +3,11 @@ use actix_web::web::Data; use lemmy_api_common::{ site::{ListRegistrationApplications, ListRegistrationApplicationsResponse}, utils::{get_local_user_view_from_jwt, is_admin}, + LemmyContext, }; use lemmy_db_schema::source::local_site::LocalSite; use lemmy_db_views::registration_application_view::RegistrationApplicationQuery; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; /// Lists registration applications, filterable by undenied only. #[async_trait::async_trait(?Send)] diff --git a/crates/api/src/site/registration_applications/unread_count.rs b/crates/api/src/site/registration_applications/unread_count.rs index 7fb8906a..a22d14e9 100644 --- a/crates/api/src/site/registration_applications/unread_count.rs +++ b/crates/api/src/site/registration_applications/unread_count.rs @@ -3,11 +3,11 @@ use actix_web::web::Data; use lemmy_api_common::{ site::{GetUnreadRegistrationApplicationCount, GetUnreadRegistrationApplicationCountResponse}, utils::{get_local_user_view_from_jwt, is_admin}, + LemmyContext, }; use lemmy_db_schema::source::local_site::LocalSite; use lemmy_db_views::structs::RegistrationApplicationView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for GetUnreadRegistrationApplicationCount { diff --git a/crates/api/src/site/resolve_object.rs b/crates/api/src/site/resolve_object.rs index 0e59c683..47aa248e 100644 --- a/crates/api/src/site/resolve_object.rs +++ b/crates/api/src/site/resolve_object.rs @@ -4,13 +4,13 @@ use diesel::NotFound; use lemmy_api_common::{ site::{ResolveObject, ResolveObjectResponse}, utils::{check_private_instance, get_local_user_view_from_jwt_opt}, + LemmyContext, }; use lemmy_apub::fetcher::search::{search_query_to_object_id, SearchableObjects}; use lemmy_db_schema::{newtypes::PersonId, source::local_site::LocalSite, utils::DbPool}; use lemmy_db_views::structs::{CommentView, PostView}; use lemmy_db_views_actor::structs::{CommunityView, PersonViewSafe}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for ResolveObject { diff --git a/crates/api/src/site/search.rs b/crates/api/src/site/search.rs index 5d813fcf..1033f92e 100644 --- a/crates/api/src/site/search.rs +++ b/crates/api/src/site/search.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ site::{Search, SearchResponse}, utils::{check_private_instance, get_local_user_view_from_jwt_opt}, + LemmyContext, }; use lemmy_apub::{fetcher::resolve_actor_identifier, objects::community::ApubCommunity}; use lemmy_db_schema::{ @@ -14,7 +15,6 @@ use lemmy_db_schema::{ use lemmy_db_views::{comment_view::CommentQuery, post_view::PostQuery}; use lemmy_db_views_actor::{community_view::CommunityQuery, person_view::PersonQuery}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl Perform for Search { diff --git a/crates/api/src/websocket.rs b/crates/api/src/websocket.rs index 391b84e0..0e0c015a 100644 --- a/crates/api/src/websocket.rs +++ b/crates/api/src/websocket.rs @@ -3,21 +3,21 @@ use actix_web::web::Data; use lemmy_api_common::{ utils::get_local_user_view_from_jwt, websocket::{ - CommunityJoin, - CommunityJoinResponse, - ModJoin, - ModJoinResponse, - PostJoin, - PostJoinResponse, - UserJoin, - UserJoinResponse, + messages::{JoinCommunityRoom, JoinModRoom, JoinPostRoom, JoinUserRoom}, + structs::{ + CommunityJoin, + CommunityJoinResponse, + ModJoin, + ModJoinResponse, + PostJoin, + PostJoinResponse, + UserJoin, + UserJoinResponse, + }, }, -}; -use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{ - messages::{JoinCommunityRoom, JoinModRoom, JoinPostRoom, JoinUserRoom}, LemmyContext, }; +use lemmy_utils::{error::LemmyError, ConnectionId}; #[async_trait::async_trait(?Send)] impl Perform for UserJoin { diff --git a/crates/api_common/Cargo.toml b/crates/api_common/Cargo.toml index bfbaa8e2..a4c80da5 100644 --- a/crates/api_common/Cargo.toml +++ b/crates/api_common/Cargo.toml @@ -36,6 +36,17 @@ rosetta-i18n = { workspace = true, optional = true } percent-encoding = { workspace = true, optional = true } webpage = { version = "1.4.0", default-features = false, features = ["serde"], optional = true } encoding = { version = "0.2.33", optional = true } +rand = { workspace = true } +serde_json = { workspace = true } +actix = { workspace = true } +anyhow = { workspace = true } +tokio = { workspace = true } +strum = { workspace = true } +strum_macros = { workspace = true } +opentelemetry = { workspace = true } +tracing-opentelemetry = { workspace = true } +actix-web-actors = { version = "4.1.0", default-features = false } +background-jobs = "0.13.0" [dev-dependencies] actix-rt = { workspace = true } diff --git a/crates/api_common/src/lib.rs b/crates/api_common/src/lib.rs index ef907f88..bcd603e5 100644 --- a/crates/api_common/src/lib.rs +++ b/crates/api_common/src/lib.rs @@ -11,7 +11,78 @@ pub mod site; pub mod utils; pub mod websocket; +#[macro_use] +extern crate strum_macros; pub extern crate lemmy_db_schema; pub extern crate lemmy_db_views; pub extern crate lemmy_db_views_actor; pub extern crate lemmy_db_views_moderator; + +use crate::websocket::chat_server::ChatServer; +use actix::Addr; +use lemmy_db_schema::{source::secret::Secret, utils::DbPool}; +use lemmy_utils::{ + rate_limit::RateLimitCell, + settings::{structs::Settings, SETTINGS}, +}; +use reqwest_middleware::ClientWithMiddleware; + +pub struct LemmyContext { + pool: DbPool, + chat_server: Addr, + client: ClientWithMiddleware, + settings: Settings, + secret: Secret, + rate_limit_cell: RateLimitCell, +} + +impl LemmyContext { + pub fn create( + pool: DbPool, + chat_server: Addr, + client: ClientWithMiddleware, + settings: Settings, + secret: Secret, + settings_updated_channel: RateLimitCell, + ) -> LemmyContext { + LemmyContext { + pool, + chat_server, + client, + settings, + secret, + rate_limit_cell: settings_updated_channel, + } + } + pub fn pool(&self) -> &DbPool { + &self.pool + } + pub fn chat_server(&self) -> &Addr { + &self.chat_server + } + pub fn client(&self) -> &ClientWithMiddleware { + &self.client + } + pub fn settings(&self) -> &'static Settings { + &SETTINGS + } + pub fn secret(&self) -> &Secret { + &self.secret + } + pub fn settings_updated_channel(&self) -> &RateLimitCell { + &self.rate_limit_cell + } +} + +impl Clone for LemmyContext { + fn clone(&self) -> Self { + LemmyContext { + pool: self.pool.clone(), + chat_server: self.chat_server.clone(), + client: self.client.clone(), + settings: self.settings.clone(), + secret: self.secret.clone(), + rate_limit_cell: self.rate_limit_cell.clone(), + } + } +} diff --git a/crates/websocket/src/chat_server.rs b/crates/api_common/src/websocket/chat_server.rs similarity index 98% rename from crates/websocket/src/chat_server.rs rename to crates/api_common/src/websocket/chat_server.rs index 8577e042..c8f59e3d 100644 --- a/crates/websocket/src/chat_server.rs +++ b/crates/api_common/src/websocket/chat_server.rs @@ -1,14 +1,17 @@ use crate::{ - messages::{CaptchaItem, StandardMessage, WsMessage}, - serialize_websocket_message, + comment::CommentResponse, + post::PostResponse, + websocket::{ + messages::{CaptchaItem, StandardMessage, WsMessage}, + serialize_websocket_message, + OperationType, + UserOperation, + UserOperationCrud, + }, LemmyContext, - OperationType, - UserOperation, - UserOperationCrud, }; use actix::prelude::*; use anyhow::Context as acontext; -use lemmy_api_common::{comment::CommentResponse, post::PostResponse}; use lemmy_db_schema::{ newtypes::{CommunityId, LocalUserId, PostId}, source::secret::Secret, diff --git a/crates/websocket/src/handlers.rs b/crates/api_common/src/websocket/handlers.rs similarity index 99% rename from crates/websocket/src/handlers.rs rename to crates/api_common/src/websocket/handlers.rs index 90ef01a4..6f3d164c 100644 --- a/crates/websocket/src/handlers.rs +++ b/crates/api_common/src/websocket/handlers.rs @@ -1,4 +1,4 @@ -use crate::{ +use crate::websocket::{ chat_server::{ChatServer, SessionInfo}, messages::{ CaptchaItem, diff --git a/crates/websocket/src/messages.rs b/crates/api_common/src/websocket/messages.rs similarity index 97% rename from crates/websocket/src/messages.rs rename to crates/api_common/src/websocket/messages.rs index 21b6ac4b..f8112416 100644 --- a/crates/websocket/src/messages.rs +++ b/crates/api_common/src/websocket/messages.rs @@ -1,6 +1,5 @@ -use crate::UserOperation; +use crate::{comment::CommentResponse, post::PostResponse, websocket::UserOperation}; use actix::{prelude::*, Recipient}; -use lemmy_api_common::{comment::CommentResponse, post::PostResponse}; use lemmy_db_schema::newtypes::{CommunityId, LocalUserId, PostId}; use lemmy_utils::{ConnectionId, IpAddr}; use serde::{Deserialize, Serialize}; diff --git a/crates/websocket/src/lib.rs b/crates/api_common/src/websocket/mod.rs similarity index 58% rename from crates/websocket/src/lib.rs rename to crates/api_common/src/websocket/mod.rs index e73e784e..d1e30f44 100644 --- a/crates/websocket/src/lib.rs +++ b/crates/api_common/src/websocket/mod.rs @@ -1,15 +1,4 @@ -#[macro_use] -extern crate strum_macros; - -use crate::chat_server::ChatServer; -use actix::Addr; -use lemmy_db_schema::{source::secret::Secret, utils::DbPool}; -use lemmy_utils::{ - error::LemmyError, - rate_limit::RateLimitCell, - settings::{structs::Settings, SETTINGS}, -}; -use reqwest_middleware::ClientWithMiddleware; +use lemmy_utils::error::LemmyError; use serde::Serialize; pub mod chat_server; @@ -17,66 +6,7 @@ pub mod handlers; pub mod messages; pub mod routes; pub mod send; - -pub struct LemmyContext { - pool: DbPool, - chat_server: Addr, - client: ClientWithMiddleware, - settings: Settings, - secret: Secret, - rate_limit_cell: RateLimitCell, -} - -impl LemmyContext { - pub fn create( - pool: DbPool, - chat_server: Addr, - client: ClientWithMiddleware, - settings: Settings, - secret: Secret, - settings_updated_channel: RateLimitCell, - ) -> LemmyContext { - LemmyContext { - pool, - chat_server, - client, - settings, - secret, - rate_limit_cell: settings_updated_channel, - } - } - pub fn pool(&self) -> &DbPool { - &self.pool - } - pub fn chat_server(&self) -> &Addr { - &self.chat_server - } - pub fn client(&self) -> &ClientWithMiddleware { - &self.client - } - pub fn settings(&self) -> &'static Settings { - &SETTINGS - } - pub fn secret(&self) -> &Secret { - &self.secret - } - pub fn settings_updated_channel(&self) -> &RateLimitCell { - &self.rate_limit_cell - } -} - -impl Clone for LemmyContext { - fn clone(&self) -> Self { - LemmyContext { - pool: self.pool.clone(), - chat_server: self.chat_server.clone(), - client: self.client.clone(), - settings: self.settings.clone(), - secret: self.secret.clone(), - rate_limit_cell: self.rate_limit_cell.clone(), - } - } -} +pub mod structs; #[derive(Serialize)] struct WebsocketResponse { diff --git a/crates/websocket/src/routes.rs b/crates/api_common/src/websocket/routes.rs similarity index 97% rename from crates/websocket/src/routes.rs rename to crates/api_common/src/websocket/routes.rs index a3b1b046..7b500ce4 100644 --- a/crates/websocket/src/routes.rs +++ b/crates/api_common/src/websocket/routes.rs @@ -1,6 +1,8 @@ use crate::{ - chat_server::ChatServer, - messages::{Connect, Disconnect, StandardMessage, WsMessage}, + websocket::{ + chat_server::ChatServer, + messages::{Connect, Disconnect, StandardMessage, WsMessage}, + }, LemmyContext, }; use actix::prelude::*; diff --git a/crates/websocket/src/send.rs b/crates/api_common/src/websocket/send.rs similarity index 98% rename from crates/websocket/src/send.rs rename to crates/api_common/src/websocket/send.rs index 2793534f..6f3506ae 100644 --- a/crates/websocket/src/send.rs +++ b/crates/api_common/src/websocket/send.rs @@ -1,14 +1,14 @@ use crate::{ - messages::{SendComment, SendCommunityRoomMessage, SendPost, SendUserRoomMessage}, - LemmyContext, - OperationType, -}; -use lemmy_api_common::{ comment::CommentResponse, community::CommunityResponse, post::PostResponse, private_message::PrivateMessageResponse, utils::{check_person_block, get_interface_language, send_email_to_user}, + websocket::{ + messages::{SendComment, SendCommunityRoomMessage, SendPost, SendUserRoomMessage}, + OperationType, + }, + LemmyContext, }; use lemmy_db_schema::{ newtypes::{CommentId, CommunityId, LocalUserId, PersonId, PostId, PrivateMessageId}, diff --git a/crates/api_common/src/websocket.rs b/crates/api_common/src/websocket/structs.rs similarity index 100% rename from crates/api_common/src/websocket.rs rename to crates/api_common/src/websocket/structs.rs diff --git a/crates/api_crud/Cargo.toml b/crates/api_crud/Cargo.toml index b4f68a8d..7a16aed5 100644 --- a/crates/api_crud/Cargo.toml +++ b/crates/api_crud/Cargo.toml @@ -15,7 +15,6 @@ lemmy_db_schema = { workspace = true, features = ["full"] } lemmy_db_views = { workspace = true, features = ["full"] } lemmy_db_views_actor = { workspace = true, features = ["full"] } lemmy_api_common = { workspace = true, features = ["full"] } -lemmy_websocket = { workspace = true } activitypub_federation = { workspace = true } bcrypt = { workspace = true } serde_json = { workspace = true } diff --git a/crates/api_crud/src/comment/create.rs b/crates/api_crud/src/comment/create.rs index f027b0fe..a3be10a6 100644 --- a/crates/api_crud/src/comment/create.rs +++ b/crates/api_crud/src/comment/create.rs @@ -10,6 +10,11 @@ use lemmy_api_common::{ get_post, local_site_to_slur_regex, }, + websocket::{ + send::{send_comment_ws_message, send_local_notifs}, + UserOperationCrud, + }, + LemmyContext, }; use lemmy_apub::{ generate_local_apub_endpoint, @@ -32,11 +37,6 @@ use lemmy_utils::{ utils::{remove_slurs, scrape_text_for_mentions}, ConnectionId, }; -use lemmy_websocket::{ - send::{send_comment_ws_message, send_local_notifs}, - LemmyContext, - UserOperationCrud, -}; #[async_trait::async_trait(?Send)] impl PerformCrud for CreateComment { diff --git a/crates/api_crud/src/comment/delete.rs b/crates/api_crud/src/comment/delete.rs index 549d2f36..f14d0d41 100644 --- a/crates/api_crud/src/comment/delete.rs +++ b/crates/api_crud/src/comment/delete.rs @@ -3,6 +3,11 @@ use actix_web::web::Data; use lemmy_api_common::{ comment::{CommentResponse, DeleteComment}, utils::{check_community_ban, get_local_user_view_from_jwt}, + websocket::{ + send::{send_comment_ws_message, send_local_notifs}, + UserOperationCrud, + }, + LemmyContext, }; use lemmy_apub::activities::deletion::{send_apub_delete_in_community, DeletableObjects}; use lemmy_db_schema::{ @@ -15,11 +20,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::CommentView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{ - send::{send_comment_ws_message, send_local_notifs}, - LemmyContext, - UserOperationCrud, -}; #[async_trait::async_trait(?Send)] impl PerformCrud for DeleteComment { diff --git a/crates/api_crud/src/comment/list.rs b/crates/api_crud/src/comment/list.rs index afee451a..3e7444bf 100644 --- a/crates/api_crud/src/comment/list.rs +++ b/crates/api_crud/src/comment/list.rs @@ -7,6 +7,7 @@ use lemmy_api_common::{ get_local_user_view_from_jwt_opt, listing_type_with_site_default, }, + LemmyContext, }; use lemmy_apub::{fetcher::resolve_actor_identifier, objects::community::ApubCommunity}; use lemmy_db_schema::{ @@ -15,7 +16,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::comment_view::CommentQuery; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl PerformCrud for GetComments { diff --git a/crates/api_crud/src/comment/read.rs b/crates/api_crud/src/comment/read.rs index 7d5779ff..98b3431c 100644 --- a/crates/api_crud/src/comment/read.rs +++ b/crates/api_crud/src/comment/read.rs @@ -3,11 +3,11 @@ use actix_web::web::Data; use lemmy_api_common::{ comment::{CommentResponse, GetComment}, utils::{check_private_instance, get_local_user_view_from_jwt_opt}, + LemmyContext, }; use lemmy_db_schema::source::local_site::LocalSite; use lemmy_db_views::structs::CommentView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl PerformCrud for GetComment { diff --git a/crates/api_crud/src/comment/remove.rs b/crates/api_crud/src/comment/remove.rs index c1e581e0..09e5fdfc 100644 --- a/crates/api_crud/src/comment/remove.rs +++ b/crates/api_crud/src/comment/remove.rs @@ -3,6 +3,11 @@ use actix_web::web::Data; use lemmy_api_common::{ comment::{CommentResponse, RemoveComment}, utils::{check_community_ban, get_local_user_view_from_jwt, is_mod_or_admin}, + websocket::{ + send::{send_comment_ws_message, send_local_notifs}, + UserOperationCrud, + }, + LemmyContext, }; use lemmy_apub::activities::deletion::{send_apub_delete_in_community, DeletableObjects}; use lemmy_db_schema::{ @@ -16,11 +21,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::CommentView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{ - send::{send_comment_ws_message, send_local_notifs}, - LemmyContext, - UserOperationCrud, -}; #[async_trait::async_trait(?Send)] impl PerformCrud for RemoveComment { diff --git a/crates/api_crud/src/comment/update.rs b/crates/api_crud/src/comment/update.rs index 0d89acc2..d1fcccd9 100644 --- a/crates/api_crud/src/comment/update.rs +++ b/crates/api_crud/src/comment/update.rs @@ -10,6 +10,11 @@ use lemmy_api_common::{ is_mod_or_admin, local_site_to_slur_regex, }, + websocket::{ + send::{send_comment_ws_message, send_local_notifs}, + UserOperationCrud, + }, + LemmyContext, }; use lemmy_apub::protocol::activities::{ create_or_update::note::CreateOrUpdateNote, @@ -29,11 +34,6 @@ use lemmy_utils::{ utils::{remove_slurs, scrape_text_for_mentions}, ConnectionId, }; -use lemmy_websocket::{ - send::{send_comment_ws_message, send_local_notifs}, - LemmyContext, - UserOperationCrud, -}; #[async_trait::async_trait(?Send)] impl PerformCrud for EditComment { diff --git a/crates/api_crud/src/community/create.rs b/crates/api_crud/src/community/create.rs index 437671ee..caa1a363 100644 --- a/crates/api_crud/src/community/create.rs +++ b/crates/api_crud/src/community/create.rs @@ -4,6 +4,7 @@ use actix_web::web::Data; use lemmy_api_common::{ community::{CommunityResponse, CreateCommunity}, utils::{get_local_user_view_from_jwt, is_admin, local_site_to_slur_regex}, + LemmyContext, }; use lemmy_apub::{ generate_followers_url, @@ -32,7 +33,6 @@ use lemmy_utils::{ utils::{check_slurs, check_slurs_opt, is_valid_actor_name}, ConnectionId, }; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl PerformCrud for CreateCommunity { diff --git a/crates/api_crud/src/community/delete.rs b/crates/api_crud/src/community/delete.rs index 41f14b52..7d3122ab 100644 --- a/crates/api_crud/src/community/delete.rs +++ b/crates/api_crud/src/community/delete.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ community::{CommunityResponse, DeleteCommunity}, utils::get_local_user_view_from_jwt, + websocket::{send::send_community_ws_message, UserOperationCrud}, + LemmyContext, }; use lemmy_apub::activities::deletion::{send_apub_delete_in_community, DeletableObjects}; use lemmy_db_schema::{ @@ -11,7 +13,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::CommunityModeratorView; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud}; #[async_trait::async_trait(?Send)] impl PerformCrud for DeleteCommunity { diff --git a/crates/api_crud/src/community/list.rs b/crates/api_crud/src/community/list.rs index 37a9d88a..f77ebce7 100644 --- a/crates/api_crud/src/community/list.rs +++ b/crates/api_crud/src/community/list.rs @@ -3,11 +3,11 @@ use actix_web::web::Data; use lemmy_api_common::{ community::{ListCommunities, ListCommunitiesResponse}, utils::{check_private_instance, get_local_user_view_from_jwt_opt}, + LemmyContext, }; use lemmy_db_schema::{source::local_site::LocalSite, traits::DeleteableOrRemoveable}; use lemmy_db_views_actor::community_view::CommunityQuery; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl PerformCrud for ListCommunities { diff --git a/crates/api_crud/src/community/read.rs b/crates/api_crud/src/community/read.rs index 1b3e5ff4..a008f786 100644 --- a/crates/api_crud/src/community/read.rs +++ b/crates/api_crud/src/community/read.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ community::{GetCommunity, GetCommunityResponse}, utils::{check_private_instance, get_local_user_view_from_jwt_opt}, + websocket::messages::GetCommunityUsersOnline, + LemmyContext, }; use lemmy_apub::{ fetcher::resolve_actor_identifier, @@ -20,7 +22,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{messages::GetCommunityUsersOnline, LemmyContext}; #[async_trait::async_trait(?Send)] impl PerformCrud for GetCommunity { diff --git a/crates/api_crud/src/community/remove.rs b/crates/api_crud/src/community/remove.rs index 1977f5cd..77c2bde3 100644 --- a/crates/api_crud/src/community/remove.rs +++ b/crates/api_crud/src/community/remove.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ community::{CommunityResponse, RemoveCommunity}, utils::{get_local_user_view_from_jwt, is_admin}, + websocket::{send::send_community_ws_message, UserOperationCrud}, + LemmyContext, }; use lemmy_apub::activities::deletion::{send_apub_delete_in_community, DeletableObjects}; use lemmy_db_schema::{ @@ -13,7 +15,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::{error::LemmyError, utils::naive_from_unix, ConnectionId}; -use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud}; #[async_trait::async_trait(?Send)] impl PerformCrud for RemoveCommunity { diff --git a/crates/api_crud/src/community/update.rs b/crates/api_crud/src/community/update.rs index 8e60b3f8..2bde94ea 100644 --- a/crates/api_crud/src/community/update.rs +++ b/crates/api_crud/src/community/update.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ community::{CommunityResponse, EditCommunity}, utils::{get_local_user_view_from_jwt, local_site_to_slur_regex}, + websocket::{send::send_community_ws_message, UserOperationCrud}, + LemmyContext, }; use lemmy_apub::protocol::activities::community::update::UpdateCommunity; use lemmy_db_schema::{ @@ -17,7 +19,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views_actor::structs::CommunityModeratorView; use lemmy_utils::{error::LemmyError, utils::check_slurs_opt, ConnectionId}; -use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud}; #[async_trait::async_trait(?Send)] impl PerformCrud for EditCommunity { diff --git a/crates/api_crud/src/lib.rs b/crates/api_crud/src/lib.rs index b50d3cd2..fde81edd 100644 --- a/crates/api_crud/src/lib.rs +++ b/crates/api_crud/src/lib.rs @@ -18,9 +18,10 @@ use lemmy_api_common::{ GetPrivateMessages, }, site::{CreateSite, EditSite, GetSite}, + websocket::{serialize_websocket_message, UserOperationCrud}, + LemmyContext, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperationCrud}; use serde::Deserialize; mod comment; diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index cad8b28e..2353def6 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -11,6 +11,8 @@ use lemmy_api_common::{ local_site_to_slur_regex, mark_post_as_read, }, + websocket::{send::send_post_ws_message, UserOperationCrud}, + LemmyContext, }; use lemmy_apub::{ generate_local_apub_endpoint, @@ -34,7 +36,6 @@ use lemmy_utils::{ utils::{check_slurs, check_slurs_opt, clean_url_params, is_valid_post_title}, ConnectionId, }; -use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud}; use tracing::{warn, Instrument}; use url::Url; use webmention::{Webmention, WebmentionError}; diff --git a/crates/api_crud/src/post/delete.rs b/crates/api_crud/src/post/delete.rs index a0b93008..de1490b1 100644 --- a/crates/api_crud/src/post/delete.rs +++ b/crates/api_crud/src/post/delete.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ post::{DeletePost, PostResponse}, utils::{check_community_ban, check_community_deleted_or_removed, get_local_user_view_from_jwt}, + websocket::{send::send_post_ws_message, UserOperationCrud}, + LemmyContext, }; use lemmy_apub::activities::deletion::{send_apub_delete_in_community, DeletableObjects}; use lemmy_db_schema::{ @@ -13,7 +15,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud}; #[async_trait::async_trait(?Send)] impl PerformCrud for DeletePost { diff --git a/crates/api_crud/src/post/list.rs b/crates/api_crud/src/post/list.rs index bf4086e4..42944cad 100644 --- a/crates/api_crud/src/post/list.rs +++ b/crates/api_crud/src/post/list.rs @@ -7,6 +7,7 @@ use lemmy_api_common::{ get_local_user_view_from_jwt_opt, listing_type_with_site_default, }, + LemmyContext, }; use lemmy_apub::{fetcher::resolve_actor_identifier, objects::community::ApubCommunity}; use lemmy_db_schema::{ @@ -15,7 +16,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::post_view::PostQuery; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl PerformCrud for GetPosts { diff --git a/crates/api_crud/src/post/read.rs b/crates/api_crud/src/post/read.rs index 5e2582a0..44d1be63 100644 --- a/crates/api_crud/src/post/read.rs +++ b/crates/api_crud/src/post/read.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ post::{GetPost, GetPostResponse}, utils::{check_private_instance, get_local_user_view_from_jwt_opt, mark_post_as_read}, + websocket::messages::GetPostUsersOnline, + LemmyContext, }; use lemmy_db_schema::{ aggregates::structs::{PersonPostAggregates, PersonPostAggregatesForm}, @@ -12,7 +14,6 @@ use lemmy_db_schema::{ use lemmy_db_views::structs::PostView; use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{messages::GetPostUsersOnline, LemmyContext}; #[async_trait::async_trait(?Send)] impl PerformCrud for GetPost { diff --git a/crates/api_crud/src/post/remove.rs b/crates/api_crud/src/post/remove.rs index b062bc65..525c08a6 100644 --- a/crates/api_crud/src/post/remove.rs +++ b/crates/api_crud/src/post/remove.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ post::{PostResponse, RemovePost}, utils::{check_community_ban, get_local_user_view_from_jwt, is_mod_or_admin}, + websocket::{send::send_post_ws_message, UserOperationCrud}, + LemmyContext, }; use lemmy_apub::activities::deletion::{send_apub_delete_in_community, DeletableObjects}; use lemmy_db_schema::{ @@ -14,7 +16,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud}; #[async_trait::async_trait(?Send)] impl PerformCrud for RemovePost { diff --git a/crates/api_crud/src/post/update.rs b/crates/api_crud/src/post/update.rs index 11b566bc..4c3038c8 100644 --- a/crates/api_crud/src/post/update.rs +++ b/crates/api_crud/src/post/update.rs @@ -9,6 +9,8 @@ use lemmy_api_common::{ get_local_user_view_from_jwt, local_site_to_slur_regex, }, + websocket::{send::send_post_ws_message, UserOperationCrud}, + LemmyContext, }; use lemmy_apub::protocol::activities::{ create_or_update::page::CreateOrUpdatePage, @@ -28,7 +30,6 @@ use lemmy_utils::{ utils::{check_slurs_opt, clean_url_params, is_valid_post_title}, ConnectionId, }; -use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud}; #[async_trait::async_trait(?Send)] impl PerformCrud for EditPost { diff --git a/crates/api_crud/src/private_message/create.rs b/crates/api_crud/src/private_message/create.rs index 35bc09e2..6f099f79 100644 --- a/crates/api_crud/src/private_message/create.rs +++ b/crates/api_crud/src/private_message/create.rs @@ -9,6 +9,8 @@ use lemmy_api_common::{ local_site_to_slur_regex, send_email_to_user, }, + websocket::{send::send_pm_ws_message, UserOperationCrud}, + LemmyContext, }; use lemmy_apub::{ generate_local_apub_endpoint, @@ -27,7 +29,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::LocalUserView; use lemmy_utils::{error::LemmyError, utils::remove_slurs, ConnectionId}; -use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud}; #[async_trait::async_trait(?Send)] impl PerformCrud for CreatePrivateMessage { diff --git a/crates/api_crud/src/private_message/delete.rs b/crates/api_crud/src/private_message/delete.rs index 51cded6d..ad6b78d3 100644 --- a/crates/api_crud/src/private_message/delete.rs +++ b/crates/api_crud/src/private_message/delete.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ private_message::{DeletePrivateMessage, PrivateMessageResponse}, utils::get_local_user_view_from_jwt, + websocket::{send::send_pm_ws_message, UserOperationCrud}, + LemmyContext, }; use lemmy_apub::activities::deletion::send_apub_delete_private_message; use lemmy_db_schema::{ @@ -10,7 +12,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud}; #[async_trait::async_trait(?Send)] impl PerformCrud for DeletePrivateMessage { diff --git a/crates/api_crud/src/private_message/read.rs b/crates/api_crud/src/private_message/read.rs index f0741398..88bb0830 100644 --- a/crates/api_crud/src/private_message/read.rs +++ b/crates/api_crud/src/private_message/read.rs @@ -3,11 +3,11 @@ use actix_web::web::Data; use lemmy_api_common::{ private_message::{GetPrivateMessages, PrivateMessagesResponse}, utils::get_local_user_view_from_jwt, + LemmyContext, }; use lemmy_db_schema::traits::DeleteableOrRemoveable; use lemmy_db_views::private_message_view::PrivateMessageQuery; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl PerformCrud for GetPrivateMessages { diff --git a/crates/api_crud/src/private_message/update.rs b/crates/api_crud/src/private_message/update.rs index 5f79735e..b6e08c9c 100644 --- a/crates/api_crud/src/private_message/update.rs +++ b/crates/api_crud/src/private_message/update.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ private_message::{EditPrivateMessage, PrivateMessageResponse}, utils::{get_local_user_view_from_jwt, local_site_to_slur_regex}, + websocket::{send::send_pm_ws_message, UserOperationCrud}, + LemmyContext, }; use lemmy_apub::protocol::activities::{ create_or_update::chat_message::CreateOrUpdateChatMessage, @@ -17,7 +19,6 @@ use lemmy_db_schema::{ utils::naive_now, }; use lemmy_utils::{error::LemmyError, utils::remove_slurs, ConnectionId}; -use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud}; #[async_trait::async_trait(?Send)] impl PerformCrud for EditPrivateMessage { diff --git a/crates/api_crud/src/site/create.rs b/crates/api_crud/src/site/create.rs index 8b2b9c18..22631d51 100644 --- a/crates/api_crud/src/site/create.rs +++ b/crates/api_crud/src/site/create.rs @@ -10,6 +10,7 @@ use lemmy_api_common::{ local_site_to_slur_regex, site_description_length_check, }, + LemmyContext, }; use lemmy_apub::generate_site_inbox_url; use lemmy_db_schema::{ @@ -28,7 +29,6 @@ use lemmy_utils::{ utils::{check_application_question, check_slurs, check_slurs_opt}, ConnectionId, }; -use lemmy_websocket::LemmyContext; use url::Url; #[async_trait::async_trait(?Send)] diff --git a/crates/api_crud/src/site/read.rs b/crates/api_crud/src/site/read.rs index dbf64c6c..8f27bb2e 100644 --- a/crates/api_crud/src/site/read.rs +++ b/crates/api_crud/src/site/read.rs @@ -3,6 +3,8 @@ use actix_web::web::Data; use lemmy_api_common::{ site::{GetSite, GetSiteResponse, MyUserInfo}, utils::{build_federated_instances, get_local_user_settings_view_from_jwt_opt}, + websocket::messages::GetUsersOnline, + LemmyContext, }; use lemmy_db_schema::source::{actor_language::SiteLanguage, language::Language, tagline::Tagline}; use lemmy_db_views::structs::{LocalUserDiscussionLanguageView, SiteView}; @@ -14,7 +16,6 @@ use lemmy_db_views_actor::structs::{ PersonViewSafe, }; use lemmy_utils::{error::LemmyError, version, ConnectionId}; -use lemmy_websocket::{messages::GetUsersOnline, LemmyContext}; #[async_trait::async_trait(?Send)] impl PerformCrud for GetSite { diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs index 07e96582..e738a251 100644 --- a/crates/api_crud/src/site/update.rs +++ b/crates/api_crud/src/site/update.rs @@ -9,6 +9,8 @@ use lemmy_api_common::{ local_site_to_slur_regex, site_description_length_check, }, + websocket::{messages::SendAllMessage, UserOperationCrud}, + LemmyContext, }; use lemmy_db_schema::{ source::{ @@ -31,7 +33,6 @@ use lemmy_utils::{ utils::{check_application_question, check_slurs_opt}, ConnectionId, }; -use lemmy_websocket::{messages::SendAllMessage, LemmyContext, UserOperationCrud}; use std::str::FromStr; #[async_trait::async_trait(?Send)] diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs index d1b5fbc3..5686348f 100644 --- a/crates/api_crud/src/user/create.rs +++ b/crates/api_crud/src/user/create.rs @@ -10,6 +10,8 @@ use lemmy_api_common::{ send_new_applicant_email_to_admins, send_verification_email, }, + websocket::messages::CheckCaptcha, + LemmyContext, }; use lemmy_apub::{ generate_inbox_url, @@ -33,7 +35,6 @@ use lemmy_utils::{ utils::{check_slurs, check_slurs_opt, is_valid_actor_name}, ConnectionId, }; -use lemmy_websocket::{messages::CheckCaptcha, LemmyContext}; #[async_trait::async_trait(?Send)] impl PerformCrud for Register { diff --git a/crates/api_crud/src/user/delete.rs b/crates/api_crud/src/user/delete.rs index 59474767..87ad78e4 100644 --- a/crates/api_crud/src/user/delete.rs +++ b/crates/api_crud/src/user/delete.rs @@ -4,10 +4,10 @@ use bcrypt::verify; use lemmy_api_common::{ person::{DeleteAccount, DeleteAccountResponse}, utils::{delete_user_account, get_local_user_view_from_jwt}, + LemmyContext, }; use lemmy_apub::protocol::activities::deletion::delete_user::DeleteUser; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl PerformCrud for DeleteAccount { diff --git a/crates/api_crud/src/user/read.rs b/crates/api_crud/src/user/read.rs index ccf5189c..b7b155a7 100644 --- a/crates/api_crud/src/user/read.rs +++ b/crates/api_crud/src/user/read.rs @@ -3,6 +3,7 @@ use actix_web::web::Data; use lemmy_api_common::{ person::{GetPersonDetails, GetPersonDetailsResponse}, utils::{check_private_instance, get_local_user_view_from_jwt_opt}, + LemmyContext, }; use lemmy_apub::{fetcher::resolve_actor_identifier, objects::person::ApubPerson}; use lemmy_db_schema::{ @@ -12,7 +13,6 @@ use lemmy_db_schema::{ use lemmy_db_views::{comment_view::CommentQuery, post_view::PostQuery}; use lemmy_db_views_actor::structs::{CommunityModeratorView, PersonViewSafe}; use lemmy_utils::{error::LemmyError, ConnectionId}; -use lemmy_websocket::LemmyContext; #[async_trait::async_trait(?Send)] impl PerformCrud for GetPersonDetails { diff --git a/crates/apub/Cargo.toml b/crates/apub/Cargo.toml index c2a8827e..720fa593 100644 --- a/crates/apub/Cargo.toml +++ b/crates/apub/Cargo.toml @@ -19,7 +19,6 @@ lemmy_db_schema = { workspace = true, features = ["full"] } lemmy_db_views = { workspace = true, features = ["full"] } lemmy_db_views_actor = { workspace = true, features = ["full"] } lemmy_api_common = { workspace = true, features = ["full"] } -lemmy_websocket = { workspace = true } activitypub_federation = { workspace = true } diesel = { workspace = true } chrono = { workspace = true } diff --git a/crates/apub/src/activities/block/block_user.rs b/crates/apub/src/activities/block/block_user.rs index 1d726e7c..c77bfde3 100644 --- a/crates/apub/src/activities/block/block_user.rs +++ b/crates/apub/src/activities/block/block_user.rs @@ -23,7 +23,10 @@ use activitypub_federation::{ use activitystreams_kinds::{activity::BlockType, public}; use anyhow::anyhow; use chrono::NaiveDateTime; -use lemmy_api_common::utils::{remove_user_data, remove_user_data_in_community}; +use lemmy_api_common::{ + utils::{remove_user_data, remove_user_data_in_community}, + LemmyContext, +}; use lemmy_db_schema::{ source::{ community::{ @@ -38,7 +41,6 @@ use lemmy_db_schema::{ traits::{Bannable, Crud, Followable}, }; use lemmy_utils::{error::LemmyError, utils::convert_datetime}; -use lemmy_websocket::LemmyContext; use url::Url; impl BlockUser { diff --git a/crates/apub/src/activities/block/mod.rs b/crates/apub/src/activities/block/mod.rs index bc2ea77f..5a8c48f1 100644 --- a/crates/apub/src/activities/block/mod.rs +++ b/crates/apub/src/activities/block/mod.rs @@ -5,9 +5,9 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, traits::ApubObject}; use chrono::NaiveDateTime; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{source::site::Site, utils::DbPool}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::Deserialize; use url::Url; diff --git a/crates/apub/src/activities/block/undo_block_user.rs b/crates/apub/src/activities/block/undo_block_user.rs index eb54f5e4..56f794dc 100644 --- a/crates/apub/src/activities/block/undo_block_user.rs +++ b/crates/apub/src/activities/block/undo_block_user.rs @@ -19,6 +19,7 @@ use activitypub_federation::{ utils::verify_domains_match, }; use activitystreams_kinds::{activity::UndoType, public}; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ source::{ community::{CommunityPersonBan, CommunityPersonBanForm}, @@ -28,7 +29,6 @@ use lemmy_db_schema::{ traits::{Bannable, Crud}, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use url::Url; impl UndoBlockUser { diff --git a/crates/apub/src/activities/community/add_mod.rs b/crates/apub/src/activities/community/add_mod.rs index c212cfe1..2bdf2be5 100644 --- a/crates/apub/src/activities/community/add_mod.rs +++ b/crates/apub/src/activities/community/add_mod.rs @@ -20,6 +20,7 @@ use activitypub_federation::{ traits::{ActivityHandler, Actor}, }; use activitystreams_kinds::{activity::AddType, public}; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ source::{ community::{CommunityModerator, CommunityModeratorForm}, @@ -28,7 +29,6 @@ use lemmy_db_schema::{ traits::{Crud, Joinable}, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use url::Url; impl AddMod { diff --git a/crates/apub/src/activities/community/announce.rs b/crates/apub/src/activities/community/announce.rs index b6c31af5..1ca1aa84 100644 --- a/crates/apub/src/activities/community/announce.rs +++ b/crates/apub/src/activities/community/announce.rs @@ -18,8 +18,8 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler}; use activitystreams_kinds::{activity::AnnounceType, public}; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde_json::Value; use tracing::debug; use url::Url; diff --git a/crates/apub/src/activities/community/mod.rs b/crates/apub/src/activities/community/mod.rs index a7b35595..3d0bb4c3 100644 --- a/crates/apub/src/activities/community/mod.rs +++ b/crates/apub/src/activities/community/mod.rs @@ -6,9 +6,9 @@ use crate::{ protocol::activities::community::announce::AnnounceActivity, }; use activitypub_federation::{core::object_id::ObjectId, traits::Actor}; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::source::person::PersonFollower; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use url::Url; pub mod add_mod; diff --git a/crates/apub/src/activities/community/remove_mod.rs b/crates/apub/src/activities/community/remove_mod.rs index 3934df3b..ca8d5b04 100644 --- a/crates/apub/src/activities/community/remove_mod.rs +++ b/crates/apub/src/activities/community/remove_mod.rs @@ -20,6 +20,7 @@ use activitypub_federation::{ traits::{ActivityHandler, Actor}, }; use activitystreams_kinds::{activity::RemoveType, public}; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ source::{ community::{CommunityModerator, CommunityModeratorForm}, @@ -28,7 +29,6 @@ use lemmy_db_schema::{ traits::{Crud, Joinable}, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use url::Url; impl RemoveMod { diff --git a/crates/apub/src/activities/community/report.rs b/crates/apub/src/activities/community/report.rs index 440a8ebb..2741af7e 100644 --- a/crates/apub/src/activities/community/report.rs +++ b/crates/apub/src/activities/community/report.rs @@ -12,7 +12,12 @@ use activitypub_federation::{ traits::{ActivityHandler, Actor}, }; use activitystreams_kinds::activity::FlagType; -use lemmy_api_common::{comment::CommentReportResponse, post::PostReportResponse}; +use lemmy_api_common::{ + comment::CommentReportResponse, + post::PostReportResponse, + websocket::{messages::SendModRoomMessage, UserOperation}, + LemmyContext, +}; use lemmy_db_schema::{ source::{ comment_report::{CommentReport, CommentReportForm}, @@ -22,7 +27,6 @@ use lemmy_db_schema::{ }; use lemmy_db_views::structs::{CommentReportView, PostReportView}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation}; use url::Url; impl Report { diff --git a/crates/apub/src/activities/community/update.rs b/crates/apub/src/activities/community/update.rs index f41f2d47..c0d1a279 100644 --- a/crates/apub/src/activities/community/update.rs +++ b/crates/apub/src/activities/community/update.rs @@ -17,9 +17,12 @@ use activitypub_federation::{ traits::{ActivityHandler, ApubObject}, }; use activitystreams_kinds::{activity::UpdateType, public}; +use lemmy_api_common::{ + websocket::{send::send_community_ws_message, UserOperationCrud}, + LemmyContext, +}; use lemmy_db_schema::{source::community::Community, traits::Crud}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud}; use url::Url; impl UpdateCommunity { diff --git a/crates/apub/src/activities/create_or_update/comment.rs b/crates/apub/src/activities/create_or_update/comment.rs index a4b60ad4..5def0460 100644 --- a/crates/apub/src/activities/create_or_update/comment.rs +++ b/crates/apub/src/activities/create_or_update/comment.rs @@ -24,7 +24,11 @@ use activitypub_federation::{ utils::verify_domains_match, }; use activitystreams_kinds::public; -use lemmy_api_common::utils::check_post_deleted_or_removed; +use lemmy_api_common::{ + utils::check_post_deleted_or_removed, + websocket::{send::send_comment_ws_message, UserOperationCrud}, + LemmyContext, +}; use lemmy_db_schema::{ source::{ comment::{CommentLike, CommentLikeForm}, @@ -34,7 +38,6 @@ use lemmy_db_schema::{ traits::{Crud, Likeable}, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperationCrud}; use url::Url; impl CreateOrUpdateNote { diff --git a/crates/apub/src/activities/create_or_update/mod.rs b/crates/apub/src/activities/create_or_update/mod.rs index 2c68ad80..b53dd2eb 100644 --- a/crates/apub/src/activities/create_or_update/mod.rs +++ b/crates/apub/src/activities/create_or_update/mod.rs @@ -1,12 +1,12 @@ use crate::{local_instance, objects::person::ApubPerson}; use activitypub_federation::core::object_id::ObjectId; +use lemmy_api_common::{websocket::send::send_local_notifs, LemmyContext}; use lemmy_db_schema::{ newtypes::LocalUserId, source::{comment::Comment, post::Post}, traits::Crud, }; use lemmy_utils::{error::LemmyError, utils::scrape_text_for_mentions}; -use lemmy_websocket::{send::send_local_notifs, LemmyContext}; pub mod comment; pub mod post; diff --git a/crates/apub/src/activities/create_or_update/post.rs b/crates/apub/src/activities/create_or_update/post.rs index abe9be1a..161b26b9 100644 --- a/crates/apub/src/activities/create_or_update/post.rs +++ b/crates/apub/src/activities/create_or_update/post.rs @@ -22,6 +22,10 @@ use activitypub_federation::{ utils::{verify_domains_match, verify_urls_match}, }; use activitystreams_kinds::public; +use lemmy_api_common::{ + websocket::{send::send_post_ws_message, UserOperationCrud}, + LemmyContext, +}; use lemmy_db_schema::{ source::{ community::Community, @@ -30,7 +34,6 @@ use lemmy_db_schema::{ traits::{Crud, Likeable}, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud}; use url::Url; impl CreateOrUpdatePage { diff --git a/crates/apub/src/activities/create_or_update/private_message.rs b/crates/apub/src/activities/create_or_update/private_message.rs index eb310ce9..431e699c 100644 --- a/crates/apub/src/activities/create_or_update/private_message.rs +++ b/crates/apub/src/activities/create_or_update/private_message.rs @@ -13,9 +13,12 @@ use activitypub_federation::{ traits::{ActivityHandler, Actor, ApubObject}, utils::verify_domains_match, }; +use lemmy_api_common::{ + websocket::{send::send_pm_ws_message, UserOperationCrud}, + LemmyContext, +}; use lemmy_db_schema::{source::person::Person, traits::Crud}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud}; use url::Url; impl CreateOrUpdateChatMessage { diff --git a/crates/apub/src/activities/deletion/delete.rs b/crates/apub/src/activities/deletion/delete.rs index 8298a6fe..ae93d6e0 100644 --- a/crates/apub/src/activities/deletion/delete.rs +++ b/crates/apub/src/activities/deletion/delete.rs @@ -9,6 +9,13 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler}; use activitystreams_kinds::activity::DeleteType; +use lemmy_api_common::{ + websocket::{ + send::{send_comment_ws_message_simple, send_community_ws_message, send_post_ws_message}, + UserOperationCrud, + }, + LemmyContext, +}; use lemmy_db_schema::{ source::{ comment::{Comment, CommentUpdateForm}, @@ -26,11 +33,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::{ - send::{send_comment_ws_message_simple, send_community_ws_message, send_post_ws_message}, - LemmyContext, - UserOperationCrud, -}; use url::Url; #[async_trait::async_trait(?Send)] diff --git a/crates/apub/src/activities/deletion/delete_user.rs b/crates/apub/src/activities/deletion/delete_user.rs index 08d9d395..ffe664d5 100644 --- a/crates/apub/src/activities/deletion/delete_user.rs +++ b/crates/apub/src/activities/deletion/delete_user.rs @@ -11,9 +11,8 @@ use activitypub_federation::{ utils::verify_urls_match, }; use activitystreams_kinds::{activity::DeleteType, public}; -use lemmy_api_common::utils::delete_user_account; +use lemmy_api_common::{utils::delete_user_account, LemmyContext}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use url::Url; /// This can be separate from Delete activity because it doesn't need to be handled in shared inbox diff --git a/crates/apub/src/activities/deletion/mod.rs b/crates/apub/src/activities/deletion/mod.rs index bf4b920a..d05e4502 100644 --- a/crates/apub/src/activities/deletion/mod.rs +++ b/crates/apub/src/activities/deletion/mod.rs @@ -28,6 +28,18 @@ use activitypub_federation::{ utils::verify_domains_match, }; use activitystreams_kinds::public; +use lemmy_api_common::{ + websocket::{ + send::{ + send_comment_ws_message_simple, + send_community_ws_message, + send_pm_ws_message, + send_post_ws_message, + }, + UserOperationCrud, + }, + LemmyContext, +}; use lemmy_db_schema::{ source::{ comment::{Comment, CommentUpdateForm}, @@ -39,16 +51,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::{ - send::{ - send_comment_ws_message_simple, - send_community_ws_message, - send_pm_ws_message, - send_post_ws_message, - }, - LemmyContext, - UserOperationCrud, -}; use std::ops::Deref; use url::Url; diff --git a/crates/apub/src/activities/deletion/undo_delete.rs b/crates/apub/src/activities/deletion/undo_delete.rs index 8b845400..bc6f9fd1 100644 --- a/crates/apub/src/activities/deletion/undo_delete.rs +++ b/crates/apub/src/activities/deletion/undo_delete.rs @@ -9,6 +9,13 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler}; use activitystreams_kinds::activity::UndoType; +use lemmy_api_common::{ + websocket::{ + send::{send_comment_ws_message_simple, send_community_ws_message, send_post_ws_message}, + UserOperationCrud, + }, + LemmyContext, +}; use lemmy_db_schema::{ source::{ comment::{Comment, CommentUpdateForm}, @@ -26,11 +33,6 @@ use lemmy_db_schema::{ traits::Crud, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::{ - send::{send_comment_ws_message_simple, send_community_ws_message, send_post_ws_message}, - LemmyContext, - UserOperationCrud, -}; use url::Url; #[async_trait::async_trait(?Send)] diff --git a/crates/apub/src/activities/following/accept.rs b/crates/apub/src/activities/following/accept.rs index 5a8baa4c..880db0d9 100644 --- a/crates/apub/src/activities/following/accept.rs +++ b/crates/apub/src/activities/following/accept.rs @@ -11,12 +11,15 @@ use activitypub_federation::{ utils::verify_urls_match, }; use activitystreams_kinds::activity::AcceptType; -use lemmy_api_common::community::CommunityResponse; +use lemmy_api_common::{ + community::CommunityResponse, + websocket::{messages::SendUserRoomMessage, UserOperation}, + LemmyContext, +}; use lemmy_db_schema::{source::community::CommunityFollower, traits::Followable}; use lemmy_db_views::structs::LocalUserView; use lemmy_db_views_actor::structs::CommunityView; use lemmy_utils::error::LemmyError; -use lemmy_websocket::{messages::SendUserRoomMessage, LemmyContext, UserOperation}; use url::Url; impl AcceptFollow { diff --git a/crates/apub/src/activities/following/follow.rs b/crates/apub/src/activities/following/follow.rs index 867eb291..82c0c37a 100644 --- a/crates/apub/src/activities/following/follow.rs +++ b/crates/apub/src/activities/following/follow.rs @@ -17,6 +17,7 @@ use activitypub_federation::{ traits::{ActivityHandler, Actor}, }; use activitystreams_kinds::activity::FollowType; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ source::{ community::{CommunityFollower, CommunityFollowerForm}, @@ -25,7 +26,6 @@ use lemmy_db_schema::{ traits::Followable, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use url::Url; impl Follow { diff --git a/crates/apub/src/activities/following/undo_follow.rs b/crates/apub/src/activities/following/undo_follow.rs index 012ebfb9..7d48f9f3 100644 --- a/crates/apub/src/activities/following/undo_follow.rs +++ b/crates/apub/src/activities/following/undo_follow.rs @@ -13,6 +13,7 @@ use activitypub_federation::{ utils::verify_urls_match, }; use activitystreams_kinds::activity::UndoType; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ source::{ community::{CommunityFollower, CommunityFollowerForm}, @@ -21,7 +22,6 @@ use lemmy_db_schema::{ traits::Followable, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use url::Url; impl UndoFollow { diff --git a/crates/apub/src/activities/mod.rs b/crates/apub/src/activities/mod.rs index c38eadcd..1528a273 100644 --- a/crates/apub/src/activities/mod.rs +++ b/crates/apub/src/activities/mod.rs @@ -13,13 +13,13 @@ use activitypub_federation::{ }; use activitystreams_kinds::public; use anyhow::anyhow; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ newtypes::CommunityId, source::{community::Community, local_site::LocalSite}, }; use lemmy_db_views_actor::structs::{CommunityPersonBanView, CommunityView}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::Serialize; use std::ops::Deref; use tracing::info; diff --git a/crates/apub/src/activities/voting/mod.rs b/crates/apub/src/activities/voting/mod.rs index bff67efe..a01dcb2e 100644 --- a/crates/apub/src/activities/voting/mod.rs +++ b/crates/apub/src/activities/voting/mod.rs @@ -2,6 +2,13 @@ use crate::{ objects::{comment::ApubComment, person::ApubPerson, post::ApubPost}, protocol::activities::voting::vote::VoteType, }; +use lemmy_api_common::{ + websocket::{ + send::{send_comment_ws_message_simple, send_post_ws_message}, + UserOperation, + }, + LemmyContext, +}; use lemmy_db_schema::{ source::{ comment::{CommentLike, CommentLikeForm}, @@ -10,11 +17,6 @@ use lemmy_db_schema::{ traits::Likeable, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::{ - send::{send_comment_ws_message_simple, send_post_ws_message}, - LemmyContext, - UserOperation, -}; pub mod undo_vote; pub mod vote; diff --git a/crates/apub/src/activities/voting/undo_vote.rs b/crates/apub/src/activities/voting/undo_vote.rs index 20c9432c..dca106de 100644 --- a/crates/apub/src/activities/voting/undo_vote.rs +++ b/crates/apub/src/activities/voting/undo_vote.rs @@ -25,9 +25,9 @@ use activitypub_federation::{ utils::verify_urls_match, }; use activitystreams_kinds::activity::UndoType; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{newtypes::CommunityId, source::community::Community, traits::Crud}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use url::Url; impl UndoVote { diff --git a/crates/apub/src/activities/voting/vote.rs b/crates/apub/src/activities/voting/vote.rs index f8d44ed9..bc702fd8 100644 --- a/crates/apub/src/activities/voting/vote.rs +++ b/crates/apub/src/activities/voting/vote.rs @@ -17,13 +17,13 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler}; use anyhow::anyhow; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ newtypes::CommunityId, source::{community::Community, local_site::LocalSite}, traits::Crud, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use url::Url; /// Vote has as:Public value in cc field, unlike other activities. This indicates to other software diff --git a/crates/apub/src/activity_lists.rs b/crates/apub/src/activity_lists.rs index fa8eece3..fa343d8a 100644 --- a/crates/apub/src/activity_lists.rs +++ b/crates/apub/src/activity_lists.rs @@ -24,8 +24,8 @@ use crate::{ }, }; use activitypub_federation::{data::Data, deser::context::WithContext, traits::ActivityHandler}; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/crates/apub/src/collections/mod.rs b/crates/apub/src/collections/mod.rs index e2a274a0..4c27beb4 100644 --- a/crates/apub/src/collections/mod.rs +++ b/crates/apub/src/collections/mod.rs @@ -1,5 +1,5 @@ use crate::objects::community::ApubCommunity; -use lemmy_websocket::LemmyContext; +use lemmy_api_common::LemmyContext; pub(crate) mod community_moderators; pub(crate) mod community_outbox; diff --git a/crates/apub/src/fetcher/deletable_apub_object.rs b/crates/apub/src/fetcher/deletable_apub_object.rs index c84ebabb..0eae410c 100644 --- a/crates/apub/src/fetcher/deletable_apub_object.rs +++ b/crates/apub/src/fetcher/deletable_apub_object.rs @@ -13,7 +13,7 @@ use lemmy_db_schema::source::{ site::Site, }; use lemmy_utils::LemmyError; -use lemmy_websocket::LemmyContext; +use lemmy_api_common::LemmyContext; // TODO: merge this trait with ApubObject (means that db_schema needs to depend on apub_lib) #[async_trait::async_trait(?Send)] diff --git a/crates/apub/src/fetcher/mod.rs b/crates/apub/src/fetcher/mod.rs index d98bb8e4..56398924 100644 --- a/crates/apub/src/fetcher/mod.rs +++ b/crates/apub/src/fetcher/mod.rs @@ -1,9 +1,9 @@ use crate::{fetcher::webfinger::webfinger_resolve_actor, ActorType}; use activitypub_federation::traits::ApubObject; use itertools::Itertools; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::traits::ApubActor; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; pub mod post_or_comment; pub mod search; diff --git a/crates/apub/src/fetcher/post_or_comment.rs b/crates/apub/src/fetcher/post_or_comment.rs index d2d0b91f..b44d9f16 100644 --- a/crates/apub/src/fetcher/post_or_comment.rs +++ b/crates/apub/src/fetcher/post_or_comment.rs @@ -7,12 +7,12 @@ use crate::{ }; use activitypub_federation::traits::ApubObject; use chrono::NaiveDateTime; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ source::{community::Community, post::Post}, traits::Crud, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::Deserialize; use url::Url; diff --git a/crates/apub/src/fetcher/search.rs b/crates/apub/src/fetcher/search.rs index 1daccd3a..95b47f5e 100644 --- a/crates/apub/src/fetcher/search.rs +++ b/crates/apub/src/fetcher/search.rs @@ -6,8 +6,8 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, traits::ApubObject}; use chrono::NaiveDateTime; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::Deserialize; use url::Url; diff --git a/crates/apub/src/fetcher/user_or_community.rs b/crates/apub/src/fetcher/user_or_community.rs index 156f5e83..14fc5c34 100644 --- a/crates/apub/src/fetcher/user_or_community.rs +++ b/crates/apub/src/fetcher/user_or_community.rs @@ -5,8 +5,8 @@ use crate::{ }; use activitypub_federation::traits::{Actor, ApubObject}; use chrono::NaiveDateTime; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/crates/apub/src/fetcher/webfinger.rs b/crates/apub/src/fetcher/webfinger.rs index 8e97d7d0..4a0ff4fd 100644 --- a/crates/apub/src/fetcher/webfinger.rs +++ b/crates/apub/src/fetcher/webfinger.rs @@ -2,9 +2,9 @@ use crate::{local_instance, ActorType, FEDERATION_HTTP_FETCH_LIMIT}; use activitypub_federation::{core::object_id::ObjectId, traits::ApubObject}; use anyhow::anyhow; use itertools::Itertools; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::newtypes::DbUrl; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use tracing::debug; use url::Url; diff --git a/crates/apub/src/http/comment.rs b/crates/apub/src/http/comment.rs index 498a23c8..fbadd42b 100644 --- a/crates/apub/src/http/comment.rs +++ b/crates/apub/src/http/comment.rs @@ -5,9 +5,9 @@ use crate::{ use activitypub_federation::traits::ApubObject; use actix_web::{web, web::Path, HttpResponse}; use diesel::result::Error::NotFound; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{newtypes::CommentId, source::comment::Comment, traits::Crud}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::Deserialize; #[derive(Deserialize)] diff --git a/crates/apub/src/http/community.rs b/crates/apub/src/http/community.rs index 8b860f57..5b1a5b92 100644 --- a/crates/apub/src/http/community.rs +++ b/crates/apub/src/http/community.rs @@ -17,9 +17,9 @@ use activitypub_federation::{ traits::ApubObject, }; use actix_web::{web, HttpRequest, HttpResponse}; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{source::community::Community, traits::ApubActor}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::Deserialize; #[derive(Deserialize)] diff --git a/crates/apub/src/http/mod.rs b/crates/apub/src/http/mod.rs index f351ea4f..c4602c33 100644 --- a/crates/apub/src/http/mod.rs +++ b/crates/apub/src/http/mod.rs @@ -15,9 +15,9 @@ use activitypub_federation::{ }; use actix_web::{web, HttpRequest, HttpResponse}; use http::StatusCode; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::source::activity::Activity; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use once_cell::sync::OnceCell; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_json::Value; diff --git a/crates/apub/src/http/person.rs b/crates/apub/src/http/person.rs index 0ca31bd5..19c57b20 100644 --- a/crates/apub/src/http/person.rs +++ b/crates/apub/src/http/person.rs @@ -8,9 +8,9 @@ use crate::{ }; use activitypub_federation::{deser::context::WithContext, traits::ApubObject}; use actix_web::{web, HttpRequest, HttpResponse}; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{source::person::Person, traits::ApubActor}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::Deserialize; #[derive(Deserialize)] diff --git a/crates/apub/src/http/post.rs b/crates/apub/src/http/post.rs index 5da69fb4..85a4406f 100644 --- a/crates/apub/src/http/post.rs +++ b/crates/apub/src/http/post.rs @@ -5,9 +5,9 @@ use crate::{ use activitypub_federation::traits::ApubObject; use actix_web::{web, HttpResponse}; use diesel::result::Error::NotFound; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{newtypes::PostId, source::post::Post, traits::Crud}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::Deserialize; #[derive(Deserialize)] diff --git a/crates/apub/src/http/site.rs b/crates/apub/src/http/site.rs index 201fc5b3..7a945ac7 100644 --- a/crates/apub/src/http/site.rs +++ b/crates/apub/src/http/site.rs @@ -6,9 +6,9 @@ use crate::{ }; use activitypub_federation::{deser::context::WithContext, traits::ApubObject}; use actix_web::{web, HttpRequest, HttpResponse}; +use lemmy_api_common::LemmyContext; use lemmy_db_views::structs::SiteView; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use url::Url; pub(crate) async fn get_apub_site_http( diff --git a/crates/apub/src/lib.rs b/crates/apub/src/lib.rs index f5d8d356..48fd58f1 100644 --- a/crates/apub/src/lib.rs +++ b/crates/apub/src/lib.rs @@ -8,13 +8,13 @@ use activitypub_federation::{ }; use anyhow::Context; use async_trait::async_trait; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ newtypes::DbUrl, source::{activity::Activity, instance::Instance, local_site::LocalSite}, utils::DbPool, }; use lemmy_utils::{error::LemmyError, location_info, settings::structs::Settings}; -use lemmy_websocket::LemmyContext; use once_cell::sync::Lazy; use tokio::sync::OnceCell; use url::{ParseError, Url}; diff --git a/crates/apub/src/mentions.rs b/crates/apub/src/mentions.rs index 8e24270d..ae7d9b6c 100644 --- a/crates/apub/src/mentions.rs +++ b/crates/apub/src/mentions.rs @@ -5,6 +5,7 @@ use crate::{ }; use activitypub_federation::core::object_id::ObjectId; use activitystreams_kinds::link::MentionType; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ source::{comment::Comment, person::Person, post::Post}, traits::Crud, @@ -14,7 +15,6 @@ use lemmy_utils::{ error::LemmyError, utils::{scrape_text_for_mentions, MentionData}, }; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use serde_json::Value; use url::Url; diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index df20700f..a4c6ef73 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -20,7 +20,7 @@ use activitypub_federation::{ }; use activitystreams_kinds::{object::NoteType, public}; use chrono::NaiveDateTime; -use lemmy_api_common::utils::local_site_opt_to_slur_regex; +use lemmy_api_common::{utils::local_site_opt_to_slur_regex, LemmyContext}; use lemmy_db_schema::{ source::{ comment::{Comment, CommentInsertForm, CommentUpdateForm}, @@ -35,7 +35,6 @@ use lemmy_utils::{ error::LemmyError, utils::{convert_datetime, markdown_to_html, remove_slurs}, }; -use lemmy_websocket::LemmyContext; use std::ops::Deref; use url::Url; diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index aefc7edb..a454813b 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -20,6 +20,7 @@ use activitypub_federation::{ use activitystreams_kinds::actor::GroupType; use chrono::NaiveDateTime; use itertools::Itertools; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ source::{ actor_language::CommunityLanguage, @@ -33,7 +34,6 @@ use lemmy_utils::{ error::LemmyError, utils::{convert_datetime, markdown_to_html}, }; -use lemmy_websocket::LemmyContext; use std::ops::Deref; use tracing::debug; use url::Url; diff --git a/crates/apub/src/objects/instance.rs b/crates/apub/src/objects/instance.rs index 9f33ee51..18e9d9f2 100644 --- a/crates/apub/src/objects/instance.rs +++ b/crates/apub/src/objects/instance.rs @@ -20,7 +20,7 @@ use activitypub_federation::{ utils::verify_domains_match, }; use chrono::NaiveDateTime; -use lemmy_api_common::utils::local_site_opt_to_slur_regex; +use lemmy_api_common::{utils::local_site_opt_to_slur_regex, LemmyContext}; use lemmy_db_schema::{ source::{ actor_language::SiteLanguage, @@ -34,7 +34,6 @@ use lemmy_utils::{ error::LemmyError, utils::{check_slurs, check_slurs_opt, convert_datetime, markdown_to_html}, }; -use lemmy_websocket::LemmyContext; use std::ops::Deref; use tracing::debug; use url::Url; diff --git a/crates/apub/src/objects/mod.rs b/crates/apub/src/objects/mod.rs index 5098d0b2..1bf621fc 100644 --- a/crates/apub/src/objects/mod.rs +++ b/crates/apub/src/objects/mod.rs @@ -56,14 +56,17 @@ pub(crate) fn verify_is_remote_object(id: &Url, settings: &Settings) -> Result<( pub(crate) mod tests { use actix::Actor; use anyhow::anyhow; - use lemmy_api_common::request::build_user_agent; + use lemmy_api_common::{ + request::build_user_agent, + websocket::chat_server::ChatServer, + LemmyContext, + }; use lemmy_db_schema::{source::secret::Secret, utils::build_db_pool_for_tests}; use lemmy_utils::{ error::LemmyError, rate_limit::{RateLimitCell, RateLimitConfig}, settings::SETTINGS, }; - use lemmy_websocket::{chat_server::ChatServer, LemmyContext}; use reqwest::{Client, Request, Response}; use reqwest_middleware::{ClientBuilder, Middleware, Next}; use task_local_extensions::Extensions; diff --git a/crates/apub/src/objects/person.rs b/crates/apub/src/objects/person.rs index fb450557..ad7fc1c9 100644 --- a/crates/apub/src/objects/person.rs +++ b/crates/apub/src/objects/person.rs @@ -19,7 +19,7 @@ use activitypub_federation::{ utils::verify_domains_match, }; use chrono::NaiveDateTime; -use lemmy_api_common::utils::local_site_opt_to_slur_regex; +use lemmy_api_common::{utils::local_site_opt_to_slur_regex, LemmyContext}; use lemmy_db_schema::{ source::{ instance::Instance, @@ -32,7 +32,6 @@ use lemmy_utils::{ error::LemmyError, utils::{check_slurs, check_slurs_opt, convert_datetime, markdown_to_html}, }; -use lemmy_websocket::LemmyContext; use std::ops::Deref; use url::Url; diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index b7d38e34..f79e3055 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -22,7 +22,11 @@ use activitypub_federation::{ }; use activitystreams_kinds::public; use chrono::NaiveDateTime; -use lemmy_api_common::{request::fetch_site_data, utils::local_site_opt_to_slur_regex}; +use lemmy_api_common::{ + request::fetch_site_data, + utils::local_site_opt_to_slur_regex, + LemmyContext, +}; use lemmy_db_schema::{ self, source::{ @@ -38,7 +42,6 @@ use lemmy_utils::{ error::LemmyError, utils::{check_slurs, convert_datetime, markdown_to_html, remove_slurs}, }; -use lemmy_websocket::LemmyContext; use std::ops::Deref; use url::Url; diff --git a/crates/apub/src/objects/private_message.rs b/crates/apub/src/objects/private_message.rs index 47a9c5d1..f4807076 100644 --- a/crates/apub/src/objects/private_message.rs +++ b/crates/apub/src/objects/private_message.rs @@ -15,7 +15,7 @@ use activitypub_federation::{ utils::verify_domains_match, }; use chrono::NaiveDateTime; -use lemmy_api_common::utils::check_person_block; +use lemmy_api_common::{utils::check_person_block, LemmyContext}; use lemmy_db_schema::{ source::{ person::Person, @@ -27,7 +27,6 @@ use lemmy_utils::{ error::LemmyError, utils::{convert_datetime, markdown_to_html}, }; -use lemmy_websocket::LemmyContext; use std::ops::Deref; use url::Url; diff --git a/crates/apub/src/protocol/activities/block/block_user.rs b/crates/apub/src/protocol/activities/block/block_user.rs index 91467a96..364fe9b9 100644 --- a/crates/apub/src/protocol/activities/block/block_user.rs +++ b/crates/apub/src/protocol/activities/block/block_user.rs @@ -8,8 +8,8 @@ use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserial use activitystreams_kinds::activity::BlockType; use anyhow::anyhow; use chrono::{DateTime, FixedOffset}; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use url::Url; diff --git a/crates/apub/src/protocol/activities/block/undo_block_user.rs b/crates/apub/src/protocol/activities/block/undo_block_user.rs index ade126ee..9646315f 100644 --- a/crates/apub/src/protocol/activities/block/undo_block_user.rs +++ b/crates/apub/src/protocol/activities/block/undo_block_user.rs @@ -6,8 +6,8 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many}; use activitystreams_kinds::activity::UndoType; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use url::Url; diff --git a/crates/apub/src/protocol/activities/community/add_mod.rs b/crates/apub/src/protocol/activities/community/add_mod.rs index f23fcbae..c8ea5daa 100644 --- a/crates/apub/src/protocol/activities/community/add_mod.rs +++ b/crates/apub/src/protocol/activities/community/add_mod.rs @@ -6,8 +6,8 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many}; use activitystreams_kinds::activity::AddType; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/crates/apub/src/protocol/activities/community/remove_mod.rs b/crates/apub/src/protocol/activities/community/remove_mod.rs index 2ee744b7..57d9c1bc 100644 --- a/crates/apub/src/protocol/activities/community/remove_mod.rs +++ b/crates/apub/src/protocol/activities/community/remove_mod.rs @@ -6,8 +6,8 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many}; use activitystreams_kinds::activity::RemoveType; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/crates/apub/src/protocol/activities/community/report.rs b/crates/apub/src/protocol/activities/community/report.rs index 34738c56..a66e08b0 100644 --- a/crates/apub/src/protocol/activities/community/report.rs +++ b/crates/apub/src/protocol/activities/community/report.rs @@ -7,8 +7,8 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one}; use activitystreams_kinds::activity::FlagType; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/crates/apub/src/protocol/activities/community/update.rs b/crates/apub/src/protocol/activities/community/update.rs index f534f236..8bf39a82 100644 --- a/crates/apub/src/protocol/activities/community/update.rs +++ b/crates/apub/src/protocol/activities/community/update.rs @@ -6,8 +6,8 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many}; use activitystreams_kinds::activity::UpdateType; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/crates/apub/src/protocol/activities/create_or_update/note.rs b/crates/apub/src/protocol/activities/create_or_update/note.rs index 0de7161f..a952811b 100644 --- a/crates/apub/src/protocol/activities/create_or_update/note.rs +++ b/crates/apub/src/protocol/activities/create_or_update/note.rs @@ -6,9 +6,9 @@ use crate::{ protocol::{activities::CreateOrUpdateType, objects::note::Note, InCommunity}, }; use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many}; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{source::community::Community, traits::Crud}; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/crates/apub/src/protocol/activities/create_or_update/page.rs b/crates/apub/src/protocol/activities/create_or_update/page.rs index b0311b5f..9d45ae0b 100644 --- a/crates/apub/src/protocol/activities/create_or_update/page.rs +++ b/crates/apub/src/protocol/activities/create_or_update/page.rs @@ -5,8 +5,8 @@ use crate::{ protocol::{activities::CreateOrUpdateType, objects::page::Page, InCommunity}, }; use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many}; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/crates/apub/src/protocol/activities/deletion/delete.rs b/crates/apub/src/protocol/activities/deletion/delete.rs index f5ae40d8..8a0c1b0b 100644 --- a/crates/apub/src/protocol/activities/deletion/delete.rs +++ b/crates/apub/src/protocol/activities/deletion/delete.rs @@ -7,12 +7,12 @@ use crate::{ use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many}; use activitystreams_kinds::activity::DeleteType; use anyhow::anyhow; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ source::{community::Community, post::Post}, traits::Crud, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use url::Url; diff --git a/crates/apub/src/protocol/activities/deletion/undo_delete.rs b/crates/apub/src/protocol/activities/deletion/undo_delete.rs index c4946850..0e2c0f98 100644 --- a/crates/apub/src/protocol/activities/deletion/undo_delete.rs +++ b/crates/apub/src/protocol/activities/deletion/undo_delete.rs @@ -6,8 +6,8 @@ use crate::{ }; use activitypub_federation::{core::object_id::ObjectId, deser::helpers::deserialize_one_or_many}; use activitystreams_kinds::activity::UndoType; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use url::Url; diff --git a/crates/apub/src/protocol/activities/voting/undo_vote.rs b/crates/apub/src/protocol/activities/voting/undo_vote.rs index 1d17cf15..7c23036c 100644 --- a/crates/apub/src/protocol/activities/voting/undo_vote.rs +++ b/crates/apub/src/protocol/activities/voting/undo_vote.rs @@ -6,8 +6,8 @@ use crate::{ }; use activitypub_federation::core::object_id::ObjectId; use activitystreams_kinds::activity::UndoType; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/crates/apub/src/protocol/activities/voting/vote.rs b/crates/apub/src/protocol/activities/voting/vote.rs index 5da9b791..a88aa3da 100644 --- a/crates/apub/src/protocol/activities/voting/vote.rs +++ b/crates/apub/src/protocol/activities/voting/vote.rs @@ -6,8 +6,8 @@ use crate::{ protocol::InCommunity, }; use activitypub_federation::core::object_id::ObjectId; +use lemmy_api_common::LemmyContext; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use std::convert::TryFrom; use strum_macros::Display; diff --git a/crates/apub/src/protocol/collections/group_followers.rs b/crates/apub/src/protocol/collections/group_followers.rs index ac1ef228..0a095bb7 100644 --- a/crates/apub/src/protocol/collections/group_followers.rs +++ b/crates/apub/src/protocol/collections/group_followers.rs @@ -1,9 +1,9 @@ use crate::generate_followers_url; use activitystreams_kinds::collection::CollectionType; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::source::community::Community; use lemmy_db_views_actor::structs::CommunityFollowerView; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/crates/apub/src/protocol/mod.rs b/crates/apub/src/protocol/mod.rs index a65e74da..16bdb1b2 100644 --- a/crates/apub/src/protocol/mod.rs +++ b/crates/apub/src/protocol/mod.rs @@ -1,9 +1,9 @@ use crate::{local_instance, objects::community::ApubCommunity}; use activitypub_federation::{deser::values::MediaTypeMarkdown, utils::fetch_object_http}; use activitystreams_kinds::object::ImageType; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::newtypes::DbUrl; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::collections::HashMap; use url::Url; diff --git a/crates/apub/src/protocol/objects/group.rs b/crates/apub/src/protocol/objects/group.rs index 564aed16..316af1a8 100644 --- a/crates/apub/src/protocol/objects/group.rs +++ b/crates/apub/src/protocol/objects/group.rs @@ -19,7 +19,7 @@ use activitypub_federation::{ }; use activitystreams_kinds::actor::GroupType; use chrono::{DateTime, FixedOffset}; -use lemmy_api_common::utils::local_site_opt_to_slur_regex; +use lemmy_api_common::{utils::local_site_opt_to_slur_regex, LemmyContext}; use lemmy_db_schema::{ newtypes::InstanceId, source::community::{CommunityInsertForm, CommunityUpdateForm}, @@ -29,7 +29,6 @@ use lemmy_utils::{ error::LemmyError, utils::{check_slurs, check_slurs_opt}, }; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use url::Url; diff --git a/crates/apub/src/protocol/objects/note.rs b/crates/apub/src/protocol/objects/note.rs index 21f7bcf3..f8263d87 100644 --- a/crates/apub/src/protocol/objects/note.rs +++ b/crates/apub/src/protocol/objects/note.rs @@ -15,12 +15,12 @@ use activitypub_federation::{ }; use activitystreams_kinds::object::NoteType; use chrono::{DateTime, FixedOffset}; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ source::{community::Community, post::Post}, traits::Crud, }; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use std::ops::Deref; diff --git a/crates/apub/src/protocol/objects/page.rs b/crates/apub/src/protocol/objects/page.rs index b25e1d97..1ff12bc2 100644 --- a/crates/apub/src/protocol/objects/page.rs +++ b/crates/apub/src/protocol/objects/page.rs @@ -20,9 +20,9 @@ use activitystreams_kinds::{ }; use chrono::{DateTime, FixedOffset}; use itertools::Itertools; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::newtypes::DbUrl; use lemmy_utils::error::LemmyError; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use url::Url; diff --git a/crates/routes/Cargo.toml b/crates/routes/Cargo.toml index cbcd259c..a2778349 100644 --- a/crates/routes/Cargo.toml +++ b/crates/routes/Cargo.toml @@ -13,7 +13,6 @@ doctest = false [dependencies] lemmy_utils = { workspace = true } -lemmy_websocket = { workspace = true } lemmy_db_views = { workspace = true } lemmy_db_views_actor = { workspace = true } lemmy_db_schema = { workspace = true } diff --git a/crates/routes/src/feeds.rs b/crates/routes/src/feeds.rs index 436148b9..72181bf6 100644 --- a/crates/routes/src/feeds.rs +++ b/crates/routes/src/feeds.rs @@ -1,6 +1,7 @@ use actix_web::{error::ErrorBadRequest, web, Error, HttpRequest, HttpResponse, Result}; use anyhow::anyhow; use chrono::{DateTime, NaiveDateTime, Utc}; +use lemmy_api_common::LemmyContext; use lemmy_db_schema::{ newtypes::LocalUserId, source::{community::Community, local_user::LocalUser, person::Person}, @@ -20,7 +21,6 @@ use lemmy_db_views_actor::{ structs::{CommentReplyView, PersonMentionView}, }; use lemmy_utils::{claims::Claims, error::LemmyError, utils::markdown_to_html}; -use lemmy_websocket::LemmyContext; use once_cell::sync::Lazy; use rss::{ extension::dublincore::DublinCoreExtensionBuilder, diff --git a/crates/routes/src/images.rs b/crates/routes/src/images.rs index 716b18be..6e839e21 100644 --- a/crates/routes/src/images.rs +++ b/crates/routes/src/images.rs @@ -11,10 +11,9 @@ use actix_web::{ HttpResponse, }; use futures::stream::{Stream, StreamExt}; -use lemmy_api_common::utils::get_local_user_view_from_jwt; +use lemmy_api_common::{utils::get_local_user_view_from_jwt, LemmyContext}; use lemmy_db_schema::source::local_site::LocalSite; use lemmy_utils::{claims::Claims, rate_limit::RateLimitCell, REQWEST_TIMEOUT}; -use lemmy_websocket::LemmyContext; use reqwest::Body; use reqwest_middleware::{ClientWithMiddleware, RequestBuilder}; use serde::{Deserialize, Serialize}; diff --git a/crates/routes/src/nodeinfo.rs b/crates/routes/src/nodeinfo.rs index 9c3a3240..3a8b4185 100644 --- a/crates/routes/src/nodeinfo.rs +++ b/crates/routes/src/nodeinfo.rs @@ -1,8 +1,8 @@ use actix_web::{error::ErrorBadRequest, web, Error, HttpResponse, Result}; use anyhow::anyhow; +use lemmy_api_common::LemmyContext; use lemmy_db_views::structs::SiteView; use lemmy_utils::{error::LemmyError, version}; -use lemmy_websocket::LemmyContext; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/crates/routes/src/webfinger.rs b/crates/routes/src/webfinger.rs index 11395976..7d9ff2bf 100644 --- a/crates/routes/src/webfinger.rs +++ b/crates/routes/src/webfinger.rs @@ -1,12 +1,12 @@ use actix_web::{web, web::Query, HttpResponse}; use anyhow::Context; +use lemmy_api_common::LemmyContext; use lemmy_apub::fetcher::webfinger::{WebfingerLink, WebfingerResponse}; use lemmy_db_schema::{ source::{community::Community, person::Person}, traits::ApubActor, }; use lemmy_utils::{error::LemmyError, location_info}; -use lemmy_websocket::LemmyContext; use serde::Deserialize; use url::Url; diff --git a/crates/websocket/Cargo.toml b/crates/websocket/Cargo.toml deleted file mode 100644 index 829b759a..00000000 --- a/crates/websocket/Cargo.toml +++ /dev/null @@ -1,38 +0,0 @@ -[package] -name = "lemmy_websocket" -version.workspace = true -edition.workspace = true -description.workspace = true -license.workspace = true -homepage.workspace = true -documentation.workspace = true -repository.workspace = true - -[lib] -name = "lemmy_websocket" -path = "src/lib.rs" -doctest = false - -[dependencies] -lemmy_utils = { workspace = true } -lemmy_api_common = { workspace = true, features = ["full"] } -lemmy_db_schema = { workspace = true, features = ["full"] } -lemmy_db_views = { workspace = true, features = ["full"] } -lemmy_db_views_actor = { workspace = true, features = ["full"] } -reqwest-middleware = { workspace = true } -tracing = { workspace = true } -rand = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -actix = { workspace = true } -anyhow = { workspace = true } -diesel = { workspace = true } -tokio = { workspace = true } -strum = { workspace = true } -strum_macros = { workspace = true } -chrono = { workspace = true } -actix-web = { workspace = true } -opentelemetry = { workspace = true } -tracing-opentelemetry = { workspace = true } -actix-web-actors = { version = "4.1.0", default-features = false } -background-jobs = "0.13.0" diff --git a/src/api_routes.rs b/src/api_routes.rs index 82a73f88..626857c6 100644 --- a/src/api_routes.rs +++ b/src/api_routes.rs @@ -94,11 +94,14 @@ use lemmy_api_common::{ ResolveObject, Search, }, - websocket::{CommunityJoin, ModJoin, PostJoin, UserJoin}, + websocket::{ + routes::chat_route, + structs::{CommunityJoin, ModJoin, PostJoin, UserJoin}, + }, + LemmyContext, }; use lemmy_api_crud::PerformCrud; use lemmy_utils::rate_limit::RateLimitCell; -use lemmy_websocket::{routes::chat_route, LemmyContext}; use serde::Deserialize; pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) { diff --git a/src/main.rs b/src/main.rs index 728b3d37..e4b8e8e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,8 @@ use lemmy_api_common::{ check_private_instance_and_federation_enabled, local_site_rate_limit_to_rate_limit_config, }, + websocket::chat_server::ChatServer, + LemmyContext, }; use lemmy_api_crud::match_websocket_operation_crud; use lemmy_db_schema::{ @@ -32,7 +34,6 @@ use lemmy_utils::{ rate_limit::RateLimitCell, settings::{structs::Settings, SETTINGS}, }; -use lemmy_websocket::{chat_server::ChatServer, LemmyContext}; use reqwest::Client; use reqwest_middleware::ClientBuilder; use reqwest_retry::{policies::ExponentialBackoff, RetryTransientMiddleware};