This commit is contained in:
@@ -429,7 +429,7 @@ async def publish_draft(_: None, info: GraphQLResolveInfo, draft_id: int) -> dic
|
||||
return {"error": f"Cannot publish draft: {error}"}
|
||||
|
||||
# Проверяем, есть ли уже публикация для этого черновика
|
||||
shout = None
|
||||
shout: Any = None
|
||||
if draft.shout:
|
||||
shout = session.query(Shout).where(Shout.id == draft.shout).first()
|
||||
if shout:
|
||||
@@ -463,6 +463,10 @@ async def publish_draft(_: None, info: GraphQLResolveInfo, draft_id: int) -> dic
|
||||
session.add(shout)
|
||||
session.flush() # Получаем ID нового шаута
|
||||
|
||||
# Ensure shout is not None before proceeding
|
||||
if not shout:
|
||||
return {"error": "Failed to create or update shout"}
|
||||
|
||||
# Очищаем существующие связи
|
||||
session.query(ShoutAuthor).where(ShoutAuthor.shout == shout.id).delete()
|
||||
session.query(ShoutTopic).where(ShoutTopic.shout == shout.id).delete()
|
||||
@@ -493,7 +497,7 @@ async def publish_draft(_: None, info: GraphQLResolveInfo, draft_id: int) -> dic
|
||||
await notify_shout(shout.dict(), "published")
|
||||
|
||||
# Обновляем поисковый индекс
|
||||
await search_service.perform_index(shout)
|
||||
search_service.index(shout)
|
||||
|
||||
logger.info(f"Successfully published shout #{shout.id} from draft #{draft_id}")
|
||||
logger.debug(f"Shout data: {shout.dict()}")
|
||||
|
||||
Reference in New Issue
Block a user