summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Godwin2022-12-15 18:58:11 -0700
committerAndrew Godwin2022-12-15 18:58:11 -0700
commitc0cd5a55530079a6ba11f65065658b4fd1236a86 (patch)
tree694c534fea54aa24fa3fe99a648706b60ae8f57e
parent31dc08ad0dfe7c0b5e8491b30b9dab415d44210d (diff)
downloadtakahe-c0cd5a55530079a6ba11f65065658b4fd1236a86.tar.gz
takahe-c0cd5a55530079a6ba11f65065658b4fd1236a86.tar.bz2
takahe-c0cd5a55530079a6ba11f65065658b4fd1236a86.zip
Some hashtag json-ld fiddling
-rw-r--r--activities/models/post.py10
-rw-r--r--core/ld.py18
2 files changed, 17 insertions, 11 deletions
diff --git a/activities/models/post.py b/activities/models/post.py
index d31b52c..df80457 100644
--- a/activities/models/post.py
+++ b/activities/models/post.py
@@ -347,7 +347,9 @@ class Post(StatorModel):
"""
Returns the content formatted for remote consumption
"""
- return self.linkify_mentions(sanitize_post(self.content))
+ return Hashtag.linkify_hashtags(
+ self.linkify_mentions(sanitize_post(self.content))
+ )
def safe_content_plain(self):
"""
@@ -515,14 +517,14 @@ class Post(StatorModel):
Returns the AP JSON for this object
"""
value = {
- "to": "as:Public",
+ "to": "Public",
"cc": [],
"type": "Note",
"id": self.object_uri,
"published": format_ld_date(self.published),
"attributedTo": self.author.actor_uri,
"content": self.safe_content_remote(),
- "as:sensitive": self.sensitive,
+ "sensitive": self.sensitive,
"url": self.absolute_object_uri(),
"tag": [],
"attachment": [],
@@ -543,7 +545,7 @@ class Post(StatorModel):
{
"href": f"https://{self.author.domain.uri_domain}/tags/{hashtag}/",
"name": f"#{hashtag}",
- "type": "as:Hashtag",
+ "type": "Hashtag",
}
)
# Emoji
diff --git a/core/ld.py b/core/ld.py
index 4b01e71..950bf06 100644
--- a/core/ld.py
+++ b/core/ld.py
@@ -407,14 +407,18 @@ def canonicalise(json_data: dict, include_security: bool = False) -> dict:
"""
if not isinstance(json_data, dict):
raise ValueError("Pass decoded JSON data into LDDocument")
- context: str | list[str]
+ context = [
+ "https://www.w3.org/ns/activitystreams",
+ {
+ "sensitive": "as:sensitive",
+ "toot": "http://joinmastodon.org/ns#",
+ "votersCount": "toot:votersCount",
+ "Hashtag": "as:Hashtag",
+ "Public": "as:Public",
+ },
+ ]
if include_security:
- context = [
- "https://www.w3.org/ns/activitystreams",
- "https://w3id.org/security/v1",
- ]
- else:
- context = "https://www.w3.org/ns/activitystreams"
+ context.append("https://w3id.org/security/v1")
if "@context" not in json_data:
json_data["@context"] = context