From: Felix Ableitner Date: Mon, 8 Nov 2021 15:04:02 +0000 (+0100) Subject: Include apub context from file, so that it can be embedded in docs X-Git-Url: http://these/git/%7B%60%24%7BarchiveTodayUrl%7D/static/%7Bpost.embed_video_url%7D?a=commitdiff_plain;h=c21c142a9a5414fbd6859cf22cb2d459b9e1503f;p=lemmy.git Include apub context from file, so that it can be embedded in docs --- diff --git a/crates/apub/assets/lemmy/context.json b/crates/apub/assets/lemmy/context.json new file mode 100644 index 00000000..88f3a658 --- /dev/null +++ b/crates/apub/assets/lemmy/context.json @@ -0,0 +1,19 @@ +[ + "https://www.w3.org/ns/activitystreams", + { + "stickied": "as:stickied", + "pt": "https://join-lemmy.org#", + "sc": "http://schema.org#", + "matrixUserId": { + "type": "sc:Text", + "id": "as:alsoKnownAs" + }, + "sensitive": "as:sensitive", + "comments_enabled": { + "type": "sc:Boolean", + "id": "pt:commentsEnabled" + }, + "moderators": "as:moderators" + }, + "https://w3id.org/security/v1" +] \ No newline at end of file diff --git a/crates/apub/src/context.rs b/crates/apub/src/context.rs index cf4b704f..55486872 100644 --- a/crates/apub/src/context.rs +++ b/crates/apub/src/context.rs @@ -1,33 +1,9 @@ -use activitystreams::{base::AnyBase, context, primitives::OneOrMany}; +use activitystreams::{base::AnyBase, primitives::OneOrMany}; use serde::{Deserialize, Serialize}; -use serde_json::json; -use url::Url; lazy_static! { - static ref CONTEXT: OneOrMany = { - let context_ext = AnyBase::from_arbitrary_json(json!( - { - "sc": "http://schema.org#", - "sensitive": "as:sensitive", - "stickied": "as:stickied", - "pt": "https://join-lemmy.org#", - "comments_enabled": { - "type": "sc:Boolean", - "id": "pt:commentsEnabled" - }, - "moderators": "as:moderators", - "matrixUserId": { - "type": "sc:Text", - "id": "as:alsoKnownAs" - }, - })) - .expect("parse context"); - OneOrMany::from(vec![ - AnyBase::from(context()), - context_ext, - AnyBase::from(Url::parse("https://w3id.org/security/v1").expect("parse context")), - ]) - }; + static ref CONTEXT: OneOrMany = + serde_json::from_str(include_str!("../assets/lemmy/context.json")).expect("parse context"); } #[derive(Serialize, Deserialize)]