This commit is contained in:
parent
e17690f27b
commit
5e2842774a
|
@ -1,3 +1,4 @@
|
|||
import json
|
||||
import time
|
||||
|
||||
from sqlalchemy import and_, desc, select
|
||||
|
@ -52,6 +53,18 @@ async def get_my_shout(_, info, shout_id: int):
|
|||
if not shout:
|
||||
return {"error": "no shout found", "shout": None}
|
||||
|
||||
# Преобразуем media JSON в список объектов MediaItem
|
||||
if hasattr(shout, "media") and shout.media:
|
||||
if isinstance(shout.media, str):
|
||||
try:
|
||||
shout.media = json.loads(shout.media)
|
||||
except:
|
||||
shout.media = []
|
||||
if not isinstance(shout.media, list):
|
||||
shout.media = [shout.media] if shout.media else []
|
||||
else:
|
||||
shout.media = []
|
||||
|
||||
logger.debug(f"got {len(shout.authors)} shout authors, created by {shout.created_by}")
|
||||
is_editor = "editor" in roles
|
||||
logger.debug(f'viewer is{'' if is_editor else ' not'} editor')
|
||||
|
|
|
@ -13,7 +13,7 @@ resolvers = [query, mutation]
|
|||
async def request_graphql_data(gql, url=AUTH_URL, headers=None):
|
||||
"""
|
||||
Выполняет GraphQL запрос к указанному URL
|
||||
|
||||
|
||||
:param gql: GraphQL запрос
|
||||
:param url: URL для запроса, по умолчанию AUTH_URL
|
||||
:param headers: Заголовки запроса
|
||||
|
@ -37,5 +37,6 @@ async def request_graphql_data(gql, url=AUTH_URL, headers=None):
|
|||
logger.error(f"{url}: {response.status_code} {response.text}")
|
||||
except Exception as _e:
|
||||
import traceback
|
||||
|
||||
logger.error(f"request_graphql_data error: {traceback.format_exc()}")
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue
Block a user