Two apschema versions

merge-requests/8/head
Bob Mottram 2021-01-10 14:21:54 +00:00
parent 758747740e
commit 60b0e3fdfb
2 changed files with 52 additions and 1 deletions

View File

@ -11,6 +11,7 @@ validContexts = (
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/identity/v1",
"https://w3id.org/security/v1",
"*/apschema/v1.9"
"*/apschema/v1.21"
)
@ -54,6 +55,48 @@ def hasValidContext(postJsonObject: {}) -> bool:
return True
def getApschemaV1_9() -> {}:
# https://domain/apschema/v1.9
return {
"@context": {
"zot": "https://hub.disroot.org/apschema#",
"id": "@id",
"type": "@type",
"commentPolicy": "as:commentPolicy",
"meData": "zot:meData",
"meDataType": "zot:meDataType",
"meEncoding": "zot:meEncoding",
"meAlgorithm": "zot:meAlgorithm",
"meCreator": "zot:meCreator",
"meSignatureValue": "zot:meSignatureValue",
"locationAddress": "zot:locationAddress",
"locationPrimary": "zot:locationPrimary",
"locationDeleted": "zot:locationDeleted",
"nomadicLocation": "zot:nomadicLocation",
"nomadicHubs": "zot:nomadicHubs",
"emojiReaction": "zot:emojiReaction",
"expires": "zot:expires",
"directMessage": "zot:directMessage",
"schema": "http://schema.org#",
"PropertyValue": "schema:PropertyValue",
"value": "schema:value",
"magicEnv": {
"@id": "zot:magicEnv",
"@type": "@id"
},
"nomadicLocations": {
"@id": "zot:nomadicLocations",
"@type": "@id"
},
"ostatus": "http://ostatus.org#",
"conversation": "ostatus:conversation",
"diaspora": "https://diasporafoundation.org/ns/",
"guid": "diaspora:guid",
"Hashtag": "as:Hashtag"
}
}
def getApschemaV1_21() -> {}:
# https://domain/apschema/v1.21
return {

View File

@ -37,6 +37,7 @@ import traceback
from collections import deque, namedtuple
from numbers import Integral, Real
from context import getApschemaV1_9
from context import getApschemaV1_21
from context import getV1Schema
from context import getV1SecuritySchema
@ -397,7 +398,14 @@ def load_document(url):
'document': getActivitystreamsSchema()
}
return doc
elif url == 'https://raitisoja.com/apschema/v1.21':
elif url.endswith('/apschema/v1.9'):
doc = {
'contextUrl': None,
'documentUrl': url,
'document': getApschemaV1_9()
}
return doc
elif url.endswith('/apschema/v1.21'):
doc = {
'contextUrl': None,
'documentUrl': url,