From 030afbc2e78a91b1a302ca59c4ea0ccef9057019 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 26 Nov 2022 03:04:46 +0100 Subject: [PATCH] Merge websocket crate into api_common --- Cargo.lock | 44 +++-------- Cargo.toml | 3 - crates/api/Cargo.toml | 1 - crates/api/src/comment/like.rs | 3 +- crates/api/src/comment/save.rs | 2 +- crates/api/src/comment_report/create.rs | 3 +- crates/api/src/comment_report/list.rs | 2 +- crates/api/src/comment_report/resolve.rs | 3 +- crates/api/src/community/add_mod.rs | 3 +- crates/api/src/community/ban.rs | 3 +- crates/api/src/community/block.rs | 2 +- crates/api/src/community/follow.rs | 2 +- crates/api/src/community/hide.rs | 3 +- crates/api/src/community/transfer.rs | 2 +- crates/api/src/lib.rs | 8 +- crates/api/src/local_user/add_admin.rs | 3 +- crates/api/src/local_user/ban_person.rs | 3 +- crates/api/src/local_user/block.rs | 2 +- crates/api/src/local_user/change_password.rs | 2 +- .../local_user/change_password_after_reset.rs | 2 +- crates/api/src/local_user/get_captcha.rs | 7 +- crates/api/src/local_user/list_banned.rs | 2 +- crates/api/src/local_user/login.rs | 2 +- .../local_user/notifications/list_mentions.rs | 2 +- .../local_user/notifications/list_replies.rs | 2 +- .../local_user/notifications/mark_all_read.rs | 2 +- .../notifications/mark_mention_read.rs | 2 +- .../notifications/mark_reply_read.rs | 2 +- .../local_user/notifications/unread_count.rs | 2 +- crates/api/src/local_user/report_count.rs | 2 +- crates/api/src/local_user/reset_password.rs | 2 +- crates/api/src/local_user/save_settings.rs | 2 +- crates/api/src/local_user/verify_email.rs | 2 +- crates/api/src/post/get_link_metadata.rs | 2 +- crates/api/src/post/like.rs | 3 +- crates/api/src/post/lock.rs | 3 +- crates/api/src/post/mark_read.rs | 2 +- crates/api/src/post/save.rs | 2 +- crates/api/src/post/sticky.rs | 3 +- crates/api/src/post_report/create.rs | 3 +- crates/api/src/post_report/list.rs | 2 +- crates/api/src/post_report/resolve.rs | 3 +- crates/api/src/private_message/mark_read.rs | 3 +- .../api/src/private_message_report/create.rs | 3 +- crates/api/src/private_message_report/list.rs | 2 +- .../api/src/private_message_report/resolve.rs | 3 +- crates/api/src/site/leave_admin.rs | 2 +- crates/api/src/site/mod_log.rs | 2 +- crates/api/src/site/purge/comment.rs | 2 +- crates/api/src/site/purge/community.rs | 2 +- crates/api/src/site/purge/person.rs | 2 +- crates/api/src/site/purge/post.rs | 2 +- .../site/registration_applications/approve.rs | 2 +- .../site/registration_applications/list.rs | 2 +- .../registration_applications/unread_count.rs | 2 +- crates/api/src/site/resolve_object.rs | 2 +- crates/api/src/site/search.rs | 2 +- crates/api/src/websocket.rs | 24 +++--- crates/api_common/Cargo.toml | 11 +++ crates/api_common/src/lib.rs | 71 ++++++++++++++++++ .../src/websocket}/chat_server.rs | 15 ++-- .../src/websocket}/handlers.rs | 2 +- .../src/websocket}/messages.rs | 3 +- .../src/websocket/mod.rs} | 74 +------------------ .../src/websocket}/routes.rs | 6 +- .../src => api_common/src/websocket}/send.rs | 10 +-- .../{websocket.rs => websocket/structs.rs} | 0 crates/api_crud/Cargo.toml | 1 - crates/api_crud/src/comment/create.rs | 10 +-- crates/api_crud/src/comment/delete.rs | 10 +-- crates/api_crud/src/comment/list.rs | 2 +- crates/api_crud/src/comment/read.rs | 2 +- crates/api_crud/src/comment/remove.rs | 10 +-- crates/api_crud/src/comment/update.rs | 10 +-- crates/api_crud/src/community/create.rs | 2 +- crates/api_crud/src/community/delete.rs | 3 +- crates/api_crud/src/community/list.rs | 2 +- crates/api_crud/src/community/read.rs | 3 +- crates/api_crud/src/community/remove.rs | 3 +- crates/api_crud/src/community/update.rs | 3 +- crates/api_crud/src/lib.rs | 3 +- crates/api_crud/src/post/create.rs | 3 +- crates/api_crud/src/post/delete.rs | 3 +- crates/api_crud/src/post/list.rs | 2 +- crates/api_crud/src/post/read.rs | 3 +- crates/api_crud/src/post/remove.rs | 3 +- crates/api_crud/src/post/update.rs | 3 +- crates/api_crud/src/private_message/create.rs | 3 +- crates/api_crud/src/private_message/delete.rs | 3 +- crates/api_crud/src/private_message/read.rs | 2 +- crates/api_crud/src/private_message/update.rs | 3 +- crates/api_crud/src/site/create.rs | 2 +- crates/api_crud/src/site/read.rs | 3 +- crates/api_crud/src/site/update.rs | 3 +- crates/api_crud/src/user/create.rs | 3 +- crates/api_crud/src/user/delete.rs | 2 +- crates/api_crud/src/user/read.rs | 2 +- crates/apub/Cargo.toml | 1 - .../apub/src/activities/block/block_user.rs | 6 +- crates/apub/src/activities/block/mod.rs | 2 +- .../src/activities/block/undo_block_user.rs | 2 +- .../apub/src/activities/community/add_mod.rs | 2 +- .../apub/src/activities/community/announce.rs | 2 +- crates/apub/src/activities/community/mod.rs | 2 +- .../src/activities/community/remove_mod.rs | 2 +- .../apub/src/activities/community/report.rs | 8 +- .../apub/src/activities/community/update.rs | 5 +- .../activities/create_or_update/comment.rs | 7 +- .../src/activities/create_or_update/mod.rs | 2 +- .../src/activities/create_or_update/post.rs | 5 +- .../create_or_update/private_message.rs | 5 +- crates/apub/src/activities/deletion/delete.rs | 12 +-- .../src/activities/deletion/delete_user.rs | 3 +- crates/apub/src/activities/deletion/mod.rs | 22 +++--- .../src/activities/deletion/undo_delete.rs | 12 +-- .../apub/src/activities/following/accept.rs | 7 +- .../apub/src/activities/following/follow.rs | 2 +- .../src/activities/following/undo_follow.rs | 2 +- crates/apub/src/activities/mod.rs | 2 +- crates/apub/src/activities/voting/mod.rs | 12 +-- .../apub/src/activities/voting/undo_vote.rs | 2 +- crates/apub/src/activities/voting/vote.rs | 2 +- crates/apub/src/activity_lists.rs | 2 +- crates/apub/src/collections/mod.rs | 2 +- .../apub/src/fetcher/deletable_apub_object.rs | 2 +- crates/apub/src/fetcher/mod.rs | 2 +- crates/apub/src/fetcher/post_or_comment.rs | 2 +- crates/apub/src/fetcher/search.rs | 2 +- crates/apub/src/fetcher/user_or_community.rs | 2 +- crates/apub/src/fetcher/webfinger.rs | 2 +- crates/apub/src/http/comment.rs | 2 +- crates/apub/src/http/community.rs | 2 +- crates/apub/src/http/mod.rs | 2 +- crates/apub/src/http/person.rs | 2 +- crates/apub/src/http/post.rs | 2 +- crates/apub/src/http/site.rs | 2 +- crates/apub/src/lib.rs | 2 +- crates/apub/src/mentions.rs | 2 +- crates/apub/src/objects/comment.rs | 3 +- crates/apub/src/objects/community.rs | 2 +- crates/apub/src/objects/instance.rs | 3 +- crates/apub/src/objects/mod.rs | 7 +- crates/apub/src/objects/person.rs | 3 +- crates/apub/src/objects/post.rs | 7 +- crates/apub/src/objects/private_message.rs | 3 +- .../protocol/activities/block/block_user.rs | 2 +- .../activities/block/undo_block_user.rs | 2 +- .../protocol/activities/community/add_mod.rs | 2 +- .../activities/community/remove_mod.rs | 2 +- .../protocol/activities/community/report.rs | 2 +- .../protocol/activities/community/update.rs | 2 +- .../activities/create_or_update/note.rs | 2 +- .../activities/create_or_update/page.rs | 2 +- .../protocol/activities/deletion/delete.rs | 2 +- .../activities/deletion/undo_delete.rs | 2 +- .../protocol/activities/voting/undo_vote.rs | 2 +- .../src/protocol/activities/voting/vote.rs | 2 +- .../protocol/collections/group_followers.rs | 2 +- crates/apub/src/protocol/mod.rs | 2 +- crates/apub/src/protocol/objects/group.rs | 3 +- crates/apub/src/protocol/objects/note.rs | 2 +- crates/apub/src/protocol/objects/page.rs | 2 +- crates/routes/Cargo.toml | 1 - crates/routes/src/feeds.rs | 2 +- crates/routes/src/images.rs | 3 +- crates/routes/src/nodeinfo.rs | 2 +- crates/routes/src/webfinger.rs | 2 +- crates/websocket/Cargo.toml | 38 ---------- src/api_routes.rs | 7 +- src/main.rs | 3 +- 170 files changed, 404 insertions(+), 384 deletions(-) rename crates/{websocket/src => api_common/src/websocket}/chat_server.rs (98%) rename crates/{websocket/src => api_common/src/websocket}/handlers.rs (99%) rename crates/{websocket/src => api_common/src/websocket}/messages.rs (97%) rename crates/{websocket/src/lib.rs => api_common/src/websocket/mod.rs} (58%) rename crates/{websocket/src => api_common/src/websocket}/routes.rs (97%) rename crates/{websocket/src => api_common/src/websocket}/send.rs (98%) rename crates/api_common/src/{websocket.rs => websocket/structs.rs} (100%) delete mode 100644 crates/websocket/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index c083fba9d..954754929 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 67e85b27b..16ca864f4 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 b707545b6..17c0127b4 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 6ca87f3cf..1ba6ec791 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 647f0ed53..cc6955de0 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 2533aba1c..99c653e23 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 4a9041e99..b99716e88 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 8055e9484..16598ffa9 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 ff54edda7..d307a672d 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 7b0897ad8..018ccd012 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 840d17665..6c6efc213 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 fbabebc2c..51d5ad9b6 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 111a89d01..54a08135a 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 5da0d8e3e..bb69de092 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 dbff533ea..0473f1e88 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 ceca80f90..8091f97e4 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 2482e408e..a848175e4 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 44bd668f7..798d36774 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 38fac32b5..e4e9004ea 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 3ac48252e..f9556b533 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 3d1b88845..5eacc4fd8 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 16df72ccc..31d4e3be6 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 613543877..dac0d9bf5 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 d231f7184..5e3b63e7a 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 102229985..375864b58 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 3b8ad0f44..9f8926dc3 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 c42e294a8..655f78846 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 2ec5fd806..fa3367e33 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 47d826fdd..442977a2c 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 1372e4caa..7dd63b7ad 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 078d55ec3..8def6d3c6 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 4aa3a7437..807e8262d 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 73db4bea5..238692ff0 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 54e2cfe7c..aae211a50 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 ec2edc33e..d15e649b9 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 ae726ee92..4348971fe 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 18f86521c..228fdac0d 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 0a240f9eb..9e8ca9ce1 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 384ba52d6..ccba5f2c3 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 ca4113a3b..2fd2d08be 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 7a79f04b7..188a722ff 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 687bdcce1..6c3d62f18 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 0b7bb676a..ba0e70d59 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 490fd55bf..6b923c102 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 0279cb83b..17fc438ff 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 a7af798ad..eeda4ed42 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 4a6687b32..4674f43bf 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 f1ab9f45c..85bfc40ce 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 d5a11216f..54f3c0edf 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 74373d81f..c70c8c0a7 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 f5aad6e1d..8a5f6ac09 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 ee5adf723..b3ec28eac 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 bb1252598..c5089b5d5 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 3d9ed326e..1ce709b35 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 7fb8906af..a22d14e95 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 0e59c6835..47aa248e7 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 5d813fcfd..1033f92e6 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 391b84e0d..0e0c015a1 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 bfbaa8e25..a4c80da52 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 ef907f88a..bcd603e5f 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 8577e0429..c8f59e3d2 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 90ef01a4b..6f3d164c9 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 21b6ac4b7..f81124161 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 e73e784e2..d1e30f448 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 a3b1b0460..7b500ce4c 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 2793534f4..6f3506aee 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 b4f68a8df..7a16aed5c 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 f027b0fe2..a3be10a63 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 549d2f366..f14d0d415 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 afee451a3..3e7444bf7 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 7d5779ffe..98b3431c2 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 c1e581e0c..09e5fdfca 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 0d89acc29..d1fcccd9c 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 437671eef..caa1a363d 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 41f14b527..7d3122ab4 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 37a9d88a4..f77ebce75 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 1b3e5ff48..a008f7865 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 1977f5cd1..77c2bde30 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 8e60b3f88..2bde94ea6 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 b50d3cd27..fde81eddb 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 cad8b28e2..2353def6d 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 a0b930084..de1490b1c 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 bf4086e47..42944cada 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 5e2582a07..44d1be63a 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 b062bc653..525c08a68 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 11b566bc9..4c3038c87 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 35bc09e22..6f099f793 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 51cded6d1..ad6b78d3e 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 f0741398e..88bb08300 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 5f79735e9..b6e08c9c6 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 8b2b9c18b..22631d514 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 dbf64c6c3..8f27bb2ee 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 07e965823..e738a2513 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 d1b5fbc3e..5686348f7 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 594747673..87ad78e44 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 ccf5189cd..b7b155a74 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 c2a8827eb..720fa5937 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 1d726e7ce..c77bfde35 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 bc2ea77f0..5a8c48f13 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 eb54f5e48..56f794dc1 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 c212cfe14..2bdf2be5e 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 b6c31af5d..1ca1aa848 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 a7b35595e..3d0bb4c3d 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 3934df3b1..ca8d5b042 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 440a8ebbb..2741af7e8 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 f41f2d47c..c0d1a2799 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 a4b60ad4d..5def04604 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 2c68ad80f..b53dd2eb8 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 abe9be1a6..161b26b9d 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 eb310ce9c..431e699ce 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 8298a6fe0..ae93d6e09 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 08d9d3959..ffe664d59 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 bf4b920a8..d05e45021 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 8b845400e..bc6f9fd14 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 5a8baa4c7..880db0d99 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 867eb2913..82c0c37a5 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 012ebfb90..7d48f9f3c 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 c38eadcda..1528a273c 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 bff67efee..a01dcb2ea 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 20c9432cd..dca106ded 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 f8d44ed98..bc702fd86 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 fa8eece38..fa343d8ae 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 e2a274a01..4c27beb41 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 c84ebabbc..0eae410c6 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 d98bb8e4d..563989241 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 d2d0b91f6..b44d9f16f 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 1daccd3a4..95b47f5e4 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 156f5e83a..14fc5c344 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 8e97d7d07..4a0ff4fd8 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 498a23c8a..fbadd42ba 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 8b860f573..5b1a5b926 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 f351ea4f0..c4602c337 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 0ca31bd5c..19c57b20c 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 5da69fb45..85a4406f5 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 201fc5b3a..7a945ac72 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 f5d8d3565..48fd58f1d 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 8e24270d0..ae7d9b6c1 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 df20700fb..a4c6ef737 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 aefc7edb2..a454813bb 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 9f33ee518..18e9d9f25 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 5098d0b2b..1bf621fca 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 fb450557d..ad7fc1c9c 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 b7d38e347..f79e3055a 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 47a9c5d13..f4807076b 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 91467a96c..364fe9b9f 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 ade126eec..9646315ff 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 f23fcbae0..c8ea5daa9 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 2ee744b7f..57d9c1bca 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 34738c56a..a66e08b05 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 f534f2369..8bf39a826 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 0de7161f4..a952811be 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 b0311b5ff..9d45ae0bf 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 f5ae40d8a..8a0c1b0bd 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 c4946850a..0e2c0f982 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 1d17cf158..7c23036c6 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 5da9b791c..a88aa3da9 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 ac1ef2285..0a095bb70 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 a65e74da2..16bdb1b29 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 564aed169..316af1a8d 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 21f7bcf38..f8263d874 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 b25e1d97c..1ff12bc29 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 cbcd259c0..a27783494 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 436148b96..72181bf6a 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 716b18be8..6e839e214 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 9c3a32402..3a8b41859 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 113959769..7d9ff2bfe 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 829b759af..000000000 --- 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 82a73f884..626857c69 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 728b3d370..e4b8e8e32 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};