mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-25 00:30:59 +00:00
Fix identity metadata not properly propagating through AP (#589)
This commit is contained in:
parent
bb8f589da7
commit
9038e498d5
3 changed files with 31 additions and 2 deletions
|
@ -11,7 +11,7 @@ from api import schemas
|
|||
from api.decorators import scope_required
|
||||
from api.pagination import MastodonPaginator, PaginatingApiResponse, PaginationResult
|
||||
from core.models import Config
|
||||
from users.models import Identity
|
||||
from users.models import Identity, IdentityStates
|
||||
from users.services import IdentityService
|
||||
from users.shortcuts import by_handle_or_404
|
||||
|
||||
|
@ -70,6 +70,7 @@ def update_credentials(
|
|||
if header:
|
||||
service.set_image(header)
|
||||
identity.save()
|
||||
identity.transition_perform(IdentityStates.edited)
|
||||
return schemas.Account.from_identity(identity, source=True)
|
||||
|
||||
|
||||
|
|
|
@ -240,3 +240,31 @@ async def test_fetch_webfinger_url(httpx_mock: HTTPXMock, config_system):
|
|||
await Identity.fetch_webfinger_url("example.com")
|
||||
== "https://example.com/.well-known/webfinger?resource={uri}"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_attachment_to_ap(identity: Identity, config_system):
|
||||
"""
|
||||
Tests identity attachment conversion to AP format.
|
||||
"""
|
||||
identity.metadata = [
|
||||
{
|
||||
"type": "http://schema.org#PropertyValue",
|
||||
"name": "Website",
|
||||
"value": "http://example.com",
|
||||
}
|
||||
]
|
||||
|
||||
response = identity.to_ap()
|
||||
|
||||
assert response["attachment"]
|
||||
assert len(response["attachment"]) == 1
|
||||
|
||||
attachment = response["attachment"][0]
|
||||
|
||||
assert attachment["type"] == "PropertyValue"
|
||||
assert attachment["name"] == "Website"
|
||||
assert attachment["value"] == (
|
||||
'<a href="http://example.com" rel="nofollow">'
|
||||
'<span class="invisible">http://</span>example.com</a>'
|
||||
)
|
||||
|
|
|
@ -534,7 +534,7 @@ class Identity(StatorModel):
|
|||
if self.metadata:
|
||||
response["attachment"] = [
|
||||
{
|
||||
"type": "http://schema.org#PropertyValue",
|
||||
"type": "PropertyValue",
|
||||
"name": FediverseHtmlParser(item["name"]).plain_text,
|
||||
"value": FediverseHtmlParser(item["value"]).html,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue