mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 05:49:16 +02:00
Rejecting media files on an instance or account now purge existing media
This commit is contained in:
parent
cb3dacedbe
commit
377f237fdb
5 changed files with 102 additions and 32 deletions
|
@ -198,27 +198,34 @@ def delete_qs(qs):
|
|||
)
|
||||
|
||||
|
||||
def handle_purge_actors(ids):
|
||||
def handle_purge_actors(ids, only=[]):
|
||||
"""
|
||||
Empty only means we purge everything
|
||||
Otherwise, we purge only the requested bits: media
|
||||
"""
|
||||
# purge follows (received emitted)
|
||||
delete_qs(models.LibraryFollow.objects.filter(target__actor_id__in=ids))
|
||||
delete_qs(models.LibraryFollow.objects.filter(actor_id__in=ids))
|
||||
delete_qs(models.Follow.objects.filter(target_id__in=ids))
|
||||
delete_qs(models.Follow.objects.filter(actor_id__in=ids))
|
||||
if not only:
|
||||
delete_qs(models.LibraryFollow.objects.filter(target__actor_id__in=ids))
|
||||
delete_qs(models.Follow.objects.filter(actor_id__in=ids))
|
||||
|
||||
# purge audio content
|
||||
delete_qs(music_models.Upload.objects.filter(library__actor_id__in=ids))
|
||||
delete_qs(music_models.Library.objects.filter(actor_id__in=ids))
|
||||
if not only or "media" in only:
|
||||
delete_qs(models.LibraryFollow.objects.filter(actor_id__in=ids))
|
||||
delete_qs(models.Follow.objects.filter(target_id__in=ids))
|
||||
delete_qs(music_models.Upload.objects.filter(library__actor_id__in=ids))
|
||||
delete_qs(music_models.Library.objects.filter(actor_id__in=ids))
|
||||
|
||||
# purge remaining activities / deliveries
|
||||
delete_qs(models.InboxItem.objects.filter(actor_id__in=ids))
|
||||
delete_qs(models.Activity.objects.filter(actor_id__in=ids))
|
||||
if not only:
|
||||
delete_qs(models.InboxItem.objects.filter(actor_id__in=ids))
|
||||
delete_qs(models.Activity.objects.filter(actor_id__in=ids))
|
||||
|
||||
|
||||
@celery.app.task(name="federation.purge_actors")
|
||||
def purge_actors(ids=[], domains=[]):
|
||||
def purge_actors(ids=[], domains=[], only=[]):
|
||||
actors = models.Actor.objects.filter(
|
||||
Q(id__in=ids) | Q(domain_id__in=domains)
|
||||
).order_by("id")
|
||||
found_ids = list(actors.values_list("id", flat=True))
|
||||
logger.info("Starting purging %s accounts", len(found_ids))
|
||||
handle_purge_actors(ids=found_ids)
|
||||
handle_purge_actors(ids=found_ids, only=only)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue