notifier-draft-2

This commit is contained in:
2023-11-24 05:18:02 +03:00
parent ec20a4ebcd
commit 73797752f2
9 changed files with 283 additions and 11 deletions

View File

@@ -25,11 +25,11 @@ async def load_notifications(_, info, params=None):
notifications = []
with local_session() as session:
total_count = session.query(Notification).where(Notification.author == author_id).count()
total_count = session.query(Notification).where(Notification.user == user_id).count()
total_unread_count = (
session.query(Notification)
.where(and_(Notification.author == author_id, Notification.seen == False)) # noqa: E712
.where(and_(Notification.user == user_id, Notification.seen == False)) # noqa: E712
.count()
)
@@ -47,7 +47,7 @@ async def load_notifications(_, info, params=None):
@mutation.field("markNotificationAsRead")
@login_required
async def mark_notification_as_read(_, info, notification_id: int):
author_id = info.context["author_id"]
user_id = info.context["user_id"]
with local_session() as session:
notification = (
@@ -64,8 +64,7 @@ async def mark_notification_as_read(_, info, notification_id: int):
@mutation.field("markAllNotificationsAsRead")
@login_required
async def mark_all_notifications_as_read(_, info):
auth: AuthCredentials = info.context["request"].auth
user_id = auth.user_id
user_id = info.context["user_id"]
statement = (
update(Notification)