28 lines
652 B
Python
28 lines
652 B
Python
from __future__ import annotations
|
|||
|
|
|
||
|
|
from uuid import uuid4
|
||
|
|
|
||
|
|
from django.conf import settings
|
||
|
|
from django.core.cache import cache
|
||
|
|
|
||
|
|
|
||
|
|
def sensitive_words_version_key() -> str:
|
||
|
|
return str(
|
||
|
|
getattr(
|
||
|
|
settings,
|
||
|
|
"MODERATION_CACHE_VERSION_KEY",
|
||
|
|
"moderation:sensitive_words:version",
|
||
|
|
)
|
||
|
|
or "moderation:sensitive_words:version"
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def get_sensitive_words_version() -> str:
|
||
|
|
return str(cache.get(sensitive_words_version_key()) or "0")
|
||
|
|
|
||
|
|
|
||
|
|
def bump_sensitive_words_version() -> str:
|
||
|
|
version = uuid4().hex
|
||
|
|
cache.set(sensitive_words_version_key(), version, timeout=None)
|
||
|
|
return version
|