mirror of https://github.com/LemmyNet/lemmy.git
Add tests for lotide federation, make lotide groups fetchable
parent
55bb68f6f9
commit
8a8f9c729a
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"publicKey": {
|
||||
"id": "https://narwhal.city//communities/12#main-key",
|
||||
"owner": "https://narwhal.city/communities/12",
|
||||
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtktBbjovDSQmjZo1SIGK\n1TP1FKuIj8JlFgY6iGrAA5IBUN8PPKRzvo0U0FDvF+7SsUx+yiY0JrU1KzWcJxRr\nCfTrjNzaKeMS4E6ZU9czf8D157JUJQtkgikObxwU84eY5K+jic1ZgGv2eX77E6f/\nBZFO8StdS73g8a1vxPEsJVBn/VEVdsD9fg3uvhwFN7UrUKoKGf+1h2PajeX1aPZb\ntD3ql3Xff2IZFZu6Euj80OezozQ6/AqZx+qW6HfjvSf30C8ZGYU1PSF6MczY+Sg6\n6nyPMfmbKykYgWqfRMZ/NKaldsIjN8nMRDCfHASt6+pNmZgWh9HvSaFiSFKIn3Xj\nXwIDAQAB\n-----END PUBLIC KEY-----\n",
|
||||
"signatureAlgorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
|
||||
},
|
||||
"featured": "https://narwhal.city/communities/12/featured",
|
||||
"inbox": "https://narwhal.city/communities/12/inbox",
|
||||
"outbox": "https://narwhal.city/communities/12/outbox",
|
||||
"followers": "https://narwhal.city/communities/12/followers",
|
||||
"preferredUsername": "Iotide",
|
||||
"summary": "This is for talking about lotide\r\n\r\n\r\nI accidentally called it iotide because I misread the text when I made it lol",
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
{
|
||||
"featured": {
|
||||
"@id": "toot:featured",
|
||||
"@type": "@id"
|
||||
},
|
||||
"toot": "http://joinmastodon.org/ns#"
|
||||
}
|
||||
],
|
||||
"id": "https://narwhal.city/communities/12",
|
||||
"type": "Group",
|
||||
"name": "Iotide"
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"source": {
|
||||
"mediaType": "text/markdown",
|
||||
"content": "ed: now featuring Bob Dylan and RNG"
|
||||
},
|
||||
"attributedTo": "https://narwhal.city/users/3",
|
||||
"content": "<p>ed: now featuring Bob Dylan and RNG</p>\n",
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"inReplyTo": "https://narwhal.city/posts/9",
|
||||
"to": "https://narwhal.city/users/1",
|
||||
"cc": [
|
||||
"https://www.w3.org/ns/activitystreams#Public",
|
||||
"https://narwhal.city/communities/4"
|
||||
],
|
||||
"id": "https://narwhal.city/comments/3",
|
||||
"type": "Note",
|
||||
"mediaType": "text/html",
|
||||
"published": "2020-12-31T06:47:24.470801+00:00"
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"publicKey": {
|
||||
"id": "https://narwhal.city//users/3#main-key",
|
||||
"owner": "https://narwhal.city/users/3",
|
||||
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvC+ZURasjlyX1o4FqMWB\npAppKWU2zPV7cUokKsnKo9m2PKw+53mmVUMQ66LtN80l/WCK/hy7r2lDKvpyt3YO\nnEsNcSCYLaYnTLDNkE2u14kx8jKOFiyRKKVKCNA32b+XvM+rLDmfaNOeBsB92mVR\nVmIz+WO+0FVPtg1MQMKWIoe6SgKW8SHpz/qVeggYNMKp/b2ai7Of0KTSbYIcqFR2\nT8g/6L5Mmjz4zKIn+a5GFmBNTMTCsJTxa5yOjPwefh/9SrukWt01N5KLrIpmApms\nRoJSsBWh0xo7N+v23PaFHEkaJ2zCtT5zkzITa8bUfHoIc3rM6Ipa1uFlnmrnUIZE\nUQIDAQAB\n-----END PUBLIC KEY-----\n",
|
||||
"signatureAlgorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
|
||||
},
|
||||
"inbox": "https://narwhal.city/users/3/inbox",
|
||||
"outbox": "https://narwhal.city/users/3/outbox",
|
||||
"preferredUsername": "57H",
|
||||
"endpoints": {
|
||||
"sharedInbox": "https://narwhal.city/inbox"
|
||||
},
|
||||
"summary": "",
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1"
|
||||
],
|
||||
"id": "https://narwhal.city/users/3",
|
||||
"type": "Person",
|
||||
"name": "57H"
|
||||
}
|
|
@ -103,9 +103,9 @@ impl ApubObject for ApubCommunity {
|
|||
inbox: self.inbox_url.clone().into(),
|
||||
outbox: ObjectId::new(generate_outbox_url(&self.actor_id)?),
|
||||
followers: self.followers_url.clone().into(),
|
||||
endpoints: Endpoints {
|
||||
shared_inbox: self.shared_inbox_url.clone().map(|s| s.into()),
|
||||
},
|
||||
endpoints: self.shared_inbox_url.clone().map(|s| Endpoints {
|
||||
shared_inbox: s.into(),
|
||||
}),
|
||||
public_key: self.get_public_key()?,
|
||||
published: Some(convert_datetime(self.published)),
|
||||
updated: self.updated.map(convert_datetime),
|
||||
|
|
|
@ -106,9 +106,9 @@ impl ApubObject for ApubPerson {
|
|||
matrix_user_id: self.matrix_user_id.clone(),
|
||||
published: Some(convert_datetime(self.published)),
|
||||
outbox: generate_outbox_url(&self.actor_id)?.into(),
|
||||
endpoints: Endpoints {
|
||||
shared_inbox: self.shared_inbox_url.clone().map(|s| s.into()),
|
||||
},
|
||||
endpoints: self.shared_inbox_url.clone().map(|s| Endpoints {
|
||||
shared_inbox: s.into(),
|
||||
}),
|
||||
public_key: self.get_public_key()?,
|
||||
updated: self.updated.map(convert_datetime),
|
||||
unparsed: Default::default(),
|
||||
|
@ -167,7 +167,7 @@ impl ApubObject for ApubPerson {
|
|||
public_key: person.public_key.public_key_pem,
|
||||
last_refreshed_at: Some(naive_now()),
|
||||
inbox_url: Some(person.inbox.into()),
|
||||
shared_inbox_url: Some(person.endpoints.shared_inbox.map(|s| s.into())),
|
||||
shared_inbox_url: Some(person.endpoints.map(|e| e.shared_inbox.into())),
|
||||
matrix_user_id: Some(person.matrix_user_id),
|
||||
};
|
||||
let person = blocking(context.pool(), move |conn| {
|
||||
|
|
|
@ -43,7 +43,7 @@ pub struct Group {
|
|||
pub(crate) inbox: Url,
|
||||
pub(crate) outbox: ObjectId<ApubCommunityOutbox>,
|
||||
pub(crate) followers: Url,
|
||||
pub(crate) endpoints: Endpoints,
|
||||
pub(crate) endpoints: Option<Endpoints>,
|
||||
pub(crate) public_key: PublicKey,
|
||||
pub(crate) published: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
||||
|
@ -87,7 +87,7 @@ impl Group {
|
|||
banner: Some(self.image.map(|i| i.url.into())),
|
||||
followers_url: Some(self.followers.into()),
|
||||
inbox_url: Some(self.inbox.into()),
|
||||
shared_inbox_url: Some(self.endpoints.shared_inbox.map(|s| s.into())),
|
||||
shared_inbox_url: Some(self.endpoints.map(|e| e.shared_inbox.into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@ pub(crate) mod tombstone;
|
|||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Endpoints {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub shared_inbox: Option<Url>,
|
||||
pub shared_inbox: Url,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -27,21 +26,37 @@ mod tests {
|
|||
};
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_parse_object() {
|
||||
async fn test_parse_object_lemmy() {
|
||||
test_parse_lemmy_item::<Person>("assets/lemmy/objects/person.json");
|
||||
test_parse_lemmy_item::<Group>("assets/lemmy/objects/group.json");
|
||||
test_parse_lemmy_item::<Page>("assets/lemmy/objects/page.json");
|
||||
test_parse_lemmy_item::<Note>("assets/lemmy/objects/note.json");
|
||||
test_parse_lemmy_item::<ChatMessage>("assets/lemmy/objects/chat_message.json");
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_parse_object_pleroma() {
|
||||
file_to_json_object::<WithContext<Person>>("assets/pleroma/objects/person.json");
|
||||
file_to_json_object::<WithContext<Note>>("assets/pleroma/objects/note.json");
|
||||
file_to_json_object::<WithContext<ChatMessage>>("assets/pleroma/objects/chat_message.json");
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_parse_object_smithereen() {
|
||||
file_to_json_object::<WithContext<Person>>("assets/smithereen/objects/person.json");
|
||||
file_to_json_object::<Note>("assets/smithereen/objects/note.json");
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_parse_object_mastodon() {
|
||||
file_to_json_object::<Person>("assets/mastodon/objects/person.json");
|
||||
file_to_json_object::<Note>("assets/mastodon/objects/note.json");
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_parse_object_lotide() {
|
||||
file_to_json_object::<WithContext<Group>>("assets/lotide/objects/group.json");
|
||||
file_to_json_object::<WithContext<Person>>("assets/lotide/objects/person.json");
|
||||
file_to_json_object::<WithContext<Note>>("assets/lotide/objects/note.json");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ pub struct Person {
|
|||
pub(crate) inbox: Url,
|
||||
/// mandatory field in activitypub, currently empty in lemmy
|
||||
pub(crate) outbox: Url,
|
||||
pub(crate) endpoints: Endpoints,
|
||||
pub(crate) endpoints: Option<Endpoints>,
|
||||
pub(crate) public_key: PublicKey,
|
||||
pub(crate) published: Option<DateTime<FixedOffset>>,
|
||||
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
||||
|
|
Loading…
Reference in New Issue