Rewrite apub object test json to serve as nice examples

breaking-apub-changes
Felix Ableitner 2021-10-22 14:29:47 +02:00
parent e14e0c3cae
commit 88fa0dbada
11 changed files with 97 additions and 87 deletions

View File

@ -18,17 +18,17 @@
},
"https://w3id.org/security/v1"
],
"attributedTo": "https://lemmy.ml/u/nutomic",
"content": "While I very much get and respect the general sentiment, I think from the perspective of a Central European non-English person in a country with a significant number of, also non-English speaking Nazis, the current approach of filtering slurs based on an English regex is fatally flawed. You can happily use Lemmy to create a hostile far right community where everyone is easily able to use whatever hurtful slurs they want as long as they are not the few specifically blocked English ones. \n\nOn the other hand you create a situation where people feel the need to question the choice of software of their community because they read about censorship or whatever to be used in Lemmy and might stay away and move to other software even though the would maybe never be affected by the slur-filter as the number is not so large and the overlap with other languages not very big.\n\nSo I would argue that this specific implementation of a slur-filter just doesn't achieve what it aims to achieve and should be fundamentally rethought, maybe as configurable per instance.",
"id": "https://lemmy.ml/comment/38741",
"inReplyTo": "https://lemmy.ml/post/55143",
"id": "https://enterprise.lemmy.ml/comment/38741",
"type": "Note",
"attributedTo": "https://enterprise.lemmy.ml/u/picard",
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"inReplyTo": "https://enterprise.lemmy.ml/post/55143",
"content": "first comment!",
"mediaType": "text/html",
"published": "2021-03-01T13:42:43.966208+00:00",
"source": {
"content": "While I very much get and respect the general sentiment, I think from the perspective of a Central European non-English person in a country with a significant number of, also non-English speaking Nazis, the current approach of filtering slurs based on an English regex is fatally flawed. You can happily use Lemmy to create a hostile far right community where everyone is easily able to use whatever hurtful slurs they want as long as they are not the few specifically blocked English ones. \n\nOn the other hand you create a situation where people feel the need to question the choice of software of their community because they read about censorship or whatever to be used in Lemmy and might stay away and move to other software even though the would maybe never be affected by the slur-filter as the number is not so large and the overlap with other languages not very big.\n\nSo I would argue that this specific implementation of a slur-filter just doesn't achieve what it aims to achieve and should be fundamentally rethought, maybe as configurable per instance.",
"content": "first comment!",
"mediaType": "text/markdown"
},
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"type": "Note",
"published": "2021-03-01T13:42:43.966208+00:00",
"updated": "2021-03-01T13:43:03.955787+00:00"
}

View File

@ -18,32 +18,36 @@
},
"https://w3id.org/security/v1"
],
"summary": "<p>Lemmy Announcements</p>\n<hr />\n<p>Feel free to announce new communities here.</p>\n<p>Other than that, this is <em>reserved for admin use only</em>.</p>\n",
"endpoints": {
"sharedInbox": "https://lemmy.ml/inbox"
"id": "https://enterprise.lemmy.ml/c/tenforward",
"type": "Group",
"preferredUsername": "main",
"name": "Ten Forward",
"summary": "<p>Lounge and recreation facility</p>\n<hr />\n<p>Welcome to the <a href=\"https://memory-alpha.fandom.com/wiki/USS_Enterprise_(NCC-1701-D)\">Enterprise</a>!.</p>\n",
"source": {
"content": "Lounge and recreation facility\n\n---\n\nWelcome to the [Enterprise](https://memory-alpha.fandom.com/wiki/USS_Enterprise_(NCC-1701-D))!.",
"mediaType": "text/markdown"
},
"followers": "https://lemmy.ml/c/announcements/followers",
"sensitive": false,
"icon": {
"type": "Image",
"url": "https://lemmy.ml/pictrs/image/waqyZwLAy4.webp"
"url": "https://enterprise.lemmy.ml/pictrs/image/waqyZwLAy4.webp"
},
"id": "https://lemmy.ml/c/announcements",
"inbox": "https://lemmy.ml/c/announcements/inbox",
"moderators": "https://lemmy.ml/c/announcements/moderators",
"name": "Announcements",
"outbox": "https://lemmy.ml/c/announcements/outbox",
"preferredUsername": "announcements",
"image": {
"type": "Image",
"url": "https://enterprise.lemmy.ml/pictrs/image/Wt8zoMcCmE.jpg"
},
"inbox": "https://enterprise.lemmy.ml/c/tenforward/inbox",
"followers": "https://enterprise.lemmy.ml/c/tenforward/followers",
"moderators": "https://enterprise.lemmy.ml/c/tenforward/moderators",
"endpoints": {
"sharedInbox": "https://enterprise.lemmy.ml/inbox"
},
"outbox": "https://enterprise.lemmy.ml/c/tenforward/outbox",
"publicKey": {
"id": "https://lemmy.ml/c/announcements#main-key",
"owner": "https://lemmy.ml/c/announcements",
"id": "https://enterprise.lemmy.ml/c/tenforward#main-key",
"owner": "https://enterprise.lemmy.ml/c/tenforward",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzRjKTNtvDCmugplwEh+g\nx1bhKm6BHUZfXfpscgMMm7tXFswSDzUQirMgfkxa9ubfr1PDFKffA2vQ9x6CyuO/\n70xTafdOHyV1tSqzgKz0ZvFZ/VCOo6qy1mYWVkrtBm/fKzM+87MdkKYB/zI4VyEJ\nLfLQgjwxBAEYUH3CBG71U0gO0TwbimWNN0vqlfp0QfThNe1WYObF88ZVzMLgFbr7\nRHBItZjlZ/d8foPDidlIR3l2dJjy0EsD8F9JM340jtX7LXqFmU4j1AQKNHTDLnUF\nwYVhzuQGNJ504l5LZkFG54XfIFT7dx2QwuuM9bSnfPv/98RYrq1Si6tCkxEt1cVe\n4wIDAQAB\n-----END PUBLIC KEY-----\n"
},
"published": "2019-06-02T16:43:50.799554+00:00",
"sensitive": false,
"source": {
"content": "Lemmy Announcements\n\n---\n\nFeel free to announce new communities here.\n\nOther than that, this is *reserved for admin use only*.",
"mediaType": "text/markdown"
},
"type": "Group",
"updated": "2021-03-10T17:18:10.498868+00:00"
}

View File

@ -18,28 +18,33 @@
},
"https://w3id.org/security/v1"
],
"summary": "<p>Lemmy maintainer. Interested in politics, video games, and many other things.</p>\n",
"endpoints": {
"sharedInbox": "https://lemmy.ml/inbox"
"id": "https://enterprise.lemmy.ml/u/picard",
"type": "Person",
"preferredUsername": "picard",
"name": "Jean-Luc Picard",
"summary": "<p>Captain of the starship <strong>Enterprise</strong>.</p>\n",
"source": {
"content": "Captain of the starship **Enterprise**.",
"mediaType": "text/markdown"
},
"icon": {
"type": "Image",
"url": "https://lemmy.ml/pictrs/image/ed9ej7.jpg"
"url": "https://enterprise.lemmy.ml/pictrs/image/ed9ej7.jpg"
},
"id": "https://lemmy.ml/u/nutomic",
"inbox": "https://lemmy.ml/u/nutomic/inbox",
"outbox": "https://lemmy.ml/u/nutomic/outbox",
"preferredUsername": "nutomic",
"publicKey": {
"id": "https://lemmy.ml/u/nutomic#main-key",
"owner": "https://lemmy.ml/u/nutomic",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0lP99/s5Vv+XbPdkeqIJ\nwoD4GFnHmBnBHdEKChEUWfWj1TtioC/rGNoXFQeXQA3Amhy4nxSceiDnUgwkkuQY\nv0MtIW58NzgknEavtllxL+LSds5pg3gANaDIk8UiWTkqXTg0GnlJMpCK1Chen0l/\nszL6DEvUyTSuS5ZYDXFgewF89Pe7U0S15V5U2Harv7AgJYDyxmUL0D1pGuUCRqcE\nl5MTHJjrXeNnH1w2g8aly8YlO/Cr0L51rFg/lBF23vni7ZLv8HbmWh6YpaAf1R8h\nE45zKR7OHqymdjzrg1ITBwovefpwMkVgnJ+Wdr4HPnFlBSkXPoZeM11+Z8L0anzA\nXwIDAQAB\n-----END PUBLIC KEY-----\n"
"image": {
"type": "Image",
"url": "https://enterprise.lemmy.ml/pictrs/image/XenaYI5hTn.png"
},
"inbox": "https://enterprise.lemmy.ml/u/picard/inbox",
"outbox": "https://enterprise.lemmy.ml/u/picard/outbox",
"endpoints": {
"sharedInbox": "https://enterprise.lemmy.ml/inbox"
},
"published": "2020-01-17T01:38:22.348392+00:00",
"source": {
"content": "Lemmy maintainer. Interested in politics, video games, and many other things.",
"mediaType": "text/markdown"
},
"type": "Person",
"updated": "2021-08-13T00:11:15.941990+00:00"
"updated": "2021-08-13T00:11:15.941990+00:00",
"publicKey": {
"id": "https://enterprise.lemmy.ml/u/picard#main-key",
"owner": "https://enterprise.lemmy.ml/u/picard",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0lP99/s5Vv+XbPdkeqIJ\nwoD4GFnHmBnBHdEKChEUWfWj1TtioC/rGNoXFQeXQA3Amhy4nxSceiDnUgwkkuQY\nv0MtIW58NzgknEavtllxL+LSds5pg3gANaDIk8UiWTkqXTg0GnlJMpCK1Chen0l/\nszL6DEvUyTSuS5ZYDXFgewF89Pe7U0S15V5U2Harv7AgJYDyxmUL0D1pGuUCRqcE\nl5MTHJjrXeNnH1w2g8aly8YlO/Cr0L51rFg/lBF23vni7ZLv8HbmWh6YpaAf1R8h\nE45zKR7OHqymdjzrg1ITBwovefpwMkVgnJ+Wdr4HPnFlBSkXPoZeM11+Z8L0anzA\nXwIDAQAB\n-----END PUBLIC KEY-----\n"
}
}

View File

@ -18,22 +18,22 @@
},
"https://w3id.org/security/v1"
],
"attributedTo": "https://lemmy.ml/u/nutomic",
"commentsEnabled": true,
"content": "<p>Recently there have been some discussions about the political stances of the Lemmy developers and site admins. To clear up some misconceptions: Lemmy is run by a team of people with different ideologies, including anti-capitalist, communist, anarchist, and others. While @dessalines and I are communists, we take decisions collectively, and don't demand that anyone adopt our views or convert to our ideologies. We wouldn't devote so much time to building a federated site otherwise.</p>\n<p>What's important to us is that you follow the site rules and <a href=\"https://join.lemmy.ml/docs/en/code_of_conduct.html\">Code of Conduct</a>. Meaning primarily, no-bigotry, and being respectful towards others. As long as that is the case, we can get along perfectly fine.</p>\n<p>In general we are open for constructive feedback, so please contact any member of the admin team if you have an idea how to improve Lemmy.</p>\n<h2>Slur Filter</h2>\n<p>We also noticed a consistent criticism of the built-in slur filter in Lemmy. Not so much on lemmy.ml itself, but whenever Lemmy is recommended elsewhere, a few usual suspects keep bringing it up. To these people we say the following: we are using the slur filter as a tool to keep a friendly atmosphere, and prevent racists, sexists and other bigots from using Lemmy. Its existence alone has lead many of them to not make an account, or run an instance: a clear net positive.</p>\n<p>You can see for yourself the words which are blocked (content warning, <a href=\"https://github.com/LemmyNet/lemmy/blob/main/crates/utils/src/utils.rs#L10\">link here</a>). Note that it doesn't include any simple swear words, but only slurs which are used to insult and attack other people. If you want to use any of these words, then please stay on one of the many platforms that permit them. Lemmy is not for you, and we don't want you here.</p>\n<p>We are fully aware that the slur filter is not perfect. It is made for American English, and can give false positives in other languages or dialects. We are totally willing to fix such problems on a case by case basis, simply open an issue in our <a href=\"https://github.com/LemmyNet/lemmy/issues\">repo </a>with a description of the problem.</p>\n",
"id": "https://lemmy.ml/post/55143",
"mediaType": "text/html",
"name": "Statement on Politics of Lemmy.ml",
"published": "2021-02-26T12:35:34.292626+00:00",
"sensitive": false,
"source": {
"content": "Recently there have been some discussions about the political stances of the Lemmy developers and site admins. To clear up some misconceptions: Lemmy is run by a team of people with different ideologies, including anti-capitalist, communist, anarchist, and others. While @dessalines and I are communists, we take decisions collectively, and don't demand that anyone adopt our views or convert to our ideologies. We wouldn't devote so much time to building a federated site otherwise.\n\nWhat's important to us is that you follow the site rules and [Code of Conduct](https://join.lemmy.ml/docs/en/code_of_conduct.html). Meaning primarily, no-bigotry, and being respectful towards others. As long as that is the case, we can get along perfectly fine.\n\nIn general we are open for constructive feedback, so please contact any member of the admin team if you have an idea how to improve Lemmy. \n\n## Slur Filter\n\nWe also noticed a consistent criticism of the built-in slur filter in Lemmy. Not so much on lemmy.ml itself, but whenever Lemmy is recommended elsewhere, a few usual suspects keep bringing it up. To these people we say the following: we are using the slur filter as a tool to keep a friendly atmosphere, and prevent racists, sexists and other bigots from using Lemmy. Its existence alone has lead many of them to not make an account, or run an instance: a clear net positive.\n\nYou can see for yourself the words which are blocked (content warning, [link here](https://github.com/LemmyNet/lemmy/blob/main/crates/utils/src/utils.rs#L10)). Note that it doesn't include any simple swear words, but only slurs which are used to insult and attack other people. If you want to use any of these words, then please stay on one of the many platforms that permit them. Lemmy is not for you, and we don't want you here.\n\nWe are fully aware that the slur filter is not perfect. It is made for American English, and can give false positives in other languages or dialects. We are totally willing to fix such problems on a case by case basis, simply open an issue in our [repo ](https://github.com/LemmyNet/lemmy/issues)with a description of the problem.",
"mediaType": "text/markdown"
},
"stickied": true,
"id": "https://enterprise.lemmy.ml/post/55143",
"type": "Page",
"attributedTo": "https://enterprise.lemmy.ml/u/picard",
"to": [
"https://lemmy.ml/c/announcements",
"https://enterprise.lemmy.ml/c/tenforward",
"https://www.w3.org/ns/activitystreams#Public"
],
"type": "Page"
"name": "Post title",
"content": "<p>This is a post in the /c/tenforward community</p>\n",
"mediaType": "text/html",
"source": {
"content": "This is a post in the /c/tenforward community",
"mediaType": "text/markdown"
},
"sensitive": false,
"commentsEnabled": true,
"stickied": true,
"published": "2021-02-26T12:35:34.292626+00:00"
}

View File

@ -18,17 +18,17 @@
},
"https://w3id.org/security/v1"
],
"attributedTo": "https://lemmy.ml/u/nutomic",
"content": "test",
"id": "https://lemmy.ml/private_message/1621",
"mediaType": "text/html",
"published": "2021-10-21T10:13:14.597721+00:00",
"source": {
"content": "test",
"mediaType": "text/markdown"
},
"id": "https://enterprise.lemmy.ml/private_message/1621",
"type": "ChatMessage",
"attributedTo": "https://enterprise.lemmy.ml/u/picard",
"to": [
"https://queer.hacktivis.me/users/lanodan"
],
"type": "ChatMessage"
"content": "Hello hello, testing",
"mediaType": "text/html",
"source": {
"content": "Hello hello, testing",
"mediaType": "text/markdown"
},
"published": "2021-10-21T10:13:14.597721+00:00"
}

View File

@ -16,7 +16,7 @@
"context": "https://queer.hacktivis.me/contexts/34cba3d2-2f35-4169-aeff-56af9bfeb753",
"conversation": "https://queer.hacktivis.me/contexts/34cba3d2-2f35-4169-aeff-56af9bfeb753",
"id": "https://queer.hacktivis.me/objects/8d4973f4-53de-49cd-8c27-df160e16a9c2",
"inReplyTo": "https://lemmy.ml/post/55143",
"inReplyTo": "https://enterprise.lemmy.ml/post/55143",
"published": "2021-10-07T18:06:52.555500Z",
"sensitive": null,
"source": "@popolon@pleroma.popolon.org Have what?",

View File

@ -325,7 +325,7 @@ mod tests {
#[serial]
async fn test_fetch_lemmy_comment() {
let context = init_context();
let url = Url::parse("https://lemmy.ml/comment/38741").unwrap();
let url = Url::parse("https://enterprise.lemmy.ml/comment/38741").unwrap();
let data = prepare_comment_test(&url, &context).await;
let json = file_to_json_object("assets/lemmy-comment.json");
@ -335,7 +335,7 @@ mod tests {
.unwrap();
assert_eq!(comment.ap_id.clone().into_inner(), url);
assert_eq!(comment.content.len(), 1063);
assert_eq!(comment.content.len(), 14);
assert!(!comment.local);
assert_eq!(request_counter, 0);
@ -350,7 +350,7 @@ mod tests {
#[serial]
async fn test_fetch_pleroma_comment() {
let context = init_context();
let url = Url::parse("https://lemmy.ml/comment/38741").unwrap();
let url = Url::parse("https://enterprise.lemmy.ml/comment/38741").unwrap();
let data = prepare_comment_test(&url, &context).await;
let pleroma_url =

View File

@ -327,20 +327,21 @@ mod tests {
let mut json: Group = file_to_json_object("assets/lemmy-community.json");
let json_orig = json.clone();
// change these links so they dont fetch over the network
json.moderators = Some(Url::parse("https://lemmy.ml/c/announcements/not_moderators").unwrap());
json.outbox = Url::parse("https://lemmy.ml/c/announcements/not_outbox").unwrap();
json.moderators =
Some(Url::parse("https://enterprise.lemmy.ml/c/tenforward/not_moderators").unwrap());
json.outbox = Url::parse("https://enterprise.lemmy.ml/c/tenforward/not_outbox").unwrap();
let url = Url::parse("https://lemmy.ml/c/announcements").unwrap();
let url = Url::parse("https://enterprise.lemmy.ml/c/tenforward").unwrap();
let mut request_counter = 0;
let community = ApubCommunity::from_apub(&json, &context, &url, &mut request_counter)
.await
.unwrap();
assert_eq!(community.actor_id.clone().into_inner(), url);
assert_eq!(community.title, "Announcements");
assert_eq!(community.title, "Ten Forward");
assert!(community.public_key.is_some());
assert!(!community.local);
assert_eq!(community.description.as_ref().unwrap().len(), 126);
assert_eq!(community.description.as_ref().unwrap().len(), 132);
// this makes two requests to the (intentionally) broken outbox/moderators collections
assert_eq!(request_counter, 2);

View File

@ -278,17 +278,17 @@ mod tests {
async fn test_fetch_lemmy_person() {
let context = init_context();
let json = file_to_json_object("assets/lemmy-person.json");
let url = Url::parse("https://lemmy.ml/u/nutomic").unwrap();
let url = Url::parse("https://enterprise.lemmy.ml/u/picard").unwrap();
let mut request_counter = 0;
let person = ApubPerson::from_apub(&json, &context, &url, &mut request_counter)
.await
.unwrap();
assert_eq!(person.actor_id.clone().into_inner(), url);
assert_eq!(person.name, "nutomic");
assert_eq!(person.display_name, Some("Jean-Luc Picard".to_string()));
assert!(person.public_key.is_some());
assert!(!person.local);
assert_eq!(person.bio.as_ref().unwrap().len(), 77);
assert_eq!(person.bio.as_ref().unwrap().len(), 39);
assert_eq!(request_counter, 0);
let to_apub = person.to_apub(context.pool()).await.unwrap();

View File

@ -292,7 +292,7 @@ mod tests {
#[serial]
async fn test_fetch_lemmy_post() {
let context = init_context();
let url = Url::parse("https://lemmy.ml/post/55143").unwrap();
let url = Url::parse("https://enterprise.lemmy.ml/post/55143").unwrap();
let community_json = file_to_json_object("assets/lemmy-community.json");
let community = ApubCommunity::from_apub(&community_json, &context, &url, &mut 0)
.await
@ -308,9 +308,9 @@ mod tests {
.unwrap();
assert_eq!(post.ap_id.clone().into_inner(), url);
assert_eq!(post.name, "Statement on Politics of Lemmy.ml");
assert_eq!(post.name, "Post title");
assert!(post.body.is_some());
assert_eq!(post.body.as_ref().unwrap().len(), 2144);
assert_eq!(post.body.as_ref().unwrap().len(), 45);
assert!(!post.locked);
assert!(post.stickied);
assert_eq!(request_counter, 0);

View File

@ -217,7 +217,7 @@ mod tests {
#[serial]
async fn test_fetch_lemmy_pm() {
let context = init_context();
let url = Url::parse("https://lemmy.ml/private_message/1621").unwrap();
let url = Url::parse("https://enterprise.lemmy.ml/private_message/1621").unwrap();
let lemmy_person = file_to_json_object("assets/lemmy-person.json");
let person1 = ApubPerson::from_apub(&lemmy_person, &context, &url, &mut 0)
.await
@ -234,7 +234,7 @@ mod tests {
.unwrap();
assert_eq!(pm.ap_id.clone().into_inner(), url);
assert_eq!(pm.content.len(), 4);
assert_eq!(pm.content.len(), 20);
assert_eq!(request_counter, 0);
let to_apub = pm.to_apub(context.pool()).await.unwrap();