From 1099f8a185ff4289e3c1ea197be60ae4bdedc53f Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 5 Mar 2024 12:50:01 +0300 Subject: [PATCH] 401-ex --- resolvers/reader.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resolvers/reader.py b/resolvers/reader.py index 9a5ab425..fd0092dd 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -75,7 +75,9 @@ async def get_shout(_, info, slug=None, shout_id=None): author = session.query(Author).filter(Author.user == user_id).first() if not isinstance(author, Author): - return {'error': 'access denied'} + raise HTTPException( + status_code=401, detail='shout is not published yet' + ) author_id = author.id if author else None if ( @@ -84,7 +86,9 @@ async def get_shout(_, info, slug=None, shout_id=None): and not any(x == author_id for x in [a.id for a in shout.authors]) and 'editor' not in roles ): - return {'error': 'access denied'} + raise HTTPException( + status_code=401, detail='shout is not published yet' + ) shout.stat = { 'viewed': await ViewedStorage.get_shout(shout.slug),