mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 11:21:32 +00:00
Merge pull request #1914 from LemmyNet/dont-announce-note
Dont announce comments, edited posts to Pleroma/Mastodon followers
This commit is contained in:
commit
6d35508f08
4 changed files with 7 additions and 30 deletions
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
http::{is_activity_already_known, ActivityCommonFields},
|
http::{is_activity_already_known, ActivityCommonFields},
|
||||||
insert_activity,
|
insert_activity,
|
||||||
objects::community::ApubCommunity,
|
objects::community::ApubCommunity,
|
||||||
protocol::activities::community::announce::AnnounceActivity,
|
protocol::activities::{community::announce::AnnounceActivity, CreateOrUpdateType},
|
||||||
};
|
};
|
||||||
use activitystreams::{activity::kind::AnnounceType, public};
|
use activitystreams::{activity::kind::AnnounceType, public};
|
||||||
use lemmy_apub_lib::{
|
use lemmy_apub_lib::{
|
||||||
|
@ -61,13 +61,11 @@ impl AnnounceActivity {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Pleroma (and likely Mastodon) can't handle activities like Announce/Create/Page. So for
|
// Pleroma and 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
|
// compatibility, we also send Announce/Page so that they can follow Lemmy communities.
|
||||||
// Announce/Note (for new and updated posts/comments).
|
|
||||||
use AnnouncableActivities::*;
|
use AnnouncableActivities::*;
|
||||||
let object = match object {
|
let object = match object {
|
||||||
CreateOrUpdatePost(c) => Page(c.object),
|
CreateOrUpdatePost(c) if c.kind == CreateOrUpdateType::Create => Page(c.object),
|
||||||
CreateOrUpdateComment(c) => Note(c.object),
|
|
||||||
_ => return Ok(()),
|
_ => return Ok(()),
|
||||||
};
|
};
|
||||||
let announce_compat = AnnounceActivity::new(object, community, context)?;
|
let announce_compat = AnnounceActivity::new(object, community, context)?;
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
voting::{undo_vote::UndoVote, vote::Vote},
|
voting::{undo_vote::UndoVote, vote::Vote},
|
||||||
},
|
},
|
||||||
objects::{note::Note, page::Page},
|
objects::page::Page,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use lemmy_apub_lib::traits::ActivityHandler;
|
use lemmy_apub_lib::traits::ActivityHandler;
|
||||||
|
@ -84,8 +84,6 @@ pub enum AnnouncableActivities {
|
||||||
RemoveMod(RemoveMod),
|
RemoveMod(RemoveMod),
|
||||||
// For compatibility with Pleroma/Mastodon (send only)
|
// For compatibility with Pleroma/Mastodon (send only)
|
||||||
Page(Page),
|
Page(Page),
|
||||||
// For compatibility with Pleroma/Mastodon (send only)
|
|
||||||
Note(Note),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait(?Send)]
|
#[async_trait::async_trait(?Send)]
|
||||||
|
@ -109,7 +107,6 @@ impl GetCommunity for AnnouncableActivities {
|
||||||
AddMod(a) => a.get_community(context, request_counter).await?,
|
AddMod(a) => a.get_community(context, request_counter).await?,
|
||||||
RemoveMod(a) => a.get_community(context, request_counter).await?,
|
RemoveMod(a) => a.get_community(context, request_counter).await?,
|
||||||
Page(_) => unimplemented!(),
|
Page(_) => unimplemented!(),
|
||||||
Note(_) => unimplemented!(),
|
|
||||||
};
|
};
|
||||||
Ok(community)
|
Ok(community)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ pub mod following;
|
||||||
pub mod private_message;
|
pub mod private_message;
|
||||||
pub mod voting;
|
pub mod voting;
|
||||||
|
|
||||||
#[derive(Clone, Debug, ToString, Deserialize, Serialize)]
|
#[derive(Clone, Debug, ToString, Deserialize, Serialize, PartialEq)]
|
||||||
pub enum CreateOrUpdateType {
|
pub enum CreateOrUpdateType {
|
||||||
Create,
|
Create,
|
||||||
Update,
|
Update,
|
||||||
|
|
|
@ -4,15 +4,9 @@ use crate::{
|
||||||
protocol::Source,
|
protocol::Source,
|
||||||
};
|
};
|
||||||
use activitystreams::{link::Mention, object::kind::NoteType, unparsed::Unparsed};
|
use activitystreams::{link::Mention, object::kind::NoteType, unparsed::Unparsed};
|
||||||
use anyhow::anyhow;
|
|
||||||
use chrono::{DateTime, FixedOffset};
|
use chrono::{DateTime, FixedOffset};
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_apub_lib::{
|
use lemmy_apub_lib::{object_id::ObjectId, values::MediaTypeHtml};
|
||||||
data::Data,
|
|
||||||
object_id::ObjectId,
|
|
||||||
traits::ActivityHandler,
|
|
||||||
values::MediaTypeHtml,
|
|
||||||
};
|
|
||||||
use lemmy_db_schema::{newtypes::CommentId, source::post::Post, traits::Crud};
|
use lemmy_db_schema::{newtypes::CommentId, source::post::Post, traits::Crud};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
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