mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-10 06:54:12 +00:00
Dont announce comments, edited posts to Pleroma/Mastodon followers
This commit is contained in:
parent
8fc252ec55
commit
aeb34199f5
4 changed files with 7 additions and 30 deletions
|
@ -4,7 +4,7 @@ use crate::{
|
|||
http::{is_activity_already_known, ActivityCommonFields},
|
||||
insert_activity,
|
||||
objects::community::ApubCommunity,
|
||||
protocol::activities::community::announce::AnnounceActivity,
|
||||
protocol::activities::{community::announce::AnnounceActivity, CreateOrUpdateType},
|
||||
};
|
||||
use activitystreams::{activity::kind::AnnounceType, public};
|
||||
use lemmy_apub_lib::{
|
||||
|
@ -61,13 +61,11 @@ impl AnnounceActivity {
|
|||
)
|
||||
.await?;
|
||||
|
||||
// Pleroma (and likely Mastodon) can't handle activities like Announce/Create/Page. So for
|
||||
// compatibility to allow them to follow Lemmy communities, we also send Announce/Page and
|
||||
// Announce/Note (for new and updated posts/comments).
|
||||
// Pleroma and Mastodon can't handle activities like Announce/Create/Page. So for
|
||||
// compatibility, we also send Announce/Page so that they can follow Lemmy communities.
|
||||
use AnnouncableActivities::*;
|
||||
let object = match object {
|
||||
CreateOrUpdatePost(c) => Page(c.object),
|
||||
CreateOrUpdateComment(c) => Note(c.object),
|
||||
CreateOrUpdatePost(c) if c.kind == CreateOrUpdateType::Create => Page(c.object),
|
||||
_ => return Ok(()),
|
||||
};
|
||||
let announce_compat = AnnounceActivity::new(object, community, context)?;
|
||||
|
|
|
@ -26,7 +26,7 @@ use crate::{
|
|||
},
|
||||
voting::{undo_vote::UndoVote, vote::Vote},
|
||||
},
|
||||
objects::{note::Note, page::Page},
|
||||
objects::page::Page,
|
||||
},
|
||||
};
|
||||
use lemmy_apub_lib::traits::ActivityHandler;
|
||||
|
@ -84,8 +84,6 @@ pub enum AnnouncableActivities {
|
|||
RemoveMod(RemoveMod),
|
||||
// For compatibility with Pleroma/Mastodon (send only)
|
||||
Page(Page),
|
||||
// For compatibility with Pleroma/Mastodon (send only)
|
||||
Note(Note),
|
||||
}
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
|
@ -109,7 +107,6 @@ impl GetCommunity for AnnouncableActivities {
|
|||
AddMod(a) => a.get_community(context, request_counter).await?,
|
||||
RemoveMod(a) => a.get_community(context, request_counter).await?,
|
||||
Page(_) => unimplemented!(),
|
||||
Note(_) => unimplemented!(),
|
||||
};
|
||||
Ok(community)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ pub mod following;
|
|||
pub mod private_message;
|
||||
pub mod voting;
|
||||
|
||||
#[derive(Clone, Debug, ToString, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, ToString, Deserialize, Serialize, PartialEq)]
|
||||
pub enum CreateOrUpdateType {
|
||||
Create,
|
||||
Update,
|
||||
|
|
|
@ -4,15 +4,9 @@ use crate::{
|
|||
protocol::Source,
|
||||
};
|
||||
use activitystreams::{link::Mention, object::kind::NoteType, unparsed::Unparsed};
|
||||
use anyhow::anyhow;
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use lemmy_api_common::blocking;
|
||||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
object_id::ObjectId,
|
||||
traits::ActivityHandler,
|
||||
values::MediaTypeHtml,
|
||||
};
|
||||
use lemmy_apub_lib::{object_id::ObjectId, values::MediaTypeHtml};
|
||||
use lemmy_db_schema::{newtypes::CommentId, source::post::Post, traits::Crud};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
|
@ -89,15 +83,3 @@ impl Note {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For Pleroma/Mastodon compat. Unimplemented because its only used for sending.
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl ActivityHandler for Note {
|
||||
type DataType = LemmyContext;
|
||||
async fn verify(&self, _: &Data<Self::DataType>, _: &mut i32) -> Result<(), LemmyError> {
|
||||
Err(anyhow!("Announce/Page can only be sent, not received").into())
|
||||
}
|
||||
async fn receive(self, _: &Data<Self::DataType>, _: &mut i32) -> Result<(), LemmyError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue