follow-fmr
All checks were successful
Deploy on push / deploy (push) Successful in 22s

This commit is contained in:
Untone 2024-05-01 04:01:21 +03:00
parent c68322e550
commit dc9c66c00f
2 changed files with 8 additions and 4 deletions

View File

@ -40,19 +40,23 @@ async def get_my_shout(_, info, shout_id: int):
if not shout:
return {"error": "no shout found", "shout": None}
logger.debug(f'got shout authors: {shout.authors} created by {shout.created_by}')
logger.debug(
f"got 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')
is_creator = author_id == shout.created_by
logger.debug(f'viewer is{'' if is_creator else ' not'} creator')
is_author = bool(list(filter(lambda x: x.id == int(author_id), [x for x in shout.authors])))
is_author = bool(
list(filter(lambda x: x.id == int(author_id), [x for x in shout.authors]))
)
logger.debug(f'viewer is{'' if is_creator else ' not'} author')
can_edit = is_editor or is_author or is_creator
if not can_edit:
return {"error": "forbidden", "shout": None}
logger.debug('got shout editor with data')
logger.debug("got shout editor with data")
return {"error": None, "shout": shout}

View File

@ -101,7 +101,7 @@ def login_required(f):
info.context["roles"] = user_roles
author = await get_author_by_user(user_id)
if not author:
logger.error(f'author profile not found for user {user_id}')
logger.error(f"author profile not found for user {user_id}")
info.context["author"] = author
return await f(*args, **kwargs)