From 8e8952dd46f3d99a1ea6b9c969b708dd167e2698 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 18 Dec 2023 18:37:39 +0300 Subject: [PATCH] last-seen-mark-remove --- resolvers/follower.py | 4 ---- services/auth.py | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/resolvers/follower.py b/resolvers/follower.py index f9d48ce7..8eaf75af 100644 --- a/resolvers/follower.py +++ b/resolvers/follower.py @@ -95,10 +95,6 @@ async def get_my_followed(_, info): with local_session() as session: author = session.query(Author).filter(Author.user == user_id).first() if author: - # update author's last_seen timestamp - author.last_seen = time.time() - session.add(author) - authors_query = ( select(Author) .join(AuthorFollower, AuthorFollower.follower == Author.id) diff --git a/services/auth.py b/services/auth.py index 1d8cba24..240b79af 100644 --- a/services/auth.py +++ b/services/auth.py @@ -1,7 +1,7 @@ from functools import wraps -import aiohttp -from aiohttp.web import HTTPUnauthorized +from aiohttp import ClientSession +from starlette.exceptions import HTTPException from settings import AUTH_URL @@ -32,7 +32,7 @@ async def check_auth(req) -> str | None: } try: # Asynchronous HTTP request to the authentication server - async with aiohttp.ClientSession() as session: + async with ClientSession() as session: async with session.post(AUTH_URL, json=gql, headers=headers) as response: if response.status == 200: data = await response.json() @@ -47,7 +47,7 @@ async def check_auth(req) -> str | None: print(f"[services.auth] {e}") if not user_id: - raise HTTPUnauthorized(text="Please, login first") + raise HTTPException(status_code=401,detail="Unauthorized") def login_required(f):