Some more JSON-LD namespace fixing

This commit is contained in:
Andrew Godwin 2022-12-17 17:48:33 -07:00
parent c5e00a2c73
commit b6a8737d2e
3 changed files with 11 additions and 6 deletions

View File

@ -12,6 +12,7 @@ from django.utils.safestring import mark_safe
from core.files import get_remote_file from core.files import get_remote_file
from core.html import strip_html from core.html import strip_html
from core.ld import format_ld_date
from core.models import Config from core.models import Config
from core.uploads import upload_emoji_namer from core.uploads import upload_emoji_namer
from core.uris import AutoAbsoluteUrl, RelativeAbsoluteUrl, StaticAbsoluteUrl from core.uris import AutoAbsoluteUrl, RelativeAbsoluteUrl, StaticAbsoluteUrl
@ -218,13 +219,14 @@ class Emoji(StatorModel):
""" """
return { return {
"id": self.object_uri or f"https://{settings.MAIN_DOMAIN}/emoji/{self.pk}/", "id": self.object_uri or f"https://{settings.MAIN_DOMAIN}/emoji/{self.pk}/",
"type": "toot:Emoji", "type": "Emoji",
"name": self.shortcode, "name": f":{self.shortcode}:",
"icon": { "icon": {
"type": "Image", "type": "Image",
"mediaType": self.mimetype, "mediaType": self.mimetype,
"url": self.full_url().absolute, "url": self.full_url().absolute,
}, },
"updated": format_ld_date(self.updated),
} }
@classmethod @classmethod

View File

@ -96,7 +96,7 @@ class PostAttachment(StatorModel):
"width": self.width, "width": self.width,
"height": self.height, "height": self.height,
"mediaType": self.mimetype, "mediaType": self.mimetype,
"toot:focalPoint": [0, 0], "blurhash": self.blurhash,
} }
### Mastodon Client API ### ### Mastodon Client API ###

View File

@ -410,12 +410,15 @@ def canonicalise(json_data: dict, include_security: bool = False) -> dict:
context = [ context = [
"https://www.w3.org/ns/activitystreams", "https://www.w3.org/ns/activitystreams",
{ {
"blurhash": "toot:blurhash",
"Emoji": "toot:Emoji",
"focalPoint": {"@container": "@list", "@id": "toot:focalPoint"},
"Hashtag": "as:Hashtag",
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"Public": "as:Public",
"sensitive": "as:sensitive", "sensitive": "as:sensitive",
"toot": "http://joinmastodon.org/ns#", "toot": "http://joinmastodon.org/ns#",
"votersCount": "toot:votersCount", "votersCount": "toot:votersCount",
"Hashtag": "as:Hashtag",
"Public": "as:Public",
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
}, },
] ]
if include_security: if include_security: