]> Untitled Git - lemmy.git/commitdiff
Change Person, Instance types (#2200)
authorNutomic <me@nutomic.com>
Tue, 12 Apr 2022 17:10:35 +0000 (17:10 +0000)
committerGitHub <noreply@github.com>
Tue, 12 Apr 2022 17:10:35 +0000 (17:10 +0000)
crates/apub/assets/friendica/objects/person_1.json [moved from crates/apub/assets/friendica/objects/person.json with 100% similarity]
crates/apub/assets/friendica/objects/person_2.json [new file with mode: 0644]
crates/apub/src/objects/instance.rs
crates/apub/src/protocol/objects/instance.rs
crates/apub/src/protocol/objects/mod.rs
crates/apub/src/protocol/objects/person.rs

diff --git a/crates/apub/assets/friendica/objects/person_2.json b/crates/apub/assets/friendica/objects/person_2.json
new file mode 100644 (file)
index 0000000..a57fced
--- /dev/null
@@ -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 <br>➡️➡️ 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": "<a href=\"https://mastodon.uno/@informapirata\" target=\"_blank\" rel=\"noopener noreferrer\">https://mastodon.uno/@informapirata</a>"
+    }
+  ],
+  "generator": {
+    "type": "Service",
+    "name": "Friendica 'Siberian Iris' 2022.03-1452",
+    "url": "https://poliverso.org"
+  }
+}
index fbd0bed966271a4c575f7803c1386e4cba163ead..c3641fca923be50fd0654441feefac459db8541d 100644 (file)
@@ -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<Self::ApubType, LemmyError> {
     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)),
index ee3a0a96e6a30ec32d108725149c33e33b168a3d..353d6500e196e4f5edb029420b8ad05a707859f4 100644 (file)
@@ -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<ApubSite>,
   // site name
   pub(crate) name: String,
index e7971366f3b24c491a5ecd415394fa39b4732c98..d61bf13cca225282ee5a97ea9f4878406770fe5e 100644 (file)
@@ -71,7 +71,8 @@ mod tests {
 
   #[test]
   fn test_parse_object_friendica() {
-    test_json::<Person>("assets/friendica/objects/person.json").unwrap();
+    test_json::<Person>("assets/friendica/objects/person_1.json").unwrap();
+    test_json::<Person>("assets/friendica/objects/person_2.json").unwrap();
     test_json::<Page>("assets/friendica/objects/page_1.json").unwrap();
     test_json::<Page>("assets/friendica/objects/page_2.json").unwrap();
     test_json::<Note>("assets/friendica/objects/note.json").unwrap();
index f69b1ad646ce2e71280ad394797b36d5f81d3195..1fe072a3d4a0a2803fee6b998d96072b5c890048 100644 (file)
@@ -12,6 +12,7 @@ use url::Url;
 pub enum UserTypes {
   Person,
   Service,
+  Organization,
 }
 
 #[skip_serializing_none]