2021-06-18 21:29:24 +00:00
|
|
|
""" ActivityPub-specific json response wrapper """
|
2020-12-30 10:12:04 +00:00
|
|
|
from django.http import JsonResponse
|
|
|
|
|
|
|
|
from .base_activity import ActivityEncoder
|
|
|
|
|
2021-03-08 16:49:10 +00:00
|
|
|
|
2020-12-30 10:12:04 +00:00
|
|
|
class ActivitypubResponse(JsonResponse):
|
|
|
|
"""
|
|
|
|
A class to be used in any place that's serializing responses for
|
|
|
|
Activitypub enabled clients. Uses JsonResponse under the hood, but already
|
|
|
|
configures some stuff beforehand. Made to be a drop-in replacement of
|
|
|
|
JsonResponse.
|
|
|
|
"""
|
|
|
|
|
2021-03-08 16:49:10 +00:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
data,
|
|
|
|
encoder=ActivityEncoder,
|
|
|
|
safe=False,
|
|
|
|
json_dumps_params=None,
|
|
|
|
**kwargs
|
|
|
|
):
|
|
|
|
|
|
|
|
if "content_type" not in kwargs:
|
|
|
|
kwargs["content_type"] = "application/activity+json"
|
2020-12-30 10:12:04 +00:00
|
|
|
|
|
|
|
super().__init__(data, encoder, safe, json_dumps_params, **kwargs)
|