kopia lustrzana https://gitlab.com/marnanel/chapeau
bowler's StatusView now has an activity_get method.
rodzic
ccdc414ad8
commit
ecbba37661
|
@ -4,8 +4,47 @@
|
||||||
|
|
||||||
import django.views
|
import django.views
|
||||||
import logging
|
import logging
|
||||||
|
import kepi.bowler_pub.views.activitypub as ap
|
||||||
|
import kepi.trilby_api.models.status as status
|
||||||
|
|
||||||
logger = logging.getLogger(name='kepi')
|
logger = logging.getLogger(name='kepi')
|
||||||
|
|
||||||
class StatusView(django.views.View):
|
class StatusView(ap.KepiView):
|
||||||
pass # TODO
|
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
|
||||||
|
|
Ładowanie…
Reference in New Issue