-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
59 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from __future__ import annotations | ||
from datetime import datetime | ||
from typing import TYPE_CHECKING | ||
from mipac.manager.client import ClientActions | ||
from mipac.manager.reaction import ReactionManager | ||
from mipac.models.lite.user import UserLite | ||
from mipac.models.note import Note | ||
|
||
if TYPE_CHECKING: | ||
from mipac.types.notification import IReactionNf | ||
|
||
|
||
class Reaction: | ||
def __init__( | ||
self, reaction: IReactionNf, *, client: ClientActions | ||
) -> None: | ||
self.__reaction: IReactionNf = reaction | ||
self.__client: ClientActions = client | ||
|
||
@property | ||
def id(self) -> str: | ||
return self.__reaction['id'] | ||
|
||
@property | ||
def created_at(self) -> datetime: | ||
return datetime.strptime( | ||
self.__reaction['created_at'], '%Y-%m-%dT%H:%M:%S.%fZ' | ||
) | ||
|
||
@property | ||
def type(self) -> str: | ||
return self.__reaction['type'] | ||
|
||
@property | ||
def is_read(self) -> bool: | ||
return self.__reaction['is_read'] | ||
|
||
@property | ||
def user(self) -> UserLite: | ||
return UserLite(self.__reaction['user']) | ||
|
||
@property | ||
def note(self) -> Note: | ||
return Note(self.__reaction['note'], client=self.__client) | ||
|
||
@property | ||
def reaction(self) -> str: | ||
return self.__reaction['reaction'] | ||
|
||
@property | ||
def action(self) -> ReactionManager: | ||
return self.__client.reaction |