kopia lustrzana https://gitlab.com/jaywink/federation
Tweak activitypub_object_view process_payload call signature
Now passes `response.content` as is and also passes in the request object.merge-requests/135/head
rodzic
331421c216
commit
aff1a8e59e
|
@ -14,7 +14,7 @@
|
|||
|
||||
When used, a few extra settings must be given in the Django `FEDERATION` configuration dictionary.
|
||||
* `get_object_function` should contain the Python path to a function that takes an ActivityPub ID and returns an object matching the ID or `None`.
|
||||
* `process_payload_function` should contain the Python path to a function that takes in a federation payload and processes it. It should return `True` if successful (or placed in queue for processing later) or `False` in case of any errors.
|
||||
* `process_payload_function` should contain the Python path to a function that takes in a federation payload and request object. It should return `True` if successful (or placed in queue for processing later) or `False` in case of any errors.
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ Some settings need to be set in Django settings. An example is below:
|
|||
}
|
||||
openRegistrations
|
||||
|
||||
* ``process_payload_function`` (optional) function that takes in a federation payload and processes it. It should return ``True`` if successful (or placed in queue for processing later) or ``False`` in case of any errors.
|
||||
* ``process_payload_function`` (optional) function that takes in a federation payload and request object. It should return ``True`` if successful (or placed in queue for processing later) or ``False`` in case of any errors.
|
||||
* ``search_path`` (optional) site search path which ends in a parameter for search input, for example "/search?q="
|
||||
|
||||
Protocols
|
||||
|
|
|
@ -38,8 +38,7 @@ def activitypub_object_view(func):
|
|||
|
||||
def post(request, *args, **kwargs):
|
||||
process_payload_function = get_function_from_config('process_payload_function')
|
||||
payload = json.loads(request.body)
|
||||
result = process_payload_function(payload)
|
||||
result = process_payload_function(request.body, request)
|
||||
if result:
|
||||
return JsonResponse({}, content_type='application/json', status=202)
|
||||
else:
|
||||
|
|
|
@ -47,7 +47,7 @@ class TestActivityPubObjectView:
|
|||
response = dummy_view(request=request)
|
||||
|
||||
assert response.status_code == 202
|
||||
mock_func.assert_called_once_with({"foo": "bar"})
|
||||
mock_func.assert_called_once_with(b'{"foo": "bar"}', request)
|
||||
|
||||
@patch("federation.entities.activitypub.django.views.get_function_from_config")
|
||||
def test_receives_messages_to_inbox__cbv(self, mock_get_config):
|
||||
|
@ -58,7 +58,7 @@ class TestActivityPubObjectView:
|
|||
response = view(request=request)
|
||||
|
||||
assert response.status_code == 202
|
||||
mock_func.assert_called_once_with({"foo": "bar"})
|
||||
mock_func.assert_called_once_with(b'{"foo": "bar"}', request)
|
||||
|
||||
@pytest.mark.parametrize('content_type', (
|
||||
'application/json', 'application/activity+json', 'application/ld+json',
|
||||
|
|
Ładowanie…
Reference in New Issue