Include Identity metadata fields in ActivityPub messages (#295)
This commit is contained in:
parent
a949c99d48
commit
c6c3914cc7
|
@ -45,14 +45,14 @@ def sanitize_html(post_html: str) -> str:
|
||||||
return mark_safe(cleaner.clean(post_html))
|
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.
|
Strips all tags from the text, then linkifies it.
|
||||||
"""
|
"""
|
||||||
cleaner = bleach.Cleaner(
|
cleaner = bleach.Cleaner(
|
||||||
tags=[],
|
tags=[],
|
||||||
strip=True,
|
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))
|
return mark_safe(cleaner.clean(post_html))
|
||||||
|
|
||||||
|
|
|
@ -483,6 +483,15 @@ class Identity(StatorModel):
|
||||||
response["endpoints"] = {
|
response["endpoints"] = {
|
||||||
"sharedInbox": f"https://{self.domain.uri_domain}/inbox/",
|
"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
|
return response
|
||||||
|
|
||||||
def to_ap_tag(self):
|
def to_ap_tag(self):
|
||||||
|
|
Loading…
Reference in New Issue