This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user