This commit is contained in:
parent
e17690f27b
commit
5e2842774a
|
@ -1,3 +1,4 @@
|
||||||
|
import json
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from sqlalchemy import and_, desc, select
|
from sqlalchemy import and_, desc, select
|
||||||
|
@ -52,6 +53,18 @@ async def get_my_shout(_, info, shout_id: int):
|
||||||
if not shout:
|
if not shout:
|
||||||
return {"error": "no shout found", "shout": None}
|
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}")
|
logger.debug(f"got {len(shout.authors)} shout authors, created by {shout.created_by}")
|
||||||
is_editor = "editor" in roles
|
is_editor = "editor" in roles
|
||||||
logger.debug(f'viewer is{'' if is_editor else ' not'} editor')
|
logger.debug(f'viewer is{'' if is_editor else ' not'} editor')
|
||||||
|
|
|
@ -37,5 +37,6 @@ async def request_graphql_data(gql, url=AUTH_URL, headers=None):
|
||||||
logger.error(f"{url}: {response.status_code} {response.text}")
|
logger.error(f"{url}: {response.status_code} {response.text}")
|
||||||
except Exception as _e:
|
except Exception as _e:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
logger.error(f"request_graphql_data error: {traceback.format_exc()}")
|
logger.error(f"request_graphql_data error: {traceback.format_exc()}")
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user