74 lines
1.6 KiB
Python
74 lines
1.6 KiB
Python
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:
|
|
id: str
|
|
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]
|