feat(im): add listFriends, addFriend, removeFriend to ImSDK
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
父节点
d7e7cd8e2d
当前提交
03261f3416
@ -424,6 +424,31 @@ export const ImSDK = {
|
|||||||
return ImSDK.sendMessage(toId, chatType, 'FILE', content)
|
return ImSDK.sendMessage(toId, chatType, 'FILE', content)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async listFriends(): Promise<string[]> {
|
||||||
|
const config = getConfig()
|
||||||
|
const res = await apiRequest<{ data?: string[] } | string[]>('/api/im/friends', {
|
||||||
|
params: { appId: config.appId },
|
||||||
|
})
|
||||||
|
if (Array.isArray(res)) return res
|
||||||
|
return (res as { data?: string[] }).data ?? []
|
||||||
|
},
|
||||||
|
|
||||||
|
async addFriend(friendId: string): Promise<void> {
|
||||||
|
const config = getConfig()
|
||||||
|
await apiRequest('/api/im/friends', {
|
||||||
|
method: 'POST',
|
||||||
|
params: { appId: config.appId, friendId },
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async removeFriend(friendId: string): Promise<void> {
|
||||||
|
const config = getConfig()
|
||||||
|
await apiRequest(`/api/im/friends/${encodeURIComponent(friendId)}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
params: { appId: config.appId },
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
disconnect(): void {
|
disconnect(): void {
|
||||||
client?.disconnect()
|
client?.disconnect()
|
||||||
client = null
|
client = null
|
||||||
|
|||||||
@ -1,5 +1,11 @@
|
|||||||
export { ImSDK } from './ImSDK'
|
export { ImSDK } from './ImSDK'
|
||||||
export type { ConversationData } from './ImSDK'
|
export type { ConversationData } from './ImSDK'
|
||||||
|
import { ImSDK as _ImSDK } from './ImSDK'
|
||||||
|
|
||||||
|
// Convenience named exports for friend APIs
|
||||||
|
export const listFriends = (): Promise<string[]> => _ImSDK.listFriends()
|
||||||
|
export const addFriend = (friendId: string): Promise<void> => _ImSDK.addFriend(friendId)
|
||||||
|
export const removeFriend = (friendId: string): Promise<void> => _ImSDK.removeFriend(friendId)
|
||||||
export { ImClient } from './ImClient'
|
export { ImClient } from './ImClient'
|
||||||
export { ImDatabase } from './db/ImDatabase'
|
export { ImDatabase } from './db/ImDatabase'
|
||||||
export type { MessageSearchParams } from './db/ImDatabase'
|
export type { MessageSearchParams } from './db/ImDatabase'
|
||||||
|
|||||||
@ -10,6 +10,7 @@ export { ScaledImage } from '../packages/common/src'
|
|||||||
export { ImSDK } from '../packages/im/src'
|
export { ImSDK } from '../packages/im/src'
|
||||||
export { ImClient } from '../packages/im/src'
|
export { ImClient } from '../packages/im/src'
|
||||||
export { uploadFile } from '../packages/im/src'
|
export { uploadFile } from '../packages/im/src'
|
||||||
|
export { listFriends, addFriend, removeFriend } from '../packages/im/src'
|
||||||
export type {
|
export type {
|
||||||
ImMessage, ImGroup, ChatType, MsgType, MsgStatus,
|
ImMessage, ImGroup, ChatType, MsgType, MsgStatus,
|
||||||
ImEventListener, SendMessageParams,
|
ImEventListener, SendMessageParams,
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户