私聊功能未完成

This commit is contained in:
2026-06-12 20:24:18 +08:00
parent e16442f348
commit 6c0285c015
8 changed files with 640 additions and 112 deletions
+14 -2
View File
@@ -63,6 +63,7 @@ async function requestJSON<T>(path: string, init?: RequestInit): Promise<T> {
type ListQueryOptions = {
nodeId?: string
channelId?: string
since?: string
until?: string
}
@@ -73,6 +74,9 @@ function listPath(path: string, limit: number, offset: number, nodeIdOrOptions:
if (options.nodeId) {
params.set('node_id', options.nodeId)
}
if (options.channelId) {
params.set('channel_id', options.channelId)
}
if (options.since) {
params.set('since', options.since)
}
@@ -157,8 +161,8 @@ export function getEnabledMapSources(): Promise<PublicMapTileSourcesResponse> {
return getJSON<PublicMapTileSourcesResponse>('/api/map-source/enabled')
}
export function getTextMessages(limit = 100, offset = 0, nodeId = ''): Promise<ListResponse<TextMessage>> {
return getJSON<ListResponse<TextMessage>>(listPath('/api/text-messages', limit, offset, nodeId))
export function getTextMessages(limit = 100, offset = 0, nodeIdOrOptions: string | ListQueryOptions = ''): Promise<ListResponse<TextMessage>> {
return getJSON<ListResponse<TextMessage>>(listPath('/api/text-messages', limit, offset, nodeIdOrOptions))
}
export function deleteTextMessage(id: number): Promise<{ status: string }> {
@@ -373,6 +377,14 @@ export function getBotMessages(botId = 0, limit = 100, offset = 0): Promise<List
return getJSON<ListResponse<BotMessage>>(`/api/admin/bot/messages?${params.toString()}`)
}
export function getBotDirectTextMessages(botId: number, targetNodeNum: number, limit = 100, offset = 0, channelId = ''): Promise<ListResponse<TextMessage>> {
const params = new URLSearchParams({ bot_id: String(botId), target_node_num: String(targetNodeNum), limit: String(limit), offset: String(offset) })
if (channelId) {
params.set('channel_id', channelId)
}
return getJSON<ListResponse<TextMessage>>(`/api/admin/bot/direct-messages?${params.toString()}`)
}
export function sendBotMessage(payload: BotSendMessagePayload): Promise<BotMessageMutationResponse> {
return postJSON<BotMessageMutationResponse>('/api/admin/bot/messages', payload)
}