mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-22 07:10:59 +00:00
Some hashtag json-ld fiddling
This commit is contained in:
parent
31dc08ad0d
commit
c0cd5a5553
2 changed files with 17 additions and 11 deletions
|
@ -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
|
||||
|
|
14
core/ld.py
14
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]
|
||||
if include_security:
|
||||
context = [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
{
|
||||
"sensitive": "as:sensitive",
|
||||
"toot": "http://joinmastodon.org/ns#",
|
||||
"votersCount": "toot:votersCount",
|
||||
"Hashtag": "as:Hashtag",
|
||||
"Public": "as:Public",
|
||||
},
|
||||
]
|
||||
else:
|
||||
context = "https://www.w3.org/ns/activitystreams"
|
||||
if include_security:
|
||||
context.append("https://w3id.org/security/v1")
|
||||
if "@context" not in json_data:
|
||||
json_data["@context"] = context
|
||||
|
||||
|
|
Loading…
Reference in a new issue