From e0b3562e80539eae4c15f098269b67f3e3f04035 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 20 May 2024 16:23:49 +0300 Subject: [PATCH] follow/unfollow-handling-noauthor --- resolvers/follower.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/resolvers/follower.py b/resolvers/follower.py index ed81c597..0090fd2b 100644 --- a/resolvers/follower.py +++ b/resolvers/follower.py @@ -41,10 +41,10 @@ async def cache_by_slug(what: str, slug: str): async def follow(_, info, what, slug): error = None user_id = info.context.get("user_id") - follower_dict = info.context["author"] - follower_id = follower_dict.get("id") - if not user_id or not follower_id: + follower_dict = info.context.get("author") + if not user_id or not follower_dict: return {"error": "unauthorized"} + follower_id = follower_dict.get("id") entity = what.lower() follows = [] @@ -91,13 +91,10 @@ async def unfollow(_, info, what, slug): follows = [] error = None user_id = info.context.get("user_id") - follower_dict = info.context["author"] - follower_id = follower_dict.get("id") - if not user_id: + follower_dict = info.context.get("author") + if not user_id or not follower_dict: return {"error": "unauthorized"} - - if not follower_id: - return {"error": "cant find follower account"} + follower_id = follower_dict.get("id") entity = what.lower() follows = []