0.1.0-fixes
All checks were successful
deploy / deploy (push) Successful in 1m11s

This commit is contained in:
2023-12-22 12:09:03 +03:00
parent 5c6a680832
commit e22d5468ab
12 changed files with 340 additions and 171 deletions

72
resolvers/model.py Normal file
View File

@@ -0,0 +1,72 @@
import strawberry
from typing import List, Optional
from strawberry_sqlalchemy_mapper import StrawberrySQLAlchemyMapper
from orm.notification import Notification as NotificationMessage
strawberry_sqlalchemy_mapper = StrawberrySQLAlchemyMapper()
@strawberry_sqlalchemy_mapper.type(NotificationMessage)
class Notification:
id: int
action: str # create update delete join follow etc.
entity: str # REACTION SHOUT FOLLOWER
created_at: int
payload: str # JSON data
seen: List[int] # NOTE: adds author_id when seen
# TODO: add recipient defining field
@strawberry.type
class NotificationSeenResult:
error: str | None
@strawberry.type
class NotificationAuthor:
id: int
slug: str
name: str
pic: str
following_id: Optional[int]
@strawberry.type
class NotificationShout:
id: int
slug: str
title: str
created_at: int
authors: List[NotificationAuthor]
@strawberry.type
class NotificationReaction:
id: int
kind: str
shout: NotificationShout
reply_to: int
created_by: NotificationAuthor
created_at: int
@strawberry.type
class NotificationGroup:
authors: List[NotificationAuthor]
updated_at: int
entity: str
action: Optional[str]
shout: Optional[NotificationShout]
reactions: Optional[List[int]]
# latest reaction.created_at for reactions-updates
# no timestamp for followers-updates
# latest shout.created_at for shouts-updates
# you are invited in authors list
@strawberry.type
class NotificationsResult:
notifications: List[NotificationGroup]
unread: int
total: int
error: Optional[str]