plugin AP Gateway: various fixes and improvements:
- Sign item requests with the service/node actor and use the publisher for `attributedTo`. - http_server: add missing `requestor_actor_id` to all `ap_*_request` handlers. - http_server: fix following acceptation in `handle_follow_activity`. - http_server: unescape `%40` in `get_ap_actor_data` at the beginning and use it everywhere. - pubsub_service: delete subscription from storage on unsubscribe. - Fix missing arguments in some calls. - Fix various issues coming from conversion of data models to Pydantic. - plugin XEP-0277: add `MbData.is_edit` property.
This commit is contained in:
parent
50ffc8c3b4
commit
8afde9962a
6 changed files with 155 additions and 71 deletions
|
|
@ -42,6 +42,7 @@ from libervia.backend.plugins import plugin_comp_ap_gateway
|
|||
from libervia.backend.plugins.plugin_comp_ap_gateway import constants as ap_const
|
||||
from libervia.backend.plugins.plugin_comp_ap_gateway import TYPE_ACTOR
|
||||
from libervia.backend.plugins.plugin_comp_ap_gateway.http_server import HTTPServer
|
||||
from libervia.backend.plugins.plugin_misc_identity import IdentityData
|
||||
from libervia.backend.plugins.plugin_xep_0277 import NS_ATOM, MbData
|
||||
from libervia.backend.plugins.plugin_xep_0424 import NS_MESSAGE_RETRACT
|
||||
from libervia.backend.plugins.plugin_xep_0465 import NS_PPS
|
||||
|
|
@ -671,6 +672,7 @@ class TestActivityPubGateway:
|
|||
|
||||
ap_url = parse.urljoin(f"https://{ap_gateway.public_url}", path)
|
||||
kwargs = {
|
||||
"requestor_actor_id": test_jid.full(),
|
||||
"request": request,
|
||||
"data": data,
|
||||
"account_jid": test_jid,
|
||||
|
|
@ -701,8 +703,11 @@ class TestActivityPubGateway:
|
|||
assert outbox["first"]
|
||||
assert outbox["last"]
|
||||
|
||||
page_params = self.ap_request_params(ap_gateway, url=outbox["first"])
|
||||
# the page request doesn't take the requestor actor ID
|
||||
page_params.pop("requestor_actor_id")
|
||||
first_page = await ap_gateway.server.resource.ap_outbox_page_request(
|
||||
**self.ap_request_params(ap_gateway, url=outbox["first"])
|
||||
**page_params
|
||||
)
|
||||
assert first_page["@context"] == ["https://www.w3.org/ns/activitystreams"]
|
||||
assert (
|
||||
|
|
@ -1134,10 +1139,10 @@ class TestActivityPubGateway:
|
|||
# XXX: XMPP identity is normally an amalgam of metadata from several
|
||||
# XEPs/locations (vCard4, vcard-tmp, etc)
|
||||
with patch.object(ap_gateway._i, "get_identity") as get_identity:
|
||||
get_identity.return_value = {
|
||||
"nicknames": ["nick1", "nick2"],
|
||||
"description": "test description",
|
||||
}
|
||||
get_identity.return_value = IdentityData(
|
||||
nicknames=["nick1", "nick2"],
|
||||
description="test description",
|
||||
)
|
||||
actor_data = await ap_gateway.server.resource.ap_actor_request(
|
||||
**self.ap_request_params(ap_gateway, ap_const.TYPE_ACTOR)
|
||||
)
|
||||
|
|
@ -1388,6 +1393,8 @@ class TestActivityPubGateway:
|
|||
TEST_JID,
|
||||
ap_gateway._m.namespace,
|
||||
[item_elt],
|
||||
TEST_JID,
|
||||
subscribe_extra_nodes=False,
|
||||
)
|
||||
|
||||
assert ap_post.called
|
||||
|
|
@ -1444,17 +1451,19 @@ class TestActivityPubGateway:
|
|||
assert cache_pubsub_items.called
|
||||
# the microblog data put in cache correspond to the item sent to subscribers
|
||||
__, __, __, [mb_data] = cache_pubsub_items.call_args.args
|
||||
extra = mb_data.extra
|
||||
repeated = extra.repeated
|
||||
repeated = mb_data["extra"]["repeated"]
|
||||
assert repeated is not None
|
||||
assert repeated.by == ap_gateway.get_local_jid_from_account(TEST_AP_ACCOUNT)
|
||||
assert (
|
||||
repeated["by"]
|
||||
== ap_gateway.get_local_jid_from_account(TEST_AP_ACCOUNT).full()
|
||||
)
|
||||
xmpp_item_xmpp_url = xmpp_uri.build_xmpp_uri(
|
||||
"pubsub",
|
||||
path=TEST_JID.full(),
|
||||
node=ap_gateway._m.namespace,
|
||||
item=xmpp_item["id"],
|
||||
)
|
||||
assert repeated.uri == xmpp_item_xmpp_url
|
||||
assert repeated["uri"] == xmpp_item_xmpp_url
|
||||
|
||||
@ed
|
||||
async def test_xmpp_attachment_noticed_to_ap_like(self, ap_gateway, monkeypatch):
|
||||
|
|
|
|||
Loading…
Reference in a new issue