mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-27 02:10:35 +00:00
Change Person, Instance types (#2200)
This commit is contained in:
parent
2180bd0369
commit
bbd739af9b
6 changed files with 86 additions and 6 deletions
70
crates/apub/assets/friendica/objects/person_2.json
Normal file
70
crates/apub/assets/friendica/objects/person_2.json
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -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)),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -12,6 +12,7 @@ use url::Url;
|
|||
pub enum UserTypes {
|
||||
Person,
|
||||
Service,
|
||||
Organization,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
|
|
Loading…
Reference in a new issue