用户权限
enum UserProfileVisibility {
NOT_SET = 0,
INVISIBLE = 1,
EVERYONE = 2
}
已读回执响应信息
interface IReadReceiptResponseInfo {
isReceiptRequestMessage?: boolean,
hasRespond?: boolean,
readerList?: string[]
}
用户信息
interface IUserProfileInfo {
userId?: string,
name?: string,
portraitUri?: string,
uniqueId?: string,
email?: string,
birthday?: string,
gender?: number,
location?: string,
role?: number,
level?: number,
extraProfile?: {
key: string
}
}
更新用户资料
function updateMyUserProfile(profile: IUserProfileInfo): Promise<IAsyncRes<{
errorKey: string,
}>>
批量获取用户资料
function getUserProfiles(userIds: string[]): Promise<IAsyncRes<IUserProfileInfo[]>>
获取当前用户资料
function getMyUserProfile(): Promise<IAsyncRes<IUserProfileInfo>>
用户权限设置
function updateMyUserProfileVisibility(visibility: UserProfileVisibility): Promise<IAsyncRes<void>>
用户权限获取
function getMyUserProfileVisibility(): Promise<IAsyncRes<UserProfileVisibility>>
按用户应用号精确搜索用户信息
function searchUserProfileByUniqueId(uniqueId: string): Promise<IAsyncRes<IUserProfileInfo>>
消息审核状态
enum MessageAuditType {
DISALLOW = 0,
ALLOW = 1
}
消息审核配置结构
interface IAuditInfo {
audit?: {
auditType?: MessageAuditType,
project?: string,
strategy?: string,
}
}
上传方法
enum UploadMethod {
QINIU = 1,
ALI = 2,
AWS = 3,
STC = 4,
MINIO = 5
}
interface IMessageReadReceiptV4Response {
list: IMessageReader[],
readCount: number,
totalCount: number
}
v2 版本合并转发消息 content 结构
interface ICombineV2MessageContent {
conversationType: ConversationType,
summaryList: string[],
nameList: string[],
msgNum: number,
msgList?: ICombinedMessage[],
jsonMsgKey?: string,
remoteUrl?: string
}
代理信息
interface IProxy {
socksHost: string,
socksPort: number,
socksUsername?: string,
socksPassword?: string
}
下载鉴权信息
interface IDownloadAuth {
type: 0 | 1,
url?: string
}
设置指定会话类型的免打扰级别
function setConversationTypeNotificationLevel(conversationType: ConversationType, level: NotificationLevel): Promise<IAsyncRes<void>>
获取指定会话类型的免打扰级别
function getConversationTypeNotificationLevel(conversationType: ConversationType): Promise<IAsyncRes<NotificationLevel>>
获取本地全部会话的状态
function getAllConversationState(): Promise<IAsyncRes<IConversationState[]>>
当前服务器时间 校准时间,可能存在误差
function getServerTime(): number
(内部方法)用于统计各组件版本信息
function __addSDKVersion(name: string, version: string): void
type CombineV2MessageContent = ICombineV2MessageContent & IExtraData & IUserInfo & IMentionedInfo;
设置代理
function setProxy(proxy: null | IProxy): IPromiseResult<IProxy>
获取代理
function getProxy(): IPromiseResult<IProxy>
测试代理
function testProxy(proxy: IProxy, testHost: string): IPromiseResult<IResponse>
创建文件上传任务
function createUploadTask(uploadInfo: IUploadInfo): Promise<IAsyncRes<UploadTask>>
停止文件上传任务
function stopUploadTask(taskId: number): Promise<IAsyncRes<boolean>>
function upload(uploadInfo: IUploadInfo): Promise<IAsyncRes<IUploadResult>>
获取下载鉴权信息
function getDownloadAuth(url: string): Promise<IAsyncRes<{
deadline: number,
token?: string,
downloadAuthInfo?: IDownloadAuth,
}>>
上传任务
class UploadTask{
constructor(info: IUploadInfo, config: IUploadConfig),
private readonly _promise: Promise<IAsyncRes<IUploadResult>>,
private _resolve: ResolveFunc,
private _client: null | AUpload,
readonly id: number,
abort(undefined): unknown,
private _uploadInLoop(uploadUrlList: IUploadUrlInfo[], uploadInfo: IUploadInfo, getFileToken: (fileType: FileType, fileName?: string, httpMethod?: POST | PUT, queryString?: string, url?: string) => Promise<IUploadAuth & {
bos: string,
qiniu: string,
ossConfig: string,
}>, serverType?: number, failList: {
type: EUploadType,
url: string,
code: number,
msg: undefined | string,
}[] = []): unknown,
private _handleUpload(info: IUploadInfo, conf: IUploadConfig): unknown,
awaitResult(undefined): unknown
}
interface IUploadConfig {
getFileToken: (fileType: FileType, fileName?: string, httpMethod?: POST | PUT, queryString?: string, url?: string) => Promise<IUploadAuth & {
bos: string,
qiniu: string,
ossConfig: string,
}>,
getFileUrl: (fileType: FileType, fileName?: string, saveName?: string, uploadRes?: {
isBosRes: boolean,
downloadUrl: string,
}, serverType: UploadMethod) => Promise<{
downloadUrl: string,
}>,
customDomain: string,
serverType?: number,
ossConfig?: string,
uploadServer?: string,
bosAddr?: string
}
interface IUploadInfo {
file: File,
onProgress?: (loaded: number, total: number) => void,
fileType: FileType,
contentDisposition?: inline | attachment,
thumbnailConfig?: IThumbnailConfig
}
interface IUploadResult {
name: string,
downloadUrl: string,
uniqueName: string,
size: number,
type: string,
duration?: number,
length?: number,
thumbnail?: string,
width?: number,
height?: number
}
修改消息内容
function setMessageContent(messageId: number, content: Object, messageType: string): Promise<IAsyncRes<void>>
批量向本地插入消息
function batchInsertMessage(messages: IInsertMessage[], checkDuplicate: boolean): Promise<IAsyncRes<boolean>>
function setCheckChatRoomDuplicateMessage(checkDuplicate?: boolean): Promise<IAsyncRes<boolean>>
融云 IM 错误码
enum ErrorCode {
RC_USER_PROFILE_KEY_NOT_ALLOW_SDK_SET = 24360, RC_USER_PROFILE_KEY_NOT_EXIST = 24361, RC_USER_PROFILE_EXT_KEY_NOT_EXIST = 24362, RC_USER_PROFILE_EXT_KV_COUNT_EXCEED_LIMIT = 24363, RC_USER_PROFILE_VALUE_LENGTH_EXCEED_LIMIT = 24364, RC_USER_PROFILE_QUERY_COUNT_EXCEED_LIMIT = 24365, RC_USER_PROFILE_USER_NOT_EXIST = 24366, RC_USER_PROFILE_VALUE_CAN_ONLY_BE_NUMBERS = 24367, RC_USER_PROFILE_VALUE_EXCEED_RANGE = 24368, RC_USER_PROFILE_SERVICE_UNAVAILABLE = 24369, INVALID_PARAMETER_UNIQUE_ID = 34236, INVALID_PARAMETER_USER_PROFILE = 34312, INVALID_PARAMETER_USER_PROFILE_VISIBILITY = 34313,}
订阅类型
enum SubscribeType {
USER_PROFILE = 2,}
订阅关系信息
interface ISubscribeRelationInfo {
subscribeType: ONLINE_STATUS, subscribeType: SubscribeType,}
订阅用户状态信息
interface ISubscribeUserStatusInfo {
userProfile?: IUserProfileInfo, subscribeType: ONLINE_STATUS, subscribeType: SubscribeType,}
订阅用户状态
// 变更前
function subscribeUserStatus(userIds: string[], subscribeType: ONLINE_STATUS, expiry: number): Promise<IAsyncRes<string[]>>
// 变更后
function subscribeUserStatus(userIds: string[], subscribeType: SubscribeType, expiry: number): Promise<IAsyncRes<string[]>>
取消订阅用户状态
// 变更前
function unSubscribeUserStatus(userIds: string[], subscribeType: ONLINE_STATUS): Promise<IAsyncRes<void>>
// 变更后
function unSubscribeUserStatus(userIds: string[], subscribeType: SubscribeType): Promise<IAsyncRes<void>>
分页查询已订阅用户的状态信息
// 变更前
function getSubscribeUserList(subscribeType: ONLINE_STATUS, pageSize: number, offset: number): Promise<IAsyncRes<ISubscribeUserStatusInfo[]>>
// 变更后
function getSubscribeUserList(subscribeType: SubscribeType, pageSize: number, offset: number): Promise<IAsyncRes<ISubscribeUserStatusInfo[]>>
查询订阅状态信息
// 变更前
function getSubscribeUserStatus(subscribeType: ONLINE_STATUS, userIds: string[]): Promise<IAsyncRes<ISubscribeUserStatusInfo[]>>
// 变更后
function getSubscribeUserStatus(subscribeType: SubscribeType, userIds: string[]): Promise<IAsyncRes<ISubscribeUserStatusInfo[]>>
事件监听名称
enum Events {
OWN_USER_PROFILE_CHANGED = "OWN_USER_PROFILE_CHANGED",}
事件监听器
type EventListeners = { OWN_USER_PROFILE_CHANGED: (data: IUserProfileInfo) => void, SYNC_SUBSCRIBED_USER_STATUS_FINISHED: () => void, SYNC_SUBSCRIBED_USER_STATUS_FINISHED: (type: SubscribeType) => void,}