2021-11-03 17:33:51 +00:00
|
|
|
use crate::{
|
|
|
|
activities::{
|
2021-11-15 21:37:19 +00:00
|
|
|
community::{announce::GetCommunity, send_activity_in_community},
|
2021-11-05 00:24:10 +00:00
|
|
|
deletion::{receive_delete_action, verify_delete_activity, DeletableObjects},
|
2021-11-03 17:33:51 +00:00
|
|
|
generate_activity_id,
|
|
|
|
verify_activity,
|
|
|
|
verify_is_public,
|
|
|
|
},
|
|
|
|
activity_lists::AnnouncableActivities,
|
|
|
|
objects::{community::ApubCommunity, person::ApubPerson},
|
|
|
|
protocol::activities::deletion::delete::Delete,
|
|
|
|
};
|
2021-11-19 17:47:06 +00:00
|
|
|
use activitystreams_kinds::{activity::DeleteType, public};
|
2021-07-17 16:20:44 +00:00
|
|
|
use lemmy_api_common::blocking;
|
2021-10-06 20:20:05 +00:00
|
|
|
use lemmy_apub_lib::{
|
|
|
|
data::Data,
|
2021-11-05 00:24:10 +00:00
|
|
|
object_id::ObjectId,
|
2021-10-29 10:32:42 +00:00
|
|
|
traits::{ActivityHandler, ActorType},
|
2021-10-06 20:20:05 +00:00
|
|
|
};
|
2021-10-16 13:33:38 +00:00
|
|
|
use lemmy_db_schema::{
|
|
|
|
source::{
|
|
|
|
comment::Comment,
|
|
|
|
community::Community,
|
|
|
|
moderator::{
|
|
|
|
ModRemoveComment,
|
|
|
|
ModRemoveCommentForm,
|
|
|
|
ModRemoveCommunity,
|
|
|
|
ModRemoveCommunityForm,
|
|
|
|
ModRemovePost,
|
|
|
|
ModRemovePostForm,
|
|
|
|
},
|
|
|
|
post::Post,
|
2021-08-17 18:04:58 +00:00
|
|
|
},
|
2021-10-16 13:33:38 +00:00
|
|
|
traits::Crud,
|
2021-08-17 18:04:58 +00:00
|
|
|
};
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
use lemmy_utils::LemmyError;
|
2021-08-17 18:04:58 +00:00
|
|
|
use lemmy_websocket::{
|
|
|
|
send::{send_comment_ws_message_simple, send_community_ws_message, send_post_ws_message},
|
|
|
|
LemmyContext,
|
|
|
|
UserOperationCrud,
|
|
|
|
};
|
2021-11-03 17:33:51 +00:00
|
|
|
use url::Url;
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
|
|
|
|
#[async_trait::async_trait(?Send)]
|
2021-08-17 18:04:58 +00:00
|
|
|
impl ActivityHandler for Delete {
|
2021-10-06 20:20:05 +00:00
|
|
|
type DataType = LemmyContext;
|
2021-12-06 14:54:47 +00:00
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
async fn verify(
|
|
|
|
&self,
|
2021-10-06 20:20:05 +00:00
|
|
|
context: &Data<LemmyContext>,
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
request_counter: &mut i32,
|
|
|
|
) -> Result<(), LemmyError> {
|
2021-11-16 00:58:15 +00:00
|
|
|
verify_is_public(&self.to, &[])?;
|
2021-11-03 17:33:51 +00:00
|
|
|
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
2021-10-28 12:47:56 +00:00
|
|
|
let community = self.get_community(context, request_counter).await?;
|
2021-08-17 18:04:58 +00:00
|
|
|
verify_delete_activity(
|
2021-11-16 00:58:15 +00:00
|
|
|
&self.object.id,
|
2021-11-03 17:33:51 +00:00
|
|
|
&self.actor,
|
2021-10-28 12:47:56 +00:00
|
|
|
&community,
|
2021-08-17 18:04:58 +00:00
|
|
|
self.summary.is_some(),
|
|
|
|
context,
|
|
|
|
request_counter,
|
|
|
|
)
|
|
|
|
.await?;
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[tracing::instrument(skip_all)]
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
async fn receive(
|
2021-08-12 12:48:09 +00:00
|
|
|
self,
|
2021-10-06 20:20:05 +00:00
|
|
|
context: &Data<LemmyContext>,
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
request_counter: &mut i32,
|
|
|
|
) -> Result<(), LemmyError> {
|
2021-08-17 18:04:58 +00:00
|
|
|
if let Some(reason) = self.summary {
|
|
|
|
// We set reason to empty string if it doesn't exist, to distinguish between delete and
|
|
|
|
// remove. Here we change it back to option, so we don't write it to db.
|
|
|
|
let reason = if reason.is_empty() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(reason)
|
|
|
|
};
|
2021-11-16 00:58:15 +00:00
|
|
|
receive_remove_action(
|
|
|
|
&self.actor,
|
|
|
|
&self.object.id,
|
|
|
|
reason,
|
|
|
|
context,
|
|
|
|
request_counter,
|
|
|
|
)
|
|
|
|
.await
|
2021-08-17 18:04:58 +00:00
|
|
|
} else {
|
2021-11-16 00:58:15 +00:00
|
|
|
receive_delete_action(&self.object.id, &self.actor, true, context, request_counter).await
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-17 18:04:58 +00:00
|
|
|
impl Delete {
|
2021-08-19 21:24:33 +00:00
|
|
|
pub(in crate::activities::deletion) fn new(
|
2021-10-18 21:36:44 +00:00
|
|
|
actor: &ApubPerson,
|
2021-11-16 00:58:15 +00:00
|
|
|
object: DeletableObjects,
|
2021-08-17 18:04:58 +00:00
|
|
|
summary: Option<String>,
|
2021-09-22 15:57:09 +00:00
|
|
|
context: &LemmyContext,
|
2021-08-19 21:24:33 +00:00
|
|
|
) -> Result<Delete, LemmyError> {
|
|
|
|
Ok(Delete {
|
2021-09-25 15:44:52 +00:00
|
|
|
actor: ObjectId::new(actor.actor_id()),
|
2021-10-25 17:22:34 +00:00
|
|
|
to: vec![public()],
|
2021-11-16 00:58:15 +00:00
|
|
|
object: object.to_tombstone()?,
|
2021-08-17 18:04:58 +00:00
|
|
|
kind: DeleteType::Delete,
|
|
|
|
summary,
|
2021-09-22 15:57:09 +00:00
|
|
|
id: generate_activity_id(
|
|
|
|
DeleteType::Delete,
|
|
|
|
&context.settings().get_protocol_and_hostname(),
|
|
|
|
)?,
|
2021-08-19 21:24:33 +00:00
|
|
|
unparsed: Default::default(),
|
|
|
|
})
|
|
|
|
}
|
2021-12-06 14:54:47 +00:00
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
2021-08-19 21:24:33 +00:00
|
|
|
pub(in crate::activities::deletion) async fn send(
|
2021-10-18 21:36:44 +00:00
|
|
|
actor: &ApubPerson,
|
|
|
|
community: &ApubCommunity,
|
2021-11-16 00:58:15 +00:00
|
|
|
object: DeletableObjects,
|
2021-08-19 21:24:33 +00:00
|
|
|
summary: Option<String>,
|
|
|
|
context: &LemmyContext,
|
|
|
|
) -> Result<(), LemmyError> {
|
2021-11-16 00:58:15 +00:00
|
|
|
let delete = Delete::new(actor, object, summary, context)?;
|
2021-08-19 21:24:33 +00:00
|
|
|
let delete_id = delete.id.clone();
|
2021-08-17 18:04:58 +00:00
|
|
|
|
|
|
|
let activity = AnnouncableActivities::Delete(delete);
|
2021-11-15 21:37:19 +00:00
|
|
|
send_activity_in_community(activity, &delete_id, actor, community, vec![], context).await
|
2021-08-17 18:04:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[tracing::instrument(skip_all)]
|
2021-08-17 18:04:58 +00:00
|
|
|
pub(in crate::activities) async fn receive_remove_action(
|
2021-10-18 21:36:44 +00:00
|
|
|
actor: &ObjectId<ApubPerson>,
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
object: &Url,
|
2021-08-17 18:04:58 +00:00
|
|
|
reason: Option<String>,
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
context: &LemmyContext,
|
|
|
|
request_counter: &mut i32,
|
2021-08-17 18:04:58 +00:00
|
|
|
) -> Result<(), LemmyError> {
|
2021-12-06 22:54:34 +00:00
|
|
|
let actor = actor
|
|
|
|
.dereference(context, context.client(), request_counter)
|
|
|
|
.await?;
|
2021-08-17 18:04:58 +00:00
|
|
|
use UserOperationCrud::*;
|
|
|
|
match DeletableObjects::read_from_db(object, context).await? {
|
|
|
|
DeletableObjects::Community(community) => {
|
|
|
|
if community.local {
|
2021-12-06 14:54:47 +00:00
|
|
|
return Err(LemmyError::from_message(
|
|
|
|
"Only local admin can remove community",
|
|
|
|
));
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
}
|
2021-08-17 18:04:58 +00:00
|
|
|
let form = ModRemoveCommunityForm {
|
|
|
|
mod_person_id: actor.id,
|
|
|
|
community_id: community.id,
|
|
|
|
removed: Some(true),
|
|
|
|
reason,
|
|
|
|
expires: None,
|
|
|
|
};
|
|
|
|
blocking(context.pool(), move |conn| {
|
|
|
|
ModRemoveCommunity::create(conn, &form)
|
|
|
|
})
|
|
|
|
.await??;
|
|
|
|
let deleted_community = blocking(context.pool(), move |conn| {
|
|
|
|
Community::update_removed(conn, community.id, true)
|
|
|
|
})
|
|
|
|
.await??;
|
|
|
|
|
|
|
|
send_community_ws_message(deleted_community.id, RemoveCommunity, None, None, context).await?;
|
|
|
|
}
|
|
|
|
DeletableObjects::Post(post) => {
|
|
|
|
let form = ModRemovePostForm {
|
|
|
|
mod_person_id: actor.id,
|
|
|
|
post_id: post.id,
|
|
|
|
removed: Some(true),
|
|
|
|
reason,
|
|
|
|
};
|
|
|
|
blocking(context.pool(), move |conn| {
|
|
|
|
ModRemovePost::create(conn, &form)
|
|
|
|
})
|
|
|
|
.await??;
|
|
|
|
let removed_post = blocking(context.pool(), move |conn| {
|
|
|
|
Post::update_removed(conn, post.id, true)
|
|
|
|
})
|
|
|
|
.await??;
|
|
|
|
|
|
|
|
send_post_ws_message(removed_post.id, RemovePost, None, None, context).await?;
|
|
|
|
}
|
|
|
|
DeletableObjects::Comment(comment) => {
|
|
|
|
let form = ModRemoveCommentForm {
|
|
|
|
mod_person_id: actor.id,
|
|
|
|
comment_id: comment.id,
|
|
|
|
removed: Some(true),
|
|
|
|
reason,
|
|
|
|
};
|
|
|
|
blocking(context.pool(), move |conn| {
|
|
|
|
ModRemoveComment::create(conn, &form)
|
|
|
|
})
|
|
|
|
.await??;
|
|
|
|
let removed_comment = blocking(context.pool(), move |conn| {
|
|
|
|
Comment::update_removed(conn, comment.id, true)
|
|
|
|
})
|
|
|
|
.await??;
|
|
|
|
|
|
|
|
send_comment_ws_message_simple(removed_comment.id, RemoveComment, context).await?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(())
|
Apub inbox rewrite (#1652)
* start to implement apub inbox routing lib
* got something that almost works
* it compiles!
* implemented some more
* move library code to separate crate (most of it)
* convert private message handlers
* convert all comment receivers (except undo comment)
* convert post receiver
* add verify trait
* convert community receivers
* add cc field for all activities which i forgot before
* convert inbox functions, add missing checks
* convert undo like/dislike receivers
* convert undo_delete and undo_remove receivers
* move block/unblock activities
* convert remaining activity receivers
* reimplement http signature verification and other checks
* also use actor type for routing, VerifyActivity and SendActivity traits
* cleanup and restructure apub_receive code
* wip: try to fix activity routing
* implement a (very bad) derive macro for activityhandler
* working activity routing!
* rework pm verify(), fix tests and confirm manually
also remove inbox username check which was broken
* rework following verify(), fix tests and test manually
* fix post/comment create/update, rework voting
* Rewrite remove/delete post/comment, fix tests, test manually
* Rework and fix (un)block user, announce, update post
* some code cleanup
* rework delete/remove activity receivers (still quite messy)
* rewrite, test and fix add/remove mod, update community handlers
* add docs for ActivityHandler derive macro
* dont try to compile macro comments
2021-07-17 16:08:46 +00:00
|
|
|
}
|
2021-10-28 11:46:48 +00:00
|
|
|
|
|
|
|
#[async_trait::async_trait(?Send)]
|
|
|
|
impl GetCommunity for Delete {
|
2021-12-06 14:54:47 +00:00
|
|
|
#[tracing::instrument(skip_all)]
|
2021-10-28 11:46:48 +00:00
|
|
|
async fn get_community(
|
|
|
|
&self,
|
|
|
|
context: &LemmyContext,
|
|
|
|
_request_counter: &mut i32,
|
|
|
|
) -> Result<ApubCommunity, LemmyError> {
|
2021-11-16 00:58:15 +00:00
|
|
|
let community_id = match DeletableObjects::read_from_db(&self.object.id, context).await? {
|
2021-10-28 11:46:48 +00:00
|
|
|
DeletableObjects::Community(c) => c.id,
|
|
|
|
DeletableObjects::Comment(c) => {
|
|
|
|
let post = blocking(context.pool(), move |conn| Post::read(conn, c.post_id)).await??;
|
|
|
|
post.community_id
|
|
|
|
}
|
|
|
|
DeletableObjects::Post(p) => p.community_id,
|
|
|
|
};
|
|
|
|
let community = blocking(context.pool(), move |conn| {
|
|
|
|
Community::read(conn, community_id)
|
|
|
|
})
|
|
|
|
.await??;
|
|
|
|
Ok(community.into())
|
|
|
|
}
|
|
|
|
}
|