mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 07:36:01 +00:00
Fix bug with Mastodon undo follow activities (#4364)
This commit is contained in:
parent
0d35c247f9
commit
9240a653c0
|
@ -125,7 +125,6 @@ impl ActivityHandler for BlockUser {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
match self.target.dereference(context).await? {
|
||||
SiteOrCommunity::Site(site) => {
|
||||
|
@ -149,6 +148,7 @@ impl ActivityHandler for BlockUser {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let expires = self.expires.map(Into::into);
|
||||
let mod_person = self.actor.dereference(context).await?;
|
||||
let blocked_person = self.object.dereference(context).await?;
|
||||
|
|
|
@ -89,7 +89,6 @@ impl ActivityHandler for UndoBlockUser {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_domains_match(self.actor.inner(), self.object.actor.inner())?;
|
||||
self.object.verify(context).await?;
|
||||
|
@ -98,6 +97,7 @@ impl ActivityHandler for UndoBlockUser {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let expires = self.object.expires.map(Into::into);
|
||||
let mod_person = self.actor.dereference(context).await?;
|
||||
let blocked_person = self.object.object.dereference(context).await?;
|
||||
|
|
|
@ -145,14 +145,14 @@ impl ActivityHandler for AnnounceActivity {
|
|||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
async fn verify(&self, _context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let object: AnnouncableActivities = self.object.object(context).await?.try_into()?;
|
||||
|
||||
// This is only for sending, not receiving so we reject it.
|
||||
|
|
|
@ -115,7 +115,6 @@ impl ActivityHandler for CollectionAdd {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
let community = self.community(context).await?;
|
||||
verify_person_in_community(&self.actor, &community, context).await?;
|
||||
|
@ -125,6 +124,7 @@ impl ActivityHandler for CollectionAdd {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let (community, collection_type) =
|
||||
Community::get_by_collection_url(&mut context.pool(), &self.target.into()).await?;
|
||||
match collection_type {
|
||||
|
|
|
@ -110,7 +110,6 @@ impl ActivityHandler for CollectionRemove {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
let community = self.community(context).await?;
|
||||
verify_person_in_community(&self.actor, &community, context).await?;
|
||||
|
@ -120,6 +119,7 @@ impl ActivityHandler for CollectionRemove {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let (community, collection_type) =
|
||||
Community::get_by_collection_url(&mut context.pool(), &self.target.into()).await?;
|
||||
match collection_type {
|
||||
|
|
|
@ -81,7 +81,6 @@ impl ActivityHandler for UndoLockPage {
|
|||
}
|
||||
|
||||
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
let community = self.community(context).await?;
|
||||
verify_person_in_community(&self.actor, &community, context).await?;
|
||||
|
@ -91,6 +90,7 @@ impl ActivityHandler for UndoLockPage {
|
|||
}
|
||||
|
||||
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let form = PostUpdateForm {
|
||||
locked: Some(false),
|
||||
..Default::default()
|
||||
|
|
|
@ -92,7 +92,6 @@ impl ActivityHandler for Report {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let community = self.community(context).await?;
|
||||
verify_person_in_community(&self.actor, &community, context).await?;
|
||||
Ok(())
|
||||
|
@ -100,6 +99,7 @@ impl ActivityHandler for Report {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let actor = self.actor.dereference(context).await?;
|
||||
let reason = self.reason()?;
|
||||
match self.object.dereference(context).await? {
|
||||
|
|
|
@ -72,7 +72,6 @@ impl ActivityHandler for UpdateCommunity {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
let community = self.community(context).await?;
|
||||
verify_person_in_community(&self.actor, &community, context).await?;
|
||||
|
@ -83,6 +82,7 @@ impl ActivityHandler for UpdateCommunity {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let community = self.community(context).await?;
|
||||
|
||||
let community_update_form = self.object.into_update_form();
|
||||
|
|
|
@ -115,7 +115,6 @@ impl ActivityHandler for CreateOrUpdateNote {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
let post = self.object.get_parents(context).await?.0;
|
||||
let community = self.community(context).await?;
|
||||
|
@ -131,6 +130,7 @@ impl ActivityHandler for CreateOrUpdateNote {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
// Need to do this check here instead of Note::from_json because we need the person who
|
||||
// send the activity, not the comment author.
|
||||
let existing_comment = self.object.id.dereference_local(context).await.ok();
|
||||
|
|
|
@ -105,7 +105,6 @@ impl ActivityHandler for CreateOrUpdatePage {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
let community = self.community(context).await?;
|
||||
verify_person_in_community(&self.actor, &community, context).await?;
|
||||
|
@ -140,6 +139,7 @@ impl ActivityHandler for CreateOrUpdatePage {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let post = ApubPost::from_json(self.object, context).await?;
|
||||
|
||||
// author likes their own post by default
|
||||
|
|
|
@ -58,7 +58,6 @@ impl ActivityHandler for CreateOrUpdateChatMessage {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_person(&self.actor, context).await?;
|
||||
verify_domains_match(self.actor.inner(), self.object.id.inner())?;
|
||||
verify_domains_match(self.to[0].inner(), self.object.to[0].inner())?;
|
||||
|
@ -68,6 +67,7 @@ impl ActivityHandler for CreateOrUpdateChatMessage {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
ApubPrivateMessage::from_json(self.object, context).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -43,13 +43,13 @@ impl ActivityHandler for Delete {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_delete_activity(self, self.summary.is_some(), context).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
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.
|
||||
|
|
|
@ -42,7 +42,6 @@ impl ActivityHandler for UndoDelete {
|
|||
}
|
||||
|
||||
async fn verify(&self, data: &Data<Self::DataType>) -> Result<(), Self::Error> {
|
||||
insert_received_activity(&self.id, data).await?;
|
||||
self.object.verify(data).await?;
|
||||
verify_delete_activity(&self.object, self.object.summary.is_some(), data).await?;
|
||||
Ok(())
|
||||
|
@ -50,6 +49,7 @@ impl ActivityHandler for UndoDelete {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
if self.object.summary.is_some() {
|
||||
UndoDelete::receive_undo_remove_action(
|
||||
&self.actor.dereference(context).await?,
|
||||
|
|
|
@ -53,7 +53,6 @@ impl ActivityHandler for AcceptFollow {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_urls_match(self.actor.inner(), self.object.object.inner())?;
|
||||
self.object.verify(context).await?;
|
||||
if let Some(to) = &self.to {
|
||||
|
@ -64,6 +63,7 @@ impl ActivityHandler for AcceptFollow {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let community = self.actor.dereference(context).await?;
|
||||
let person = self.object.actor.dereference(context).await?;
|
||||
// This will throw an error if no follow was requested
|
||||
|
|
|
@ -77,7 +77,6 @@ impl ActivityHandler for Follow {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_person(&self.actor, context).await?;
|
||||
let object = self.object.dereference(context).await?;
|
||||
if let UserOrCommunity::Community(c) = object {
|
||||
|
@ -91,6 +90,7 @@ impl ActivityHandler for Follow {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let actor = self.actor.dereference(context).await?;
|
||||
let object = self.object.dereference(context).await?;
|
||||
match object {
|
||||
|
|
|
@ -65,7 +65,6 @@ impl ActivityHandler for UndoFollow {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
verify_urls_match(self.actor.inner(), self.object.actor.inner())?;
|
||||
verify_person(&self.actor, context).await?;
|
||||
self.object.verify(context).await?;
|
||||
|
@ -77,6 +76,7 @@ impl ActivityHandler for UndoFollow {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let person = self.actor.dereference(context).await?;
|
||||
let object = self.object.object.dereference(context).await?;
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ impl ActivityHandler for UndoVote {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let community = self.community(context).await?;
|
||||
verify_person_in_community(&self.actor, &community, context).await?;
|
||||
verify_urls_match(self.actor.inner(), self.object.actor.inner())?;
|
||||
|
@ -67,6 +66,7 @@ impl ActivityHandler for UndoVote {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let actor = self.actor.dereference(context).await?;
|
||||
let object = self.object.object.dereference(context).await?;
|
||||
match object {
|
||||
|
|
|
@ -56,7 +56,6 @@ impl ActivityHandler for Vote {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let community = self.community(context).await?;
|
||||
verify_person_in_community(&self.actor, &community, context).await?;
|
||||
let enable_downvotes = LocalSite::read(&mut context.pool())
|
||||
|
@ -72,6 +71,7 @@ impl ActivityHandler for Vote {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
|
||||
insert_received_activity(&self.id, context).await?;
|
||||
let actor = self.actor.dereference(context).await?;
|
||||
let object = self.object.dereference(context).await?;
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit e2cc2912dac3f74959a934ad66ec833a04e847ae
|
||||
Subproject commit 2139975ef383077e4709a4f2cae42922fd63b860
|
Loading…
Reference in a new issue