author-followers-fix
This commit is contained in:
@@ -108,7 +108,11 @@ async def get_current_user(_, info):
|
||||
|
||||
if authors_with_stat and len(authors_with_stat) > 0:
|
||||
# Обновляем только статистику
|
||||
author.stat = authors_with_stat[0].stat
|
||||
# Проверяем, является ли author объектом или словарем
|
||||
if isinstance(author, dict):
|
||||
author["stat"] = authors_with_stat[0].stat
|
||||
else:
|
||||
author.stat = authors_with_stat[0].stat
|
||||
except Exception as e:
|
||||
logger.warning(f"[getSession] Не удалось добавить статистику к автору: {e}")
|
||||
|
||||
|
@@ -50,7 +50,7 @@ async def get_all_authors(current_user_id=None):
|
||||
authors = session.execute(authors_query).scalars().unique().all()
|
||||
|
||||
# Преобразуем авторов в словари с учетом прав доступа
|
||||
return [author.dict(current_user_id, False) for author in authors]
|
||||
return [author.dict(access=False) for author in authors]
|
||||
|
||||
# Используем универсальную функцию для кеширования запросов
|
||||
return await cached_query(cache_key, fetch_all_authors)
|
||||
|
@@ -69,7 +69,7 @@ async def follow(_, info, what, slug="", entity_id=0):
|
||||
# Если это автор, учитываем фильтрацию данных
|
||||
if what == "AUTHOR":
|
||||
# Полная версия для кэширования
|
||||
entity_dict = entity.dict(is_admin=True)
|
||||
entity_dict = entity.dict(access=True)
|
||||
else:
|
||||
entity_dict = entity.dict()
|
||||
|
||||
@@ -116,7 +116,7 @@ async def follow(_, info, what, slug="", entity_id=0):
|
||||
if hasattr(temp_author, key):
|
||||
setattr(temp_author, key, value)
|
||||
# Добавляем отфильтрованную версию
|
||||
follows_filtered.append(temp_author.dict(viewer_id, False))
|
||||
follows_filtered.append(temp_author.dict(access=False))
|
||||
|
||||
if not existing_sub:
|
||||
# Создаем объект автора для entity_dict
|
||||
@@ -125,7 +125,7 @@ async def follow(_, info, what, slug="", entity_id=0):
|
||||
if hasattr(temp_author, key):
|
||||
setattr(temp_author, key, value)
|
||||
# Добавляем отфильтрованную версию
|
||||
follows = [*follows_filtered, temp_author.dict(viewer_id, False)]
|
||||
follows = [*follows_filtered, temp_author.dict(access=False)]
|
||||
else:
|
||||
follows = follows_filtered
|
||||
else:
|
||||
@@ -209,7 +209,7 @@ async def unfollow(_, info, what, slug="", entity_id=0):
|
||||
logger.debug("Обновление кэша после отписки")
|
||||
# Если это автор, кэшируем полную версию
|
||||
if what == "AUTHOR":
|
||||
await cache_method(entity.dict(is_admin=True))
|
||||
await cache_method(entity.dict(access=True))
|
||||
else:
|
||||
await cache_method(entity.dict())
|
||||
|
||||
@@ -232,7 +232,7 @@ async def unfollow(_, info, what, slug="", entity_id=0):
|
||||
if hasattr(temp_author, key):
|
||||
setattr(temp_author, key, value)
|
||||
# Добавляем отфильтрованную версию
|
||||
follows_filtered.append(temp_author.dict(viewer_id, False))
|
||||
follows_filtered.append(temp_author.dict(access=False))
|
||||
|
||||
follows = follows_filtered
|
||||
else:
|
||||
|
Reference in New Issue
Block a user