add and remove reactions

This commit is contained in:
john 2025-05-28 20:49:08 +02:00
parent dab626f227
commit 48e7094c5e
6 changed files with 185 additions and 39 deletions

View file

@ -48,9 +48,7 @@ export class PostsService {
amount: number | null,
): Promise<Post[]> {
const response = await this.client.GET('/posts', {
params: {
query: { From: cursor ?? undefined, Amount: amount ?? undefined, Author: username },
},
query: { From: cursor ?? undefined, Amount: amount ?? undefined, Author: username },
credentials: 'include',
})
@ -60,6 +58,34 @@ export class PostsService {
return response.data?.posts.map((post) => Post.fromDto(post))
}
async addReaction(postId: string, emoji: string): Promise<void> {
const response = await this.client.POST('/posts/{postId}/reactions', {
params: {
path: { postId }
},
body: { emoji },
credentials: 'include',
})
if (!response.data) {
throw new Error('Failed to add reaction')
}
}
async removeReaction(postId: string, emoji: string): Promise<void> {
const response = await this.client.DELETE('/posts/{postId}/reactions', {
params: {
path: { postId }
},
body: { emoji },
credentials: 'include',
})
if (!response.data) {
throw new Error('Failed to remove reaction')
}
}
}
interface CreatePostMedia {