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::{
)
.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)?;
},
voting::{undo_vote::UndoVote, vote::Vote},
},
- objects::{note::Note, page::Page},
+ objects::page::Page,
},
};
use lemmy_apub_lib::traits::ActivityHandler;
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)]
AddMod(a) => a.get_community(context, request_counter).await?,
RemoveMod(a) => a.get_community(context, request_counter).await?,
Page(_) => unimplemented!(),
- Note(_) => unimplemented!(),
};
Ok(community)
}
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,
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;
}
}
}
-
-// 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!()
- }
-}