2017-04-26 00:35:52 +02:00
|
|
|
from typing import Any
|
|
|
|
|
2022-07-19 00:14:23 +02:00
|
|
|
import bmemcached
|
2017-04-26 00:35:52 +02:00
|
|
|
from django.conf import settings
|
2017-11-16 00:55:49 +01:00
|
|
|
from django.core.cache import cache
|
2017-04-26 00:35:52 +02:00
|
|
|
from django.db.models import F
|
2023-10-12 19:43:45 +02:00
|
|
|
from typing_extensions import override
|
2017-11-16 00:55:49 +01:00
|
|
|
|
2024-05-24 16:49:56 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2020-07-04 10:49:43 +02:00
|
|
|
from zerver.models import UserMessage
|
2017-04-26 00:35:52 +02:00
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2024-05-24 16:49:56 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
2017-04-26 00:35:52 +02:00
|
|
|
help = """Script to mark all messages as unread."""
|
|
|
|
|
2023-10-12 19:43:45 +02:00
|
|
|
@override
|
2017-10-27 12:57:54 +02:00
|
|
|
def handle(self, *args: Any, **options: Any) -> None:
|
2017-04-26 00:35:52 +02:00
|
|
|
assert settings.DEVELOPMENT
|
2021-02-12 08:20:45 +01:00
|
|
|
UserMessage.objects.all().update(flags=F("flags").bitand(~UserMessage.flags.read))
|
2022-10-08 06:10:17 +02:00
|
|
|
_cache = cache._cache # type: ignore[attr-defined] # not in stubs
|
2022-07-19 00:14:23 +02:00
|
|
|
assert isinstance(_cache, bmemcached.Client)
|
|
|
|
_cache.flush_all()
|