Use our instance policies to discard fetched and inbox objects

This commit is contained in:
Eliot Berriot 2019-01-09 17:52:14 +01:00
parent 9151a185e0
commit 1c55f2c9a6
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
15 changed files with 317 additions and 31 deletions

View file

@ -316,15 +316,8 @@ class ManageInstancePolicySerializer(serializers.ModelSerializer):
@transaction.atomic
def save(self, *args, **kwargs):
block_all = self.validated_data.get("block_all", False)
need_purge = (
# we purge when we create with block all
(not self.instance and block_all)
or
# or when block all value switch from False to True
(self.instance and block_all and not self.instance.block_all)
)
instance = super().save(*args, **kwargs)
need_purge = self.instance.is_active and self.instance.block_all
if need_purge:
target = instance.target