From 94bf54b192e5074779a2dd6f1caaf0eac959e2bb Mon Sep 17 00:00:00 2001 From: Untone Date: Wed, 1 May 2024 02:38:17 +0300 Subject: [PATCH] get-my-shout-fix --- resolvers/editor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resolvers/editor.py b/resolvers/editor.py index 4ee98362..cf62f089 100644 --- a/resolvers/editor.py +++ b/resolvers/editor.py @@ -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}