From 6ac12c6f79b3a3e4d4882d5739aaf3957ee37c51 Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 22:20:33 +0300 Subject: [PATCH 1/2] =?UTF-8?q?attachment=5Fids=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D0=B5=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itd/client.py | 10 ++++++---- itd/routes/comments.py | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/itd/client.py b/itd/client.py index 714f5cd..9b8bd38 100644 --- a/itd/client.py +++ b/itd/client.py @@ -352,12 +352,13 @@ class Client: @refresh_on_error - def add_comment(self, post_id: UUID, content: str) -> Comment: + def add_comment(self, post_id: UUID, content: str, attachment_ids: list[UUID] = []) -> Comment: """Добавить комментарий Args: post_id (str): UUID поста content (str): Содержание + attachment_ids (list[UUID]): Список UUID прикреплённых файлов reply_comment_id (UUID | None, optional): ID коммента для ответа. Defaults to None. Raises: @@ -367,7 +368,7 @@ class Client: Returns: Comment: Комментарий """ - res = add_comment(self.token, post_id, content) + res = add_comment(self.token, post_id, content, attachment_ids) if res.status_code == 422 and 'found' in res.json(): raise ValidationError(*list(res.json()['found'].items())[0]) if res.json().get('error', {}).get('code') == 'NOT_FOUND': @@ -378,13 +379,14 @@ class Client: @refresh_on_error - def add_reply_comment(self, comment_id: UUID, content: str, author_id: UUID) -> Comment: + def add_reply_comment(self, comment_id: UUID, content: str, author_id: UUID, attachment_ids: list[UUID] = []) -> Comment: """Добавить ответный комментарий Args: comment_id (str): UUID комментария content (str): Содержание author_id (UUID | None, optional): ID пользователя, отправившего комментарий. Defaults to None. + attachment_ids (list[UUID]): Список UUID прикреплённых файлов Raises: ValidationError: Ошибка валидации @@ -393,7 +395,7 @@ class Client: Returns: Comment: Комментарий """ - res = add_reply_comment(self.token, comment_id, content, author_id) + res = add_reply_comment(self.token, comment_id, content, author_id, attachment_ids) if res.status_code == 500 and 'Failed query' in res.text: raise NotFound('User') if res.status_code == 422 and 'found' in res.json(): diff --git a/itd/routes/comments.py b/itd/routes/comments.py index d98ddf2..c211b17 100644 --- a/itd/routes/comments.py +++ b/itd/routes/comments.py @@ -2,11 +2,11 @@ from uuid import UUID from itd.request import fetch -def add_comment(token: str, post_id: UUID, content: str): - return fetch(token, 'post', f'posts/{post_id}/comments', {'content': content}) +def add_comment(token: str, post_id: UUID, content: str, attachment_ids: list[UUID] = []): + return fetch(token, 'post', f'posts/{post_id}/comments', {'content': content, "attachmentIds": list(map(str, attachment_ids))}) -def add_reply_comment(token: str, comment_id: UUID, content: str, author_id: UUID): - return fetch(token, 'post', f'comments/{comment_id}/replies', {'content': content, 'replyToUserId': str(author_id)}) +def add_reply_comment(token: str, comment_id: UUID, content: str, author_id: UUID, attachment_ids: list[UUID] = []): + return fetch(token, 'post', f'comments/{comment_id}/replies', {'content': content, 'replyToUserId': str(author_id), "attachmentIds": list(map(str, attachment_ids))}) def get_comments(token: str, post_id: UUID, limit: int = 20, cursor: int = 0, sort: str = 'popular'): return fetch(token, 'get', f'posts/{post_id}/comments', {'limit': limit, 'sort': sort, 'cursor': cursor}) From a547bbfdfb833866aa9182545d99426ddf540dbe Mon Sep 17 00:00:00 2001 From: Rationess Date: Tue, 3 Feb 2026 22:22:27 +0300 Subject: [PATCH 2/2] =?UTF-8?q?mime=5Ftype=20=D0=BD=D0=B5=20=D1=82=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D0=BA=D0=BE=20png=20=D1=82=D0=B0=D0=BC=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B6=D0=B5=D1=82=20=D0=B1=D1=8B=D1=82=D1=8C=20=D0=B8=20?= =?UTF-8?q?jpg=20=D0=B8=20gid.=20=D0=95=D1=89=D1=91=20=D0=B8=20=D0=B0?= =?UTF-8?q?=D1=83=D0=B4=D0=B8=D0=BE=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- itd/models/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itd/models/file.py b/itd/models/file.py index f7f34e7..635df8c 100644 --- a/itd/models/file.py +++ b/itd/models/file.py @@ -8,7 +8,7 @@ class File(BaseModel): id: UUID url: str filename: str - mime_type: str = Field('image/png', alias='mimeType') + mime_type: str = Field(alias='mimeType') size: int