search-index-fixed
All checks were successful
Deploy on push / deploy (push) Successful in 5m49s

This commit is contained in:
2025-08-30 18:53:38 +03:00
parent 05b5c3defd
commit 2dad23f86c
3 changed files with 39 additions and 9 deletions

View File

@@ -73,7 +73,9 @@ async def notify_shout(shout: dict[str, Any], action: str = "update") -> None:
logger.error(f"Failed to publish to channel {channel_name}: {e}")
async def notify_follower(follower: dict[str, Any], author_id: int, action: str = "follow", subscription_id: int | None = None) -> None:
async def notify_follower(
follower: dict[str, Any], author_id: int, action: str = "follow", subscription_id: int | None = None
) -> None:
channel_name = f"follower:{author_id}"
try:
# Simplify dictionary before publishing
@@ -89,8 +91,8 @@ async def notify_follower(follower: dict[str, Any], author_id: int, action: str
"id": subscription_id or 999, # ID записи подписки из БД
"follower_id": simplified_follower["id"],
"following_id": author_id,
"created_at": datetime.now(UTC).isoformat()
}
"created_at": datetime.now(UTC).isoformat(),
},
}
# save in channel
@@ -106,7 +108,9 @@ async def notify_follower(follower: dict[str, Any], author_id: int, action: str
if json_data:
# Use the 'await' keyword when publishing
await redis.publish(channel_name, json_data)
logger.debug(f"📡 Отправлено SSE уведомление о подписке: author_id={author_id}, follower={simplified_follower.get('name')}")
logger.debug(
f"📡 Отправлено SSE уведомление о подписке: author_id={author_id}, follower={simplified_follower.get('name')}"
)
except (ConnectionError, TimeoutError, KeyError, ValueError) as e:
# Log the error and re-raise it