Files
zulip/zilencer/management/commands/mark_all_messages_unread.py
Anders Kaseorg 6e4c3e41dc python: Normalize quotes with Black.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-12 13:11:19 -08:00

18 lines
520 B
Python

from typing import Any
from django.conf import settings
from django.core.cache import cache
from django.core.management.base import BaseCommand
from django.db.models import F
from zerver.models import UserMessage
class Command(BaseCommand):
help = """Script to mark all messages as unread."""
def handle(self, *args: Any, **options: Any) -> None:
assert settings.DEVELOPMENT
UserMessage.objects.all().update(flags=F("flags").bitand(~UserMessage.flags.read))
cache._cache.flush_all()