login-fix+draft_create-fix
All checks were successful
Deploy on push / deploy (push) Successful in 6s
All checks were successful
Deploy on push / deploy (push) Successful in 6s
This commit is contained in:
parent
4070f4fcde
commit
97d2b914b7
|
@ -79,7 +79,7 @@ async def load_drafts(_, info):
|
|||
Returns:
|
||||
dict: Список черновиков или сообщение об ошибке
|
||||
"""
|
||||
author_dict = info.context.get("author", {})
|
||||
author_dict = info.context.get("author") or {}
|
||||
author_id = author_dict.get("id")
|
||||
|
||||
if not author_id:
|
||||
|
@ -152,7 +152,7 @@ async def create_draft(_, info, draft_input):
|
|||
... assert result['draft'].title == 'Test'
|
||||
... return result
|
||||
"""
|
||||
author_dict = info.context.get("author", {})
|
||||
author_dict = info.context.get("author") or {}
|
||||
author_id = author_dict.get("id")
|
||||
|
||||
if not author_id:
|
||||
|
@ -226,7 +226,7 @@ async def update_draft(_, info, draft_id: int, draft_input):
|
|||
Returns:
|
||||
dict: Обновленный черновик или сообщение об ошибке
|
||||
"""
|
||||
author_dict = info.context.get("author", {})
|
||||
author_dict = info.context.get("author") or {}
|
||||
author_id = author_dict.get("id")
|
||||
|
||||
if not author_id:
|
||||
|
@ -328,7 +328,7 @@ async def update_draft(_, info, draft_id: int, draft_input):
|
|||
@mutation.field("delete_draft")
|
||||
@login_required
|
||||
async def delete_draft(_, info, draft_id: int):
|
||||
author_dict = info.context.get("author", {})
|
||||
author_dict = info.context.get("author") or {}
|
||||
author_id = author_dict.get("id")
|
||||
|
||||
with local_session() as session:
|
||||
|
@ -387,7 +387,7 @@ async def publish_draft(_, info, draft_id: int):
|
|||
Returns:
|
||||
dict: Результат публикации с shout или сообщением об ошибке
|
||||
"""
|
||||
author_dict = info.context.get("author", {})
|
||||
author_dict = info.context.get("author") or {}
|
||||
author_id = author_dict.get("id")
|
||||
|
||||
if not author_id:
|
||||
|
@ -490,7 +490,7 @@ async def unpublish_draft(_, info, draft_id: int):
|
|||
Returns:
|
||||
dict: Результат операции с информацией о черновике или сообщением об ошибке
|
||||
"""
|
||||
author_dict = info.context.get("author", {})
|
||||
author_dict = info.context.get("author") or {}
|
||||
author_id = author_dict.get("id")
|
||||
|
||||
if author_id:
|
||||
|
|
|
@ -135,7 +135,7 @@ async def get_my_shout(_, info, shout_id: int):
|
|||
@query.field("get_shouts_drafts")
|
||||
@login_required
|
||||
async def get_shouts_drafts(_, info):
|
||||
author_dict = info.context.get("author")
|
||||
author_dict = info.context.get("author") or {}
|
||||
if not author_dict:
|
||||
return {"error": "author profile was not found"}
|
||||
author_id = author_dict.get("id")
|
||||
|
@ -158,7 +158,7 @@ async def get_shouts_drafts(_, info):
|
|||
# @login_required
|
||||
async def create_shout(_, info, inp):
|
||||
logger.info(f"Starting create_shout with input: {inp}")
|
||||
author_dict = info.context.get("author")
|
||||
author_dict = info.context.get("author") or {}
|
||||
logger.debug(f"Context author: {author_dict}")
|
||||
|
||||
if not author_dict:
|
||||
|
@ -385,7 +385,8 @@ def patch_topics(session, shout, topics_input):
|
|||
# @mutation.field("update_shout")
|
||||
# @login_required
|
||||
async def update_shout(_, info, shout_id: int, shout_input=None, publish=False):
|
||||
author_id = info.context.get("author").get("id")
|
||||
author_dict = info.context.get("author") or {}
|
||||
author_id = author_dict.get("id")
|
||||
if not author_id:
|
||||
logger.error("Unauthorized update attempt")
|
||||
return {"error": "unauthorized"}
|
||||
|
@ -597,7 +598,7 @@ async def update_shout(_, info, shout_id: int, shout_input=None, publish=False):
|
|||
# @mutation.field("delete_shout")
|
||||
# @login_required
|
||||
async def delete_shout(_, info, shout_id: int):
|
||||
author_dict = info.context.get("author")
|
||||
author_dict = info.context.get("author") or {}
|
||||
if not author_dict:
|
||||
return {"error": "author profile was not found"}
|
||||
author_id = author_dict.get("id")
|
||||
|
|
|
@ -30,7 +30,7 @@ async def follow(_, info, what, slug="", entity_id=0):
|
|||
viewer_id = info.context.get("author", {}).get("id")
|
||||
if not viewer_id:
|
||||
return {"error": "Access denied"}
|
||||
follower_dict = info.context.get("author")
|
||||
follower_dict = info.context.get("author") or {}
|
||||
logger.debug(f"follower: {follower_dict}")
|
||||
|
||||
if not viewer_id or not follower_dict:
|
||||
|
@ -151,7 +151,7 @@ async def unfollow(_, info, what, slug="", entity_id=0):
|
|||
viewer_id = info.context.get("author", {}).get("id")
|
||||
if not viewer_id:
|
||||
return GraphQLError("Access denied")
|
||||
follower_dict = info.context.get("author")
|
||||
follower_dict = info.context.get("author") or {}
|
||||
logger.debug(f"follower: {follower_dict}")
|
||||
|
||||
if not viewer_id or not follower_dict:
|
||||
|
|
|
@ -203,7 +203,7 @@ def get_notifications_grouped(author_id: int, after: int = 0, limit: int = 10, o
|
|||
@query.field("load_notifications")
|
||||
@login_required
|
||||
async def load_notifications(_, info, after: int, limit: int = 50, offset=0):
|
||||
author_dict = info.context.get("author")
|
||||
author_dict = info.context.get("author") or {}
|
||||
author_id = author_dict.get("id")
|
||||
error = None
|
||||
total = 0
|
||||
|
|
|
@ -83,7 +83,7 @@ def get_reactions_with_stat(q, limit=10, offset=0):
|
|||
reactions = []
|
||||
|
||||
with local_session() as session:
|
||||
result_rows = session.execute(q)
|
||||
result_rows = session.execute(q).unique()
|
||||
for reaction, author, shout, comments_count, rating_stat in result_rows:
|
||||
# Пропускаем реакции с отсутствующими shout или author
|
||||
if not shout or not author:
|
||||
|
|
Loading…
Reference in New Issue
Block a user