Add SendActivity trait so that api crates compile in parallel with lemmy_apub

This commit is contained in:
Felix Ableitner 2022-11-28 15:29:33 +01:00
parent 8892c39bac
commit d423044b60
159 changed files with 203 additions and 428 deletions

View file

@ -20,7 +20,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"] }
activitypub_federation = { workspace = true }
diesel = { workspace = true }
bcrypt = { workspace = true }
chrono = { workspace = true }

View file

@ -5,14 +5,6 @@ use lemmy_api_common::{
context::LemmyContext,
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,
protocol::activities::voting::{
undo_vote::UndoVote,
vote::{Vote, VoteType},
},
};
use lemmy_db_schema::{
newtypes::LocalUserId,
@ -25,7 +17,6 @@ use lemmy_db_schema::{
};
use lemmy_db_views::structs::{CommentView, LocalUserView};
use lemmy_utils::{error::LemmyError, ConnectionId};
use std::convert::TryInto;
#[async_trait::async_trait(?Send)]
impl Perform for CreateCommentLike {

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
comment::{CommentResponse, SaveComment},
context::LemmyContext,
utils::get_local_user_view_from_jwt,
LemmyContext,
};
use lemmy_db_schema::{
source::comment::{CommentSaved, CommentSavedForm},

View file

@ -5,7 +5,6 @@ use lemmy_api_common::{
context::LemmyContext,
utils::{check_community_ban, get_local_user_view_from_jwt},
websocket::{messages::SendModRoomMessage, UserOperation},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
comment::{ListCommentReports, ListCommentReportsResponse},
context::LemmyContext,
utils::get_local_user_view_from_jwt,
LemmyContext,
};
use lemmy_db_views::comment_report_view::CommentReportQuery;
use lemmy_utils::{error::LemmyError, ConnectionId};

View file

@ -5,7 +5,6 @@ use lemmy_api_common::{
context::LemmyContext,
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;

View file

@ -5,11 +5,6 @@ use lemmy_api_common::{
context::LemmyContext,
utils::{get_local_user_view_from_jwt, is_mod_or_admin},
websocket::{messages::SendCommunityRoomMessage, UserOperation},
LemmyContext,
};
use lemmy_apub::{
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::community::{add_mod::AddMod, remove_mod::RemoveMod},
};
use lemmy_db_schema::{
source::{

View file

@ -5,12 +5,6 @@ use lemmy_api_common::{
context::LemmyContext,
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,
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser},
};
use lemmy_db_schema::{
source::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
community::{BlockCommunity, BlockCommunityResponse},
context::LemmyContext,
utils::get_local_user_view_from_jwt,
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
community::{CommunityResponse, FollowCommunity},
context::LemmyContext,
utils::{check_community_ban, check_community_deleted_or_removed, get_local_user_view_from_jwt},
LemmyContext,
};
use lemmy_db_schema::{
source::community::{Community, CommunityFollower, CommunityFollowerForm},

View file

@ -5,7 +5,6 @@ use lemmy_api_common::{
context::LemmyContext,
utils::{get_local_user_view_from_jwt, is_admin},
websocket::{send::send_community_ws_message, UserOperationCrud},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -5,7 +5,6 @@ use lemmy_api_common::{
community::{GetCommunityResponse, TransferCommunity},
context::LemmyContext,
utils::get_local_user_view_from_jwt,
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -1,81 +1,8 @@
use actix_web::web::Data;
use captcha::Captcha;
use lemmy_api_common::{
comment::{
CreateCommentLike,
CreateCommentReport,
ListCommentReports,
ResolveCommentReport,
SaveComment,
},
community::{
AddModToCommunity,
BanFromCommunity,
BlockCommunity,
FollowCommunity,
TransferCommunity,
},
person::{
AddAdmin,
BanPerson,
BlockPerson,
ChangePassword,
GetBannedPersons,
GetCaptcha,
GetPersonMentions,
GetReplies,
GetReportCount,
GetUnreadCount,
Login,
MarkAllAsRead,
MarkCommentReplyAsRead,
MarkPersonMentionAsRead,
PasswordChangeAfterReset,
PasswordReset,
SaveUserSettings,
VerifyEmail,
},
post::{
CreatePostLike,
CreatePostReport,
GetSiteMetadata,
ListPostReports,
LockPost,
MarkPostAsRead,
ResolvePostReport,
SavePost,
StickyPost,
},
private_message::{
CreatePrivateMessageReport,
ListPrivateMessageReports,
MarkPrivateMessageAsRead,
ResolvePrivateMessageReport,
},
site::{
ApproveRegistrationApplication,
GetModlog,
GetUnreadRegistrationApplicationCount,
LeaveAdmin,
ListRegistrationApplications,
PurgeComment,
PurgeCommunity,
PurgePerson,
PurgePost,
ResolveObject,
Search,
},
utils::local_site_to_slur_regex,
websocket::{
serialize_websocket_message,
structs::{CommunityJoin, ModJoin, PostJoin, UserJoin},
UserOperation,
},
LemmyContext,
};
use lemmy_api_common::{context::LemmyContext, utils::local_site_to_slur_regex};
use lemmy_db_schema::source::local_site::LocalSite;
use lemmy_utils::{error::LemmyError, utils::check_slurs, ConnectionId};
use serde::Deserialize;
mod comment;
mod comment_report;

View file

@ -5,7 +5,6 @@ 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::{

View file

@ -5,11 +5,6 @@ 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,
protocol::activities::block::{block_user::BlockUser, undo_block_user::UndoBlockUser},
};
use lemmy_db_schema::{
source::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
person::{BlockPerson, BlockPersonResponse},
utils::get_local_user_view_from_jwt,
LemmyContext,
};
use lemmy_db_schema::{
source::person_block::{PersonBlock, PersonBlockForm},

View file

@ -5,7 +5,6 @@ use lemmy_api_common::{
context::LemmyContext,
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};

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
person::{LoginResponse, PasswordChangeAfterReset},
utils::password_length_check,
LemmyContext,
};
use lemmy_db_schema::source::{
local_user::LocalUser,

View file

@ -3,9 +3,9 @@ use actix_web::web::Data;
use captcha::{gen, Difficulty};
use chrono::Duration;
use lemmy_api_common::{
context::LemmyContext,
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};

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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};

View file

@ -5,7 +5,6 @@ use lemmy_api_common::{
context::LemmyContext,
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;

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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};

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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};

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
person::{GetRepliesResponse, MarkAllAsRead},
utils::get_local_user_view_from_jwt,
LemmyContext,
};
use lemmy_db_schema::source::{
comment_reply::CommentReply,

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
person::{MarkPersonMentionAsRead, PersonMentionResponse},
utils::get_local_user_view_from_jwt,
LemmyContext,
};
use lemmy_db_schema::{
source::person_mention::{PersonMention, PersonMentionUpdateForm},

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
person::{CommentReplyResponse, MarkCommentReplyAsRead},
utils::get_local_user_view_from_jwt,
LemmyContext,
};
use lemmy_db_schema::{
source::comment_reply::{CommentReply, CommentReplyUpdateForm},

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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};

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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};

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
person::{PasswordReset, PasswordResetResponse},
utils::send_password_reset_email,
LemmyContext,
};
use lemmy_db_views::structs::LocalUserView;
use lemmy_utils::{error::LemmyError, ConnectionId};

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
person::{LoginResponse, SaveUserSettings},
utils::{get_local_user_view_from_jwt, send_verification_email},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
person::{VerifyEmail, VerifyEmailResponse},
utils::send_email_verification_success,
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
post::{GetSiteMetadata, GetSiteMetadataResponse},
request::fetch_site_metadata,
LemmyContext,
};
use lemmy_utils::{error::LemmyError, ConnectionId};

View file

@ -11,15 +11,6 @@ use lemmy_api_common::{
mark_post_as_read,
},
websocket::{send::send_post_ws_message, UserOperation},
LemmyContext,
};
use lemmy_apub::{
fetcher::post_or_comment::PostOrComment,
objects::post::ApubPost,
protocol::activities::voting::{
undo_vote::UndoVote,
vote::{Vote, VoteType},
},
};
use lemmy_db_schema::{
source::{

View file

@ -10,11 +10,6 @@ use lemmy_api_common::{
is_mod_or_admin,
},
websocket::{send::send_post_ws_message, UserOperation},
LemmyContext,
};
use lemmy_apub::{
objects::post::ApubPost,
protocol::activities::{create_or_update::page::CreateOrUpdatePage, CreateOrUpdateType},
};
use lemmy_db_schema::{
source::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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};

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
post::{PostResponse, SavePost},
utils::{get_local_user_view_from_jwt, mark_post_as_read},
LemmyContext,
};
use lemmy_db_schema::{
source::post::{PostSaved, PostSavedForm},

View file

@ -10,11 +10,6 @@ use lemmy_api_common::{
is_mod_or_admin,
},
websocket::{send::send_post_ws_message, UserOperation},
LemmyContext,
};
use lemmy_apub::{
objects::post::ApubPost,
protocol::activities::{create_or_update::page::CreateOrUpdatePage, CreateOrUpdateType},
};
use lemmy_db_schema::{
source::{

View file

@ -5,7 +5,6 @@ use lemmy_api_common::{
post::{CreatePostReport, PostReportResponse},
utils::{check_community_ban, get_local_user_view_from_jwt},
websocket::{messages::SendModRoomMessage, UserOperation},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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};

View file

@ -5,7 +5,6 @@ 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;

View file

@ -5,7 +5,6 @@ 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},

View file

@ -5,7 +5,6 @@ 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,

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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};

View file

@ -5,7 +5,6 @@ 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,

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
site::{GetSiteResponse, LeaveAdmin},
utils::{get_local_user_view_from_jwt, is_admin},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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},

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
site::{PurgeComment, PurgeItemResponse},
utils::{get_local_user_view_from_jwt, is_admin},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -5,7 +5,6 @@ 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::{

View file

@ -5,7 +5,6 @@ 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::{

View file

@ -5,7 +5,6 @@ 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::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
site::{ApproveRegistrationApplication, RegistrationApplicationResponse},
utils::{get_local_user_view_from_jwt, is_admin, send_application_approved_email},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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;

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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;

View file

@ -16,7 +16,6 @@ use lemmy_api_common::{
UserJoinResponse,
},
},
LemmyContext,
};
use lemmy_utils::{error::LemmyError, ConnectionId};

View file

@ -20,72 +20,3 @@ 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<ChatServer>,
client: ClientWithMiddleware,
settings: Settings,
secret: Secret,
rate_limit_cell: RateLimitCell,
}
impl LemmyContext {
pub fn create(
pool: DbPool,
chat_server: Addr<ChatServer>,
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<ChatServer> {
&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(),
}
}
}

View file

@ -808,3 +808,65 @@ pub fn generate_outbox_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
pub fn generate_moderators_url(community_id: &DbUrl) -> Result<DbUrl, LemmyError> {
Ok(Url::parse(&format!("{}/moderators", community_id))?.into())
}
pub enum EndpointType {
Community,
Person,
Post,
Comment,
PrivateMessage,
}
/// Generates an apub endpoint for a given domain, IE xyz.tld
pub fn generate_local_apub_endpoint(
endpoint_type: EndpointType,
name: &str,
domain: &str,
) -> Result<DbUrl, ParseError> {
let point = match endpoint_type {
EndpointType::Community => "c",
EndpointType::Person => "u",
EndpointType::Post => "post",
EndpointType::Comment => "comment",
EndpointType::PrivateMessage => "private_message",
};
Ok(Url::parse(&format!("{}/{}/{}", domain, point, name))?.into())
}
pub fn generate_followers_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{}/followers", actor_id))?.into())
}
pub fn generate_inbox_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{}/inbox", actor_id))?.into())
}
pub fn generate_site_inbox_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
let mut actor_id: Url = actor_id.clone().into();
actor_id.set_path("site_inbox");
Ok(actor_id.into())
}
pub fn generate_shared_inbox_url(actor_id: &DbUrl) -> Result<DbUrl, LemmyError> {
let actor_id: Url = actor_id.clone().into();
let url = format!(
"{}://{}{}/inbox",
&actor_id.scheme(),
&actor_id.host_str().context(location_info!())?,
if let Some(port) = actor_id.port() {
format!(":{}", port)
} else {
String::new()
},
);
Ok(Url::parse(&url)?.into())
}
pub fn generate_outbox_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{}/outbox", actor_id))?.into())
}
pub fn generate_moderators_url(community_id: &DbUrl) -> Result<DbUrl, LemmyError> {
Ok(Url::parse(&format!("{}/moderators", community_id))?.into())
}

View file

@ -1,14 +1,15 @@
use crate::{
comment::CommentResponse,
context::LemmyContext,
post::PostResponse,
websocket::{
messages::{CaptchaItem, StandardMessage, WsMessage},
serialize_websocket_message,
OperationType,
UserOperation,
UserOperationApub,
UserOperationCrud,
},
LemmyContext,
};
use actix::prelude::*;
use anyhow::Context as acontext;

View file

@ -1,9 +1,9 @@
use crate::{
context::LemmyContext,
websocket::{
chat_server::ChatServer,
messages::{Connect, Disconnect, StandardMessage, WsMessage},
},
LemmyContext,
};
use actix::prelude::*;
use actix_web::{web, Error, HttpRequest, HttpResponse};

View file

@ -9,7 +9,6 @@ use crate::{
messages::{SendComment, SendCommunityRoomMessage, SendPost, SendUserRoomMessage},
OperationType,
},
LemmyContext,
};
use lemmy_db_schema::{
newtypes::{CommentId, CommunityId, LocalUserId, PersonId, PostId, PrivateMessageId},

View file

@ -17,17 +17,6 @@ use lemmy_api_common::{
send::{send_comment_ws_message, send_local_notifs},
UserOperationCrud,
},
websocket::{
send::{send_comment_ws_message, send_local_notifs},
UserOperationCrud,
},
LemmyContext,
};
use lemmy_apub::{
generate_local_apub_endpoint,
objects::comment::ApubComment,
protocol::activities::{create_or_update::note::CreateOrUpdateNote, CreateOrUpdateType},
EndpointType,
};
use lemmy_db_schema::{
source::{

View file

@ -8,7 +8,6 @@ use lemmy_api_common::{
send::{send_comment_ws_message, send_local_notifs},
UserOperationCrud,
},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
comment::{CommentResponse, GetComment},
context::LemmyContext,
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;

View file

@ -8,7 +8,6 @@ use lemmy_api_common::{
send::{send_comment_ws_message, send_local_notifs},
UserOperationCrud,
},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -15,11 +15,6 @@ use lemmy_api_common::{
send::{send_comment_ws_message, send_local_notifs},
UserOperationCrud,
},
LemmyContext,
};
use lemmy_apub::protocol::activities::{
create_or_update::note::CreateOrUpdateNote,
CreateOrUpdateType,
};
use lemmy_db_schema::{
source::{

View file

@ -3,16 +3,17 @@ use activitypub_federation::core::signatures::generate_actor_keypair;
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,
generate_inbox_url,
generate_local_apub_endpoint,
generate_shared_inbox_url,
objects::community::ApubCommunity,
EndpointType,
context::LemmyContext,
utils::{
generate_followers_url,
generate_inbox_url,
generate_local_apub_endpoint,
generate_shared_inbox_url,
get_local_user_view_from_jwt,
is_admin,
local_site_to_slur_regex,
EndpointType,
},
};
use lemmy_db_schema::{
source::community::{

View file

@ -5,7 +5,6 @@ use lemmy_api_common::{
context::LemmyContext,
utils::get_local_user_view_from_jwt,
websocket::{send::send_community_ws_message, UserOperationCrud},
LemmyContext,
};
use lemmy_db_schema::{
source::community::{Community, CommunityUpdateForm},

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
community::{ListCommunities, ListCommunitiesResponse},
context::LemmyContext,
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;

View file

@ -5,7 +5,6 @@ use lemmy_api_common::{
context::LemmyContext,
utils::{get_local_user_view_from_jwt, is_admin},
websocket::{send::send_community_ws_message, UserOperationCrud},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -5,7 +5,6 @@ use lemmy_api_common::{
context::LemmyContext,
utils::{get_local_user_view_from_jwt, local_site_to_slur_regex},
websocket::{send::send_community_ws_message, UserOperationCrud},
LemmyContext,
};
use lemmy_db_schema::{
newtypes::PersonId,

View file

@ -1,28 +1,6 @@
use actix_web::{web, web::Data};
use lemmy_api_common::{
comment::{CreateComment, DeleteComment, EditComment, GetComment, GetComments, RemoveComment},
community::{
CreateCommunity,
DeleteCommunity,
EditCommunity,
GetCommunity,
ListCommunities,
RemoveCommunity,
},
person::{DeleteAccount, GetPersonDetails, Register},
post::{CreatePost, DeletePost, EditPost, GetPost, GetPosts, RemovePost},
private_message::{
CreatePrivateMessage,
DeletePrivateMessage,
EditPrivateMessage,
GetPrivateMessages,
},
site::{CreateSite, EditSite, GetSite},
websocket::{serialize_websocket_message, UserOperationCrud},
LemmyContext,
};
use actix_web::web::Data;
use lemmy_api_common::context::LemmyContext;
use lemmy_utils::{error::LemmyError, ConnectionId};
use serde::Deserialize;
mod comment;
mod community;

View file

@ -15,13 +15,6 @@ use lemmy_api_common::{
EndpointType,
},
websocket::{send::send_post_ws_message, UserOperationCrud},
LemmyContext,
};
use lemmy_apub::{
generate_local_apub_endpoint,
objects::post::ApubPost,
protocol::activities::{create_or_update::page::CreateOrUpdatePage, CreateOrUpdateType},
EndpointType,
};
use lemmy_db_schema::{
impls::actor_language::default_post_language,

View file

@ -5,7 +5,6 @@ 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_db_schema::{
source::post::{Post, PostUpdateForm},

View file

@ -5,7 +5,6 @@ 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},

View file

@ -5,7 +5,6 @@ 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_db_schema::{
source::{

View file

@ -11,11 +11,6 @@ use lemmy_api_common::{
local_site_to_slur_regex,
},
websocket::{send::send_post_ws_message, UserOperationCrud},
LemmyContext,
};
use lemmy_apub::protocol::activities::{
create_or_update::page::CreateOrUpdatePage,
CreateOrUpdateType,
};
use lemmy_db_schema::{
source::{

View file

@ -13,15 +13,6 @@ use lemmy_api_common::{
EndpointType,
},
websocket::{send::send_pm_ws_message, UserOperationCrud},
LemmyContext,
};
use lemmy_apub::{
generate_local_apub_endpoint,
protocol::activities::{
create_or_update::chat_message::CreateOrUpdateChatMessage,
CreateOrUpdateType,
},
EndpointType,
};
use lemmy_db_schema::{
source::{

View file

@ -5,7 +5,6 @@ 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_db_schema::{
source::private_message::{PrivateMessage, PrivateMessageUpdateForm},

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
context::LemmyContext,
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;

View file

@ -5,11 +5,6 @@ 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,
CreateOrUpdateType,
};
use lemmy_db_schema::{
source::{

View file

@ -12,7 +12,6 @@ use lemmy_api_common::{
local_site_to_slur_regex,
site_description_length_check,
},
LemmyContext,
};
use lemmy_db_schema::{
newtypes::DbUrl,

View file

@ -5,7 +5,6 @@ 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};

View file

@ -11,7 +11,6 @@ use lemmy_api_common::{
site_description_length_check,
},
websocket::{messages::SendAllMessage, UserOperationCrud},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -16,7 +16,6 @@ use lemmy_api_common::{
EndpointType,
},
websocket::messages::CheckCaptcha,
LemmyContext,
};
use lemmy_apub::{
generate_inbox_url,

View file

@ -4,8 +4,7 @@ use bcrypt::verify;
use lemmy_api_common::{
context::LemmyContext,
person::{DeleteAccount, DeleteAccountResponse},
utils::{delete_user_account, get_local_user_view_from_jwt},
LemmyContext,
utils::get_local_user_view_from_jwt,
};
use lemmy_utils::{error::LemmyError, ConnectionId};

View file

@ -24,8 +24,8 @@ use activitystreams_kinds::{activity::BlockType, public};
use anyhow::anyhow;
use chrono::NaiveDateTime;
use lemmy_api_common::{
context::LemmyContext,
utils::{remove_user_data, remove_user_data_in_community},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -9,9 +9,19 @@ 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_api_common::{
community::{BanFromCommunity, BanFromCommunityResponse},
context::LemmyContext,
person::{BanPerson, BanPersonResponse},
utils::get_local_user_view_from_jwt,
};
use lemmy_db_schema::{
source::{community::Community, person::Person, site::Site},
traits::Crud,
utils::DbPool,
};
use lemmy_db_views::structs::SiteView;
use lemmy_utils::{error::LemmyError, utils::naive_from_unix};
use serde::Deserialize;
use url::Url;

View file

@ -19,7 +19,7 @@ use activitypub_federation::{
utils::verify_domains_match,
};
use activitystreams_kinds::{activity::UndoType, public};
use lemmy_api_common::LemmyContext;
use lemmy_api_common::context::LemmyContext;
use lemmy_db_schema::{
source::{
community::{CommunityPersonBan, CommunityPersonBanForm},

View file

@ -23,7 +23,11 @@ use activitypub_federation::{
traits::{ActivityHandler, Actor},
};
use activitystreams_kinds::{activity::AddType, public};
use lemmy_api_common::LemmyContext;
use lemmy_api_common::{
community::{AddModToCommunity, AddModToCommunityResponse},
context::LemmyContext,
utils::{generate_moderators_url, get_local_user_view_from_jwt},
};
use lemmy_db_schema::{
source::{
community::{Community, CommunityModerator, CommunityModeratorForm},

View file

@ -18,7 +18,7 @@ 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_api_common::context::LemmyContext;
use lemmy_utils::error::LemmyError;
use serde_json::Value;
use tracing::debug;

View file

@ -6,7 +6,7 @@ use crate::{
protocol::activities::community::announce::AnnounceActivity,
};
use activitypub_federation::{core::object_id::ObjectId, traits::Actor};
use lemmy_api_common::LemmyContext;
use lemmy_api_common::context::LemmyContext;
use lemmy_db_schema::source::person::PersonFollower;
use lemmy_utils::error::LemmyError;
use url::Url;

View file

@ -19,7 +19,7 @@ use activitypub_federation::{
traits::{ActivityHandler, Actor},
};
use activitystreams_kinds::{activity::RemoveType, public};
use lemmy_api_common::LemmyContext;
use lemmy_api_common::{context::LemmyContext, utils::generate_moderators_url};
use lemmy_db_schema::{
source::{
community::{CommunityModerator, CommunityModeratorForm},

View file

@ -14,10 +14,11 @@ use activitypub_federation::{
};
use activitystreams_kinds::activity::FlagType;
use lemmy_api_common::{
comment::CommentReportResponse,
post::PostReportResponse,
comment::{CommentReportResponse, CreateCommentReport},
context::LemmyContext,
post::{CreatePostReport, PostReportResponse},
utils::get_local_user_view_from_jwt,
websocket::{messages::SendModRoomMessage, UserOperation},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -19,8 +19,10 @@ use activitypub_federation::{
};
use activitystreams_kinds::{activity::UpdateType, public};
use lemmy_api_common::{
community::{CommunityResponse, EditCommunity, HideCommunity},
context::LemmyContext,
utils::get_local_user_view_from_jwt,
websocket::{send::send_community_ws_message, UserOperationCrud},
LemmyContext,
};
use lemmy_db_schema::{source::community::Community, traits::Crud};
use lemmy_utils::error::LemmyError;

View file

@ -26,9 +26,10 @@ use activitypub_federation::{
};
use activitystreams_kinds::public;
use lemmy_api_common::{
comment::{CommentResponse, CreateComment, EditComment},
context::LemmyContext,
utils::check_post_deleted_or_removed,
websocket::{send::send_comment_ws_message, UserOperationCrud},
LemmyContext,
};
use lemmy_db_schema::{
newtypes::PersonId,

View file

@ -1,6 +1,6 @@
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_api_common::{context::LemmyContext, websocket::send::send_local_notifs};
use lemmy_db_schema::{
newtypes::LocalUserId,
source::{comment::Comment, post::Post},

View file

@ -24,8 +24,10 @@ use activitypub_federation::{
};
use activitystreams_kinds::public;
use lemmy_api_common::{
context::LemmyContext,
post::{CreatePost, EditPost, LockPost, PostResponse, StickyPost},
utils::get_local_user_view_from_jwt,
websocket::{send::send_post_ws_message, UserOperationCrud},
LemmyContext,
};
use lemmy_db_schema::{
newtypes::PersonId,

View file

@ -15,10 +15,15 @@ use activitypub_federation::{
utils::verify_domains_match,
};
use lemmy_api_common::{
context::LemmyContext,
private_message::{CreatePrivateMessage, EditPrivateMessage, PrivateMessageResponse},
websocket::{send::send_pm_ws_message, UserOperationCrud},
LemmyContext,
};
use lemmy_db_schema::{source::person::Person, traits::Crud};
use lemmy_db_schema::{
newtypes::PersonId,
source::{person::Person, private_message::PrivateMessage},
traits::Crud,
};
use lemmy_utils::error::LemmyError;
use url::Url;

View file

@ -10,11 +10,11 @@ use crate::{
use activitypub_federation::{core::object_id::ObjectId, data::Data, traits::ActivityHandler};
use activitystreams_kinds::activity::DeleteType;
use lemmy_api_common::{
context::LemmyContext,
websocket::{
send::{send_comment_ws_message_simple, send_community_ws_message, send_post_ws_message},
UserOperationCrud,
},
LemmyContext,
};
use lemmy_db_schema::{
source::{

View file

@ -12,7 +12,11 @@ use activitypub_federation::{
utils::verify_urls_match,
};
use activitystreams_kinds::{activity::DeleteType, public};
use lemmy_api_common::{utils::delete_user_account, LemmyContext};
use lemmy_api_common::{
context::LemmyContext,
person::{DeleteAccount, DeleteAccountResponse},
utils::{delete_user_account, get_local_user_view_from_jwt},
};
use lemmy_utils::error::LemmyError;
use url::Url;

View file

@ -30,6 +30,12 @@ use activitypub_federation::{
};
use activitystreams_kinds::public;
use lemmy_api_common::{
comment::{CommentResponse, DeleteComment, RemoveComment},
community::{CommunityResponse, DeleteCommunity, RemoveCommunity},
context::LemmyContext,
post::{DeletePost, PostResponse, RemovePost},
private_message::{DeletePrivateMessage, PrivateMessageResponse},
utils::get_local_user_view_from_jwt,
websocket::{
send::{
send_comment_ws_message_simple,
@ -39,7 +45,6 @@ use lemmy_api_common::{
},
UserOperationCrud,
},
LemmyContext,
};
use lemmy_db_schema::{
source::{

Some files were not shown because too many files have changed in this diff Show more