Include Identity metadata fields in ActivityPub messages (#295)

This commit is contained in:
Michael Manfre 2022-12-27 19:42:30 -05:00 committed by GitHub
parent a949c99d48
commit c6c3914cc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -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))

View file

@ -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):