From 2b5d4562aa3e04cc7a4431c8a707cdaf02bef833 Mon Sep 17 00:00:00 2001 From: silverpill Date: Sun, 19 Feb 2023 23:20:25 +0000 Subject: [PATCH] Make activities pass JSON-LD validation --- CHANGELOG.md | 1 + src/activitypub/types.rs | 30 +++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be84a61..7225362 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Fixed actor object JSON-LD validation errors. +- Fixed activity JSON-LD validation errors. ## [1.13.1] - 2023-02-09 diff --git a/src/activitypub/types.rs b/src/activitypub/types.rs index d3bd8b5..c4150bb 100644 --- a/src/activitypub/types.rs +++ b/src/activitypub/types.rs @@ -1,8 +1,15 @@ +use std::collections::HashMap; + use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_json::Value; -use super::constants::{AP_CONTEXT, W3ID_DATA_INTEGRITY_CONTEXT}; +use super::constants::{ + AP_CONTEXT, + MITRA_CONTEXT, + W3ID_DATA_INTEGRITY_CONTEXT, + W3ID_SECURITY_CONTEXT, +}; use super::vocabulary::HASHTAG; #[derive(Deserialize, Serialize)] @@ -101,11 +108,24 @@ pub struct Object { pub url: Option, } -pub type Context = [&'static str; 2]; +pub type Context = ( + &'static str, + &'static str, + &'static str, + HashMap<&'static str, &'static str>, +); -pub const fn build_default_context() -> Context { - [ +pub fn build_default_context() -> Context { + ( AP_CONTEXT, + W3ID_SECURITY_CONTEXT, W3ID_DATA_INTEGRITY_CONTEXT, - ] + HashMap::from([ + ("proofValue", "sec:proofValue"), + ("proofPurpose", "sec:proofPurpose"), + ("verificationMethod", "sec:verificationMethod"), + ("mitra", MITRA_CONTEXT), + ("MitraJcsRsaSignature2022", "mitra:MitraJcsRsaSignature2022"), + ]), + ) }