--- /dev/null
+{
+ "@context": [
+ "https://www.w3.org/ns/activitystreams",
+ "https://greenish.red/schemas/litepub-0.1.jsonld",
+ {
+ "@language": "und"
+ }
+ ],
+ "actor": "https://greenish.red/users/nutomic",
+ "cc": [
+ "https://greenish.red/users/nutomic/followers"
+ ],
+ "context": "https://greenish.red/contexts/f6244742-0526-4b84-ac4f-ceadf1fb4e56",
+ "context_id": 6336544,
+ "directMessage": false,
+ "id": "https://greenish.red/activities/db61d52b-9c35-486a-bf27-bbd4edc6c6a1",
+ "object": {
+ "actor": "https://greenish.red/users/nutomic",
+ "attachment": [],
+ "attributedTo": "https://greenish.red/users/nutomic",
+ "cc": [
+ "https://greenish.red/users/nutomic/followers"
+ ],
+ "content": "<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"ACimPLEXPDd7enu3cm\" href=\"https://enterprise.lemmy.ml/u/picard\" rel=\"ugc\">@<span>lanodan</span></a></span> test",
+ "context": "https://greenish.red/contexts/f6244742-0526-4b84-ac4f-ceadf1fb4e56",
+ "conversation": "https://greenish.red/contexts/f6244742-0526-4b84-ac4f-ceadf1fb4e56",
+ "id": "https://greenish.red/objects/1a522f2e-d5ab-454b-93d7-e58bc0650c2a",
+ "inReplyTo": "https://enterprise.lemmy.ml/post/55143",
+ "published": "2021-10-26T10:28:35.602455Z",
+ "sensitive": false,
+ "source": "@lanodan@ds9.lemmy.ml test",
+ "summary": "",
+ "tag": [
+ {
+ "href": "https://enterprise.lemmy.ml/u/picard",
+ "name": "@lanodan@ds9.lemmy.ml",
+ "type": "Mention"
+ }
+ ],
+ "to": [
+ "https://enterprise.lemmy.ml/u/picard",
+ "https://www.w3.org/ns/activitystreams#Public"
+ ],
+ "type": "Note"
+ },
+ "published": "2021-10-26T10:28:35.595650Z",
+ "to": [
+ "https://enterprise.lemmy.ml/u/picard",
+ "https://www.w3.org/ns/activitystreams#Public"
+ ],
+ "type": "Create"
+}
\ No newline at end of file
to: Vec<Url>,
object: Note,
cc: Vec<Url>,
+ #[serde(default)]
tag: Vec<Mention>,
#[serde(rename = "type")]
kind: CreateOrUpdateType,
Ok(())
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::objects::tests::file_to_json_object;
+ use serial_test::serial;
+
+ #[actix_rt::test]
+ #[serial]
+ async fn test_parse_pleroma_create_comment() {
+ let _: CreateOrUpdateComment = file_to_json_object("assets/pleroma-create-comment.json");
+ }
+}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Note {
+ /// Necessary to make this optional to make Pleroma Create/Note work.
+ /// TODO: change this so that context is not defined in the struct itself, but added in activity
+ /// queue and http handlers
#[serde(rename = "@context")]
- context: OneOrMany<AnyBase>,
+ context: Option<OneOrMany<AnyBase>>,
r#type: NoteType,
id: Url,
pub(crate) attributed_to: ObjectId<ApubPerson>,
};
let note = Note {
- context: lemmy_context(),
+ context: Some(lemmy_context()),
r#type: NoteType::Note,
id: self.ap_id.to_owned().into_inner(),
attributed_to: ObjectId::new(creator.actor_id),
}
#[cfg(test)]
-mod tests {
+pub(crate) mod tests {
use super::*;
use crate::objects::{
community::ApubCommunity,
use assert_json_diff::assert_json_include;
use serial_test::serial;
- async fn prepare_comment_test(
+ pub(crate) async fn prepare_comment_test(
url: &Url,
context: &LemmyContext,
) -> (ApubPerson, ApubCommunity, ApubPost) {
#[actix_rt::test]
#[serial]
- async fn test_parse_lemmy_comment() {
- // TODO: changed ObjectId::dereference() so that it always fetches if
- // last_refreshed_at() == None. But post doesnt store that and expects to never be refetched
+ pub(crate) async fn test_parse_lemmy_comment() {
let context = init_context();
let url = Url::parse("https://enterprise.lemmy.ml/comment/38741").unwrap();
let data = prepare_comment_test(&url, &context).await;
}
#[cfg(test)]
-mod tests {
+pub(crate) mod tests {
use actix::Actor;
use diesel::{
r2d2::{ConnectionManager, Pool},