mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-25 08:41:00 +00:00
Include Identity metadata fields in ActivityPub messages (#295)
This commit is contained in:
parent
a949c99d48
commit
c6c3914cc7
2 changed files with 11 additions and 2 deletions
|
@ -45,14 +45,14 @@ def sanitize_html(post_html: str) -> str:
|
|||
return mark_safe(cleaner.clean(post_html))
|
||||
|
||||
|
||||
def strip_html(post_html: str) -> str:
|
||||
def strip_html(post_html: str, *, linkify: bool = True) -> str:
|
||||
"""
|
||||
Strips all tags from the text, then linkifies it.
|
||||
"""
|
||||
cleaner = bleach.Cleaner(
|
||||
tags=[],
|
||||
strip=True,
|
||||
filters=[partial(LinkifyFilter, url_re=url_regex)],
|
||||
filters=[partial(LinkifyFilter, url_re=url_regex)] if linkify else [],
|
||||
)
|
||||
return mark_safe(cleaner.clean(post_html))
|
||||
|
||||
|
|
|
@ -483,6 +483,15 @@ class Identity(StatorModel):
|
|||
response["endpoints"] = {
|
||||
"sharedInbox": f"https://{self.domain.uri_domain}/inbox/",
|
||||
}
|
||||
if self.metadata:
|
||||
response["attachment"] = [
|
||||
{
|
||||
"type": "http://schema.org#PropertyValue",
|
||||
"name": strip_html(item["name"], linkify=False),
|
||||
"value": strip_html(item["value"]),
|
||||
}
|
||||
for item in self.metadata
|
||||
]
|
||||
return response
|
||||
|
||||
def to_ap_tag(self):
|
||||
|
|
Loading…
Reference in a new issue