mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-05-28 22:58:05 +00:00
dd0ba10b44
* Allow fetching person from Pleroma, including test case (ref #1461) * Added test case for parsing community from apub json - fixed a bug with objectid (de)serialization - fixed a bug with outbox fetching (ref #1582) * Added apub test for post * Ignore errors when reading community outbox (fixes #1582) * Dont fetch community outbox/moderators during tests * added test for lemmy comment * Added federation test for pleroma comment * Added html2md crate to parse comment html from pleroma (fixes #1461) * some fixes for update_apub_test_files.sh * Add tests for ToApub, private message, remove update script * Delete objects from db at the end of each test
74 lines
1.8 KiB
Rust
74 lines
1.8 KiB
Rust
use crate::{
|
|
activities::{
|
|
community::remove_mod::RemoveMod,
|
|
deletion::{undo_delete::UndoDelete, verify_delete_activity},
|
|
verify_activity,
|
|
},
|
|
fetcher::object_id::ObjectId,
|
|
migrations::PublicUrlMigration,
|
|
objects::{community::ApubCommunity, person::ApubPerson},
|
|
};
|
|
use activitystreams::{
|
|
activity::kind::UndoType,
|
|
base::AnyBase,
|
|
primitives::OneOrMany,
|
|
unparsed::Unparsed,
|
|
};
|
|
use lemmy_apub_lib::{
|
|
data::Data,
|
|
traits::{ActivityFields, ActivityHandler},
|
|
};
|
|
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 UndoRemovePostCommentOrCommunity {
|
|
actor: ObjectId<ApubPerson>,
|
|
to: PublicUrlMigration,
|
|
// Note, there is no such thing as Undo/Remove/Mod, so we ignore that
|
|
object: RemoveMod,
|
|
cc: [ObjectId<ApubCommunity>; 1],
|
|
#[serde(rename = "type")]
|
|
kind: UndoType,
|
|
id: Url,
|
|
#[serde(rename = "@context")]
|
|
context: OneOrMany<AnyBase>,
|
|
#[serde(flatten)]
|
|
unparsed: Unparsed,
|
|
}
|
|
|
|
#[async_trait::async_trait(?Send)]
|
|
impl ActivityHandler for UndoRemovePostCommentOrCommunity {
|
|
type DataType = LemmyContext;
|
|
async fn verify(
|
|
&self,
|
|
context: &Data<LemmyContext>,
|
|
request_counter: &mut i32,
|
|
) -> Result<(), LemmyError> {
|
|
verify_activity(self, &context.settings())?;
|
|
self.object.verify(context, request_counter).await?;
|
|
|
|
verify_delete_activity(
|
|
self.object.object.inner(),
|
|
self,
|
|
&self.cc[0],
|
|
true,
|
|
context,
|
|
request_counter,
|
|
)
|
|
.await?;
|
|
Ok(())
|
|
}
|
|
|
|
async fn receive(
|
|
self,
|
|
context: &Data<LemmyContext>,
|
|
_request_counter: &mut i32,
|
|
) -> Result<(), LemmyError> {
|
|
UndoDelete::receive_undo_remove_action(self.object.object.inner(), context).await
|
|
}
|
|
}
|