mirror of
https://github.com/revanced/revanced-api.git
synced 2025-04-30 22:54:32 +02:00

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Alexandre Teles (afterSt0rm) <alexandre.teles@ufba.br>
38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
from data.models import AnnouncementDbModel
|
|
|
|
|
|
class ContentFields(dict):
|
|
message: str | None
|
|
attachment_urls: list[str] | None
|
|
|
|
|
|
class AnnouncementResponseModel(dict):
|
|
id: int
|
|
author: str | None
|
|
title: str
|
|
content: ContentFields | None
|
|
channel: str
|
|
created_at: str
|
|
level: int | None
|
|
|
|
@staticmethod
|
|
def to_response(announcement: AnnouncementDbModel):
|
|
response = AnnouncementResponseModel(
|
|
id=announcement.id,
|
|
author=announcement.author,
|
|
title=announcement.title,
|
|
content=ContentFields(
|
|
message=announcement.message,
|
|
attachment_urls=[
|
|
attachment.attachment_url for attachment in announcement.attachments
|
|
],
|
|
)
|
|
if announcement.message or announcement.attachments
|
|
else None,
|
|
channel=announcement.channel,
|
|
created_at=str(announcement.created_at),
|
|
level=announcement.level,
|
|
)
|
|
|
|
return response
|