feat: add models part 4

This commit is contained in:
firedotguy
2026-02-05 00:20:26 +03:00
parent dd7b8c077e
commit 55630bc23f
6 changed files with 208 additions and 41 deletions

View File

@@ -1,6 +1,7 @@
from uuid import UUID
from itd.request import fetch
from itd.enums import PostsTab
def create_post(token: str, content: str, wall_recipient_id: UUID | None = None, attach_ids: list[UUID] = []):
data: dict = {'content': content}
@@ -11,16 +12,8 @@ def create_post(token: str, content: str, wall_recipient_id: UUID | None = None,
return fetch(token, 'post', 'posts', data)
def get_posts(token: str, username: str | None = None, limit: int = 20, cursor: int = 0, sort: str = '', tab: str = ''):
data: dict = {'limit': limit, 'cursor': cursor}
if username:
data['username'] = username
if sort:
data['sort'] = sort
if tab:
data['tab'] = tab
return fetch(token, 'get', 'posts', data)
def get_posts(token: str, cursor: int = 0, tab: PostsTab = PostsTab.POPULAR):
return fetch(token, 'get', 'posts', {'cursor': cursor, 'tab': tab.value})
def get_post(token: str, id: UUID):
return fetch(token, 'get', f'posts/{id}')
@@ -43,8 +36,8 @@ def repost(token: str, id: UUID, content: str | None = None):
def view_post(token: str, id: UUID):
return fetch(token, 'post', f'posts/{id}/view')
def get_liked_posts(token: str, username: str, limit: int = 20, cursor: int = 0):
return fetch(token, 'get', f'posts/user/{username}/liked', {'limit': limit, 'cursor': cursor})
def get_liked_posts(token: str, username_or_id: str | UUID, limit: int = 20, cursor: int = 0):
return fetch(token, 'get', f'posts/user/{username_or_id}/liked', {'limit': limit})
# todo post restore
# todo post like