2021-03-08 16:49:10 +00:00
|
|
|
""" the good stuff! the books! """
|
2021-01-13 21:36:01 +00:00
|
|
|
from django.http import JsonResponse
|
|
|
|
from django.shortcuts import get_object_or_404
|
|
|
|
from django.views import View
|
|
|
|
|
|
|
|
from bookwyrm import activitypub, models
|
2021-02-23 19:34:15 +00:00
|
|
|
from .helpers import is_bookwyrm_request
|
2021-01-13 21:36:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
# pylint: disable= no-self-use
|
|
|
|
class Outbox(View):
|
2021-03-08 16:49:10 +00:00
|
|
|
""" outbox """
|
|
|
|
|
2021-01-13 21:36:01 +00:00
|
|
|
def get(self, request, username):
|
2021-03-08 16:49:10 +00:00
|
|
|
""" outbox for the requested user """
|
2021-01-13 21:36:01 +00:00
|
|
|
user = get_object_or_404(models.User, localname=username)
|
2021-03-08 16:49:10 +00:00
|
|
|
filter_type = request.GET.get("type")
|
2021-01-13 21:36:01 +00:00
|
|
|
if filter_type not in models.status_models:
|
|
|
|
filter_type = None
|
|
|
|
|
|
|
|
return JsonResponse(
|
2021-02-23 19:34:15 +00:00
|
|
|
user.to_outbox(
|
|
|
|
**request.GET,
|
|
|
|
filter_type=filter_type,
|
|
|
|
pure=not is_bookwyrm_request(request)
|
|
|
|
),
|
2021-03-08 16:49:10 +00:00
|
|
|
encoder=activitypub.ActivityEncoder,
|
2021-01-13 21:36:01 +00:00
|
|
|
)
|