From 8faa494ed6e6c31467528190fac604eb06aa5a3e Mon Sep 17 00:00:00 2001 From: Marnanel Thurman Date: Sat, 10 Aug 2019 17:02:11 +0100 Subject: [PATCH] Anything with a "former_type" is deemed to be a Tombstone. This is instead of changing f_type, which has far too many knock-on effects now that we're using polymorphism. Tombstones have active=False. AllUsersView updated so that it uses the polymorphic types. --- django_kepi/models/thing.py | 6 +++--- django_kepi/views/activitypub.py | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/django_kepi/models/thing.py b/django_kepi/models/thing.py index 2f96871..832d15a 100644 --- a/django_kepi/models/thing.py +++ b/django_kepi/models/thing.py @@ -293,7 +293,7 @@ class Object(PolymorphicModel): def entomb(self): logger.info('%s: entombing', self) - if self.f_type=='Tombstone': + if self['former_type'] is not None: logger.warn(' -- already entombed; ignoring') return @@ -301,9 +301,9 @@ class Object(PolymorphicModel): raise ValueError("%s: you can't entomb remote things %s", self, str(self.remote_url)) - self['type'] = 'Tombstone' + self['former_type'] = self.f_type self['deleted'] = datetime.datetime.now() - self.active = True + self.active = False self.save() logger.info('%s: entombed', self) diff --git a/django_kepi/views/activitypub.py b/django_kepi/views/activitypub.py index 2929d59..0d02179 100644 --- a/django_kepi/views/activitypub.py +++ b/django_kepi/views/activitypub.py @@ -91,6 +91,10 @@ class KepiView(django.views.View): return self._render_object(request, result) def _to_json(self, data): + + if 'former_type' in data: + data['type'] = 'Tombstone' + result = JsonResponse( data=data, json_dumps_params={ @@ -101,7 +105,7 @@ class KepiView(django.views.View): result['Content-Type'] = 'application/activity+json' - if data['type']=='Tombstone': + if 'former_type' in data: result.reason = 'Entombed' result.status_code = 410 @@ -325,7 +329,7 @@ class AllUsersView(KepiView): logger.debug('Finding all users.') - return Object.objects.filter(f_type='Person') + return Actor.objects.all() def _modify_list_item(self, obj): return obj.activity_form