Broadcast user deletions

This commit is contained in:
Mouse Reeve 2021-04-17 12:51:36 -07:00
parent 5df2ac676b
commit 5b7f2007e8
3 changed files with 8 additions and 2 deletions

View file

@ -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)

View file

@ -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 """

View file

@ -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)