invalidate-new-follower
All checks were successful
Deploy on push / deploy (push) Successful in 5m45s

This commit is contained in:
2025-08-30 18:35:25 +03:00
parent f891b73608
commit 9752a470e0
2 changed files with 171 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ from orm.author import Author, AuthorFollower
from orm.community import Community, CommunityFollower
from orm.shout import Shout, ShoutReactionsFollower
from orm.topic import Topic, TopicFollower
from resolvers.author import invalidate_authors_cache
from services.auth import login_required
from services.notify import notify_follower
from storage.db import local_session
@@ -133,6 +134,10 @@ async def follow(
if isinstance(follower_dict, dict) and isinstance(entity_id, int):
await notify_follower(follower=follower_dict, author_id=entity_id, action="follow")
# Инвалидируем кеш статистики авторов для обновления счетчиков подписчиков
logger.debug("Инвалидируем кеш статистики авторов")
await invalidate_authors_cache(entity_id)
# Всегда получаем актуальный список подписок для возврата клиенту
if get_cached_follows_method and isinstance(follower_id, int):
logger.debug("Получение актуального списка подписок из кэша")
@@ -260,6 +265,10 @@ async def unfollow(
if what == "AUTHOR" and isinstance(follower_dict, dict):
await notify_follower(follower=follower_dict, author_id=entity_id, action="unfollow")
# Инвалидируем кеш статистики авторов для обновления счетчиков подписчиков
logger.debug("Инвалидируем кеш статистики авторов после отписки")
await invalidate_authors_cache(entity_id)
return {f"{entity_type}s": follows, "error": None}
except Exception as exc: