get-my-shout-api-fix

This commit is contained in:
Untone 2024-03-07 14:29:45 +03:00
parent 61088320c9
commit 6f3ed3704a

View File

@ -32,16 +32,15 @@ async def get_my_shout(_, info, shout_id: int):
if not shout.published_at: if not shout.published_at:
user_id = info.context.get('user_id', '') user_id = info.context.get('user_id', '')
roles = info.context.get('roles', []) roles = info.context.get('roles', [])
if not user_id:
error = 'unauthorized'
else:
if 'editor' in roles or filter( if 'editor' in roles or filter(
lambda x: x.id == author.id, [x for x in shout.authors] lambda x: x.id == author.id, [x for x in shout.authors]
): ):
return {'error': None, 'shout': shout} error = None
else: else:
error = 'forbidden' error = 'forbidden'
return {'error': error, 'shout': shout} shout = None
return {'error': error, 'shout': shout.dict()}
return {'error': 'no shout found', 'shout': None}
@query.field('get_shouts_drafts') @query.field('get_shouts_drafts')