From: Nutomic Date: Tue, 12 Apr 2022 17:10:35 +0000 (+0000) Subject: Change Person, Instance types (#2200) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/hacktivis.me/readmes/sneer-club-logo.svg?a=commitdiff_plain;h=bbd739af9b7757b5360bbe01949b5da36d9eb4c6;p=lemmy.git Change Person, Instance types (#2200) --- diff --git a/crates/apub/assets/friendica/objects/person.json b/crates/apub/assets/friendica/objects/person_1.json similarity index 100% rename from crates/apub/assets/friendica/objects/person.json rename to crates/apub/assets/friendica/objects/person_1.json diff --git a/crates/apub/assets/friendica/objects/person_2.json b/crates/apub/assets/friendica/objects/person_2.json new file mode 100644 index 00000000..a57fced5 --- /dev/null +++ b/crates/apub/assets/friendica/objects/person_2.json @@ -0,0 +1,70 @@ +{ + "@context": [ + "https://www.w3.org/ns/activitystreams", + "https://w3id.org/security/v1", + { + "vcard": "http://www.w3.org/2006/vcard/ns#", + "dfrn": "http://purl.org/macgirvin/dfrn/1.0/", + "diaspora": "https://diasporafoundation.org/ns/", + "litepub": "http://litepub.social/ns#", + "toot": "http://joinmastodon.org/ns#", + "schema": "http://schema.org#", + "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", + "sensitive": "as:sensitive", + "Hashtag": "as:Hashtag", + "directMessage": "litepub:directMessage", + "discoverable": "toot:discoverable", + "PropertyValue": "schema:PropertyValue", + "value": "schema:value" + } + ], + "id": "https://poliverso.org/profile/informapirata", + "diaspora:guid": "0477a01e-8161-2935-9a73-393807834700", + "type": "Organization", + "following": "https://poliverso.org/following/informapirata", + "followers": "https://poliverso.org/followers/informapirata", + "inbox": "https://poliverso.org/inbox/informapirata", + "outbox": "https://poliverso.org/outbox/informapirata", + "preferredUsername": "informapirata", + "name": "Informa Pirata", + "vcard:hasAddress": { + "@type": "vcard:Home", + "vcard:country-name": "Italy", + "vcard:region": "Lazio", + "vcard:locality": "" + }, + "summary": "Politica Pirata: informazione su #whistleblowing #dirittidigitali #sovranitàdigitale #copyright #privacy #cyberwarfare #pirati #Europa #opensource #opendata
➡️➡️ http://T.ME/PPINFORMA", + "url": "https://poliverso.org/profile/informapirata", + "manuallyApprovesFollowers": false, + "discoverable": true, + "publicKey": { + "id": "https://poliverso.org/profile/informapirata#main-key", + "owner": "https://poliverso.org/profile/informapirata", + "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA09bPyftct7KNf4hm+rmG\n1aX4HmJbAdiXkmxo3g7iJG21Vvd3+OQeKnjpLc0n9s9rKMrpy8FQj+E7FaVYIGcP\n/f8McmSb4ezFeNkVNKGm+Y7swpeAAmh0MBWfDD+j3WHznD+OLABhWZlnfhIxW1aD\nD6mN9mkITvLAut8vJVTaciGzjfv6AndHVerVPV8lw5gXCmvX/+NZUOjjLQVND3fL\n8fZiJjJ3NSQ1tAx0m38PVMHZGw2492gkbKxzkW6c/QyMRAOrKP2+kJQ/6O2sn/ZK\n7MtHzMQ4eUjGc0ZLWQlCqQ4oVbVTcPgwHW1+no3928fzhU95zi5oAI08wfJ5wo86\nAnPv4fnUL/gyGff/ytZ/kGhNv+jVlSbMYxiDslRoD2Zp+L1P5Ypw6iemR1rMivL4\nJMxx2FoYGD1xzKBqNcJ2cDRQ5VQGwhBs/U6XyRMrRTzhDoe5dHr49MjHGuYkUzhq\naYPgku+zA7hfjvZA982kK2jAMXPoTLoUrY7T6beanYwfFIxd++fNHxTSexrhwx7P\nqn7v+pi0WTA8Cxor4N+ICCXxVvpO7s5VERVugiJofKZhFXiE2S02S2jVoGCRtEKw\n9/iignMld/IQSojz8N+77KMYGuVT9eG9Io/mF4MjCLluNNRXklt55dz55vOHPBxg\nll83LwyA3eELfylUNV75DcsCAwEAAQ==\n-----END PUBLIC KEY-----\n" + }, + "endpoints": { + "sharedInbox": "https://poliverso.org/inbox" + }, + "icon": { + "type": "Image", + "url": "https://poliverso.org/photo/profile/informapirata.png?ts=1630486460", + "mediaType": "image/png" + }, + "attachment": [ + { + "type": "PropertyValue", + "name": "Telegram", + "value": "http://T.ME/PPINFORMA" + }, + { + "type": "PropertyValue", + "name": "Mastodon", + "value": "https://mastodon.uno/@informapirata" + } + ], + "generator": { + "type": "Service", + "name": "Friendica 'Siberian Iris' 2022.03-1452", + "url": "https://poliverso.org" + } +} diff --git a/crates/apub/src/objects/instance.rs b/crates/apub/src/objects/instance.rs index fbd0bed9..c3641fca 100644 --- a/crates/apub/src/objects/instance.rs +++ b/crates/apub/src/objects/instance.rs @@ -1,9 +1,12 @@ use crate::{ check_is_apub_id_valid, objects::{read_from_string_or_source_opt, verify_image_domain_matches}, - protocol::{objects::instance::Instance, ImageObject, Source}, + protocol::{ + objects::instance::{Instance, InstanceType}, + ImageObject, + Source, + }, }; -use activitystreams_kinds::actor::ServiceType; use chrono::NaiveDateTime; use lemmy_api_common::blocking; use lemmy_apub_lib::{ @@ -73,7 +76,7 @@ impl ApubObject for ApubSite { #[tracing::instrument(skip_all)] async fn into_apub(self, _data: &Self::DataType) -> Result { let instance = Instance { - kind: ServiceType::Service, + kind: InstanceType::Service, id: ObjectId::new(self.actor_id()), name: self.name.clone(), content: self.sidebar.as_ref().map(|d| markdown_to_html(d)), diff --git a/crates/apub/src/protocol/objects/instance.rs b/crates/apub/src/protocol/objects/instance.rs index ee3a0a96..353d6500 100644 --- a/crates/apub/src/protocol/objects/instance.rs +++ b/crates/apub/src/protocol/objects/instance.rs @@ -2,19 +2,24 @@ use crate::{ objects::instance::ApubSite, protocol::{ImageObject, Source}, }; -use activitystreams_kinds::actor::ServiceType; use chrono::{DateTime, FixedOffset}; use lemmy_apub_lib::{object_id::ObjectId, signatures::PublicKey, values::MediaTypeHtml}; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use url::Url; +#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)] +pub enum InstanceType { + Application, + Service, +} + #[skip_serializing_none] #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Instance { #[serde(rename = "type")] - pub(crate) kind: ServiceType, + pub(crate) kind: InstanceType, pub(crate) id: ObjectId, // site name pub(crate) name: String, diff --git a/crates/apub/src/protocol/objects/mod.rs b/crates/apub/src/protocol/objects/mod.rs index e7971366..d61bf13c 100644 --- a/crates/apub/src/protocol/objects/mod.rs +++ b/crates/apub/src/protocol/objects/mod.rs @@ -71,7 +71,8 @@ mod tests { #[test] fn test_parse_object_friendica() { - test_json::("assets/friendica/objects/person.json").unwrap(); + test_json::("assets/friendica/objects/person_1.json").unwrap(); + test_json::("assets/friendica/objects/person_2.json").unwrap(); test_json::("assets/friendica/objects/page_1.json").unwrap(); test_json::("assets/friendica/objects/page_2.json").unwrap(); test_json::("assets/friendica/objects/note.json").unwrap(); diff --git a/crates/apub/src/protocol/objects/person.rs b/crates/apub/src/protocol/objects/person.rs index f69b1ad6..1fe072a3 100644 --- a/crates/apub/src/protocol/objects/person.rs +++ b/crates/apub/src/protocol/objects/person.rs @@ -12,6 +12,7 @@ use url::Url; pub enum UserTypes { Person, Service, + Organization, } #[skip_serializing_none]