diff --git a/bookwyrm/models/activitypub_mixin.py b/bookwyrm/models/activitypub_mixin.py index c6ba249c..efdf9a47 100644 --- a/bookwyrm/models/activitypub_mixin.py +++ b/bookwyrm/models/activitypub_mixin.py @@ -241,7 +241,7 @@ class ObjectMixin(ActivitypubMixin): return # is this a deletion? - if hasattr(self, "deleted") and self.deleted: + if (hasattr(self, "deleted") and self.deleted) or hasattr(self, "is_active") and not self.is_active: activity = self.to_delete_activity(user) else: activity = self.to_update_activity(user) diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 15ceb19b..d0a8a34f 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -283,6 +283,12 @@ class User(OrderedCollectionPageMixin, AbstractUser): editable=False, ).save(broadcast=False) + def delete(self, *args, **kwargs): + """ deactivate rather than delete a user """ + self.is_active = False + # skip the logic in this class's save() + super().save(*args, **kwargs) + @property def local_path(self): """ this model doesn't inherit bookwyrm model, so here we are """ diff --git a/bookwyrm/tests/views/inbox/test_inbox_delete.py b/bookwyrm/tests/views/inbox/test_inbox_delete.py index 51c59015..88ef288e 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_delete.py +++ b/bookwyrm/tests/views/inbox/test_inbox_delete.py @@ -116,7 +116,7 @@ class InboxActivities(TestCase): 'type': 'Delete', 'actor': 'https://example.com/users/test-user', 'to': ['https://www.w3.org/ns/activitystreams#Public'], - 'object': 'https://example.com/users/test-user', + 'object': self.remote_user.remote_id, } views.inbox.activity_task(activity)