mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-26 22:40:21 +00:00
Merge pull request #1887 from LemmyNet/federate-smithereen
Add federation test cases for Smithereen and Mastodon
This commit is contained in:
commit
c03689ed4c
9 changed files with 385 additions and 9 deletions
55
crates/apub/assets/mastodon/activities/create_note.json
Normal file
55
crates/apub/assets/mastodon/activities/create_note.json
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
{
|
||||||
|
"id": "https://mastodon.madrid/users/felix/statuses/107224289116410645/activity",
|
||||||
|
"type": "Create",
|
||||||
|
"actor": "https://mastodon.madrid/users/felix",
|
||||||
|
"published": "2021-11-05T11:46:50Z",
|
||||||
|
"to": [
|
||||||
|
"https://mastodon.madrid/users/felix/followers"
|
||||||
|
],
|
||||||
|
"cc": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public",
|
||||||
|
"https://mamot.fr/users/retiolus"
|
||||||
|
],
|
||||||
|
"object": {
|
||||||
|
"id": "https://mastodon.madrid/users/felix/statuses/107224289116410645",
|
||||||
|
"type": "Note",
|
||||||
|
"summary": null,
|
||||||
|
"inReplyTo": "https://mamot.fr/users/retiolus/statuses/107224244380204526",
|
||||||
|
"published": "2021-11-05T11:46:50Z",
|
||||||
|
"url": "https://mastodon.madrid/@felix/107224289116410645",
|
||||||
|
"attributedTo": "https://mastodon.madrid/users/felix",
|
||||||
|
"to": [
|
||||||
|
"https://mastodon.madrid/users/felix/followers"
|
||||||
|
],
|
||||||
|
"cc": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public",
|
||||||
|
"https://mamot.fr/users/retiolus"
|
||||||
|
],
|
||||||
|
"sensitive": false,
|
||||||
|
"atomUri": "https://mastodon.madrid/users/felix/statuses/107224289116410645",
|
||||||
|
"inReplyToAtomUri": "https://mamot.fr/users/retiolus/statuses/107224244380204526",
|
||||||
|
"conversation": "tag:mamot.fr,2021-11-05:objectId=64635960:objectType=Conversation",
|
||||||
|
"content": "<p><span class=\"h-card\"><a href=\"https://mamot.fr/@retiolus\" class=\"u-url mention\">@<span>retiolus</span></a></span> i have never been disappointed by a thinkpad. if you want to save money, get a model from a few years ago, there isnt a huge difference anyway.</p>",
|
||||||
|
"contentMap": {
|
||||||
|
"en": "<p><span class=\"h-card\"><a href=\"https://mamot.fr/@retiolus\" class=\"u-url mention\">@<span>retiolus</span></a></span> i have neverbeendisappointed by a thinkpad. if you want to save money, get a model from a few years ago, there isnt a huge difference anyway.</p>"
|
||||||
|
},
|
||||||
|
"attachment": [],
|
||||||
|
"tag": [
|
||||||
|
{
|
||||||
|
"type": "Mention",
|
||||||
|
"href": "https://mamot.fr/users/retiolus",
|
||||||
|
"name": "@retiolus@mamot.fr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replies": {
|
||||||
|
"id": "https://mastodon.madrid/users/felix/statuses/107224289116410645/replies",
|
||||||
|
"type": "Collection",
|
||||||
|
"first": {
|
||||||
|
"type": "CollectionPage",
|
||||||
|
"next": "https://mastodon.madrid/users/felix/statuses/107224289116410645/replies?only_other_accounts=true&page=true",
|
||||||
|
"partOf": "https://mastodon.madrid/users/felix/statuses/107224289116410645/replies",
|
||||||
|
"items": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
crates/apub/assets/mastodon/objects/note.json
Normal file
42
crates/apub/assets/mastodon/objects/note.json
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"id": "https://mastodon.madrid/users/felix/statuses/107224289116410645",
|
||||||
|
"type": "Note",
|
||||||
|
"summary": null,
|
||||||
|
"inReplyTo": "https://mamot.fr/users/retiolus/statuses/107224244380204526",
|
||||||
|
"published": "2021-11-05T11:46:50Z",
|
||||||
|
"url": "https://mastodon.madrid/@felix/107224289116410645",
|
||||||
|
"attributedTo": "https://mastodon.madrid/users/felix",
|
||||||
|
"to": [
|
||||||
|
"https://mastodon.madrid/users/felix/followers"
|
||||||
|
],
|
||||||
|
"cc": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public",
|
||||||
|
"https://mamot.fr/users/retiolus"
|
||||||
|
],
|
||||||
|
"sensitive": false,
|
||||||
|
"atomUri": "https://mastodon.madrid/users/felix/statuses/107224289116410645",
|
||||||
|
"inReplyToAtomUri": "https://mamot.fr/users/retiolus/statuses/107224244380204526",
|
||||||
|
"conversation": "tag:mamot.fr,2021-11-05:objectId=64635960:objectType=Conversation",
|
||||||
|
"content": "<p><span class=\"h-card\"><a href=\"https://mamot.fr/@retiolus\" class=\"u-url mention\">@<span>retiolus</span></a></span> i have never been disappointed by a thinkpad. if you want to save money, get a model from a few years ago, there isnt a huge difference anyway.</p>",
|
||||||
|
"contentMap": {
|
||||||
|
"en": "<p><span class=\"h-card\"><a href=\"https://mamot.fr/@retiolus\" class=\"u-url mention\">@<span>retiolus</span></a></span> i have neverbeendisappointed by a thinkpad. if you want to save money, get a model from a few years ago, there isnt a huge difference anyway.</p>"
|
||||||
|
},
|
||||||
|
"attachment": [],
|
||||||
|
"tag": [
|
||||||
|
{
|
||||||
|
"type": "Mention",
|
||||||
|
"href": "https://mamot.fr/users/retiolus",
|
||||||
|
"name": "@retiolus@mamot.fr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replies": {
|
||||||
|
"id": "https://mastodon.madrid/users/felix/statuses/107224289116410645/replies",
|
||||||
|
"type": "Collection",
|
||||||
|
"first": {
|
||||||
|
"type": "CollectionPage",
|
||||||
|
"next": "https://mastodon.madrid/users/felix/statuses/107224289116410645/replies?only_other_accounts=true&page=true",
|
||||||
|
"partOf": "https://mastodon.madrid/users/felix/statuses/107224289116410645/replies",
|
||||||
|
"items": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
crates/apub/assets/mastodon/objects/person.json
Normal file
93
crates/apub/assets/mastodon/objects/person.json
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
{
|
||||||
|
"@context": [
|
||||||
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
"https://w3id.org/security/v1",
|
||||||
|
{
|
||||||
|
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
||||||
|
"toot": "http://joinmastodon.org/ns#",
|
||||||
|
"featured": {
|
||||||
|
"@id": "toot:featured",
|
||||||
|
"@type": "@id"
|
||||||
|
},
|
||||||
|
"alsoKnownAs": {
|
||||||
|
"@id": "as:alsoKnownAs",
|
||||||
|
"@type": "@id"
|
||||||
|
},
|
||||||
|
"movedTo": {
|
||||||
|
"@id": "as:movedTo",
|
||||||
|
"@type": "@id"
|
||||||
|
},
|
||||||
|
"schema": "http://schema.org#",
|
||||||
|
"PropertyValue": "schema:PropertyValue",
|
||||||
|
"value": "schema:value",
|
||||||
|
"IdentityProof": "toot:IdentityProof",
|
||||||
|
"discoverable": "toot:discoverable",
|
||||||
|
"Device": "toot:Device",
|
||||||
|
"Ed25519Signature": "toot:Ed25519Signature",
|
||||||
|
"Ed25519Key": "toot:Ed25519Key",
|
||||||
|
"Curve25519Key": "toot:Curve25519Key",
|
||||||
|
"EncryptedMessage": "toot:EncryptedMessage",
|
||||||
|
"publicKeyBase64": "toot:publicKeyBase64",
|
||||||
|
"deviceId": "toot:deviceId",
|
||||||
|
"claim": {
|
||||||
|
"@type": "@id",
|
||||||
|
"@id": "toot:claim"
|
||||||
|
},
|
||||||
|
"fingerprintKey": {
|
||||||
|
"@type": "@id",
|
||||||
|
"@id": "toot:fingerprintKey"
|
||||||
|
},
|
||||||
|
"identityKey": {
|
||||||
|
"@type": "@id",
|
||||||
|
"@id": "toot:identityKey"
|
||||||
|
},
|
||||||
|
"devices": {
|
||||||
|
"@type": "@id",
|
||||||
|
"@id": "toot:devices"
|
||||||
|
},
|
||||||
|
"messageFranking": "toot:messageFranking",
|
||||||
|
"messageType": "toot:messageType",
|
||||||
|
"cipherText": "toot:cipherText",
|
||||||
|
"Hashtag": "as:Hashtag",
|
||||||
|
"focalPoint": {
|
||||||
|
"@container": "@list",
|
||||||
|
"@id": "toot:focalPoint"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id": "https://mastodon.madrid/users/felix",
|
||||||
|
"type": "Person",
|
||||||
|
"following": "https://mastodon.madrid/users/felix/following",
|
||||||
|
"followers": "https://mastodon.madrid/users/felix/followers",
|
||||||
|
"inbox": "https://mastodon.madrid/users/felix/inbox",
|
||||||
|
"outbox": "https://mastodon.madrid/users/felix/outbox",
|
||||||
|
"featured": "https://mastodon.madrid/users/felix/collections/featured",
|
||||||
|
"preferredUsername": "felix",
|
||||||
|
"name": "",
|
||||||
|
"summary": "<p><a href=\"https://mastodon.madrid/tags/Lemmy\" class=\"mention hashtag\" rel=\"tag\">#<span>Lemmy</span></a> Maintainer</p>",
|
||||||
|
"url": "https://mastodon.madrid/@felix",
|
||||||
|
"manuallyApprovesFollowers": false,
|
||||||
|
"discoverable": false,
|
||||||
|
"devices": "https://mastodon.madrid/users/felix/collections/devices",
|
||||||
|
"publicKey": {
|
||||||
|
"id": "https://mastodon.madrid/users/felix#main-key",
|
||||||
|
"owner": "https://mastodon.madrid/users/felix",
|
||||||
|
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzc+evQS6XHTUdniPmFfH\n0U6aa4NaGSTQY4fmJna9w9Sr/8nNN4XWbGJLD4kawPxAXMbK63RMkkxvaHI9w+Oe\nd6oIJH2Z5qH4s2eX8f610SGDvyEZltLAY8TkMhNEp+3bOCKf1zG/uCsE7uC6Mjal\nd6KYyqoom5TwO2UWH5r6l3vyLFvnXWX2zOgSWJwLNLxMWkkd9AqM7k9+pgmeaNWD\n6JvG7Na5ywsR4CZrE5PjgtiC9LWP/H3Elgb2nIzye5HUEJuK2h1+eNFP3HSK5CF3\ncrg4DsZ1n5X3fQVm5YmFUYtEMLZL5S18dFsp6uwE0TmVOODJdnJ6+cgu0/8t2ROR\nJQIDAQAB\n-----END PUBLIC KEY-----\n"
|
||||||
|
},
|
||||||
|
"tag": [
|
||||||
|
{
|
||||||
|
"type": "Hashtag",
|
||||||
|
"href": "https://mastodon.madrid/explore/lemmy",
|
||||||
|
"name": "#lemmy"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"attachment": [],
|
||||||
|
"endpoints": {
|
||||||
|
"sharedInbox": "https://mastodon.madrid/inbox"
|
||||||
|
},
|
||||||
|
"icon": {
|
||||||
|
"type": "Image",
|
||||||
|
"mediaType": "image/jpeg",
|
||||||
|
"url": "https://mastodon.madrid/system/accounts/avatars/000/087/969/original/ffdd1c832b453bc9.jpg?1598972149"
|
||||||
|
}
|
||||||
|
}
|
54
crates/apub/assets/smithereen/activities/create_note.json
Normal file
54
crates/apub/assets/smithereen/activities/create_note.json
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
{
|
||||||
|
"type": "Create",
|
||||||
|
"id": "https://friends.grishka.me/posts/66561/activityCreate",
|
||||||
|
"published": "2021-11-09T11:42:35Z",
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"cc": [
|
||||||
|
"https://ds9.lemmy.ml/u/nutomic"
|
||||||
|
],
|
||||||
|
"actor": "https://friends.grishka.me/users/1",
|
||||||
|
"object": {
|
||||||
|
"type": "Note",
|
||||||
|
"id": "https://friends.grishka.me/posts/66561",
|
||||||
|
"attributedTo": "https://friends.grishka.me/users/1",
|
||||||
|
"content": "<p>So does this federate now?</p>",
|
||||||
|
"inReplyTo": "https://ds9.lemmy.ml/post/1723",
|
||||||
|
"published": "2021-11-09T11:42:35Z",
|
||||||
|
"tag": {
|
||||||
|
"type": "Mention",
|
||||||
|
"href": "https://ds9.lemmy.ml/u/nutomic"
|
||||||
|
},
|
||||||
|
"url": "https://friends.grishka.me/posts/66561",
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"cc": [
|
||||||
|
"https://ds9.lemmy.ml/u/nutomic"
|
||||||
|
],
|
||||||
|
"replies": {
|
||||||
|
"type": "Collection",
|
||||||
|
"id": "https://friends.grishka.me/posts/66561/replies",
|
||||||
|
"first": {
|
||||||
|
"type": "CollectionPage",
|
||||||
|
"partOf": "https://friends.grishka.me/posts/66561/replies",
|
||||||
|
"next": "https://friends.grishka.me/posts/66561/replies?page=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensitive": false,
|
||||||
|
"likes": "https://friends.grishka.me/posts/66561/likes"
|
||||||
|
},
|
||||||
|
"@context": [
|
||||||
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
{
|
||||||
|
"sensitive": "as:sensitive"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"signature": {
|
||||||
|
"creator": "https://friends.grishka.me/users/1#main-key",
|
||||||
|
"created": "2021-11-09T11:42:35Z",
|
||||||
|
"type": "RsaSignature2017",
|
||||||
|
"signatureValue": "MmEf4hjfwfQbm/W8qfONwf0uEXO4dhKApX8PlodSNi9x6E4kEgBvx7BrKg3gtqnXfU/cbGdVIN/yCz8+v7Tp2T2kj1yRpD7WjbgwzkrOlhxLi3zPXd4En/cVVdZYSfc7R6DGflXOSeOZPnKbrmY6i+1kYkM80Yc+LFtoj0Ftdgc/YbwMynt1OwPvDbB5bJo1NVyRnpNqlqia2VNmdAh1+2vREXZmINsCOFMC5c0RVzEENYMw+ZPsbVdXfoz4wfqK2u2i7SlcDKVErVNPrKn71wfGWRRiLUNupokY1x3jsWeZlPqGvAP3WGS9ChU+FxhnVHbtxIf0QmeOas3okLDSjw=="
|
||||||
|
}
|
||||||
|
}
|
30
crates/apub/assets/smithereen/objects/note.json
Normal file
30
crates/apub/assets/smithereen/objects/note.json
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"type": "Note",
|
||||||
|
"id": "https://friends.grishka.me/posts/66561",
|
||||||
|
"attributedTo": "https://friends.grishka.me/users/1",
|
||||||
|
"content": "<p>So does this federate now?</p>",
|
||||||
|
"inReplyTo": "https://ds9.lemmy.ml/post/1723",
|
||||||
|
"published": "2021-11-09T11:42:35Z",
|
||||||
|
"tag": {
|
||||||
|
"type": "Mention",
|
||||||
|
"href": "https://ds9.lemmy.ml/u/nutomic"
|
||||||
|
},
|
||||||
|
"url": "https://friends.grishka.me/posts/66561",
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"cc": [
|
||||||
|
"https://ds9.lemmy.ml/u/nutomic"
|
||||||
|
],
|
||||||
|
"replies": {
|
||||||
|
"type": "Collection",
|
||||||
|
"id": "https://friends.grishka.me/posts/66561/replies",
|
||||||
|
"first": {
|
||||||
|
"type": "CollectionPage",
|
||||||
|
"partOf": "https://friends.grishka.me/posts/66561/replies",
|
||||||
|
"next": "https://friends.grishka.me/posts/66561/replies?page=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensitive": false,
|
||||||
|
"likes": "https://friends.grishka.me/posts/66561/likes"
|
||||||
|
}
|
83
crates/apub/assets/smithereen/objects/person.json
Normal file
83
crates/apub/assets/smithereen/objects/person.json
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
{
|
||||||
|
"type": "Person",
|
||||||
|
"id": "https://friends.grishka.me/users/1",
|
||||||
|
"name": "Григорий Клюшников",
|
||||||
|
"icon": {
|
||||||
|
"type": "Image",
|
||||||
|
"image": {
|
||||||
|
"type": "Image",
|
||||||
|
"url": "https://friends.grishka.me/i/6QLsOws97AWp5N_osd74C1IC1ijnFopyCBD9MSEeXNQ/q:93/bG9jYWw6Ly8vcy91cGxvYWRzL2F2YXRhcnMvNTYzODRhODEwODk5ZTRjMzI4YmY4YmQwM2Q2MWM3NmMud2VicA.jpg",
|
||||||
|
"mediaType": "image/jpeg",
|
||||||
|
"width": 1280,
|
||||||
|
"height": 960
|
||||||
|
},
|
||||||
|
"width": 573,
|
||||||
|
"height": 572,
|
||||||
|
"cropRegion": [
|
||||||
|
0.26422762870788574,
|
||||||
|
0.3766937553882599,
|
||||||
|
0.7113820910453796,
|
||||||
|
0.9728997349739075
|
||||||
|
],
|
||||||
|
"url": "https://friends.grishka.me/i/ql_49PQcETAWgY_nC-Qj63H_Oa6FyOAEoWFkUSSkUvQ/c:573:572:nowe:338:362/q:93/bG9jYWw6Ly8vcy91cGxvYWRzL2F2YXRhcnMvNTYzODRhODEwODk5ZTRjMzI4YmY4YmQwM2Q2MWM3NmMud2VicA.jpg",
|
||||||
|
"mediaType": "image/jpeg"
|
||||||
|
},
|
||||||
|
"summary": "<p>Делаю эту хрень, пытаюсь вырвать социальные сети из жадных лап корпораций</p>\n<p></p>\n<p></p>\n<p></p>\n<p>This server does NOT support direct messages. Please write me <a href=\"https://t.me/grishka\">on Telegram</a> or Matrix (@grishk:matrix<span>.org</span>).</p>",
|
||||||
|
"url": "https://friends.grishka.me/grishka",
|
||||||
|
"preferredUsername": "grishka",
|
||||||
|
"inbox": "https://friends.grishka.me/users/1/inbox",
|
||||||
|
"outbox": "https://friends.grishka.me/users/1/outbox",
|
||||||
|
"followers": "https://friends.grishka.me/users/1/followers",
|
||||||
|
"following": "https://friends.grishka.me/users/1/following",
|
||||||
|
"endpoints": {
|
||||||
|
"sharedInbox": "https://friends.grishka.me/activitypub/sharedInbox"
|
||||||
|
},
|
||||||
|
"publicKey": {
|
||||||
|
"id": "https://friends.grishka.me/users/1#main-key",
|
||||||
|
"owner": "https://friends.grishka.me/users/1",
|
||||||
|
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjlakm+i/d9ER/hIeR7KfiFW+SdLZj2SkKIeM8cmR+YFJuh9ghFqXrkFEjcaqUnAFqe5gYDNSQACnDLA8y4DnzjfGNIohKAnRoa9x6GORmfKQvcnjaTZ53S1NvUiPPyc0Pv/vfCtY/Ab0CEXe5BLqL38oZn817Jf7pBrPRTYH7m012kvwAUTT6k0Y8lPITBEG7nzYbbuGcrN9Y/RDdwE08jmBXlZ45bahRH3VNXVpQE17dCzJB+7k+iJ1R7YCoI+DuMlBYGXGE2KVk46NZTuLnOjFV9SyXfWX4/SrJM4oxev+SX2N75tQgmNZmVVHeqg2ZcbC0WCfNjJOi2HHS9MujwIDAQAB\n-----END PUBLIC KEY-----\n"
|
||||||
|
},
|
||||||
|
"wall": "https://friends.grishka.me/users/1/wall",
|
||||||
|
"firstName": "Григорий",
|
||||||
|
"lastName": "Клюшников",
|
||||||
|
"middleName": "Александрович",
|
||||||
|
"vcard:bday": "1993-01-22",
|
||||||
|
"gender": "http://schema.org#Male",
|
||||||
|
"supportsFriendRequests": true,
|
||||||
|
"friends": "https://friends.grishka.me/users/1/friends",
|
||||||
|
"groups": "https://friends.grishka.me/users/1/groups",
|
||||||
|
"@context": [
|
||||||
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
{
|
||||||
|
"sm": "http://smithereen.software/ns#",
|
||||||
|
"cropRegion": {
|
||||||
|
"@id": "sm:cropRegion",
|
||||||
|
"@container": "@list"
|
||||||
|
},
|
||||||
|
"wall": {
|
||||||
|
"@id": "sm:wall",
|
||||||
|
"@type": "@id"
|
||||||
|
},
|
||||||
|
"sc": "http://schema.org#",
|
||||||
|
"firstName": "sc:givenName",
|
||||||
|
"lastName": "sc:familyName",
|
||||||
|
"middleName": "sc:additionalName",
|
||||||
|
"gender": {
|
||||||
|
"@id": "sc:gender",
|
||||||
|
"@type": "sc:GenderType"
|
||||||
|
},
|
||||||
|
"supportsFriendRequests": "sm:supportsFriendRequests",
|
||||||
|
"maidenName": "sm:maidenName",
|
||||||
|
"friends": {
|
||||||
|
"@id": "sm:friends",
|
||||||
|
"@type": "@id"
|
||||||
|
},
|
||||||
|
"groups": {
|
||||||
|
"@id": "sm:groups",
|
||||||
|
"@type": "@id"
|
||||||
|
},
|
||||||
|
"vcard": "http://www.w3.org/2006/vcard/ns#"
|
||||||
|
},
|
||||||
|
"https://w3id.org/security/v1"
|
||||||
|
]
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ mod tests {
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_parse_lemmy_create_or_update() {
|
async fn test_parsey_create_or_update() {
|
||||||
test_parse_lemmy_item::<CreateOrUpdatePost>(
|
test_parse_lemmy_item::<CreateOrUpdatePost>(
|
||||||
"assets/lemmy/activities/create_or_update/create_page.json",
|
"assets/lemmy/activities/create_or_update/create_page.json",
|
||||||
);
|
);
|
||||||
|
@ -24,11 +24,9 @@ mod tests {
|
||||||
test_parse_lemmy_item::<CreateOrUpdateComment>(
|
test_parse_lemmy_item::<CreateOrUpdateComment>(
|
||||||
"assets/lemmy/activities/create_or_update/create_note.json",
|
"assets/lemmy/activities/create_or_update/create_note.json",
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
#[actix_rt::test]
|
|
||||||
#[serial]
|
|
||||||
async fn test_parse_pleroma_create_or_update() {
|
|
||||||
file_to_json_object::<CreateOrUpdateComment>("assets/pleroma/activities/create_note.json");
|
file_to_json_object::<CreateOrUpdateComment>("assets/pleroma/activities/create_note.json");
|
||||||
|
file_to_json_object::<CreateOrUpdateComment>("assets/smithereen/activities/create_note.json");
|
||||||
|
file_to_json_object::<CreateOrUpdateComment>("assets/mastodon/activities/create_note.json");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,19 +17,32 @@ pub struct Endpoints {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::protocol::{
|
use crate::{
|
||||||
|
objects::tests::file_to_json_object,
|
||||||
|
protocol::{
|
||||||
objects::{chat_message::ChatMessage, group::Group, note::Note, page::Page, person::Person},
|
objects::{chat_message::ChatMessage, group::Group, note::Note, page::Page, person::Person},
|
||||||
tests::test_parse_lemmy_item,
|
tests::test_parse_lemmy_item,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
async fn test_parse_lemmy_object() {
|
async fn test_parse_object() {
|
||||||
test_parse_lemmy_item::<Person>("assets/lemmy/objects/person.json");
|
test_parse_lemmy_item::<Person>("assets/lemmy/objects/person.json");
|
||||||
test_parse_lemmy_item::<Group>("assets/lemmy/objects/group.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::<Page>("assets/lemmy/objects/page.json");
|
||||||
test_parse_lemmy_item::<Note>("assets/lemmy/objects/note.json");
|
test_parse_lemmy_item::<Note>("assets/lemmy/objects/note.json");
|
||||||
test_parse_lemmy_item::<ChatMessage>("assets/lemmy/objects/chat_message.json");
|
test_parse_lemmy_item::<ChatMessage>("assets/lemmy/objects/chat_message.json");
|
||||||
|
|
||||||
|
file_to_json_object::<Person>("assets/pleroma/objects/person.json");
|
||||||
|
file_to_json_object::<Note>("assets/pleroma/objects/note.json");
|
||||||
|
file_to_json_object::<ChatMessage>("assets/pleroma/objects/chat_message.json");
|
||||||
|
|
||||||
|
file_to_json_object::<Person>("assets/smithereen/objects/person.json");
|
||||||
|
file_to_json_object::<Note>("assets/smithereen/objects/note.json");
|
||||||
|
|
||||||
|
file_to_json_object::<Person>("assets/mastodon/objects/person.json");
|
||||||
|
file_to_json_object::<Note>("assets/mastodon/objects/note.json");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ pub struct Note {
|
||||||
pub(crate) cc: Vec<Url>,
|
pub(crate) cc: Vec<Url>,
|
||||||
pub(crate) content: String,
|
pub(crate) content: String,
|
||||||
pub(crate) media_type: Option<MediaTypeHtml>,
|
pub(crate) media_type: Option<MediaTypeHtml>,
|
||||||
|
#[serde(default)]
|
||||||
pub(crate) source: SourceCompat,
|
pub(crate) source: SourceCompat,
|
||||||
pub(crate) in_reply_to: ObjectId<PostOrComment>,
|
pub(crate) in_reply_to: ObjectId<PostOrComment>,
|
||||||
pub(crate) published: Option<DateTime<FixedOffset>>,
|
pub(crate) published: Option<DateTime<FixedOffset>>,
|
||||||
|
@ -40,10 +41,17 @@ pub struct Note {
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub(crate) enum SourceCompat {
|
pub(crate) enum SourceCompat {
|
||||||
|
None,
|
||||||
Lemmy(Source),
|
Lemmy(Source),
|
||||||
Pleroma(String),
|
Pleroma(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for SourceCompat {
|
||||||
|
fn default() -> Self {
|
||||||
|
SourceCompat::None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Note {
|
impl Note {
|
||||||
pub(crate) async fn get_parents(
|
pub(crate) async fn get_parents(
|
||||||
&self,
|
&self,
|
||||||
|
|
Loading…
Reference in a new issue