verify_person_in_community,
},
activity_lists::AnnouncableActivities,
+ local_instance,
objects::{
comment::ApubComment,
community::ApubCommunity,
private_message::ApubPrivateMessage,
},
protocol::activities::deletion::{delete::Delete, undo_delete::UndoDelete},
+ ActorType,
+};
+use activitypub_federation::{
+ core::object_id::ObjectId,
+ traits::{Actor, ApubObject},
+ utils::verify_domains_match,
};
use activitystreams_kinds::public;
use lemmy_api_common::utils::blocking;
-use lemmy_apub_lib::{
- object_id::ObjectId,
- traits::{ActorType, ApubObject},
- verify::verify_domains_match,
-};
use lemmy_db_schema::{
source::{
- comment::Comment,
- community::Community,
+ comment::{Comment, CommentUpdateForm},
+ community::{Community, CommunityUpdateForm},
person::Person,
- post::Post,
- private_message::PrivateMessage,
+ post::{Post, PostUpdateForm},
+ private_message::{PrivateMessage, PrivateMessageUpdateForm},
},
traits::Crud,
};
-use lemmy_utils::LemmyError;
+use lemmy_utils::error::LemmyError;
use lemmy_websocket::{
send::{
send_comment_ws_message_simple,
deleted: bool,
context: &LemmyContext,
) -> Result<(), LemmyError> {
- let (id, activity) = if deleted {
+ let actor = ApubPerson::from(actor);
+ let activity = if deleted {
let delete = Delete::new(&actor, object, public(), Some(&community), reason, context)?;
- (delete.id.clone(), AnnouncableActivities::Delete(delete))
+ AnnouncableActivities::Delete(delete)
} else {
let undo = UndoDelete::new(&actor, object, public(), Some(&community), reason, context)?;
- (undo.id.clone(), AnnouncableActivities::UndoDelete(undo))
+ AnnouncableActivities::UndoDelete(undo)
};
- send_activity_in_community(
- activity,
- &id,
- &ApubPerson::from(actor),
- &community.into(),
- vec![],
- context,
- )
- .await
+ send_activity_in_community(activity, &actor, &community.into(), vec![], context).await
}
#[tracing::instrument(skip_all)]
.into();
let deletable = DeletableObjects::PrivateMessage(Box::new(pm.into()));
- let inbox = vec![recipient.shared_inbox_or_inbox_url()];
+ let inbox = vec![recipient.shared_inbox_or_inbox()];
if deleted {
let delete = Delete::new(actor, deletable, recipient.actor_id(), None, None, context)?;
- let id = delete.id.clone();
- send_lemmy_activity(context, &delete, &id, actor, inbox, true).await?;
+ send_lemmy_activity(context, delete, actor, inbox, true).await?;
} else {
let undo = UndoDelete::new(actor, deletable, recipient.actor_id(), None, None, context)?;
- let id = undo.id.clone();
- send_lemmy_activity(context, &undo, &id, actor, inbox, true).await?;
+ send_lemmy_activity(context, undo, actor, inbox, true).await?;
};
Ok(())
}
verify_mod_action(
&activity.actor,
activity.object.id(),
- &community,
+ community.id,
context,
request_counter,
)
) -> Result<(), LemmyError> {
verify_person_in_community(actor, community, context, request_counter).await?;
if is_mod_action {
- verify_mod_action(actor, object_id, community, context, request_counter).await?;
+ verify_mod_action(actor, object_id, community.id, context, request_counter).await?;
} else {
// domain of post ap_id and post.creator ap_id are identical, so we just check the former
verify_domains_match(actor.inner(), object_id)?;
DeletableObjects::Community(community) => {
if community.local {
let mod_: Person = actor
- .dereference(context, context.client(), request_counter)
+ .dereference(context, local_instance(context), request_counter)
.await?
.deref()
.clone();
}
let community = blocking(context.pool(), move |conn| {
- Community::update_deleted(conn, community.id, deleted)
+ Community::update(
+ conn,
+ community.id,
+ &CommunityUpdateForm::builder()
+ .deleted(Some(deleted))
+ .build(),
+ )
})
.await??;
send_community_ws_message(
DeletableObjects::Post(post) => {
if deleted != post.deleted {
let deleted_post = blocking(context.pool(), move |conn| {
- Post::update_deleted(conn, post.id, deleted)
+ Post::update(
+ conn,
+ post.id,
+ &PostUpdateForm::builder().deleted(Some(deleted)).build(),
+ )
})
.await??;
send_post_ws_message(
DeletableObjects::Comment(comment) => {
if deleted != comment.deleted {
let deleted_comment = blocking(context.pool(), move |conn| {
- Comment::update_deleted(conn, comment.id, deleted)
+ Comment::update(
+ conn,
+ comment.id,
+ &CommentUpdateForm::builder().deleted(Some(deleted)).build(),
+ )
})
.await??;
send_comment_ws_message_simple(
}
DeletableObjects::PrivateMessage(pm) => {
let deleted_private_message = blocking(context.pool(), move |conn| {
- PrivateMessage::update_deleted(conn, pm.id, deleted)
+ PrivateMessage::update(
+ conn,
+ pm.id,
+ &PrivateMessageUpdateForm::builder()
+ .deleted(Some(deleted))
+ .build(),
+ )
})
.await??;