feat: add models part 3

This commit is contained in:
firedotguy
2026-02-01 17:20:37 +03:00
parent 2a9f7da9a9
commit ba78457de5
13 changed files with 267 additions and 78 deletions

View File

@@ -1,7 +1,8 @@
from uuid import UUID
from itd.request import fetch
def get_hastags(token: str, limit: int = 10):
return fetch(token, 'get', 'hashtags/trending', {'limit': limit})
def get_posts_by_hastag(token: str, hashtag: str, limit: int = 20, cursor: int = 0):
def get_posts_by_hastag(token: str, hashtag: str, limit: int = 20, cursor: UUID | None = None):
return fetch(token, 'get', f'hashtags/{hashtag}/posts', {'limit': limit, 'cursor': cursor})

View File

@@ -1,16 +1,15 @@
from uuid import UUID
from itd.request import fetch
def get_notifications(token: str, limit: int = 20, cursor: int = 0, type: str | None = None):
data = {'limit': str(limit), 'cursor': str(cursor)}
if type:
data['type'] = type
return fetch(token, 'get', 'notifications', data)
def get_notifications(token: str, limit: int = 20, offset: int = 0):
return fetch(token, 'get', 'notifications', {'limit': limit, 'offset': offset})
def mark_as_read(token: str, id: str):
return fetch(token, 'post', f'notification/{id}/read')
def mark_as_read(token: str, id: UUID):
return fetch(token, 'post', f'notifications/{id}/read')
def mark_all_as_read(token: str):
return fetch(token, 'post', f'notification/read-all')
return fetch(token, 'post', f'notifications/read-all')
def get_unread_notifications_count(token: str):
return fetch(token, 'get', 'notifications/count')

View File

@@ -1,11 +1,13 @@
from uuid import UUID
from itd.request import fetch
def create_post(token: str, content: str, wall_recipient_id: int | None = None, attach_ids: list[str] = []):
def create_post(token: str, content: str, wall_recipient_id: UUID | None = None, attach_ids: list[UUID] = []):
data: dict = {'content': content}
if wall_recipient_id:
data['wallRecipientId'] = wall_recipient_id
data['wallRecipientId'] = str(wall_recipient_id)
if attach_ids:
data['attachmentIds'] = attach_ids
data['attachmentIds'] = list(map(str, attach_ids))
return fetch(token, 'post', 'posts', data)
@@ -20,28 +22,29 @@ def get_posts(token: str, username: str | None = None, limit: int = 20, cursor:
return fetch(token, 'get', 'posts', data)
def get_post(token: str, id: str):
def get_post(token: str, id: UUID):
return fetch(token, 'get', f'posts/{id}')
def edit_post(token: str, id: str, content: str):
def edit_post(token: str, id: UUID, content: str):
return fetch(token, 'put', f'posts/{id}', {'content': content})
def delete_post(token: str, id: str):
def delete_post(token: str, id: UUID):
return fetch(token, 'delete', f'posts/{id}')
def pin_post(token: str, id: str):
def pin_post(token: str, id: UUID):
return fetch(token, 'post', f'posts/{id}/pin')
def repost(token: str, id: str, content: str | None = None):
def repost(token: str, id: UUID, content: str | None = None):
data = {}
if content:
data['content'] = content
return fetch(token, 'post', f'posts/{id}/repost', data)
def view_post(token: str, id: str):
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})
# todo post restore
# todo post restore
# todo post like