Add frontend messaging experience
This commit is contained in:
10
frontend/src/api/message.ts
Normal file
10
frontend/src/api/message.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { postJson } from './client'
|
||||
import type { DirectMessage, ListMessagesResponse } from './types'
|
||||
|
||||
export function sendMessage(toId: number, content: string) {
|
||||
return postJson<DirectMessage>('/message/send', { to_id: toId, content }, { authRequired: true })
|
||||
}
|
||||
|
||||
export function listMessages(peerId: number) {
|
||||
return postJson<ListMessagesResponse>('/message/list', { peer_id: peerId }, { authRequired: true })
|
||||
}
|
||||
@@ -1,6 +1,19 @@
|
||||
export type MessageResponse = { message: string }
|
||||
|
||||
export type TokenResponse = { token: string; refresh_token?: string; account_id?: number; username?: string }
|
||||
export type MessageResponse = { message: string }
|
||||
|
||||
export type DirectMessage = {
|
||||
id: number
|
||||
from_id: number
|
||||
to_id: number
|
||||
content: string
|
||||
is_read: boolean
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type ListMessagesResponse = {
|
||||
messages: DirectMessage[]
|
||||
}
|
||||
|
||||
export type TokenResponse = { token: string; refresh_token?: string; account_id?: number; username?: string }
|
||||
|
||||
export type Account = {
|
||||
id: number
|
||||
|
||||
Reference in New Issue
Block a user