Re-consider list privacy on edit

Please run ci??
This commit is contained in:
Mouse Reeve 2022-03-24 12:43:01 -07:00
parent 6808b70d3f
commit aefb0c9b14

View file

@ -115,9 +115,12 @@ class ListsStream(RedisStore):
@receiver(signals.post_save, sender=models.List) @receiver(signals.post_save, sender=models.List)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def add_list_on_create(sender, instance, created, *args, **kwargs): def add_list_on_create(sender, instance, created, *args, **kwargs):
"""add newly created lists streamsstreams""" """add newly created lists streams"""
if not created: if not created:
# the privacy may have changed, so we need to re-do the whole thing
remove_list_task.delay(instance.id, re_add=True)
return return
# when creating new things, gotta wait on the transaction # when creating new things, gotta wait on the transaction
transaction.on_commit(lambda: add_list_on_create_command(instance.id)) transaction.on_commit(lambda: add_list_on_create_command(instance.id))
@ -217,7 +220,7 @@ def populate_lists_task(user_id):
@app.task(queue=MEDIUM) @app.task(queue=MEDIUM)
def remove_list_task(list_id): def remove_list_task(list_id, re_add=False):
"""remove a list from any stream it might be in""" """remove a list from any stream it might be in"""
stores = models.User.objects.filter(local=True, is_active=True).values_list( stores = models.User.objects.filter(local=True, is_active=True).values_list(
"id", flat=True "id", flat=True
@ -227,6 +230,9 @@ def remove_list_task(list_id):
stores = [ListsStream().stream_id(idx) for idx in stores] stores = [ListsStream().stream_id(idx) for idx in stores]
ListsStream().remove_object_from_related_stores(list_id, stores=stores) ListsStream().remove_object_from_related_stores(list_id, stores=stores)
if re_add:
add_list_task.delay(list_id)
@app.task(queue=HIGH) @app.task(queue=HIGH)
def add_list_task(list_id): def add_list_task(list_id):