bowler's StatusView now has an activity_get method.

status-serialisers
Marnanel Thurman 2020-08-20 18:00:35 +01:00
rodzic ccdc414ad8
commit ecbba37661
1 zmienionych plików z 41 dodań i 2 usunięć

Wyświetl plik

@ -4,8 +4,47 @@
import django.views
import logging
import kepi.bowler_pub.views.activitypub as ap
import kepi.trilby_api.models.status as status
logger = logging.getLogger(name='kepi')
class StatusView(django.views.View):
pass # TODO
class StatusView(ap.KepiView):
def activity_get(self, request, *args, **kwargs):
self._username = kwargs['username']
self._status = kwargs['status']
logger.debug("Looking up status %d, by %s",
self._status, self._username,
)
try:
result = status.Status.objects.get(
id = self._status,
)
except status.Status.DoesNotExist:
logger.info(' -- unknown status: %s', kwargs)
return None
logger.debug(" -- found %s",
result
)
result = result.original
logger.debug(" -- found %s",
result
)
try:
if result.account.username != self._username:
logger.info(' -- status was by %s but they wanted %s',
result.account.username, self._username)
return None
except status.Status.account.RelatedObjectDoesNotExist:
logger.warn(" -- status %d has no associated account "+\
"(shouldn't happen)",
self._status)
return None
return result