mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-27 03:41:02 +00:00
Move activity structs to protocol folder
This commit is contained in:
parent
5ff044346f
commit
03d8ac75ef
71 changed files with 910 additions and 751 deletions
|
@ -1,5 +1,7 @@
|
|||
use crate::Perform;
|
||||
use std::convert::TryInto;
|
||||
|
||||
use actix_web::web::Data;
|
||||
|
||||
use lemmy_api_common::{
|
||||
blocking,
|
||||
check_community_ban,
|
||||
|
@ -9,11 +11,11 @@ use lemmy_api_common::{
|
|||
get_local_user_view_from_jwt,
|
||||
};
|
||||
use lemmy_apub::{
|
||||
activities::voting::{
|
||||
fetcher::post_or_comment::PostOrComment,
|
||||
protocol::activities::voting::{
|
||||
undo_vote::UndoVote,
|
||||
vote::{Vote, VoteType},
|
||||
},
|
||||
fetcher::post_or_comment::PostOrComment,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::LocalUserId,
|
||||
|
@ -23,7 +25,8 @@ use lemmy_db_schema::{
|
|||
use lemmy_db_views::{comment_view::CommentView, local_user_view::LocalUserView};
|
||||
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
||||
use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperation};
|
||||
use std::convert::TryInto;
|
||||
|
||||
use crate::Perform;
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl Perform for MarkCommentAsRead {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::Perform;
|
||||
use actix_web::web::Data;
|
||||
|
||||
use lemmy_api_common::{
|
||||
blocking,
|
||||
check_community_ban,
|
||||
|
@ -7,7 +7,7 @@ use lemmy_api_common::{
|
|||
get_local_user_view_from_jwt,
|
||||
is_mod_or_admin,
|
||||
};
|
||||
use lemmy_apub::{activities::report::Report, fetcher::object_id::ObjectId};
|
||||
use lemmy_apub::{fetcher::object_id::ObjectId, protocol::activities::community::report::Report};
|
||||
use lemmy_db_schema::{source::comment_report::*, traits::Reportable};
|
||||
use lemmy_db_views::{
|
||||
comment_report_view::{CommentReportQueryBuilder, CommentReportView},
|
||||
|
@ -16,6 +16,8 @@ use lemmy_db_views::{
|
|||
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
||||
use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation};
|
||||
|
||||
use crate::Perform;
|
||||
|
||||
/// Creates a comment report and notifies the moderators of the community
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl Perform for CreateCommentReport {
|
||||
|
|
|
@ -10,16 +10,16 @@ use lemmy_api_common::{
|
|||
is_mod_or_admin,
|
||||
};
|
||||
use lemmy_apub::{
|
||||
activities::{
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::{
|
||||
community::{
|
||||
add_mod::AddMod,
|
||||
block_user::BlockUserFromCommunity,
|
||||
remove_mod::RemoveMod,
|
||||
undo_block_user::UndoBlockUserFromCommunity,
|
||||
},
|
||||
following::{follow::FollowCommunity as FollowCommunityApub, undo::UndoFollowCommunity},
|
||||
following::{follow::FollowCommunity as FollowCommunityApub, undo_follow::UndoFollowCommunity},
|
||||
},
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
|
|
|
@ -12,16 +12,16 @@ use lemmy_api_common::{
|
|||
post::*,
|
||||
};
|
||||
use lemmy_apub::{
|
||||
activities::{
|
||||
post::create_or_update::CreateOrUpdatePost,
|
||||
fetcher::post_or_comment::PostOrComment,
|
||||
objects::post::ApubPost,
|
||||
protocol::activities::{
|
||||
create_or_update::post::CreateOrUpdatePost,
|
||||
voting::{
|
||||
undo_vote::UndoVote,
|
||||
vote::{Vote, VoteType},
|
||||
},
|
||||
CreateOrUpdateType,
|
||||
},
|
||||
fetcher::post_or_comment::PostOrComment,
|
||||
objects::post::ApubPost,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::{moderator::*, post::*},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::Perform;
|
||||
use actix_web::web::Data;
|
||||
|
||||
use lemmy_api_common::{
|
||||
blocking,
|
||||
check_community_ban,
|
||||
|
@ -13,7 +13,7 @@ use lemmy_api_common::{
|
|||
ResolvePostReport,
|
||||
},
|
||||
};
|
||||
use lemmy_apub::{activities::report::Report, fetcher::object_id::ObjectId};
|
||||
use lemmy_apub::{fetcher::object_id::ObjectId, protocol::activities::community::report::Report};
|
||||
use lemmy_db_schema::{
|
||||
source::post_report::{PostReport, PostReportForm},
|
||||
traits::Reportable,
|
||||
|
@ -25,6 +25,8 @@ use lemmy_db_views::{
|
|||
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
||||
use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation};
|
||||
|
||||
use crate::Perform;
|
||||
|
||||
/// Creates a post report and notifies the moderators of the community
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl Perform for CreatePostReport {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::PerformCrud;
|
||||
use actix_web::web::Data;
|
||||
|
||||
use lemmy_api_common::{
|
||||
blocking,
|
||||
check_community_ban,
|
||||
|
@ -11,13 +11,13 @@ use lemmy_api_common::{
|
|||
get_post,
|
||||
};
|
||||
use lemmy_apub::{
|
||||
activities::{
|
||||
comment::create_or_update::CreateOrUpdateComment,
|
||||
fetcher::post_or_comment::PostOrComment,
|
||||
generate_local_apub_endpoint,
|
||||
protocol::activities::{
|
||||
create_or_update::comment::CreateOrUpdateComment,
|
||||
voting::vote::{Vote, VoteType},
|
||||
CreateOrUpdateType,
|
||||
},
|
||||
fetcher::post_or_comment::PostOrComment,
|
||||
generate_local_apub_endpoint,
|
||||
EndpointType,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
|
@ -40,6 +40,8 @@ use lemmy_websocket::{
|
|||
UserOperationCrud,
|
||||
};
|
||||
|
||||
use crate::PerformCrud;
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl PerformCrud for CreateComment {
|
||||
type Response = CommentResponse;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::PerformCrud;
|
||||
use actix_web::web::Data;
|
||||
|
||||
use lemmy_api_common::{
|
||||
blocking,
|
||||
check_community_ban,
|
||||
|
@ -8,8 +8,8 @@ use lemmy_api_common::{
|
|||
comment::*,
|
||||
get_local_user_view_from_jwt,
|
||||
};
|
||||
use lemmy_apub::activities::{
|
||||
comment::create_or_update::CreateOrUpdateComment,
|
||||
use lemmy_apub::protocol::activities::{
|
||||
create_or_update::comment::CreateOrUpdateComment,
|
||||
CreateOrUpdateType,
|
||||
};
|
||||
use lemmy_db_schema::source::comment::Comment;
|
||||
|
@ -26,6 +26,8 @@ use lemmy_websocket::{
|
|||
UserOperationCrud,
|
||||
};
|
||||
|
||||
use crate::PerformCrud;
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl PerformCrud for EditComment {
|
||||
type Response = CommentResponse;
|
||||
|
|
|
@ -5,7 +5,7 @@ use lemmy_api_common::{
|
|||
community::{CommunityResponse, EditCommunity},
|
||||
get_local_user_view_from_jwt,
|
||||
};
|
||||
use lemmy_apub::activities::community::update::UpdateCommunity;
|
||||
use lemmy_apub::protocol::activities::community::update::UpdateCommunity;
|
||||
use lemmy_db_schema::{
|
||||
diesel_option_overwrite_to_url,
|
||||
naive_now,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use crate::PerformCrud;
|
||||
use actix_web::web::Data;
|
||||
use log::warn;
|
||||
use webmention::{Webmention, WebmentionError};
|
||||
|
||||
use lemmy_api_common::{
|
||||
blocking,
|
||||
check_community_ban,
|
||||
|
@ -10,13 +12,13 @@ use lemmy_api_common::{
|
|||
post::*,
|
||||
};
|
||||
use lemmy_apub::{
|
||||
activities::{
|
||||
post::create_or_update::CreateOrUpdatePost,
|
||||
fetcher::post_or_comment::PostOrComment,
|
||||
generate_local_apub_endpoint,
|
||||
protocol::activities::{
|
||||
create_or_update::post::CreateOrUpdatePost,
|
||||
voting::vote::{Vote, VoteType},
|
||||
CreateOrUpdateType,
|
||||
},
|
||||
fetcher::post_or_comment::PostOrComment,
|
||||
generate_local_apub_endpoint,
|
||||
EndpointType,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
|
@ -31,8 +33,8 @@ use lemmy_utils::{
|
|||
LemmyError,
|
||||
};
|
||||
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
|
||||
use log::warn;
|
||||
use webmention::{Webmention, WebmentionError};
|
||||
|
||||
use crate::PerformCrud;
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl PerformCrud for CreatePost {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::PerformCrud;
|
||||
use actix_web::web::Data;
|
||||
|
||||
use lemmy_api_common::{
|
||||
blocking,
|
||||
check_community_ban,
|
||||
|
@ -7,7 +7,10 @@ use lemmy_api_common::{
|
|||
get_local_user_view_from_jwt,
|
||||
post::*,
|
||||
};
|
||||
use lemmy_apub::activities::{post::create_or_update::CreateOrUpdatePost, CreateOrUpdateType};
|
||||
use lemmy_apub::protocol::activities::{
|
||||
create_or_update::post::CreateOrUpdatePost,
|
||||
CreateOrUpdateType,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
naive_now,
|
||||
source::post::{Post, PostForm},
|
||||
|
@ -22,6 +25,8 @@ use lemmy_utils::{
|
|||
};
|
||||
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
|
||||
|
||||
use crate::PerformCrud;
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl PerformCrud for EditPost {
|
||||
type Response = PostResponse;
|
||||
|
|
|
@ -7,11 +7,11 @@ use lemmy_api_common::{
|
|||
person::{CreatePrivateMessage, PrivateMessageResponse},
|
||||
};
|
||||
use lemmy_apub::{
|
||||
activities::{
|
||||
generate_local_apub_endpoint,
|
||||
protocol::activities::{
|
||||
private_message::create_or_update::CreateOrUpdatePrivateMessage,
|
||||
CreateOrUpdateType,
|
||||
},
|
||||
generate_local_apub_endpoint,
|
||||
EndpointType,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
|
|
|
@ -5,7 +5,7 @@ use lemmy_api_common::{
|
|||
get_local_user_view_from_jwt,
|
||||
person::{DeletePrivateMessage, PrivateMessageResponse},
|
||||
};
|
||||
use lemmy_apub::activities::private_message::{
|
||||
use lemmy_apub::protocol::activities::private_message::{
|
||||
delete::DeletePrivateMessage as DeletePrivateMessageApub,
|
||||
undo_delete::UndoDeletePrivateMessage,
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ use lemmy_api_common::{
|
|||
get_local_user_view_from_jwt,
|
||||
person::{EditPrivateMessage, PrivateMessageResponse},
|
||||
};
|
||||
use lemmy_apub::activities::{
|
||||
use lemmy_apub::protocol::activities::{
|
||||
private_message::create_or_update::CreateOrUpdatePrivateMessage,
|
||||
CreateOrUpdateType,
|
||||
};
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use activitystreams::{link::Mention, public, unparsed::Unparsed};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
use activitystreams::public;
|
||||
|
||||
use lemmy_api_common::{blocking, check_post_deleted_or_removed};
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType, ApubObject},
|
||||
traits::{ActivityHandler, ActorType, ApubObject},
|
||||
verify::verify_domains_match,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
|
@ -19,37 +17,18 @@ use crate::{
|
|||
activities::{
|
||||
check_community_deleted_or_removed,
|
||||
comment::{collect_non_local_mentions, get_notif_recipients},
|
||||
community::{
|
||||
announce::{AnnouncableActivities, GetCommunity},
|
||||
send_to_community,
|
||||
},
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
verify_person_in_community,
|
||||
CreateOrUpdateType,
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson},
|
||||
protocol::objects::note::Note,
|
||||
protocol::activities::{create_or_update::comment::CreateOrUpdateComment, CreateOrUpdateType},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateOrUpdateComment {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: Vec<Url>,
|
||||
object: Note,
|
||||
cc: Vec<Url>,
|
||||
#[serde(default)]
|
||||
tag: Vec<Mention>,
|
||||
#[serde(rename = "type")]
|
||||
kind: CreateOrUpdateType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl CreateOrUpdateComment {
|
||||
pub async fn send(
|
||||
comment: &ApubComment,
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{
|
||||
announce::{AnnouncableActivities, GetCommunity},
|
||||
get_community_from_moderators_url,
|
||||
send_to_community,
|
||||
},
|
||||
community::{announce::GetCommunity, get_community_from_moderators_url, send_to_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_add_remove_moderator_target,
|
||||
|
@ -12,15 +8,17 @@ use crate::{
|
|||
verify_mod_action,
|
||||
verify_person_in_community,
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
generate_moderators_url,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::community::add_mod::AddMod,
|
||||
};
|
||||
use activitystreams::{activity::kind::AddType, public, unparsed::Unparsed};
|
||||
use activitystreams::{activity::kind::AddType, public};
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
traits::{ActivityHandler, ActorType},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::community::{CommunityModerator, CommunityModeratorForm},
|
||||
|
@ -28,23 +26,6 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AddMod {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: Vec<Url>,
|
||||
object: ObjectId<ApubPerson>,
|
||||
target: Url,
|
||||
cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
kind: AddType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl AddMod {
|
||||
pub async fn send(
|
||||
|
|
|
@ -1,55 +1,27 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
comment::create_or_update::CreateOrUpdateComment,
|
||||
community::{
|
||||
add_mod::AddMod,
|
||||
block_user::BlockUserFromCommunity,
|
||||
list_community_follower_inboxes,
|
||||
remove_mod::RemoveMod,
|
||||
undo_block_user::UndoBlockUserFromCommunity,
|
||||
update::UpdateCommunity,
|
||||
},
|
||||
deletion::{delete::Delete, undo_delete::UndoDelete},
|
||||
community::list_community_follower_inboxes,
|
||||
generate_activity_id,
|
||||
post::create_or_update::CreateOrUpdatePost,
|
||||
send_lemmy_activity,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
voting::{undo_vote::UndoVote, vote::Vote},
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
http::is_activity_already_known,
|
||||
insert_activity,
|
||||
objects::community::ApubCommunity,
|
||||
protocol::activities::community::announce::AnnounceActivity,
|
||||
};
|
||||
use activitystreams::{activity::kind::AnnounceType, public, unparsed::Unparsed};
|
||||
use activitystreams::{activity::kind::AnnounceType, public};
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
verify::verify_urls_match,
|
||||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
|
||||
#[serde(untagged)]
|
||||
#[activity_handler(LemmyContext)]
|
||||
pub enum AnnouncableActivities {
|
||||
CreateOrUpdateComment(CreateOrUpdateComment),
|
||||
CreateOrUpdatePost(Box<CreateOrUpdatePost>),
|
||||
Vote(Vote),
|
||||
UndoVote(UndoVote),
|
||||
Delete(Delete),
|
||||
UndoDelete(UndoDelete),
|
||||
UpdateCommunity(Box<UpdateCommunity>),
|
||||
BlockUserFromCommunity(BlockUserFromCommunity),
|
||||
UndoBlockUserFromCommunity(UndoBlockUserFromCommunity),
|
||||
AddMod(AddMod),
|
||||
RemoveMod(RemoveMod),
|
||||
}
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
pub(crate) trait GetCommunity {
|
||||
async fn get_community(
|
||||
|
@ -59,46 +31,6 @@ pub(crate) trait GetCommunity {
|
|||
) -> Result<ApubCommunity, LemmyError>;
|
||||
}
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl GetCommunity for AnnouncableActivities {
|
||||
async fn get_community(
|
||||
&self,
|
||||
context: &LemmyContext,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<ApubCommunity, LemmyError> {
|
||||
use AnnouncableActivities::*;
|
||||
let community = match self {
|
||||
CreateOrUpdateComment(a) => a.get_community(context, request_counter).await?,
|
||||
CreateOrUpdatePost(a) => a.get_community(context, request_counter).await?,
|
||||
Vote(a) => a.get_community(context, request_counter).await?,
|
||||
UndoVote(a) => a.get_community(context, request_counter).await?,
|
||||
Delete(a) => a.get_community(context, request_counter).await?,
|
||||
UndoDelete(a) => a.get_community(context, request_counter).await?,
|
||||
UpdateCommunity(a) => a.get_community(context, request_counter).await?,
|
||||
BlockUserFromCommunity(a) => a.get_community(context, request_counter).await?,
|
||||
UndoBlockUserFromCommunity(a) => a.get_community(context, request_counter).await?,
|
||||
AddMod(a) => a.get_community(context, request_counter).await?,
|
||||
RemoveMod(a) => a.get_community(context, request_counter).await?,
|
||||
};
|
||||
verify_urls_match(self.actor(), &community.actor_id())?;
|
||||
Ok(community)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AnnounceActivity {
|
||||
actor: ObjectId<ApubCommunity>,
|
||||
to: Vec<Url>,
|
||||
object: AnnouncableActivities,
|
||||
cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
kind: AnnounceType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl AnnounceActivity {
|
||||
pub async fn send(
|
||||
object: AnnouncableActivities,
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{
|
||||
announce::{AnnouncableActivities, GetCommunity},
|
||||
send_to_community,
|
||||
},
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
verify_mod_action,
|
||||
verify_person_in_community,
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::community::block_user::BlockUserFromCommunity,
|
||||
};
|
||||
use activitystreams::{activity::kind::BlockType, public, unparsed::Unparsed};
|
||||
use activitystreams::{activity::kind::BlockType, public};
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
traits::{ActivityHandler, ActorType},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::community::{
|
||||
|
@ -30,23 +29,6 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BlockUserFromCommunity {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: Vec<Url>,
|
||||
pub(in crate::activities::community) object: ObjectId<ApubPerson>,
|
||||
cc: Vec<Url>,
|
||||
target: ObjectId<ApubCommunity>,
|
||||
#[serde(rename = "type")]
|
||||
kind: BlockType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl BlockUserFromCommunity {
|
||||
pub(in crate::activities::community) fn new(
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
use itertools::Itertools;
|
||||
use url::Url;
|
||||
|
||||
use lemmy_apub_lib::traits::ActorType;
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
|
||||
use crate::{
|
||||
activities::{
|
||||
community::announce::{AnnouncableActivities, AnnounceActivity},
|
||||
send_lemmy_activity,
|
||||
},
|
||||
activities::send_lemmy_activity,
|
||||
activity_lists::AnnouncableActivities,
|
||||
check_is_apub_id_valid,
|
||||
fetcher::object_id::ObjectId,
|
||||
insert_activity,
|
||||
objects::community::ApubCommunity,
|
||||
protocol::activities::community::announce::AnnounceActivity,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use lemmy_apub_lib::traits::ActorType;
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use url::Url;
|
||||
|
||||
pub mod add_mod;
|
||||
pub mod announce;
|
||||
pub mod block_user;
|
||||
pub mod remove_mod;
|
||||
pub mod report;
|
||||
pub mod undo_block_user;
|
||||
pub mod update;
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{
|
||||
announce::{AnnouncableActivities, GetCommunity},
|
||||
get_community_from_moderators_url,
|
||||
send_to_community,
|
||||
},
|
||||
community::{announce::GetCommunity, get_community_from_moderators_url, send_to_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_add_remove_moderator_target,
|
||||
|
@ -12,15 +8,17 @@ use crate::{
|
|||
verify_mod_action,
|
||||
verify_person_in_community,
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
generate_moderators_url,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::community::remove_mod::RemoveMod,
|
||||
};
|
||||
use activitystreams::{activity::kind::RemoveType, public, unparsed::Unparsed};
|
||||
use activitystreams::{activity::kind::RemoveType, public};
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
traits::{ActivityHandler, ActorType},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::community::{CommunityModerator, CommunityModeratorForm},
|
||||
|
@ -28,23 +26,6 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RemoveMod {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: Vec<Url>,
|
||||
pub(in crate::activities) object: ObjectId<ApubPerson>,
|
||||
cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
kind: RemoveType,
|
||||
pub(in crate::activities) target: Url,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl RemoveMod {
|
||||
pub async fn send(
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
generate_activity_id,
|
||||
send_lemmy_activity,
|
||||
verify_activity,
|
||||
verify_person_in_community,
|
||||
},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
PostOrComment,
|
||||
};
|
||||
use activitystreams::{activity::kind::FlagType, unparsed::Unparsed};
|
||||
use activitystreams::activity::kind::FlagType;
|
||||
|
||||
use lemmy_api_common::{blocking, comment::CommentReportResponse, post::PostReportResponse};
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
traits::{ActivityHandler, ActorType},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
|
@ -25,22 +15,19 @@ use lemmy_db_schema::{
|
|||
use lemmy_db_views::{comment_report_view::CommentReportView, post_report_view::PostReportView};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Report {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: [ObjectId<ApubCommunity>; 1],
|
||||
object: ObjectId<PostOrComment>,
|
||||
summary: String,
|
||||
#[serde(rename = "type")]
|
||||
kind: FlagType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
use crate::{
|
||||
activities::{
|
||||
generate_activity_id,
|
||||
send_lemmy_activity,
|
||||
verify_activity,
|
||||
verify_person_in_community,
|
||||
},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::community::report::Report,
|
||||
PostOrComment,
|
||||
};
|
||||
|
||||
impl Report {
|
||||
pub async fn send(
|
|
@ -1,24 +1,25 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{
|
||||
announce::{AnnouncableActivities, GetCommunity},
|
||||
block_user::BlockUserFromCommunity,
|
||||
send_to_community,
|
||||
},
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
verify_mod_action,
|
||||
verify_person_in_community,
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::community::{
|
||||
block_user::BlockUserFromCommunity,
|
||||
undo_block_user::UndoBlockUserFromCommunity,
|
||||
},
|
||||
};
|
||||
use activitystreams::{activity::kind::UndoType, public, unparsed::Unparsed};
|
||||
use activitystreams::{activity::kind::UndoType, public};
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
traits::{ActivityHandler, ActorType},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::community::{CommunityPersonBan, CommunityPersonBanForm},
|
||||
|
@ -26,22 +27,6 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoBlockUserFromCommunity {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: Vec<Url>,
|
||||
object: BlockUserFromCommunity,
|
||||
cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
kind: UndoType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl UndoBlockUserFromCommunity {
|
||||
pub async fn send(
|
||||
|
|
|
@ -1,11 +1,22 @@
|
|||
use activitystreams::{activity::kind::UpdateType, public, unparsed::Unparsed};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
verify_mod_action,
|
||||
verify_person_in_community,
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::{activities::community::update::UpdateCommunity, objects::group::Group},
|
||||
};
|
||||
use activitystreams::{activity::kind::UpdateType, public};
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType, ApubObject},
|
||||
traits::{ActivityHandler, ActorType, ApubObject},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::community::{Community, CommunityForm},
|
||||
|
@ -14,40 +25,6 @@ use lemmy_db_schema::{
|
|||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud};
|
||||
|
||||
use crate::{
|
||||
activities::{
|
||||
community::{
|
||||
announce::{AnnouncableActivities, GetCommunity},
|
||||
send_to_community,
|
||||
},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
verify_mod_action,
|
||||
verify_person_in_community,
|
||||
},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::objects::group::Group,
|
||||
};
|
||||
|
||||
/// This activity is received from a remote community mod, and updates the description or other
|
||||
/// fields of a local community.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdateCommunity {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: Vec<Url>,
|
||||
// TODO: would be nice to use a separate struct here, which only contains the fields updated here
|
||||
object: Group,
|
||||
cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
kind: UpdateType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl UpdateCommunity {
|
||||
pub async fn send(
|
||||
community: &ApubCommunity,
|
||||
|
|
|
@ -1,28 +1,11 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{
|
||||
announce::{AnnouncableActivities, GetCommunity},
|
||||
send_to_community,
|
||||
},
|
||||
deletion::{
|
||||
receive_delete_action,
|
||||
verify_delete_activity,
|
||||
DeletableObjects,
|
||||
WebsocketMessages,
|
||||
},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
};
|
||||
use activitystreams::{activity::kind::DeleteType, public, unparsed::Unparsed};
|
||||
use activitystreams::{activity::kind::DeleteType, public};
|
||||
use anyhow::anyhow;
|
||||
use url::Url;
|
||||
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
traits::{ActivityHandler, ActorType},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
|
@ -46,35 +29,25 @@ use lemmy_websocket::{
|
|||
LemmyContext,
|
||||
UserOperationCrud,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
use url::Url;
|
||||
|
||||
/// This is very confusing, because there are four distinct cases to handle:
|
||||
/// - user deletes their post
|
||||
/// - user deletes their comment
|
||||
/// - remote community mod deletes local community
|
||||
/// - remote community deletes itself (triggered by a mod)
|
||||
///
|
||||
/// TODO: we should probably change how community deletions work to simplify this. Probably by
|
||||
/// wrapping it in an announce just like other activities, instead of having the community send it.
|
||||
#[skip_serializing_none]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Delete {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: Vec<Url>,
|
||||
pub(in crate::activities::deletion) object: Url,
|
||||
pub(in crate::activities::deletion) cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
kind: DeleteType,
|
||||
/// If summary is present, this is a mod action (Remove in Lemmy terms). Otherwise, its a user
|
||||
/// deleting their own content.
|
||||
pub(in crate::activities::deletion) summary: Option<String>,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
deletion::{
|
||||
receive_delete_action,
|
||||
verify_delete_activity,
|
||||
DeletableObjects,
|
||||
WebsocketMessages,
|
||||
},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::deletion::delete::Delete,
|
||||
};
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl ActivityHandler for Delete {
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
deletion::{delete::Delete, undo_delete::UndoDelete},
|
||||
verify_mod_action,
|
||||
verify_person_in_community,
|
||||
},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson, post::ApubPost},
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
traits::{ActivityFields, ActorType, ApubObject},
|
||||
|
@ -19,7 +12,13 @@ use lemmy_websocket::{
|
|||
LemmyContext,
|
||||
UserOperationCrud,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
activities::{verify_mod_action, verify_person_in_community},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson, post::ApubPost},
|
||||
protocol::activities::deletion::{delete::Delete, undo_delete::UndoDelete},
|
||||
};
|
||||
|
||||
pub mod delete;
|
||||
pub mod undo_delete;
|
||||
|
|
|
@ -1,11 +1,24 @@
|
|||
use activitystreams::{activity::kind::UndoType, public};
|
||||
use anyhow::anyhow;
|
||||
use url::Url;
|
||||
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityHandler, ActorType},
|
||||
};
|
||||
use lemmy_db_schema::source::{comment::Comment, community::Community, post::Post};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::{
|
||||
send::{send_comment_ws_message_simple, send_community_ws_message, send_post_ws_message},
|
||||
LemmyContext,
|
||||
UserOperationCrud,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
activities::{
|
||||
community::{
|
||||
announce::{AnnouncableActivities, GetCommunity},
|
||||
send_to_community,
|
||||
},
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
deletion::{
|
||||
delete::Delete,
|
||||
receive_delete_action,
|
||||
verify_delete_activity,
|
||||
DeletableObjects,
|
||||
|
@ -15,39 +28,11 @@ use crate::{
|
|||
verify_activity,
|
||||
verify_is_public,
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::deletion::{delete::Delete, undo_delete::UndoDelete},
|
||||
};
|
||||
use activitystreams::{activity::kind::UndoType, public, unparsed::Unparsed};
|
||||
use anyhow::anyhow;
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
};
|
||||
use lemmy_db_schema::source::{comment::Comment, community::Community, post::Post};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::{
|
||||
send::{send_comment_ws_message_simple, send_community_ws_message, send_post_ws_message},
|
||||
LemmyContext,
|
||||
UserOperationCrud,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoDelete {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: Vec<Url>,
|
||||
object: Delete,
|
||||
cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
kind: UndoType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl ActivityHandler for UndoDelete {
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
following::follow::FollowCommunity,
|
||||
generate_activity_id,
|
||||
send_lemmy_activity,
|
||||
verify_activity,
|
||||
},
|
||||
activities::{generate_activity_id, send_lemmy_activity, verify_activity},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::following::{accept::AcceptFollowCommunity, follow::FollowCommunity},
|
||||
};
|
||||
use activitystreams::{activity::kind::AcceptType, unparsed::Unparsed};
|
||||
use activitystreams::activity::kind::AcceptType;
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
|
@ -18,21 +13,6 @@ use lemmy_apub_lib::{
|
|||
use lemmy_db_schema::{source::community::CommunityFollower, traits::Followable};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AcceptFollowCommunity {
|
||||
actor: ObjectId<ApubCommunity>,
|
||||
to: [ObjectId<ApubPerson>; 1],
|
||||
object: FollowCommunity,
|
||||
#[serde(rename = "type")]
|
||||
kind: AcceptType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl AcceptFollowCommunity {
|
||||
pub async fn send(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
following::accept::AcceptFollowCommunity,
|
||||
generate_activity_id,
|
||||
send_lemmy_activity,
|
||||
verify_activity,
|
||||
|
@ -9,12 +8,13 @@ use crate::{
|
|||
},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::following::{accept::AcceptFollowCommunity, follow::FollowCommunity},
|
||||
};
|
||||
use activitystreams::{activity::kind::FollowType, unparsed::Unparsed};
|
||||
use activitystreams::activity::kind::FollowType;
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
traits::{ActivityHandler, ActorType},
|
||||
verify::verify_urls_match,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
|
@ -23,21 +23,6 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FollowCommunity {
|
||||
pub(in crate::activities::following) actor: ObjectId<ApubPerson>,
|
||||
pub(in crate::activities::following) to: [ObjectId<ApubCommunity>; 1],
|
||||
pub(in crate::activities::following) object: ObjectId<ApubCommunity>,
|
||||
#[serde(rename = "type")]
|
||||
kind: FollowType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl FollowCommunity {
|
||||
pub(in crate::activities::following) fn new(
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
pub mod accept;
|
||||
pub mod follow;
|
||||
pub mod undo;
|
||||
pub mod undo_follow;
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
following::follow::FollowCommunity,
|
||||
generate_activity_id,
|
||||
send_lemmy_activity,
|
||||
verify_activity,
|
||||
verify_person,
|
||||
},
|
||||
activities::{generate_activity_id, send_lemmy_activity, verify_activity, verify_person},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::following::{follow::FollowCommunity, undo_follow::UndoFollowCommunity},
|
||||
};
|
||||
use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
|
||||
use activitystreams::activity::kind::UndoType;
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
|
@ -22,21 +17,6 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoFollowCommunity {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: [ObjectId<ApubCommunity>; 1],
|
||||
object: FollowCommunity,
|
||||
#[serde(rename = "type")]
|
||||
kind: UndoType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl UndoFollowCommunity {
|
||||
pub async fn send(
|
|
@ -22,8 +22,7 @@ use lemmy_db_views_actor::{
|
|||
use lemmy_utils::{settings::structs::Settings, LemmyError};
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum_macros::ToString;
|
||||
use serde::Serialize;
|
||||
use url::{ParseError, Url};
|
||||
use uuid::Uuid;
|
||||
|
||||
|
@ -33,15 +32,8 @@ pub mod deletion;
|
|||
pub mod following;
|
||||
pub mod post;
|
||||
pub mod private_message;
|
||||
pub mod report;
|
||||
pub mod voting;
|
||||
|
||||
#[derive(Clone, Debug, ToString, Deserialize, Serialize)]
|
||||
pub enum CreateOrUpdateType {
|
||||
Create,
|
||||
Update,
|
||||
}
|
||||
|
||||
/// Checks that the specified Url actually identifies a Person (by fetching it), and that the person
|
||||
/// doesn't have a site ban.
|
||||
async fn verify_person(
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use activitystreams::{public, unparsed::Unparsed};
|
||||
use activitystreams::public;
|
||||
use anyhow::anyhow;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
|
@ -16,36 +14,19 @@ use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCru
|
|||
use crate::{
|
||||
activities::{
|
||||
check_community_deleted_or_removed,
|
||||
community::{
|
||||
announce::{AnnouncableActivities, GetCommunity},
|
||||
send_to_community,
|
||||
},
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
verify_mod_action,
|
||||
verify_person_in_community,
|
||||
CreateOrUpdateType,
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
|
||||
protocol::objects::page::Page,
|
||||
protocol::activities::{create_or_update::post::CreateOrUpdatePost, CreateOrUpdateType},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateOrUpdatePost {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: Vec<Url>,
|
||||
object: Page,
|
||||
cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
kind: CreateOrUpdateType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl CreateOrUpdatePost {
|
||||
pub(crate) async fn new(
|
||||
post: &ApubPost,
|
||||
|
|
|
@ -1,40 +1,21 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
generate_activity_id,
|
||||
send_lemmy_activity,
|
||||
verify_activity,
|
||||
verify_person,
|
||||
CreateOrUpdateType,
|
||||
},
|
||||
activities::{generate_activity_id, send_lemmy_activity, verify_activity, verify_person},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{person::ApubPerson, private_message::ApubPrivateMessage},
|
||||
protocol::objects::chat_message::ChatMessage,
|
||||
protocol::activities::{
|
||||
private_message::create_or_update::CreateOrUpdatePrivateMessage,
|
||||
CreateOrUpdateType,
|
||||
},
|
||||
};
|
||||
use activitystreams::unparsed::Unparsed;
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType, ApubObject},
|
||||
traits::{ActivityHandler, ActorType, ApubObject},
|
||||
verify::verify_domains_match,
|
||||
};
|
||||
use lemmy_db_schema::{source::person::Person, traits::Crud};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateOrUpdatePrivateMessage {
|
||||
id: Url,
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: [ObjectId<ApubPerson>; 1],
|
||||
object: ChatMessage,
|
||||
#[serde(rename = "type")]
|
||||
kind: CreateOrUpdateType,
|
||||
#[serde(flatten)]
|
||||
pub unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl CreateOrUpdatePrivateMessage {
|
||||
pub async fn send(
|
||||
|
|
|
@ -2,12 +2,13 @@ use crate::{
|
|||
activities::{generate_activity_id, send_lemmy_activity, verify_activity, verify_person},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{person::ApubPerson, private_message::ApubPrivateMessage},
|
||||
protocol::activities::private_message::delete::DeletePrivateMessage,
|
||||
};
|
||||
use activitystreams::{activity::kind::DeleteType, unparsed::Unparsed};
|
||||
use activitystreams::activity::kind::DeleteType;
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
traits::{ActivityHandler, ActorType},
|
||||
verify::verify_domains_match,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
|
@ -16,21 +17,6 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DeletePrivateMessage {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: [ObjectId<ApubPerson>; 1],
|
||||
pub(in crate::activities::private_message) object: ObjectId<ApubPrivateMessage>,
|
||||
#[serde(rename = "type")]
|
||||
kind: DeleteType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl DeletePrivateMessage {
|
||||
pub(in crate::activities::private_message) fn new(
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
generate_activity_id,
|
||||
private_message::delete::DeletePrivateMessage,
|
||||
send_lemmy_activity,
|
||||
verify_activity,
|
||||
verify_person,
|
||||
},
|
||||
activities::{generate_activity_id, send_lemmy_activity, verify_activity, verify_person},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{person::ApubPerson, private_message::ApubPrivateMessage},
|
||||
protocol::activities::private_message::{
|
||||
delete::DeletePrivateMessage,
|
||||
undo_delete::UndoDeletePrivateMessage,
|
||||
},
|
||||
};
|
||||
use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
|
||||
use activitystreams::activity::kind::UndoType;
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
|
@ -22,21 +20,6 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoDeletePrivateMessage {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: [ObjectId<ApubPerson>; 1],
|
||||
object: DeletePrivateMessage,
|
||||
#[serde(rename = "type")]
|
||||
kind: UndoType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
|
||||
impl UndoDeletePrivateMessage {
|
||||
pub async fn send(
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
use crate::{
|
||||
activities::voting::vote::VoteType,
|
||||
objects::{comment::ApubComment, person::ApubPerson, post::ApubPost},
|
||||
};
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
|
@ -17,6 +13,11 @@ use lemmy_websocket::{
|
|||
UserOperation,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
objects::{comment::ApubComment, person::ApubPerson, post::ApubPost},
|
||||
protocol::activities::voting::vote::VoteType,
|
||||
};
|
||||
|
||||
pub mod undo_vote;
|
||||
pub mod vote;
|
||||
|
||||
|
|
|
@ -1,24 +1,7 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{
|
||||
announce::{AnnouncableActivities, GetCommunity},
|
||||
send_to_community,
|
||||
},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
verify_person_in_community,
|
||||
voting::{
|
||||
undo_vote_comment,
|
||||
undo_vote_post,
|
||||
vote::{Vote, VoteType},
|
||||
},
|
||||
},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
PostOrComment,
|
||||
};
|
||||
use activitystreams::{activity::kind::UndoType, public, unparsed::Unparsed};
|
||||
use std::ops::Deref;
|
||||
|
||||
use activitystreams::{activity::kind::UndoType, public};
|
||||
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
|
@ -28,23 +11,25 @@ use lemmy_apub_lib::{
|
|||
use lemmy_db_schema::{newtypes::CommunityId, source::community::Community, traits::Crud};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::ops::Deref;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoVote {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: Vec<Url>,
|
||||
object: Vote,
|
||||
cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
kind: UndoType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
verify_person_in_community,
|
||||
voting::{undo_vote_comment, undo_vote_post},
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::voting::{
|
||||
undo_vote::UndoVote,
|
||||
vote::{Vote, VoteType},
|
||||
},
|
||||
PostOrComment,
|
||||
};
|
||||
|
||||
impl UndoVote {
|
||||
pub async fn send(
|
||||
|
|
|
@ -1,25 +1,11 @@
|
|||
use crate::{
|
||||
activities::{
|
||||
community::{
|
||||
announce::{AnnouncableActivities, GetCommunity},
|
||||
send_to_community,
|
||||
},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
verify_person_in_community,
|
||||
voting::{vote_comment, vote_post},
|
||||
},
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
PostOrComment,
|
||||
};
|
||||
use activitystreams::{public, unparsed::Unparsed};
|
||||
use anyhow::anyhow;
|
||||
use std::ops::Deref;
|
||||
|
||||
use activitystreams::public;
|
||||
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
traits::{ActivityHandler, ActorType},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
newtypes::CommunityId,
|
||||
|
@ -28,51 +14,22 @@ use lemmy_db_schema::{
|
|||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{convert::TryFrom, ops::Deref};
|
||||
use strum_macros::ToString;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, ToString, Deserialize, Serialize)]
|
||||
pub enum VoteType {
|
||||
Like,
|
||||
Dislike,
|
||||
}
|
||||
|
||||
impl TryFrom<i16> for VoteType {
|
||||
type Error = LemmyError;
|
||||
|
||||
fn try_from(value: i16) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
1 => Ok(VoteType::Like),
|
||||
-1 => Ok(VoteType::Dislike),
|
||||
_ => Err(anyhow!("invalid vote value").into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&VoteType> for i16 {
|
||||
fn from(value: &VoteType) -> i16 {
|
||||
match value {
|
||||
VoteType::Like => 1,
|
||||
VoteType::Dislike => -1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Vote {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: Vec<Url>,
|
||||
pub(in crate::activities::voting) object: ObjectId<PostOrComment>,
|
||||
cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
pub(in crate::activities::voting) kind: VoteType,
|
||||
id: Url,
|
||||
#[serde(flatten)]
|
||||
unparsed: Unparsed,
|
||||
}
|
||||
use crate::{
|
||||
activities::{
|
||||
community::{announce::GetCommunity, send_to_community},
|
||||
generate_activity_id,
|
||||
verify_activity,
|
||||
verify_is_public,
|
||||
verify_person_in_community,
|
||||
voting::{vote_comment, vote_post},
|
||||
},
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::voting::vote::{Vote, VoteType},
|
||||
PostOrComment,
|
||||
};
|
||||
|
||||
impl Vote {
|
||||
pub(in crate::activities::voting) fn new(
|
||||
|
|
113
crates/apub/src/activity_lists.rs
Normal file
113
crates/apub/src/activity_lists.rs
Normal file
|
@ -0,0 +1,113 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use lemmy_apub_lib::{
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
verify::verify_urls_match,
|
||||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
|
||||
use crate::{
|
||||
activities::community::announce::GetCommunity,
|
||||
objects::community::ApubCommunity,
|
||||
protocol::activities::{
|
||||
community::{
|
||||
add_mod::AddMod,
|
||||
announce::AnnounceActivity,
|
||||
block_user::BlockUserFromCommunity,
|
||||
remove_mod::RemoveMod,
|
||||
report::Report,
|
||||
undo_block_user::UndoBlockUserFromCommunity,
|
||||
update::UpdateCommunity,
|
||||
},
|
||||
create_or_update::{comment::CreateOrUpdateComment, post::CreateOrUpdatePost},
|
||||
deletion::{delete::Delete, undo_delete::UndoDelete},
|
||||
following::{
|
||||
accept::AcceptFollowCommunity,
|
||||
follow::FollowCommunity,
|
||||
undo_follow::UndoFollowCommunity,
|
||||
},
|
||||
private_message::{
|
||||
create_or_update::CreateOrUpdatePrivateMessage,
|
||||
delete::DeletePrivateMessage,
|
||||
undo_delete::UndoDeletePrivateMessage,
|
||||
},
|
||||
voting::{undo_vote::UndoVote, vote::Vote},
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
|
||||
#[serde(untagged)]
|
||||
#[activity_handler(LemmyContext)]
|
||||
pub enum SharedInboxActivities {
|
||||
GroupInboxActivities(GroupInboxActivities),
|
||||
// Note, pm activities need to be at the end, otherwise comments will end up here. We can probably
|
||||
// avoid this problem by replacing createpm.object with our own struct, instead of NoteExt.
|
||||
PersonInboxActivities(PersonInboxActivities),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
|
||||
#[serde(untagged)]
|
||||
#[activity_handler(LemmyContext)]
|
||||
pub enum GroupInboxActivities {
|
||||
FollowCommunity(FollowCommunity),
|
||||
UndoFollowCommunity(UndoFollowCommunity),
|
||||
AnnouncableActivities(AnnouncableActivities),
|
||||
Report(Report),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
|
||||
#[serde(untagged)]
|
||||
#[activity_handler(LemmyContext)]
|
||||
pub enum PersonInboxActivities {
|
||||
AcceptFollowCommunity(AcceptFollowCommunity),
|
||||
/// Some activities can also be sent from user to user, eg a comment with mentions
|
||||
AnnouncableActivities(AnnouncableActivities),
|
||||
CreateOrUpdatePrivateMessage(CreateOrUpdatePrivateMessage),
|
||||
DeletePrivateMessage(DeletePrivateMessage),
|
||||
UndoDeletePrivateMessage(UndoDeletePrivateMessage),
|
||||
AnnounceActivity(Box<AnnounceActivity>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
|
||||
#[serde(untagged)]
|
||||
#[activity_handler(LemmyContext)]
|
||||
pub enum AnnouncableActivities {
|
||||
CreateOrUpdateComment(CreateOrUpdateComment),
|
||||
CreateOrUpdatePost(Box<CreateOrUpdatePost>),
|
||||
Vote(Vote),
|
||||
UndoVote(UndoVote),
|
||||
Delete(Delete),
|
||||
UndoDelete(UndoDelete),
|
||||
UpdateCommunity(Box<UpdateCommunity>),
|
||||
BlockUserFromCommunity(BlockUserFromCommunity),
|
||||
UndoBlockUserFromCommunity(UndoBlockUserFromCommunity),
|
||||
AddMod(AddMod),
|
||||
RemoveMod(RemoveMod),
|
||||
}
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl GetCommunity for AnnouncableActivities {
|
||||
async fn get_community(
|
||||
&self,
|
||||
context: &LemmyContext,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<ApubCommunity, LemmyError> {
|
||||
use AnnouncableActivities::*;
|
||||
let community = match self {
|
||||
CreateOrUpdateComment(a) => a.get_community(context, request_counter).await?,
|
||||
CreateOrUpdatePost(a) => a.get_community(context, request_counter).await?,
|
||||
Vote(a) => a.get_community(context, request_counter).await?,
|
||||
UndoVote(a) => a.get_community(context, request_counter).await?,
|
||||
Delete(a) => a.get_community(context, request_counter).await?,
|
||||
UndoDelete(a) => a.get_community(context, request_counter).await?,
|
||||
UpdateCommunity(a) => a.get_community(context, request_counter).await?,
|
||||
BlockUserFromCommunity(a) => a.get_community(context, request_counter).await?,
|
||||
UndoBlockUserFromCommunity(a) => a.get_community(context, request_counter).await?,
|
||||
AddMod(a) => a.get_community(context, request_counter).await?,
|
||||
RemoveMod(a) => a.get_community(context, request_counter).await?,
|
||||
};
|
||||
verify_urls_match(self.actor(), &community.actor_id())?;
|
||||
Ok(community)
|
||||
}
|
||||
}
|
|
@ -1,12 +1,7 @@
|
|||
use crate::{
|
||||
activities::{post::create_or_update::CreateOrUpdatePost, CreateOrUpdateType},
|
||||
collections::CommunityContext,
|
||||
generate_outbox_url,
|
||||
objects::{person::ApubPerson, post::ApubPost},
|
||||
protocol::collections::group_outbox::GroupOutbox,
|
||||
};
|
||||
use activitystreams::collection::kind::OrderedCollectionType;
|
||||
use chrono::NaiveDateTime;
|
||||
use url::Url;
|
||||
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
|
@ -18,7 +13,16 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
collections::CommunityContext,
|
||||
generate_outbox_url,
|
||||
objects::{person::ApubPerson, post::ApubPost},
|
||||
protocol::{
|
||||
activities::{create_or_update::post::CreateOrUpdatePost, CreateOrUpdateType},
|
||||
collections::group_outbox::GroupOutbox,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct ApubCommunityOutbox(Vec<ApubPost>);
|
||||
|
|
|
@ -1,23 +1,6 @@
|
|||
use actix_web::{body::Body, web, web::Payload, HttpRequest, HttpResponse};
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
traits::{ActivityFields, ActivityHandler, ActorType, ApubObject},
|
||||
verify::verify_domains_match,
|
||||
};
|
||||
use lemmy_db_schema::source::community::Community;
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
|
||||
use crate::{
|
||||
activities::{
|
||||
community::announce::{AnnouncableActivities, AnnounceActivity, GetCommunity},
|
||||
following::{follow::FollowCommunity, undo::UndoFollowCommunity},
|
||||
report::Report,
|
||||
verify_person_in_community,
|
||||
},
|
||||
activities::{community::announce::GetCommunity, verify_person_in_community},
|
||||
activity_lists::GroupInboxActivities,
|
||||
collections::{
|
||||
community_moderators::ApubCommunityModerators,
|
||||
community_outbox::ApubCommunityOutbox,
|
||||
|
@ -33,8 +16,22 @@ use crate::{
|
|||
receive_activity,
|
||||
},
|
||||
objects::community::ApubCommunity,
|
||||
protocol::collections::group_followers::CommunityFollowers,
|
||||
protocol::{
|
||||
activities::community::announce::AnnounceActivity,
|
||||
collections::group_followers::CommunityFollowers,
|
||||
},
|
||||
};
|
||||
use actix_web::{body::Body, web, web::Payload, HttpRequest, HttpResponse};
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
traits::{ActivityFields, ActorType, ApubObject},
|
||||
verify::verify_domains_match,
|
||||
};
|
||||
use lemmy_db_schema::source::community::Community;
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use log::info;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub(crate) struct CommunityQuery {
|
||||
|
@ -61,16 +58,6 @@ pub(crate) async fn get_apub_community_http(
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
|
||||
#[serde(untagged)]
|
||||
#[activity_handler(LemmyContext)]
|
||||
pub enum GroupInboxActivities {
|
||||
FollowCommunity(FollowCommunity),
|
||||
UndoFollowCommunity(UndoFollowCommunity),
|
||||
AnnouncableActivities(AnnouncableActivities),
|
||||
Report(Report),
|
||||
}
|
||||
|
||||
/// Handler for all incoming receive to community inboxes.
|
||||
pub async fn community_inbox(
|
||||
request: HttpRequest,
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use crate::{
|
||||
activity_lists::SharedInboxActivities,
|
||||
check_is_apub_id_valid,
|
||||
context::WithContext,
|
||||
fetcher::get_or_fetch_and_upsert_actor,
|
||||
http::{
|
||||
community::{receive_group_inbox, GroupInboxActivities},
|
||||
person::{receive_person_inbox, PersonInboxActivities},
|
||||
},
|
||||
http::{community::receive_group_inbox, person::receive_person_inbox},
|
||||
insert_activity,
|
||||
};
|
||||
use actix_web::{
|
||||
|
@ -39,16 +37,6 @@ mod person;
|
|||
mod post;
|
||||
pub mod routes;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
|
||||
#[serde(untagged)]
|
||||
#[activity_handler(LemmyContext)]
|
||||
pub enum SharedInboxActivities {
|
||||
GroupInboxActivities(GroupInboxActivities),
|
||||
// Note, pm activities need to be at the end, otherwise comments will end up here. We can probably
|
||||
// avoid this problem by replacing createpm.object with our own struct, instead of NoteExt.
|
||||
PersonInboxActivities(PersonInboxActivities),
|
||||
}
|
||||
|
||||
pub async fn shared_inbox(
|
||||
request: HttpRequest,
|
||||
payload: Payload,
|
||||
|
|
|
@ -1,23 +1,5 @@
|
|||
use actix_web::{body::Body, web, web::Payload, HttpRequest, HttpResponse};
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::traits::{ActivityFields, ActivityHandler, ApubObject};
|
||||
use lemmy_db_schema::source::person::Person;
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
|
||||
use crate::{
|
||||
activities::{
|
||||
community::announce::{AnnouncableActivities, AnnounceActivity},
|
||||
following::accept::AcceptFollowCommunity,
|
||||
private_message::{
|
||||
create_or_update::CreateOrUpdatePrivateMessage,
|
||||
delete::DeletePrivateMessage,
|
||||
undo_delete::UndoDeletePrivateMessage,
|
||||
},
|
||||
},
|
||||
activity_lists::PersonInboxActivities,
|
||||
context::WithContext,
|
||||
http::{
|
||||
create_apub_response,
|
||||
|
@ -28,6 +10,14 @@ use crate::{
|
|||
objects::person::ApubPerson,
|
||||
protocol::collections::person_outbox::UserOutbox,
|
||||
};
|
||||
use actix_web::{body::Body, web, web::Payload, HttpRequest, HttpResponse};
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::traits::ApubObject;
|
||||
use lemmy_db_schema::source::person::Person;
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
use log::info;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct PersonQuery {
|
||||
|
@ -56,19 +46,6 @@ pub(crate) async fn get_apub_person_http(
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
|
||||
#[serde(untagged)]
|
||||
#[activity_handler(LemmyContext)]
|
||||
pub enum PersonInboxActivities {
|
||||
AcceptFollowCommunity(AcceptFollowCommunity),
|
||||
/// Some activities can also be sent from user to user, eg a comment with mentions
|
||||
AnnouncableActivities(AnnouncableActivities),
|
||||
CreateOrUpdatePrivateMessage(CreateOrUpdatePrivateMessage),
|
||||
DeletePrivateMessage(DeletePrivateMessage),
|
||||
UndoDeletePrivateMessage(UndoDeletePrivateMessage),
|
||||
AnnounceActivity(Box<AnnounceActivity>),
|
||||
}
|
||||
|
||||
pub async fn person_inbox(
|
||||
request: HttpRequest,
|
||||
payload: Payload,
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
pub mod activities;
|
||||
pub(crate) mod activity_lists;
|
||||
pub(crate) mod collections;
|
||||
mod context;
|
||||
pub mod fetcher;
|
||||
pub mod http;
|
||||
pub mod migrations;
|
||||
pub mod objects;
|
||||
pub(crate) mod protocol;
|
||||
pub mod protocol;
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
|
20
crates/apub/src/protocol/activities/community/add_mod.rs
Normal file
20
crates/apub/src/protocol/activities/community/add_mod.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use crate::{fetcher::object_id::ObjectId, objects::person::ApubPerson};
|
||||
use activitystreams::{activity::kind::AddType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AddMod {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
pub(crate) object: ObjectId<ApubPerson>,
|
||||
pub(crate) target: Url,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: AddType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
23
crates/apub/src/protocol/activities/community/announce.rs
Normal file
23
crates/apub/src/protocol/activities/community/announce.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use crate::{
|
||||
activity_lists::AnnouncableActivities,
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::community::ApubCommunity,
|
||||
};
|
||||
use activitystreams::{activity::kind::AnnounceType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AnnounceActivity {
|
||||
pub(crate) actor: ObjectId<ApubCommunity>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
pub(crate) object: AnnouncableActivities,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: AnnounceType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
23
crates/apub/src/protocol/activities/community/block_user.rs
Normal file
23
crates/apub/src/protocol/activities/community/block_user.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
};
|
||||
use activitystreams::{activity::kind::BlockType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BlockUserFromCommunity {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
pub(crate) object: ObjectId<ApubPerson>,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
pub(crate) target: ObjectId<ApubCommunity>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: BlockType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
7
crates/apub/src/protocol/activities/community/mod.rs
Normal file
7
crates/apub/src/protocol/activities/community/mod.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
pub mod add_mod;
|
||||
pub mod announce;
|
||||
pub mod block_user;
|
||||
pub mod remove_mod;
|
||||
pub mod report;
|
||||
pub mod undo_block_user;
|
||||
pub mod update;
|
20
crates/apub/src/protocol/activities/community/remove_mod.rs
Normal file
20
crates/apub/src/protocol/activities/community/remove_mod.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use crate::{fetcher::object_id::ObjectId, objects::person::ApubPerson};
|
||||
use activitystreams::{activity::kind::RemoveType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RemoveMod {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
pub(crate) object: ObjectId<ApubPerson>,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: RemoveType,
|
||||
pub(crate) target: Url,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
22
crates/apub/src/protocol/activities/community/report.rs
Normal file
22
crates/apub/src/protocol/activities/community/report.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
use crate::{
|
||||
fetcher::{object_id::ObjectId, post_or_comment::PostOrComment},
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
};
|
||||
use activitystreams::{activity::kind::FlagType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Report {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: [ObjectId<ApubCommunity>; 1],
|
||||
pub(crate) object: ObjectId<PostOrComment>,
|
||||
pub(crate) summary: String,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: FlagType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::person::ApubPerson,
|
||||
protocol::activities::community::block_user::BlockUserFromCommunity,
|
||||
};
|
||||
use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoBlockUserFromCommunity {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
pub(crate) object: BlockUserFromCommunity,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: UndoType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
26
crates/apub/src/protocol/activities/community/update.rs
Normal file
26
crates/apub/src/protocol/activities/community/update.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::person::ApubPerson,
|
||||
protocol::objects::group::Group,
|
||||
};
|
||||
use activitystreams::{activity::kind::UpdateType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
/// This activity is received from a remote community mod, and updates the description or other
|
||||
/// fields of a local community.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdateCommunity {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
// TODO: would be nice to use a separate struct here, which only contains the fields updated here
|
||||
pub(crate) object: Group,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: UpdateType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::person::ApubPerson,
|
||||
protocol::{activities::CreateOrUpdateType, objects::note::Note},
|
||||
};
|
||||
use activitystreams::{link::Mention, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateOrUpdateComment {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
pub(crate) object: Note,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(default)]
|
||||
pub(crate) tag: Vec<Mention>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: CreateOrUpdateType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
pub mod comment;
|
||||
pub mod post;
|
23
crates/apub/src/protocol/activities/create_or_update/post.rs
Normal file
23
crates/apub/src/protocol/activities/create_or_update/post.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::person::ApubPerson,
|
||||
protocol::{activities::CreateOrUpdateType, objects::page::Page},
|
||||
};
|
||||
use activitystreams::unparsed::Unparsed;
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateOrUpdatePost {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
pub(crate) object: Page,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: CreateOrUpdateType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
24
crates/apub/src/protocol/activities/deletion/delete.rs
Normal file
24
crates/apub/src/protocol/activities/deletion/delete.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
use crate::{fetcher::object_id::ObjectId, objects::person::ApubPerson};
|
||||
use activitystreams::{activity::kind::DeleteType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
use url::Url;
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Delete {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
pub(crate) object: Url,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: DeleteType,
|
||||
/// If summary is present, this is a mod action (Remove in Lemmy terms). Otherwise, its a user
|
||||
/// deleting their own content.
|
||||
pub(crate) summary: Option<String>,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
2
crates/apub/src/protocol/activities/deletion/mod.rs
Normal file
2
crates/apub/src/protocol/activities/deletion/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
pub mod delete;
|
||||
pub mod undo_delete;
|
25
crates/apub/src/protocol/activities/deletion/undo_delete.rs
Normal file
25
crates/apub/src/protocol/activities/deletion/undo_delete.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
|
||||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::person::ApubPerson,
|
||||
protocol::activities::deletion::delete::Delete,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoDelete {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
pub(crate) object: Delete,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: UndoType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
22
crates/apub/src/protocol/activities/following/accept.rs
Normal file
22
crates/apub/src/protocol/activities/following/accept.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::following::follow::FollowCommunity,
|
||||
};
|
||||
use activitystreams::{activity::kind::AcceptType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AcceptFollowCommunity {
|
||||
pub(crate) actor: ObjectId<ApubCommunity>,
|
||||
pub(crate) to: [ObjectId<ApubPerson>; 1],
|
||||
pub(crate) object: FollowCommunity,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: AcceptType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
21
crates/apub/src/protocol/activities/following/follow.rs
Normal file
21
crates/apub/src/protocol/activities/following/follow.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
};
|
||||
use activitystreams::{activity::kind::FollowType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FollowCommunity {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: [ObjectId<ApubCommunity>; 1],
|
||||
pub(crate) object: ObjectId<ApubCommunity>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: FollowType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
3
crates/apub/src/protocol/activities/following/mod.rs
Normal file
3
crates/apub/src/protocol/activities/following/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub(crate) mod accept;
|
||||
pub mod follow;
|
||||
pub mod undo_follow;
|
22
crates/apub/src/protocol/activities/following/undo_follow.rs
Normal file
22
crates/apub/src/protocol/activities/following/undo_follow.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
protocol::activities::following::follow::FollowCommunity,
|
||||
};
|
||||
use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoFollowCommunity {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: [ObjectId<ApubCommunity>; 1],
|
||||
pub(crate) object: FollowCommunity,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: UndoType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
15
crates/apub/src/protocol/activities/mod.rs
Normal file
15
crates/apub/src/protocol/activities/mod.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use strum_macros::ToString;
|
||||
|
||||
pub mod community;
|
||||
pub mod create_or_update;
|
||||
pub mod deletion;
|
||||
pub mod following;
|
||||
pub mod private_message;
|
||||
pub mod voting;
|
||||
|
||||
#[derive(Clone, Debug, ToString, Deserialize, Serialize)]
|
||||
pub enum CreateOrUpdateType {
|
||||
Create,
|
||||
Update,
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::person::ApubPerson,
|
||||
protocol::{activities::CreateOrUpdateType, objects::chat_message::ChatMessage},
|
||||
};
|
||||
use activitystreams::unparsed::Unparsed;
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateOrUpdatePrivateMessage {
|
||||
pub(crate) id: Url,
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: [ObjectId<ApubPerson>; 1],
|
||||
pub(crate) object: ChatMessage,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: CreateOrUpdateType,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::{person::ApubPerson, private_message::ApubPrivateMessage},
|
||||
};
|
||||
use activitystreams::{activity::kind::DeleteType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DeletePrivateMessage {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: [ObjectId<ApubPerson>; 1],
|
||||
pub(crate) object: ObjectId<ApubPrivateMessage>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: DeleteType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
pub mod create_or_update;
|
||||
pub mod delete;
|
||||
pub mod undo_delete;
|
|
@ -0,0 +1,22 @@
|
|||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::person::ApubPerson,
|
||||
protocol::activities::private_message::delete::DeletePrivateMessage,
|
||||
};
|
||||
use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoDeletePrivateMessage {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: [ObjectId<ApubPerson>; 1],
|
||||
pub(crate) object: DeletePrivateMessage,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: UndoType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
2
crates/apub/src/protocol/activities/voting/mod.rs
Normal file
2
crates/apub/src/protocol/activities/voting/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
pub mod undo_vote;
|
||||
pub mod vote;
|
25
crates/apub/src/protocol/activities/voting/undo_vote.rs
Normal file
25
crates/apub/src/protocol/activities/voting/undo_vote.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
|
||||
use crate::{
|
||||
fetcher::object_id::ObjectId,
|
||||
objects::person::ApubPerson,
|
||||
protocol::activities::voting::vote::Vote,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoVote {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
pub(crate) object: Vote,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: UndoType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
53
crates/apub/src/protocol/activities/voting/vote.rs
Normal file
53
crates/apub/src/protocol/activities/voting/vote.rs
Normal file
|
@ -0,0 +1,53 @@
|
|||
use crate::{
|
||||
fetcher::{object_id::ObjectId, post_or_comment::PostOrComment},
|
||||
objects::person::ApubPerson,
|
||||
};
|
||||
use activitystreams::unparsed::Unparsed;
|
||||
use anyhow::anyhow;
|
||||
use lemmy_apub_lib::traits::ActivityFields;
|
||||
use lemmy_utils::LemmyError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::convert::TryFrom;
|
||||
use strum_macros::ToString;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Vote {
|
||||
pub(crate) actor: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
pub(crate) object: ObjectId<PostOrComment>,
|
||||
pub(crate) cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) kind: VoteType,
|
||||
pub(crate) id: Url,
|
||||
#[serde(flatten)]
|
||||
pub(crate) unparsed: Unparsed,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, ToString, Deserialize, Serialize)]
|
||||
pub enum VoteType {
|
||||
Like,
|
||||
Dislike,
|
||||
}
|
||||
|
||||
impl TryFrom<i16> for VoteType {
|
||||
type Error = LemmyError;
|
||||
|
||||
fn try_from(value: i16) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
1 => Ok(VoteType::Like),
|
||||
-1 => Ok(VoteType::Dislike),
|
||||
_ => Err(anyhow!("invalid vote value").into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&VoteType> for i16 {
|
||||
fn from(value: &VoteType) -> i16 {
|
||||
match value {
|
||||
VoteType::Like => 1,
|
||||
VoteType::Dislike => -1,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
use crate::activities::post::create_or_update::CreateOrUpdatePost;
|
||||
use crate::protocol::activities::create_or_update::post::CreateOrUpdatePost;
|
||||
use activitystreams::collection::kind::OrderedCollectionType;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
|
|
@ -4,6 +4,7 @@ use url::Url;
|
|||
|
||||
use lemmy_apub_lib::values::MediaTypeMarkdown;
|
||||
|
||||
pub mod activities;
|
||||
pub(crate) mod collections;
|
||||
pub(crate) mod objects;
|
||||
|
||||
|
|
Loading…
Reference in a new issue