From 051d35869b71436f6dbf57e905fb5504bcc382ab Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 22 Dec 2023 13:08:35 +0300 Subject: [PATCH] thread-id-fix --- resolvers/load.py | 6 ++++++ resolvers/model.py | 1 + services/auth.py | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/resolvers/load.py b/resolvers/load.py index 7afba79..c10d5eb 100644 --- a/resolvers/load.py +++ b/resolvers/load.py @@ -66,6 +66,7 @@ async def get_notifications_grouped( elif n.action == "create": print(f"[resolvers.schema] create shout: {shout}") notification_group = NotificationGroup( + id=thread_id, entity=n.entity, shout=shout, authors=shout.authors, @@ -105,6 +106,7 @@ async def get_notifications_grouped( reactions = [] reactions.append(reaction.id) notification_group = NotificationGroup( + id=thread_id, action=n.action, entity=n.entity, updated_at=reaction.created_at, @@ -122,6 +124,7 @@ async def get_notifications_grouped( notification_group = notifications.get(thread_id) if not notification_group: notification_group = NotificationGroup( + id=thread_id, authors=[follower], updated_at=int(time.time()), shout=None, @@ -129,6 +132,9 @@ async def get_notifications_grouped( entity="follower", action="follow", ) + else: + notification_group.authors = [follower, ] + notification_group.updated_at = int(time.time()) # store group in result notifications[thread_id] = notification_group counter += 1 diff --git a/resolvers/model.py b/resolvers/model.py index 2792322..fc3bdc2 100644 --- a/resolvers/model.py +++ b/resolvers/model.py @@ -52,6 +52,7 @@ class NotificationReaction: @strawberry.type class NotificationGroup: + id: str authors: List[NotificationAuthor] updated_at: int entity: str diff --git a/services/auth.py b/services/auth.py index 2a4fde8..1950811 100644 --- a/services/auth.py +++ b/services/auth.py @@ -47,9 +47,10 @@ async def check_auth(req) -> str | None: print(f"[services.auth] got user_id: {user_id}") return user_id except Exception as e: - + import traceback + traceback.print_exc() # Handling and logging exceptions during authentication check - print(f"[services.auth] {e}") + print(f"[services.auth] Error {e}") return None