get-my-shout-fix
All checks were successful
Deploy on push / deploy (push) Successful in 26s

This commit is contained in:
Untone 2024-05-01 02:38:17 +03:00
parent 9aacb75e84
commit 94bf54b192

View File

@ -40,9 +40,10 @@ async def get_my_shout(_, info, shout_id: int):
if not author_id:
return {"error": "no author found", "shout": None}
roles = info.context.get("roles", [])
if "editor" not in roles and not filter(
lambda x: x.id == int(author_id), [x for x in shout.authors]
):
is_editor = "editor" in roles
is_author = filter(lambda x: x.id == int(author_id), [x for x in shout.authors])
can_edit = is_editor or is_author
if not can_edit:
return {"error": "forbidden", "shout": None}
return {"error": None, "shout": shout}