diff --git a/package.json b/package.json index ac4fe26..76164a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-nim", - "version": "10.5.2", + "version": "10.6.0", "description": "NetEase IM nodejs wrapper based on NetEase IM C++ SDK", "main": "dist/node-nim.js", "bin": { diff --git a/src/callback_specialization.h b/src/callback_specialization.h index c051150..06ea849 100644 --- a/src/callback_specialization.h +++ b/src/callback_specialization.h @@ -211,6 +211,9 @@ CallbackSpecialization(V2NIMSuccessCallback); CallbackSpecialization(V2NIMSuccessCallback&>); CallbackSpecialization(V2NIMSuccessCallback); CallbackSpecialization(V2NIMSuccessCallback&>); +CallbackSpecialization(V2NIMSuccessCallback); +CallbackSpecialization(V2NIMSuccessCallback&>); +CallbackSpecialization(V2NIMSuccessCallback); namespace xpack { // std::function diff --git a/src/entry.cpp b/src/entry.cpp index b52e945..2fc06f4 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -42,6 +42,7 @@ #include "v2/v2_node_nim_login_service.h" #include "v2/v2_node_nim_message_service.h" #include "v2/v2_node_nim_notification_service.h" +#include "v2/v2_node_nim_passthrough_service.h" #include "v2/v2_node_nim_setting_service.h" #include "v2/v2_node_nim_signalling_service.h" #include "v2/v2_node_nim_storage_service.h" @@ -50,6 +51,7 @@ #include "v2/v2_node_nim_user_service.h" #include "v2/v2_node_nim_utilities.h" #include "v2_chatroom/v2_node_nim_chatroom_client.h" +#include "v2_chatroom/v2_node_nim_chatroom_queue_service.h" #include "v2_chatroom/v2_node_nim_chatroom_sdk.h" #include "v2_chatroom/v2_node_nim_chatroom_service.h" @@ -102,7 +104,9 @@ Napi::Object RegisterModule(Napi::Env env, Napi::Object exports) { node_nim::V2NodeNIMChatroomSdk::Init(env, exports); node_nim::V2NodeNIMChatroomClient::Init(env, exports); node_nim::V2NodeNIMChatroomService::Init(env, exports); - node_nim::V2NodeSubscriptionService::Init(env, exports); + node_nim::V2NodeNIMChatroomQueueService::Init(env, exports); + node_nim::V2NodeNIMSubscriptionService::Init(env, exports); + node_nim::V2NodeNIMPassthroughService::Init(env, exports); return exports; } diff --git a/src/nim/msglog/nim_node_msglog.cpp b/src/nim/msglog/nim_node_msglog.cpp index ff5567e..abd272a 100644 --- a/src/nim/msglog/nim_node_msglog.cpp +++ b/src/nim/msglog/nim_node_msglog.cpp @@ -9,40 +9,51 @@ namespace node_nim { Napi::Object NIMMsgLog::Init(Napi::Env env, Napi::Object exports) { - return InternalInit("NIMMsgLog", env, exports, - {RegApi("InitEventHandlers", &NIMMsgLog::InitEventHandlers), RegApi("QueryMsgByIDAysnc", &MsgLog::QueryMsgByIDAysnc), - RegApi("QueryMsgAsync", &MsgLog::QueryMsgAsync), - RegAmbApi("QueryMsgOnlineAsync", &MsgLog::QueryMsgOnlineAsync, - bool (*)(const MsgLog::QueryMsgOnlineAsyncParam&, const MsgLog::QueryMsgCallback&)), - RegApi("GetMessagesDynamically", &MsgLog::GetMessagesDynamically), - RegApi("QueryMsgByKeywordOnlineAsync", &MsgLog::QueryMsgByKeywordOnlineAsync), - RegApi("QueryMsgOfSpecifiedTypeInASessionAsync", &MsgLog::QueryMsgOfSpecifiedTypeInASessionAsync), - RegApi("QueryMsgByOptionsAsync", &MsgLog::QueryMsgByOptionsAsyncEx), RegApi("BatchStatusReadAsync", &MsgLog::BatchStatusReadAsync), - RegApi("BatchStatusDeleteAsync", &MsgLog::BatchStatusDeleteAsyncEx), RegApi("SetStatusAsync", &MsgLog::SetStatusAsync), - RegApi("SetSubStatusAsync", &MsgLog::SetSubStatusAsync), RegApi("WriteMsglogToLocalAsync", &MsgLog::WriteMsglogToLocalAsyncEx), - RegApi("DeleteBySessionTypeAsync", &MsgLog::DeleteBySessionTypeAsyncEx), RegApi("DeleteAsync", &MsgLog::DeleteAsync), - RegApi("DeleteAllAsync", &MsgLog::DeleteAllAsyncEx), RegApi("DeleteMsgByTimeAsync", &MsgLog::DeleteMsgByTimeAsyncEx), - RegApi("ExportDbAsync", &MsgLog::ExportDbAsync), RegApi("ImportDbAsync", &MsgLog::ImportDbAsync), - RegAmbApi("SendReceiptAsync", &MsgLog::SendReceiptAsync, void (*)(const IMMessage&, const MsgLog::MessageStatusChangedCallback&)), - RegApi("QuerySentMessageBeReaded", &MsgLog::QuerySentMessageBeReaded), - RegApi("QueryReceivedMsgReceiptSent", &MsgLog::QueryReceivedMsgReceiptSent), RegApi("UpdateLocalExtAsync", &MsgLog::UpdateLocalExtAsync), - RegApi("ReadAllAsync", &MsgLog::ReadAllAsync), RegApi("ExportBackupToRemote", &MsgLog::ExportBackupToRemote), - RegApi("ImportBackupFromRemote", &MsgLog::ImportBackupFromRemote), - RegApi("CancelImportBackupFromRemote", &MsgLog::CancelImportBackupFromRemote), - RegApi("CancelExportBackupToRemote", &MsgLog::CancelExportBackupToRemote), - RegAmbApi("DeleteHistoryOnlineAsync", &MsgLog::DeleteHistoryOnlineAsync, - void (*)(const std::string&, bool, const std::string&, const MsgLog::DeleteHistoryOnLineAsyncCallback&)), - RegAmbApi("DeleteHistoryOnlineAsyncEx", &MsgLog::DeleteHistoryOnlineAsync, - void (*)(const std::string&, nim::NIMSessionType, bool, const std::string&, const MsgLog::DeleteHistoryOnLineAsyncExCallback&)), - RegAmbApi("DeleteMessageSelfAsync", &MsgLog::DeleteMessageSelfAsync, - void (*)(const IMMessage&, const std::string, const MsgLog::DeleteMsglogSelfCallback&)), - RegApi("QueryMessageIsThreadRoot", &MsgLog::QueryMessageIsThreadRoot), RegApi("QueryMessageOnline", &MsgLog::QueryMessageOnline), - RegApi("QueryThreadHistoryMsg", &MsgLog::QueryThreadHistoryMsg), - RegApi("QueryLocalThreadHistoryMsg", &MsgLog::QueryLocalThreadHistoryMsg), - RegApi("FullTextSearchOnlineAsync", &MsgLog::FullTextSearchOnlineAsync), - RegApi("QueryMessagesByKeywordAsync", &MsgLog::QueryMessagesByKeywordAsync), - RegApi("IsMessageIndexEstablished", &MsgLog::IsMessageIndexEstablished), RegApi("BuildMsglogIndexes", &MsgLog::BuildMsglogIndexes), - RegApi("CancelMsglogIndexesBuilding", &MsgLog::CancelMsglogIndexesBuilding)}); + // clang-format off + return InternalInit("NIMMsgLog", env, exports,{ + RegApi("InitEventHandlers", &NIMMsgLog::InitEventHandlers), + RegApi("QueryMsgByIDAysnc", &MsgLog::QueryMsgByIDAysnc), + RegApi("QueryMsgAsync", &MsgLog::QueryMsgAsync), + RegAmbApi("QueryMsgOnlineAsync", &MsgLog::QueryMsgOnlineAsync, bool (*)(const MsgLog::QueryMsgOnlineAsyncParam&, const MsgLog::QueryMsgCallback&)), + RegApi("GetMessagesDynamically", &MsgLog::GetMessagesDynamically), + RegApi("QueryMsgByKeywordOnlineAsync", &MsgLog::QueryMsgByKeywordOnlineAsync), + RegApi("QueryMsgOfSpecifiedTypeInASessionAsync", &MsgLog::QueryMsgOfSpecifiedTypeInASessionAsync), + RegApi("QueryMsgByOptionsAsync", &MsgLog::QueryMsgByOptionsAsyncEx), + RegApi("BatchStatusReadAsync", &MsgLog::BatchStatusReadAsync), + RegApi("BatchStatusDeleteAsync", &MsgLog::BatchStatusDeleteAsyncEx), + RegApi("SetStatusAsync", &MsgLog::SetStatusAsync), + RegApi("SetSubStatusAsync", &MsgLog::SetSubStatusAsync), + RegApi("WriteMsglogToLocalAsync", &MsgLog::WriteMsglogToLocalAsyncEx), + RegApi("DeleteBySessionTypeAsync", &MsgLog::DeleteBySessionTypeAsyncEx), + RegApi("DeleteAsync", &MsgLog::DeleteAsync), + RegApi("DeleteAllAsync", &MsgLog::DeleteAllAsyncEx), + RegApi("DeleteMsgByTimeAsync", &MsgLog::DeleteMsgByTimeAsyncEx), + RegApi("ExportDbAsync", &MsgLog::ExportDbAsync), + RegApi("ImportDbAsync", &MsgLog::ImportDbAsync), + RegAmbApi("SendReceiptAsync", &MsgLog::SendReceiptAsync, void (*)(const IMMessage&, const MsgLog::MessageStatusChangedCallback&)), + RegApi("QuerySentMessageBeReaded", &MsgLog::QuerySentMessageBeReaded), + RegApi("QueryReceivedMsgReceiptSent", &MsgLog::QueryReceivedMsgReceiptSent), + RegApi("UpdateLocalExtAsync", &MsgLog::UpdateLocalExtAsync), + RegApi("ReadAllAsync", &MsgLog::ReadAllAsync), + RegApi("ExportBackupToRemote", &MsgLog::ExportBackupToRemote), + RegApi("ImportBackupFromRemote", &MsgLog::ImportBackupFromRemote), + RegApi("CancelImportBackupFromRemote", &MsgLog::CancelImportBackupFromRemote), + RegApi("CancelExportBackupToRemote", &MsgLog::CancelExportBackupToRemote), + RegAmbApi("DeleteHistoryOnlineAsync", &MsgLog::DeleteHistoryOnlineAsync, void (*)(const std::string&, bool, const std::string&, const MsgLog::DeleteHistoryOnLineAsyncCallback&)), + RegAmbApi("DeleteHistoryOnlineAsyncEx", &MsgLog::DeleteHistoryOnlineAsync, void (*)(const std::string&, nim::NIMSessionType, bool, const std::string&, const MsgLog::DeleteHistoryOnLineAsyncExCallback&)), + RegAmbApi("DeleteMessageSelfAsync", &MsgLog::DeleteMessageSelfAsync, void (*)(const IMMessage&, const std::string, const MsgLog::DeleteMsglogSelfCallback&)), + RegApi("QueryMessageIsThreadRoot", &MsgLog::QueryMessageIsThreadRoot), + RegApi("QueryMessageOnline", &MsgLog::QueryMessageOnline), + RegApi("QueryThreadHistoryMsg", &MsgLog::QueryThreadHistoryMsg), + RegApi("QueryLocalThreadHistoryMsg", &MsgLog::QueryLocalThreadHistoryMsg), + RegApi("FullTextSearchOnlineAsync", &MsgLog::FullTextSearchOnlineAsync), + RegApi("QueryMessagesByKeywordAsync", &MsgLog::QueryMessagesByKeywordAsync), + RegApi("IsMessageIndexEstablished", &MsgLog::IsMessageIndexEstablished), + RegApi("BuildMsglogIndexes", &MsgLog::BuildMsglogIndexes), + RegApi("CancelMsglogIndexesBuilding", &MsgLog::CancelMsglogIndexesBuilding), + RegApi("RegHistoryMessageFilterCb", &MsgLog::RegHistoryMessageFilterCb) + }); + // clang-format on } void NIMMsgLog::InitEventHandlers() { diff --git a/src/v2/v2_node_nim_friend_service.cpp b/src/v2/v2_node_nim_friend_service.cpp index d7c3498..fc4ad1b 100644 --- a/src/v2/v2_node_nim_friend_service.cpp +++ b/src/v2/v2_node_nim_friend_service.cpp @@ -17,6 +17,8 @@ Napi::Object node_nim::V2NodeNIMFriendService::Init(Napi::Env env, Napi::Object RegApi("getAddApplicationUnreadCount", &V2NIMFriendService::getAddApplicationUnreadCount), RegApi("setAddApplicationRead", &V2NIMFriendService::setAddApplicationRead), RegApi("searchFriendByOption", &V2NIMFriendService::searchFriendByOption), + RegApi("clearAllAddApplication", &V2NIMFriendService::clearAllAddApplication), + RegApi("deleteAddApplication", &V2NIMFriendService::deleteAddApplication), }); // clang-format on } diff --git a/src/v2/v2_node_nim_passthrough_service.cpp b/src/v2/v2_node_nim_passthrough_service.cpp new file mode 100644 index 0000000..37b523d --- /dev/null +++ b/src/v2/v2_node_nim_passthrough_service.cpp @@ -0,0 +1,33 @@ +/** + * @file v2_node_nim_passthrough_service.cpp + * @author Dylan (dengjiajia@corp.netease.com) + * @brief + * @date 2024/10/29 + */ + +#include "v2_node_nim_passthrough_service.h" + +namespace node_nim { + +Napi::Object V2NodeNIMPassthroughService::Init(Napi::Env env, Napi::Object exports) { + // clang-format off + return InternalInit("V2NIMPassthroughService", env, exports, { + RegApi("httpProxy", &V2NIMPassthroughService::httpProxy) + }); + // clang-format on +} + +V2NodeNIMPassthroughService::V2NodeNIMPassthroughService(const Napi::CallbackInfo& info) + : BizService("V2NIMPassthroughService", info) { + service_instance_ = &v2::V2NIMClient::get().getPassthroughService(); + initEventHandler(); +} + +void V2NodeNIMPassthroughService::initEventHandler() { + auto& passthrough_service = v2::V2NIMClient::get().getPassthroughService(); + V2NIMPassthroughListener listener; + listener.onProxyNotify = MakeNotifyCallback>("proxyNotify"); + passthrough_service.addPassthroughListener(listener); +} + +} // namespace node_nim diff --git a/src/v2/v2_node_nim_passthrough_service.h b/src/v2/v2_node_nim_passthrough_service.h new file mode 100644 index 0000000..0fb0150 --- /dev/null +++ b/src/v2/v2_node_nim_passthrough_service.h @@ -0,0 +1,25 @@ +/** + * @file v2_node_nim_passthrough_service.h + * @author Dylan (dengjiajia@corp.netease.com) + * @brief + * @date 2024/10/29 + */ + +#ifndef V2_NODE_NIM_PASSTHROUGH_SERVICE_H +#define V2_NODE_NIM_PASSTHROUGH_SERVICE_H + +#include +#include "service_base.h" + +namespace node_nim { + +class V2NodeNIMPassthroughService : public BizService { +public: + static Napi::Object Init(Napi::Env env, Napi::Object exports); + explicit V2NodeNIMPassthroughService(const Napi::CallbackInfo& info); + void initEventHandler(); +}; + +} // namespace node_nim + +#endif // V2_NODE_NIM_PASSTHROUGH_SERVICE_H diff --git a/src/v2/v2_node_nim_subscription_service.cpp b/src/v2/v2_node_nim_subscription_service.cpp index 3685a53..d2c6a96 100644 --- a/src/v2/v2_node_nim_subscription_service.cpp +++ b/src/v2/v2_node_nim_subscription_service.cpp @@ -9,7 +9,7 @@ namespace node_nim { -Napi::Object V2NodeSubscriptionService::Init(Napi::Env env, Napi::Object exports) { +Napi::Object V2NodeNIMSubscriptionService::Init(Napi::Env env, Napi::Object exports) { return InternalInit("V2NIMSubscriptionService", env, exports, { RegApi("subscribeUserStatus", &V2NIMSubscriptionService::subscribeUserStatus), @@ -19,13 +19,13 @@ Napi::Object V2NodeSubscriptionService::Init(Napi::Env env, Napi::Object exports }); } -V2NodeSubscriptionService::V2NodeSubscriptionService(const Napi::CallbackInfo& info) +V2NodeNIMSubscriptionService::V2NodeNIMSubscriptionService(const Napi::CallbackInfo& info) : BizService("V2NIMSubscriptionService", info) { service_instance_ = &v2::V2NIMClient::get().getSubscriptionService(); initEventHandler(); } -void V2NodeSubscriptionService::initEventHandler() { +void V2NodeNIMSubscriptionService::initEventHandler() { auto& subscription_service = v2::V2NIMClient::get().getSubscriptionService(); V2NIMSubscribeListener listener; listener.onUserStatusChanged = MakeNotifyCallback& status)>>("userStatusChanged"); diff --git a/src/v2/v2_node_nim_subscription_service.h b/src/v2/v2_node_nim_subscription_service.h index 1959e01..694589c 100644 --- a/src/v2/v2_node_nim_subscription_service.h +++ b/src/v2/v2_node_nim_subscription_service.h @@ -13,10 +13,10 @@ namespace node_nim { -class V2NodeSubscriptionService : public BizService { +class V2NodeNIMSubscriptionService : public BizService { public: static Napi::Object Init(Napi::Env env, Napi::Object exports); - explicit V2NodeSubscriptionService(const Napi::CallbackInfo& info); + explicit V2NodeNIMSubscriptionService(const Napi::CallbackInfo& info); void initEventHandler(); }; diff --git a/src/v2/v2_node_nim_team_service.cpp b/src/v2/v2_node_nim_team_service.cpp index 9c9f1fa..881c756 100644 --- a/src/v2/v2_node_nim_team_service.cpp +++ b/src/v2/v2_node_nim_team_service.cpp @@ -33,6 +33,8 @@ Napi::Object node_nim::V2NodeNIMTeamService::Init(Napi::Env env, Napi::Object ex {RegApi("searchTeamMembers", &V2NIMTeamService::searchTeamMembers)}, {RegApi("addTeamMembersFollow", &V2NIMTeamService::addTeamMembersFollow)}, {RegApi("removeTeamMembersFollow", &V2NIMTeamService::removeTeamMembersFollow)}, + {RegApi("clearAllTeamJoinActionInfo", &V2NIMTeamService::clearAllTeamJoinActionInfo)}, + {RegApi("deleteTeamJoinActionInfo", &V2NIMTeamService::deleteTeamJoinActionInfo)}, }); } diff --git a/src/v2_chatroom/v2_node_nim_chatroom_queue_service.cpp b/src/v2_chatroom/v2_node_nim_chatroom_queue_service.cpp new file mode 100644 index 0000000..52ea55f --- /dev/null +++ b/src/v2_chatroom/v2_node_nim_chatroom_queue_service.cpp @@ -0,0 +1,49 @@ +/** + * @file v2_node_nim_chatroom_queue_service.cpp + * @author Dylan (dengjiajia@corp.netease.com) + * @brief + * @date 2024/10/28 + */ + +#include "v2_node_nim_chatroom_queue_service.h" + +namespace node_nim { + +Napi::Object V2NodeNIMChatroomQueueService::Init(Napi::Env env, Napi::Object exports) { + // clang-format off + return InternalInit("V2NIMChatroomQueueService", env, exports,{ + RegApi("queueInit", &V2NIMChatroomQueueService::queueInit), + RegApi("queueDrop", &V2NIMChatroomQueueService::queueDrop), + RegApi("queueOffer", &V2NIMChatroomQueueService::queueOffer), + RegApi("queuePoll", &V2NIMChatroomQueueService::queuePoll), + RegApi("queuePeek", &V2NIMChatroomQueueService::queuePeek), + RegApi("queueList", &V2NIMChatroomQueueService::queueList), + RegApi("queueBatchUpdate", &V2NIMChatroomQueueService::queueBatchUpdate), + }); + // clang-format on +} + +V2NodeNIMChatroomQueueService::V2NodeNIMChatroomQueueService(const Napi::CallbackInfo& info) + : BizService("V2NIMChatroomQueueService", info) { + if (info.Length() != 2 || !info[1].IsNumber()) { + Napi::Error::New(info.Env(), "V2NIMChatroomQueueService: constructor: bad arguments").ThrowAsJavaScriptException(); + return; + } + auto instance_id = info[1].As().Int64Value(); + auto instance = v2::V2NIMChatroomClient::getInstance(instance_id); + v2::V2NIMChatroomQueueListener listener; + listener.onChatroomQueueOffered = MakeNotifyCallback>("chatroomQueueOffered"); + listener.onChatroomQueuePolled = MakeNotifyCallback>("chatroomQueuePolled"); + listener.onChatroomQueueDropped = MakeNotifyCallback>("chatroomQueueDropped"); + listener.onChatroomQueuePartCleared = + MakeNotifyCallback& keyValues)>>("chatroomQueuePartCleared"); + listener.onChatroomQueueBatchUpdated = + MakeNotifyCallback& keyValues)>>("chatroomQueueBatchUpdated"); + listener.onChatroomQueueBatchOffered = + MakeNotifyCallback& keyValues)>>("chatroomQueueBatchOffered"); + auto& chatroom_queue_service = instance->getChatroomQueueService(); + chatroom_queue_service.addQueueListener(listener); + service_instance_ = &chatroom_queue_service; +} + +} // namespace node_nim diff --git a/src/v2_chatroom/v2_node_nim_chatroom_queue_service.h b/src/v2_chatroom/v2_node_nim_chatroom_queue_service.h new file mode 100644 index 0000000..5fa7dee --- /dev/null +++ b/src/v2_chatroom/v2_node_nim_chatroom_queue_service.h @@ -0,0 +1,24 @@ +/** + * @file v2_node_nim_chatroom_queue_service.h + * @author Dylan (dengjiajia@corp.netease.com) + * @brief + * @date 2024/10/28 + */ + +#ifndef V2_NODE_NIM_CHATROOM_QUEUE_SERVICE_H +#define V2_NODE_NIM_CHATROOM_QUEUE_SERVICE_H + +#include +#include "service_base.h" + +namespace node_nim { + +class V2NodeNIMChatroomQueueService : public BizService { +public: + static Napi::Object Init(Napi::Env env, Napi::Object exports); + explicit V2NodeNIMChatroomQueueService(const Napi::CallbackInfo& info); +}; + +} // namespace node_nim + +#endif // V2_NODE_NIM_CHATROOM_QUEUE_SERVICE_H diff --git a/test/hooks.spec.js b/test/hooks.spec.js index e3f6aac..b03ea93 100644 --- a/test/hooks.spec.js +++ b/test/hooks.spec.js @@ -3,7 +3,9 @@ import assert from 'assert' exports.mochaHooks = { beforeAll: function (done) { - nim.client.init('', '', '', {}) + nim.client.init('', '', '', { + sdk_log_level_: 6, + }) nim.client.login( '45c6af3c98409b18a84451215d0bdd6e', 'jiajia01', diff --git a/test/test_chatroom_v2_spec.js b/test/test_chatroom_v2_spec.js index 630e752..9b27d2c 100644 --- a/test/test_chatroom_v2_spec.js +++ b/test/test_chatroom_v2_spec.js @@ -45,6 +45,20 @@ describe('******************** Chatroom ********************', function () { assert.strictEqual(instanceId, 0) }) }) + describe('#queueOffer', function () { + it('Offer queue should return with 0', async function () { + const queueService = chatroomInstance.getChatroomQueueService() + const spy = sinon.spy() + queueService.on('chatroomQueueOffered', spy) + await queueService.queueOffer({ + elementKey: 'test', + elementValue: 'test' + }) + // 延迟 5s + await new Promise(resolve => setTimeout(resolve, 5000)) + assert.strictEqual(spy.calledOnce, true) + }) + }) describe('#sendMessage', () => { it('Send message should trigger onSendMessage event', async function () { const spy = sinon.spy() diff --git a/test/test_msglog.js b/test/test_msglog.js index 3ab18e0..ad82f83 100644 --- a/test/test_msglog.js +++ b/test/test_msglog.js @@ -441,6 +441,25 @@ describe('********************Msglog********************', function () { }) }) }) + describe('#regHistoryMessageFilterCb', async function () { + it('regHistoryMessageFilterCb should return with 200', async function () { + NIM.nim.msgLog.regHistoryMessageFilterCb((message) => { + console.log('message filter running, messageID: ', message.client_msg_id_) + return message.client_msg_id_ === '9f9beab8-4486-7217-81ce-075716038eeb' + }) + const [code, account, toType, result] = await NIM.nim.msgLog.queryMsgOnlineAsync({ + id_: 'jiajia02', + to_type_: 0, + limit_count_: 10, + from_time_: 0, + end_time_: new Date().getTime(), + reverse_: false, + need_save_to_local_: true, + auto_download_attachment_: false + }) + console.log(result) + }) + }) }) describe('******************** Msglog thread ********************', function () { diff --git a/ts/nim/msglog.ts b/ts/nim/msglog.ts index c787d43..fe2e4bb 100644 --- a/ts/nim/msglog.ts +++ b/ts/nim/msglog.ts @@ -41,7 +41,8 @@ import { QueryMsgByKeywordParam, IsMessageIndexEstablishedCallback, BuildMsglogIndexesProgress, - BuildMsglogIndexesComplete + BuildMsglogIndexesComplete, + HistoryMessageFilter } from '../nim_def/msglog_def' import { NIMResCode } from '../nim_def/client_def' @@ -1080,4 +1081,13 @@ export class NIMMsgLog extends EventEmitter { cancelMsglogIndexesBuilding (): void { this.msglog.CancelMsglogIndexesBuilding() } + + /** + * @brief 注册云端历史消息拉取过滤器(堵塞线程,谨慎使用,避免耗时行为) + * @param filter 云端历史消息拉取过滤器 + * @return void + */ + regHistoryMessageFilterCb (filter: HistoryMessageFilter | null): void { + this.msglog.RegHistoryMessageFilterCb(filter) + } } diff --git a/ts/nim_def/msglog_def.ts b/ts/nim_def/msglog_def.ts index 8216683..7b7b484 100644 --- a/ts/nim_def/msglog_def.ts +++ b/ts/nim_def/msglog_def.ts @@ -653,6 +653,7 @@ export type FullTextSearchOnlineAsyncCallback = (rescode: NIMResCode, result: Qu export type IsMessageIndexEstablishedCallback = (is_established: boolean) => void export type BuildMsglogIndexesProgress = (total: number, built_count: number) => void export type BuildMsglogIndexesComplete = (reason: NIMBuildingMsglogIndexesCompleteReason, message: string) => void +export type HistoryMessageFilter = (result: IMMessage) => boolean export interface NIMMsgLogAPI { InitEventHandlers (): void @@ -796,4 +797,6 @@ export interface NIMMsgLogAPI { BuildMsglogIndexes (page_size: number, progress: BuildMsglogIndexesProgress | null, complete: BuildMsglogIndexesComplete | null): void CancelMsglogIndexesBuilding (): void + + RegHistoryMessageFilterCb (cb: HistoryMessageFilter | null): void } diff --git a/ts/v2/v2_nim_ai_service.ts b/ts/v2/v2_nim_ai_service.ts index 3f67d7e..ccc0194 100644 --- a/ts/v2/v2_nim_ai_service.ts +++ b/ts/v2/v2_nim_ai_service.ts @@ -1,56 +1,56 @@ import { - V2NIMAIUser, - V2NIMAIModelCallResponse, - V2NIMProxyAIModelCallParams, - V2NIMError + V2NIMAIUser, + V2NIMAIModelCallResponse, + V2NIMProxyAIModelCallParams, + V2NIMError } from 'ts/v2_def/v2_nim_struct_def' -import {EventEmitter} from "eventemitter3"; -import sdk from "../loader"; +import { EventEmitter } from 'eventemitter3' +import sdk from '../loader' -export declare interface V2NIMAIServiceEvents { - /** 数字人请求回调 */ - proxyAIModelCall: [V2NIMAIModelCallResponse] +export declare interface V2NIMAIListener { + /** 数字人请求回调 */ + proxyAIModelCall: [V2NIMAIModelCallResponse] } -export class V2NIMAIService extends EventEmitter { - instance: any +export class V2NIMAIService extends EventEmitter { + instance: any - constructor() { - super() - this.instance = new sdk.V2NIMAIService({emit: this.emit.bind(this)}) - } + constructor () { + super() + this.instance = new sdk.V2NIMAIService({ emit: this.emit.bind(this) }) + } - /** @brief 数字人拉取接口 */ - getAIUserList(): Promise> { - return new Promise((resolve, reject) => { - this.instance.getAIUserList( - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** @brief 数字人拉取接口 */ + getAIUserList (): Promise> { + return new Promise((resolve, reject) => { + this.instance.getAIUserList( + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** - * AI 数字人请求代理接口 - * @param params AI模型参数信息 - * @returns Promise - */ - proxyAIModelCall(params: V2NIMProxyAIModelCallParams): Promise { - return new Promise((resolve, reject) => { - this.instance.proxyAIModelCall( - params, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * AI 数字人请求代理接口 + * @param params AI模型参数信息 + * @returns Promise + */ + proxyAIModelCall (params: V2NIMProxyAIModelCallParams): Promise { + return new Promise((resolve, reject) => { + this.instance.proxyAIModelCall( + params, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } } diff --git a/ts/v2/v2_nim_chatroom_client.ts b/ts/v2/v2_nim_chatroom_client.ts index bc10c31..2455ea6 100644 --- a/ts/v2/v2_nim_chatroom_client.ts +++ b/ts/v2/v2_nim_chatroom_client.ts @@ -1,176 +1,293 @@ import { - V2NIMInitOption, - V2NIMError, - V2NIMChatroomEnterParams, - V2NIMChatroomEnterResult, - V2NIMChatroomInfo, - V2NIMChatroomKickedInfo + V2NIMInitOption, + V2NIMError, + V2NIMChatroomEnterParams, + V2NIMChatroomEnterResult, + V2NIMChatroomInfo, + V2NIMChatroomKickedInfo } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' import { EventEmitter } from 'eventemitter3' import { V2NIMChatroomService } from './v2_nim_chatroom_service' import { V2NIMStorageService } from './v2_nim_storage_service' +import { V2NIMChatroomQueueService } from './v2_nim_chatroom_queue_service' -export declare interface V2NIMChatroomClientEvents { - /** @brief 聊天室状态 */ - chatroomStatus: (status: number, error: V2NIMError) => void - /** @brief 进入聊天室 */ - chatroomEntered: () => void - /** @brief 退出聊天室 */ - chatroomExited: (error: V2NIMError) => void - /** @brief 自己被踢出聊天室 */ - chatroomKicked: (kickedInfo: V2NIMChatroomKickedInfo) => void +export declare interface V2NIMChatroomClientListener { + /** @brief 聊天室状态 */ + chatroomStatus: (status: number, error: V2NIMError) => void + /** @brief 进入聊天室 */ + chatroomEntered: () => void + /** @brief 退出聊天室 */ + chatroomExited: (error: V2NIMError) => void + /** @brief 自己被踢出聊天室 */ + chatroomKicked: (kickedInfo: V2NIMChatroomKickedInfo) => void } -export class V2NIMChatroomClient extends EventEmitter { - instance: any - chatroomService: V2NIMChatroomService - storageService: V2NIMStorageService - static chatroomSdk: any = new sdk.V2NIMChatroomSdk() - constructor(instanceId?: number) { - super() - this.instance = new sdk.V2NIMChatroomClient({ emit: this.emit.bind(this) }, instanceId) - this.chatroomService = new V2NIMChatroomService(this.instance.getInstanceId()) - this.storageService = new V2NIMStorageService(this.instance.getInstanceId()) - } - /** @brief 初始化 */ - /** @param option 初始化选项 */ - /** @return V2NIMError */ - static init(option: V2NIMInitOption): V2NIMError | null { - return V2NIMChatroomClient.chatroomSdk.init(option) - } +export class V2NIMChatroomClient extends EventEmitter { + instance: any + chatroomService: V2NIMChatroomService + chatroomQueueService: V2NIMChatroomQueueService + storageService: V2NIMStorageService + static chatroomSdk: any = new sdk.V2NIMChatroomSdk() - /** @brief 反初始化 */ - /** @return void */ - /** @warning 请在退出程序前调用此方法 */ - static uninit(): void { - return V2NIMChatroomClient.chatroomSdk.uninit() - } + constructor (instanceId?: number) { + super() + this.instance = new sdk.V2NIMChatroomClient({ emit: this.emit.bind(this) }, instanceId) + this.chatroomService = new V2NIMChatroomService(this.instance.getInstanceId()) + this.chatroomQueueService = new V2NIMChatroomQueueService(this.instance.getInstanceId()) + this.storageService = new V2NIMStorageService(this.instance.getInstanceId()) + } - /** @brief 创建聊天室客户端实例 */ - /** @return V2NIMChatroomClient */ - /** @pre 必须在调用此方法前调用 V2NIMChatroomClient::init */ - /** @note 建议保存持有实例 ID 而不是实例本身 */ - static newInstance(): V2NIMChatroomClient { - return new V2NIMChatroomClient() - } + /** + * @brief 初始化 + * @param option 初始化选项 + * @returns V2NIMError + * @example + * ```javascript + * const result = await V2NIMChatroomClient.init({ + * appKey: 'your app key' + * }) + * if (result) { + * console.error(result) + * } + * ``` + */ + static init (option: V2NIMInitOption): V2NIMError | null { + return V2NIMChatroomClient.chatroomSdk.init(option) + } - /** @brief 销毁聊天室客户端实例 */ - /** @param instanceId 聊天室客户端实例 ID */ - /** @return void */ - /** @pre 必须在调用此方法前调用 V2NIMChatroomClient::init */ - /** @warning 严禁在调用此方法后访问对应的聊天室客户端实例 */ - static destroyInstance(instanceId: number): void { - return V2NIMChatroomClient.chatroomSdk.destroyInstance(instanceId) - } + /** + * @brief 反初始化 + * @returns void + * @warning 请在退出程序前调用此方法 + * @example + * ```javascript + * V2NIMChatroomClient.uninit() + * ``` + */ + static uninit (): void { + return V2NIMChatroomClient.chatroomSdk.uninit() + } - /** @brief 获取聊天室客户端实例 */ - /** @return V2NIMChatroomClient */ - /** @pre 必须在调用此方法前调用 V2NIMChatroomClient::init */ - static getInstance(instanceId: number): V2NIMChatroomClient | null { - // check instanceId should be number - if (typeof instanceId !== 'number') { - return null - } - return new V2NIMChatroomClient(instanceId) - } + /** + * @brief 创建聊天室客户端实例 + * @returns V2NIMChatroomClient + * @pre 必须在调用此方法前调用 V2NIMChatroomClient::init + * @note 建议保存持有实例 ID 而不是实例本身 + * @example + * ```javascript + * const chatroomClient = V2NIMChatroomClient.newInstance() + * ``` + */ + static newInstance (): V2NIMChatroomClient { + return new V2NIMChatroomClient() + } - /** @brief 获取聊天室实例列表 */ - /** @return Array */ - /** @pre 必须在调用此方法前调用 V2NIMChatroomClient::init */ - static getInstanceList(): Array { - const instanceList = V2NIMChatroomClient.chatroomSdk.getInstanceIdList() - const result: Array = [] - for (const instanceId of instanceList) { - result.push(new V2NIMChatroomClient(instanceId)) - } - return result - } + /** + * @brief 销毁聊天室客户端实例 + * @param instanceId 聊天室客户端实例 ID + * @returns void + * @pre 必须在调用此方法前调用 V2NIMChatroomClient::init + * @warning 严禁在调用此方法后访问对应的聊天室客户端实例 + * @example + * ```javascript + * V2NIMChatroomClient.destroyInstance(instanceId) + * ``` + */ + static destroyInstance (instanceId: number): void { + return V2NIMChatroomClient.chatroomSdk.destroyInstance(instanceId) + } - /** @brief 销毁所有聊天室客户端实例 */ - /** @return void */ - /** @pre 必须在调用此方法前调用 V2NIMChatroomClient::init */ - /** @warning 严禁在调用此方法后访问任何聊天室客户端实例, 此方法会退出聊天室, 耗时可能较长 */ - static destroyAll(): void { - return V2NIMChatroomClient.chatroomSdk.destroyAll() + /** + * @param instanceId 聊天室客户端实例 ID + * @returns V2NIMChatroomClient + * @pre 必须在调用此方法前调用 V2NIMChatroomClient::init + * @example + * ```javascript + * const chatroomClient = V2NIMChatroomClient.getInstance(instanceId) + * ``` + */ + static getInstance (instanceId: number): V2NIMChatroomClient | null { + // check instanceId should be number + if (typeof instanceId !== 'number') { + return null } + return new V2NIMChatroomClient(instanceId) + } - /** @brief 获取聊天室客户端实例 ID */ - /** @return size_t */ - getInstanceId(): number { - return this.instance.getInstanceId() + /** + * @brief 获取聊天室实例列表 + * @returns Array + * @pre 必须在调用此方法前调用 V2NIMChatroomClient::init + * @example + * ```javascript + * const instanceList = V2NIMChatroomClient.getInstanceList() + * ``` + */ + static getInstanceList (): Array { + const instanceList = V2NIMChatroomClient.chatroomSdk.getInstanceIdList() + const result: Array = [] + for (const instanceId of instanceList) { + result.push(new V2NIMChatroomClient(instanceId)) } + return result + } - /** - * @brief 更新 appKey - * @param appKey - 新的 App key - * @return V2NIMError | null - */ - updateAppKey(appKey: string): V2NIMError | null { - return this.instance.updateAppKey(appKey) - } + /** + * @brief 销毁所有聊天室客户端实例 + * @returns void + * @pre 必须在调用此方法前调用 V2NIMChatroomClient::init + * @warning 严禁在调用此方法后访问任何聊天室客户端实例, 此方法会退出聊天室, 耗时可能较长 + * @example + * ```javascript + * V2NIMChatroomClient.destroyAll() + * ``` + */ + static destroyAll (): void { + return V2NIMChatroomClient.chatroomSdk.destroyAll() + } - /** @brief 进入聊天室 */ - /** @param roomId 聊天室 ID */ - /** @param enterParams 进入聊天室相关参数 */ - /** @return void */ - enter(roomId: string, enterParams: V2NIMChatroomEnterParams): Promise { - if (enterParams.__linkProvider) { - enterParams.linkProvider = (account: string, roomId: string) => { - return enterParams.__linkProvider - } - } - if (enterParams.loginOption && enterParams.loginOption.__tokenProvider) { - enterParams.loginOption.tokenProvider = (account: string, roomId: string) => { - if (!enterParams.loginOption) { - return '' - } - return enterParams.loginOption.__tokenProvider - } + /** + * @brief 获取聊天室客户端实例 ID + * @returns size_t + * @example + * ```javascript + * const instanceId = chatroomClient.getInstanceId() + * ``` + */ + getInstanceId (): number { + return this.instance.getInstanceId() + } + + /** + * @brief 更新 appKey + * @param appKey - 新的 App key + * @returns V2NIMError | null + * @example + * ```javascript + * const result = chatroomClient.updateAppKey('your new app key') + * if (result) { + * console.error(result) + * } + * ``` + */ + updateAppKey (appKey: string): V2NIMError | null { + return this.instance.updateAppKey(appKey) + } + + /** + * @brief 进入聊天室 + * @param roomId 聊天室 ID + * @param enterParams 进入聊天室相关参数 + * @returns Promise + * @example + * ```javascript + * const result = await chatroomClient.enter('your room id', { + * accountId: 'your account id', + * token: 'your token', + * roomNick: 'your room nick', + * linkProvider: (roomId, account) => { + * return ['chatroom link...'] + * } + * }) + * if (result) { + * console.error(result) + * } + * ``` + */ + enter (roomId: string, enterParams: V2NIMChatroomEnterParams): Promise { + if (enterParams.__linkProvider) { + enterParams.linkProvider = (account: string, roomId: string) => { + return enterParams.__linkProvider + } + } + if (enterParams.loginOption && enterParams.loginOption.__tokenProvider) { + enterParams.loginOption.tokenProvider = (account: string, roomId: string) => { + if (!enterParams.loginOption) { + return '' } - if (enterParams.loginOption && enterParams.loginOption.__loginExtensionProvider) { - enterParams.loginOption.loginExtensionProvider = (account: string, roomId: string) => { - if (!enterParams.loginOption) { - return '' - } - return enterParams.loginOption.__loginExtensionProvider - } + return enterParams.loginOption.__tokenProvider + } + } + if (enterParams.loginOption && enterParams.loginOption.__loginExtensionProvider) { + enterParams.loginOption.loginExtensionProvider = (account: string, roomId: string) => { + if (!enterParams.loginOption) { + return '' } - return new Promise((resolve, reject) => { - this.instance.enter( - roomId, - enterParams, - (result: V2NIMChatroomEnterResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) + return enterParams.loginOption.__loginExtensionProvider + } } + return new Promise((resolve, reject) => { + this.instance.enter( + roomId, + enterParams, + (result: V2NIMChatroomEnterResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 退出聊天室 */ - /** @return void */ - exit(): void { - this.instance.exit() - } + /** + * @brief 退出聊天室 + * @returns void + * @example + * ```javascript + * chatroomClient.exit() + * ``` + */ + exit (): void { + this.instance.exit() + } - /** @brief 查询聊天室信息 */ - /** @return V2NIMChatroomInfo */ - getChatroomInfo(): V2NIMChatroomInfo { - return this.instance.getChatroomInfo() - } + /** + * @brief 查询聊天室信息 + * @returns V2NIMChatroomInfo + * @example + * ```javascript + * const chatroomInfo = chatroomClient.getChatroomInfo() + * ``` + */ + getChatroomInfo (): V2NIMChatroomInfo { + return this.instance.getChatroomInfo() + } - /** @brief 获取聊天室服务 */ - /** @return V2NIMChatroomService */ - getChatroomService(): V2NIMChatroomService { - return this.chatroomService - } + /** + * @brief 获取聊天室服务 + * @returns V2NIMChatroomService + * @example + * ```javascript + * const chatroomService = chatroomClient.getChatroomService() + * ``` + */ + getChatroomService (): V2NIMChatroomService { + return this.chatroomService + } - /** @brief 获取存储服务 */ - /** @return V2NIMStorageService */ - getStorageService(): V2NIMStorageService { - return this.storageService - } + /** + * @brief 获取聊天室队列服务 + * @returns V2NIMChatroomQueueService + * @example + * ```javascript + * const chatroomQueueService = chatroomClient.getChatroomQueueService() + * ``` + */ + getChatroomQueueService (): V2NIMChatroomQueueService { + return this.chatroomQueueService + } + + /** + * @brief 获取存储服务 + * @returns V2NIMStorageService + * @example + * ```javascript + * const storageService = chatroomClient.getStorageService() + * ``` + */ + getStorageService (): V2NIMStorageService { + return this.storageService + } } diff --git a/ts/v2/v2_nim_chatroom_queue_service.ts b/ts/v2/v2_nim_chatroom_queue_service.ts new file mode 100644 index 0000000..f580e80 --- /dev/null +++ b/ts/v2/v2_nim_chatroom_queue_service.ts @@ -0,0 +1,166 @@ +import { EventEmitter } from 'eventemitter3' +import { V2NIMChatroomQueueElement, V2NIMChatroomQueueOfferParams, V2NIMError } from 'ts/v2_def/v2_nim_struct_def' +import sdk from '../loader' + +export declare interface V2NIMChatroomQueueListener { + /** 聊天室新增队列元素 */ + chatroomQueueOffered: [V2NIMChatroomQueueElement], + /** 聊天室移除队列元素 */ + chatroomQueuePolled: [V2NIMChatroomQueueElement], + /** 聊天室清空队列元素 */ + chatroomQueueDropped: [], + /** 聊天室清理部分队列元素 */ + chatroomQueuePartCleared: [Array], + /** 聊天室批量更新队列元素 */ + chatroomQueueBatchUpdated: [Array], + /** 聊天室批量添加队列元素 */ + chatroomQueueBatchOffered: [Array] +} + +export class V2NIMChatroomQueueService extends EventEmitter { + instance: any + + constructor (instanceId: number) { + super() + this.instance = new sdk.V2NIMChatroomQueueService({ emit: this.emit.bind(this) }, instanceId) + } + + /** + * @brief 初始化队列 + * @param size 初始化队列的长度,长度限制:0~1000 + * @returns Promise + * @example + * ```javascript + * await chatroomQueueService.queueInit(100) + * ``` + */ + queueInit (size: number): Promise { + return new Promise((resolve, reject) => { + this.instance.queueInit(size, () => { + resolve() + }, (error: V2NIMError) => { + reject(error) + }) + }) + } + + /** + * @brief 清空队列,仅管理员/创建者可以操作 + * @returns Promise + * @example + * ```javascript + * await chatroomQueueService.queueDrop() + * ``` + */ + queueDrop (): Promise { + return new Promise((resolve, reject) => { + this.instance.queueDrop(() => { + resolve() + }, (error: V2NIMError) => { + reject(error) + }) + }) + } + + /** + * @brief 聊天室队列新增或更新元素 + * @param params 新增或更新元素参数 + * @returns Promise + * @example + * ```javascript + * await chatroomQueueService.queueOffer({ + * elementKey: 'your element key', + * elementValue: 'your element value' + * }) + * ``` + */ + queueOffer (params: V2NIMChatroomQueueOfferParams): Promise { + return new Promise((resolve, reject) => { + this.instance.queueOffer(params, () => { + resolve() + }, (error: V2NIMError) => { + reject(error) + }) + }) + } + + /** + * @brief 取出头元素或者指定的元素 + * @param elementKey 指定的元素 key + * @returns Promise + * @example + * ```javascript + * const element = await chatroomQueueService.queuePoll('your element key') + * ``` + */ + queuePoll (elementKey: string): Promise { + return new Promise((resolve, reject) => { + this.instance.queuePoll(elementKey, (element: V2NIMChatroomQueueElement) => { + resolve(element) + }, (error: V2NIMError) => { + reject(error) + }) + }) + } + + /** + * @brief 查看队头元素, 不删除 + * @returns Promise + * @example + * ```javascript + * const element = await chatroomQueueService.queuePeek() + * ``` + */ + queuePeek (): Promise { + return new Promise((resolve, reject) => { + this.instance.queuePeek((element: V2NIMChatroomQueueElement) => { + resolve(element) + }, (error: V2NIMError) => { + reject(error) + }) + }) + } + + /** + * @brief 排序列出所有元素 + * @return Promise> + * @example + * ```javascript + * const elements = await chatroomQueueService.queueList() + * console.log(elements) + * ``` + */ + queueList (): Promise> { + return new Promise((resolve, reject) => { + this.instance.queueList((elements: Array) => { + resolve(elements) + }, (error: V2NIMError) => { + reject(error) + }) + }) + } + + /** + * @brief 批量更新队列元素 + * @param elements 需要更新的元素列表 + * @param notificationEnabled 是否发送通知 + * @param notificationExtension 通知扩展字段 + * @return Promise + * @example + * ```javascript + * const elementKeys = await chatroomQueueService.queueBatchUpdate([{ + * elementKey: 'your element key', + * elementValue: 'your element value' + * }], true, 'your notification extension') + * ``` + */ + queueBatchUpdate (elements: any[], notificationEnabled: boolean, notificationExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.queueBatchUpdate(elements, notificationEnabled, notificationExtension, (elementKeys: string[]) => { + resolve(elementKeys) + }, (error: V2NIMError) => { + reject(error) + }) + }) + } +} diff --git a/ts/v2/v2_nim_chatroom_service.ts b/ts/v2/v2_nim_chatroom_service.ts index 9efffda..44f3b72 100644 --- a/ts/v2/v2_nim_chatroom_service.ts +++ b/ts/v2/v2_nim_chatroom_service.ts @@ -1,388 +1,526 @@ import EventEmitter from 'eventemitter3' import { - V2NIMError, - V2NIMChatroomKickedInfo, - V2NIMChatroomMessage, - V2NIMChatroomMember, - V2NIMChatroomInfo, - V2NIMSendChatroomMessageParams, - V2NIMSendChatroomMessageResult, - V2NIMChatroomMemberQueryOption, - V2NIMChatroomMemberListResult, - V2NIMChatroomMessageListOption, - V2NIMChatroomMemberRoleUpdateParams, - V2NIMChatroomUpdateParams, - V2NIMAntispamConfig, - V2NIMChatroomSelfMemberUpdateParams, - V2NIMChatroomTagTempChatBannedParams, - V2NIMChatroomTagMemberOption, - V2NIMChatroomLocationConfig, - V2NIMChatroomTagsUpdateParams, - V2NIMChatroomTagMessageOption + V2NIMError, + V2NIMChatroomKickedInfo, + V2NIMChatroomMessage, + V2NIMChatroomMember, + V2NIMChatroomInfo, + V2NIMSendChatroomMessageParams, + V2NIMSendChatroomMessageResult, + V2NIMChatroomMemberQueryOption, + V2NIMChatroomMemberListResult, + V2NIMChatroomMessageListOption, + V2NIMChatroomMemberRoleUpdateParams, + V2NIMChatroomUpdateParams, + V2NIMAntispamConfig, + V2NIMChatroomSelfMemberUpdateParams, + V2NIMChatroomTagTempChatBannedParams, + V2NIMChatroomTagMemberOption, + V2NIMChatroomLocationConfig, + V2NIMChatroomTagsUpdateParams, + V2NIMChatroomTagMessageOption } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' import { V2NIMChatroomMemberRole } from 'ts/v2_def/v2_nim_enum_def' -export declare interface V2NIMChatroomServiceEvents { - /** 收到新消息 */ - receiveMessages: [V2NIMChatroomMessage[]] - /** 聊天室成员进入 */ - chatroomMemberEnter: [V2NIMChatroomMember] - /** 聊天室成员退出 */ - chatroomMemberExit: [string] - /** 聊天室成员角色变更 */ - chatroomMemberRoleUpdated: [V2NIMChatroomMemberRole, V2NIMChatroomMember] - /** 聊天室成员信息更新 */ - chatroomMemberInfoUpdated: [V2NIMChatroomMember] - /** 自己的禁言状态变更 */ - selfChatBannedUpdated: [boolean] - /** 自己的临时禁言状态变更 */ - selfTempChatBannedUpdated: [boolean, number] - /** 聊天室信息更新 */ - chatroomInfoUpdated: [V2NIMChatroomInfo] - /** 聊天室禁言状态更新 */ - chatroomChatBannedUpdated: [boolean] - /** 消息撤回回调 */ - messageRevokedNotification: [string, number] - /** 角色标签更新 */ - chatroomTagsUpdated: [string[]] - /** 本端发送消息状态回调 */ - sendMessage: [V2NIMChatroomMessage] +export declare interface V2NIMChatroomListener { + /** 收到新消息 */ + receiveMessages: [V2NIMChatroomMessage[]] + /** 聊天室成员进入 */ + chatroomMemberEnter: [V2NIMChatroomMember] + /** 聊天室成员退出 */ + chatroomMemberExit: [string] + /** 聊天室成员角色变更 */ + chatroomMemberRoleUpdated: [V2NIMChatroomMemberRole, V2NIMChatroomMember] + /** 聊天室成员信息更新 */ + chatroomMemberInfoUpdated: [V2NIMChatroomMember] + /** 自己的禁言状态变更 */ + selfChatBannedUpdated: [boolean] + /** 自己的临时禁言状态变更 */ + selfTempChatBannedUpdated: [boolean, number] + /** 聊天室信息更新 */ + chatroomInfoUpdated: [V2NIMChatroomInfo] + /** 聊天室禁言状态更新 */ + chatroomChatBannedUpdated: [boolean] + /** 消息撤回回调 */ + messageRevokedNotification: [string, number] + /** 角色标签更新 */ + chatroomTagsUpdated: [string[]] + /** 本端发送消息状态回调 */ + sendMessage: [V2NIMChatroomMessage] } /** @brief 聊天室服务 */ -export class V2NIMChatroomService extends EventEmitter { - instance: any - constructor(instanceId: number) { - super() - this.instance = new sdk.V2NIMChatroomService({ emit: this.emit.bind(this) }, instanceId) - } - /** @brief 发送消息 */ - /** @param message 需要发送的消息体 */ - /** @param params 发送消息相关配置参数 */ - /** @return void */ - sendMessage(message: V2NIMChatroomMessage, params: V2NIMSendChatroomMessageParams): Promise { - return new Promise((resolve, reject) => { - this.instance.sendMessage( - message, - params, - (result: V2NIMSendChatroomMessageResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } +export class V2NIMChatroomService extends EventEmitter { + instance: any - /** @brief 取消文件消息附件上传 */ - /** @param message 要取消上传的文件消息 */ - cancelMessageAttachmentUpload(message: V2NIMChatroomMessage): Promise { - return new Promise((resolve, reject) => { - this.instance.cancelMessageAttachmentUpload( - message, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + constructor (instanceId: number) { + super() + this.instance = new sdk.V2NIMChatroomService({ emit: this.emit.bind(this) }, instanceId) + } - /** @brief 分页获取聊天室成员列表 */ - /** @param queryOption 查询选项 */ - /** @return void */ - getMemberListByOption(queryOption: V2NIMChatroomMemberQueryOption): Promise { - return new Promise((resolve, reject) => { - this.instance.getMemberListByOption( - queryOption, - (result: V2NIMChatroomMemberListResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 发送消息 + * @param message 需要发送的消息体 + * @param params 发送消息相关配置参数 + * @returns void + * @example + * ```javascript + * const message = V2NIMChatroomMessageCreator.createTextMessage('Hello NTES IM') + * await chatroomService.sendMessage(message, {}) + * ``` + */ + sendMessage (message: V2NIMChatroomMessage, params: V2NIMSendChatroomMessageParams): Promise { + return new Promise((resolve, reject) => { + this.instance.sendMessage( + message, + params, + (result: V2NIMSendChatroomMessageResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 查询历史消息 */ - /** @param option 查询选项 */ - /** @return void */ - getMessageList(option: V2NIMChatroomMessageListOption): Promise> { - return new Promise((resolve, reject) => { - this.instance.getMessageList( - option, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 取消上传消息附件 + * @param message 要取消上传的文件消息 + * @returns void + * @example + * ```javascript + * await chatroomService.cancelMessageAttachmentUpload(message) + * ``` + */ + cancelMessageAttachmentUpload (message: V2NIMChatroomMessage): Promise { + return new Promise((resolve, reject) => { + this.instance.cancelMessageAttachmentUpload( + message, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 更新聊天室成员角色 */ - /** @param accountId 聊天室成员 id */ - /** @param upadateParams 更新参数 */ - /** @return void */ - updateMemberRole(accountId: string, upadateParams: V2NIMChatroomMemberRoleUpdateParams): Promise { - return new Promise((resolve, reject) => { - this.instance.updateMemberRole( - accountId, - upadateParams, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 查询聊天室成员列表 + * @param queryOption 查询选项 + * @returns V2NIMChatroomMemberListResult + * @example + * ```javascript + * const result = await chatroomService.getMemberListByOption({ + * limit: 10 + * }) + * console.log(result) + * ``` + */ + getMemberListByOption (queryOption: V2NIMChatroomMemberQueryOption): Promise { + return new Promise((resolve, reject) => { + this.instance.getMemberListByOption( + queryOption, + (result: V2NIMChatroomMemberListResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 设置聊天室成员黑名单状态 */ - /** @param accountId 聊天室成员 id */ - /** @param blocked 黑名单状态 */ - /** @param notificationExtension 通知扩展字段 */ - /** @return void */ - setMemberBlockedStatus(accountId: string, blocked: boolean, notificationExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.setMemberBlockedStatus( - accountId, - blocked, - notificationExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 查询聊天室消息列表 + * @param option 查询选项 + * @returns Array + * @example + * ```javascript + * const result = await chatroomService.getMessageList({ + * limit: 10 + * }) + * console.log(result) + * ``` + */ + getMessageList (option: V2NIMChatroomMessageListOption): Promise> { + return new Promise((resolve, reject) => { + this.instance.getMessageList( + option, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 设置聊天室成员禁言状态 */ - /** @param accountId 聊天室成员 id */ - /** @param chatBanned 禁言状态 */ - /** @param notificationExtension 通知扩展字段 */ - /** @return void */ - setMemberChatBannedStatus(accountId: string, chatBanned: boolean, notificationExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.setMemberChatBannedStatus( - accountId, - chatBanned, - notificationExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 更新聊天室成员角色 + * @param accountId 聊天室成员 id + * @param upadateParams 更新参数 + * @returns void + * @example + * ```javascript + * await chatroomService.updateMemberRole('accountId', { + * memberRole: 2 + * }) + * ``` + */ + updateMemberRole (accountId: string, upadateParams: V2NIMChatroomMemberRoleUpdateParams): Promise { + return new Promise((resolve, reject) => { + this.instance.updateMemberRole( + accountId, + upadateParams, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 设置聊天室成员临时禁言状态 */ - /** @param accountId 聊天室成员 id */ - /** @param tempChatBannedDuration 临时禁言时长, 单位秒, 0 表示取消临时禁言 */ - /** @param notificationEnabled 是否发送通知 */ - /** @param notificationExtension 通知扩展字段 */ - /** @return void */ - setMemberTempChatBanned(accountId: string, tempChatBannedDuration: number, notificationEnabled: boolean, notificationExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.setMemberTempChatBanned( - accountId, - tempChatBannedDuration, - notificationEnabled, - notificationExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 设置聊天室成员黑名单状态 + * @param accountId 聊天室成员 id + * @param blocked 黑名单状态 + * @param notificationExtension 通知扩展字段 + * @returns void + * @example + * ```javascript + * await chatroomService.setMemberBlockedStatus('accountId', true, 'your notification extension') + * ``` + */ + setMemberBlockedStatus (accountId: string, blocked: boolean, notificationExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.setMemberBlockedStatus( + accountId, + blocked, + notificationExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 更新聊天室信息 */ - /** @param updateParams 更新参数 */ - /** @param antispamConfig 反垃圾配置 */ - /** @return void */ - updateChatroomInfo(updateParams: V2NIMChatroomUpdateParams, antispamConfig: V2NIMAntispamConfig): Promise { - return new Promise((resolve, reject) => { - this.instance.updateChatroomInfo( - updateParams, - antispamConfig, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 设置聊天室成员禁言状态 + * @param accountId 聊天室成员 id + * @param chatBanned 禁言状态 + * @param notificationExtension 通知扩展字段 + * @returns void + * @example + * ```javascript + * await chatroomService.setMemberChatBannedStatus('accountId', true, 'your notification extension') + * ``` + */ + setMemberChatBannedStatus (accountId: string, chatBanned: boolean, notificationExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.setMemberChatBannedStatus( + accountId, + chatBanned, + notificationExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 更新自己在聊天室的成员信息 */ - /** @param updateParams 更新参数 */ - /** @param antispamConfig 反垃圾配置 */ - /** @return void */ - updateSelfMemberInfo(updateParams: V2NIMChatroomSelfMemberUpdateParams, antispamConfig: V2NIMAntispamConfig): Promise { - return new Promise((resolve, reject) => { - this.instance.updateSelfMemberInfo( - updateParams, - antispamConfig, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 设置聊天室成员临时禁言状态 + * @param accountId 聊天室成员 id + * @param tempChatBannedDuration 临时禁言时长, 单位秒, 0 表示取消临时禁言 + * @param notificationEnabled 是否发送通知 + * @param notificationExtension 通知扩展字段 + * @returns void + * @example + * ```javascript + * await chatroomService.setMemberTempChatBanned('accountId', 10, true, 'your notification extension') + * ``` + */ + setMemberTempChatBanned (accountId: string, tempChatBannedDuration: number, notificationEnabled: boolean, notificationExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.setMemberTempChatBanned( + accountId, + tempChatBannedDuration, + notificationEnabled, + notificationExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 根据账号列表查询成员信息 */ - /** @param accountIds 账号列表 */ - /** @return void */ - getMemberByIds(accountIds: Array): Promise> { - return new Promise((resolve, reject) => { - this.instance.getMemberByIds( - accountIds, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 更新聊天室信息 + * @param updateParams 更新参数 + * @param antispamConfig 反垃圾配置 + * @returns void + * @example + * ```javascript + * await chatroomService.updateChatroomInfo({ + * roomName: 'new room name' + * }, {}) + * ``` + */ + updateChatroomInfo (updateParams: V2NIMChatroomUpdateParams, antispamConfig: V2NIMAntispamConfig): Promise { + return new Promise((resolve, reject) => { + this.instance.updateChatroomInfo( + updateParams, + antispamConfig, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 踢出聊天室成员 */ - /** @param accountId 聊天室成员 id */ - /** @param notificationExtension 通知扩展字段 */ - /** @return void */ - kickMember(accountId: string, notificationExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.kickMember( - accountId, - notificationExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 更新自己在聊天室的成员信息 + * @param updateParams 更新参数 + * @param antispamConfig 反垃圾配置 + * @returns void + * @example + * ```javascript + * await chatroomService.updateSelfMemberInfo({ + * roomNick: 'new room nickname' + * }, {}) + * ``` + */ + updateSelfMemberInfo (updateParams: V2NIMChatroomSelfMemberUpdateParams, antispamConfig: V2NIMAntispamConfig): Promise { + return new Promise((resolve, reject) => { + this.instance.updateSelfMemberInfo( + updateParams, + antispamConfig, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 按聊天室标签临时禁言 */ - /** @param params 设置标签禁言的参数 */ - /** @return void */ - setTempChatBannedByTag(params: V2NIMChatroomTagTempChatBannedParams): Promise { - return new Promise((resolve, reject) => { - this.instance.setTempChatBannedByTag( - params, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @param accountIds 账号列表 + * @returns Array + * @example + * ```javascript + * const result = await chatroomService.getMemberByIds(['accountId1', 'accountId2']) + * console.log(result) + * ``` + */ + getMemberByIds (accountIds: Array): Promise> { + return new Promise((resolve, reject) => { + this.instance.getMemberByIds( + accountIds, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 根据标签查询成员列表 */ - /** @param option 查询成员列表的参数 */ - /** @return void */ - getMemberListByTag(option: V2NIMChatroomTagMemberOption): Promise { - return new Promise((resolve, reject) => { - this.instance.getMemberListByTag( - option, - (result: V2NIMChatroomMemberListResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 踢出聊天室成员 + * @param accountId 聊天室成员 id + * @param notificationExtension 通知扩展字段 + * @returns void + * @example + * ```javascript + * await chatroomService.kickMember('accountId', 'your notification extension') + * ``` + */ + kickMember (accountId: string, notificationExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.kickMember( + accountId, + notificationExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 查询某个标签下的成员人数 */ - /** @param tag 标签 */ - /** @return void */ - getMemberCountByTag(tag: string): Promise { - return new Promise((resolve, reject) => { - this.instance.getMemberCountByTag( - tag, - (result: number) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 按聊天室标签临时禁言 + * @param params 设置标签禁言的参数 + * @returns void + * @example + * ```javascript + * await chatroomService.setTempChatBannedByTag({ + * targetTag: 'tag', + * duration: 10 + * }) + * ``` + */ + setTempChatBannedByTag (params: V2NIMChatroomTagTempChatBannedParams): Promise { + return new Promise((resolve, reject) => { + this.instance.setTempChatBannedByTag( + params, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 更新坐标信息 */ - /** @param locationConfig 坐标信息 */ - /** @return void */ - updateChatroomLocationInfo(locationConfig: V2NIMChatroomLocationConfig): Promise { - return new Promise((resolve, reject) => { - this.instance.updateChatroomLocationInfo( - locationConfig, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 根据标签查询成员列表 + * @param option 查询成员列表的参数 + * @returns V2NIMChatroomMemberListResult + * @example + * ```javascript + * const result = await chatroomService.getMemberListByTag({ + * tag: 'tag', + * limit: 10 + * }) + * ``` + */ + getMemberListByTag (option: V2NIMChatroomTagMemberOption): Promise { + return new Promise((resolve, reject) => { + this.instance.getMemberListByTag( + option, + (result: V2NIMChatroomMemberListResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 更新聊天室 tag 信息 */ - /** @param updateParams tag 更新的参数 */ - /** @return void */ - updateChatroomTags(updateParams: V2NIMChatroomTagsUpdateParams): Promise { - return new Promise((resolve, reject) => { - this.instance.updateChatroomTags( - updateParams, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 查询某个标签下的成员人数 + * @param tag 标签 + * @returns number + * @example + * ```javascript + * const count = await chatroomService.getMemberCountByTag('tag') + * ``` + */ + getMemberCountByTag (tag: string): Promise { + return new Promise((resolve, reject) => { + this.instance.getMemberCountByTag( + tag, + (result: number) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 根据标签查询消息列表 */ - /** @param messageOption 查询参数 */ - /** @return void */ - getMessageListByTag(messageOption: V2NIMChatroomTagMessageOption): Promise> { - return new Promise((resolve, reject) => { - this.instance.getMessageListByTag( - messageOption, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 更新坐标信息 + * @param locationConfig 坐标信息 + * @returns void + * @example + * ```javascript + * await chatroomService.updateChatroomLocationInfo({ + * latitude: 30.5, + * longitude: 120.5 + * }) + * ``` + */ + updateChatroomLocationInfo (locationConfig: V2NIMChatroomLocationConfig): Promise { + return new Promise((resolve, reject) => { + this.instance.updateChatroomLocationInfo( + locationConfig, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 更新聊天室 tag 信息 + * @param updateParams tag 更新的参数 + * @returns void + * @example + * ```javascript + * await chatroomService.updateChatroomTags({ + * tags: ['tag1', 'tag2'] + * }) + * ``` + */ + updateChatroomTags (updateParams: V2NIMChatroomTagsUpdateParams): Promise { + return new Promise((resolve, reject) => { + this.instance.updateChatroomTags( + updateParams, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据标签查询消息列表 + * @param messageOption 查询参数 + * @returns Array + * @example + * ```javascript + * const result = await chatroomService.getMessageListByTag({ + * tags: ['tag1', 'tag2'], + * limit: 10 + * }) + * ``` + */ + getMessageListByTag (messageOption: V2NIMChatroomTagMessageOption): Promise> { + return new Promise((resolve, reject) => { + this.instance.getMessageListByTag( + messageOption, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } } diff --git a/ts/v2/v2_nim_client.ts b/ts/v2/v2_nim_client.ts index 76bc35d..11ff9f4 100644 --- a/ts/v2/v2_nim_client.ts +++ b/ts/v2/v2_nim_client.ts @@ -11,211 +11,305 @@ import { V2NIMTeamService } from './v2_nim_team_service' import { V2NIMSettingService } from './v2_nim_setting_service' import { V2NIMFriendService } from './v2_nim_friend_service' import { V2NIMUserService } from './v2_nim_user_service' -import { V2NIMAIService } from "./v2_nim_ai_service" -import { V2NIMSignallingService } from "./v2_nim_signalling_service" -import { V2NIMSubscriptionService } from "./v2_nim_subscription_service"; +import { V2NIMAIService } from './v2_nim_ai_service' +import { V2NIMSignallingService } from './v2_nim_signalling_service' +import { V2NIMSubscriptionService } from './v2_nim_subscription_service' +import { V2NIMPassthroughService } from './v2_nim_passthrough_service' import { - V2NIMConversationIdUtil, - V2NIMMessageCreator, - V2NIMMessageConverter, - V2NIMClientAntispamUtil, - V2NIMStorageUtil, - V2NIMMessageAttachmentCreator + V2NIMConversationIdUtil, + V2NIMMessageCreator, + V2NIMMessageConverter, + V2NIMClientAntispamUtil, + V2NIMStorageUtil, + V2NIMMessageAttachmentCreator } from './v2_nim_utilities' -export declare interface V2NIMClientEvents {} - -export class V2NIMClient extends EventEmitter { - instance: any - conversationIdUtil: V2NIMConversationIdUtil | null - messageCreator: V2NIMMessageCreator | null - messageConverter: V2NIMMessageConverter | null - messageAttachmentCreator: V2NIMMessageAttachmentCreator | null - clientAntispamUtil: V2NIMClientAntispamUtil | null - storageUtil: V2NIMStorageUtil | null - loginService: V2NIMLoginService | null - conversationService: V2NIMConversationService | null - conversationGroupService: V2NIMConversationGroupService | null - messageService: V2NIMMessageService | null - notificationService: V2NIMNotificationService | null - storageService: V2NIMStorageService | null - teamService: V2NIMTeamService | null - settingService: V2NIMSettingService | null - userService: V2NIMUserService | null - friendService: V2NIMFriendService | null - aiService: V2NIMAIService | null - signallingService: V2NIMSignallingService | null - subscriptionService: V2NIMSubscriptionService | null - constructor() { - super() - try { - this.instance = new sdk.V2NIMClient({ emit: this.emit.bind(this) }) - } catch (e) { - console.error(e) - } - this.conversationIdUtil = null - this.messageCreator = null - this.messageConverter = null - this.messageAttachmentCreator = null - this.clientAntispamUtil = null - this.storageUtil = null - this.loginService = null - this.conversationService = null - this.conversationGroupService = null - this.messageService = null - this.notificationService = null - this.storageService = null - this.teamService = null - this.settingService = null - this.userService = null - this.friendService = null - this.aiService = null - this.signallingService = null - this.subscriptionService = null - } +export declare interface V2NIMClientListener {} - /** - * 初始化 - * @param option - 初始化选项 - * @returns V2NIMError | null - * @example - */ - init(option: V2NIMInitOption): V2NIMError | null { - let error = this.instance.init(option) - if (error) { - return error - } - this.conversationIdUtil = new V2NIMConversationIdUtil() - this.messageCreator = new V2NIMMessageCreator() - this.messageConverter = new V2NIMMessageConverter() - this.messageAttachmentCreator = new V2NIMMessageAttachmentCreator() - this.clientAntispamUtil = new V2NIMClientAntispamUtil() - this.storageUtil = new V2NIMStorageUtil() - this.loginService = new V2NIMLoginService() - this.conversationService = new V2NIMConversationService() - this.conversationGroupService = new V2NIMConversationGroupService() - this.messageService = new V2NIMMessageService() - this.notificationService = new V2NIMNotificationService() - this.storageService = new V2NIMStorageService() - this.teamService = new V2NIMTeamService() - this.settingService = new V2NIMSettingService() - this.userService = new V2NIMUserService() - this.friendService = new V2NIMFriendService() - this.aiService = new V2NIMAIService() - this.signallingService = new V2NIMSignallingService() - this.subscriptionService = new V2NIMSubscriptionService() - return null - } +export class V2NIMClient extends EventEmitter { + instance: any + conversationIdUtil: V2NIMConversationIdUtil | null + messageCreator: V2NIMMessageCreator | null + messageConverter: V2NIMMessageConverter | null + messageAttachmentCreator: V2NIMMessageAttachmentCreator | null + clientAntispamUtil: V2NIMClientAntispamUtil | null + storageUtil: V2NIMStorageUtil | null + loginService: V2NIMLoginService | null + conversationService: V2NIMConversationService | null + conversationGroupService: V2NIMConversationGroupService | null + messageService: V2NIMMessageService | null + notificationService: V2NIMNotificationService | null + storageService: V2NIMStorageService | null + teamService: V2NIMTeamService | null + settingService: V2NIMSettingService | null + userService: V2NIMUserService | null + friendService: V2NIMFriendService | null + aiService: V2NIMAIService | null + signallingService: V2NIMSignallingService | null + subscriptionService: V2NIMSubscriptionService | null + passthroughService: V2NIMPassthroughService | null - /** @brief 反初始化 - * @return V2NIMError | null - */ - uninit(): V2NIMError | null { - this.conversationIdUtil = null - this.messageCreator = null - this.messageAttachmentCreator = null - this.clientAntispamUtil = null - this.loginService = null - this.conversationService = null - this.conversationGroupService = null - this.messageService = null - this.notificationService = null - this.storageService = null - this.teamService = null - this.settingService = null - this.userService = null - this.friendService = null - this.aiService = null - this.signallingService = null - this.subscriptionService = null - return this.instance.uninit() + constructor () { + super() + try { + this.instance = new sdk.V2NIMClient({ emit: this.emit.bind(this) }) + } catch (e) { + console.error(e) } + this.conversationIdUtil = null + this.messageCreator = null + this.messageConverter = null + this.messageAttachmentCreator = null + this.clientAntispamUtil = null + this.storageUtil = null + this.loginService = null + this.conversationService = null + this.conversationGroupService = null + this.messageService = null + this.notificationService = null + this.storageService = null + this.teamService = null + this.settingService = null + this.userService = null + this.friendService = null + this.aiService = null + this.signallingService = null + this.subscriptionService = null + this.passthroughService = null + } - /** - * @brief 更新 appKey - * @param appKey - 新的 App key - * @return V2NIMError | null - */ - updateAppKey(appKey: string): V2NIMError | null { - return this.instance.updateAppKey(appKey) + /** + * @brief 初始化 + * @param option - 初始化选项 + * @returns V2NIMError | null + * @example + * ```javascript + * await client.init({ + * appkey: 'your app key' + * }) + * if (error) { + * console.error(error) + * } + * ``` + */ + init (option: V2NIMInitOption): V2NIMError | null { + let error = this.instance.init(option) + if (error) { + return error } + this.conversationIdUtil = new V2NIMConversationIdUtil() + this.messageCreator = new V2NIMMessageCreator() + this.messageConverter = new V2NIMMessageConverter() + this.messageAttachmentCreator = new V2NIMMessageAttachmentCreator() + this.clientAntispamUtil = new V2NIMClientAntispamUtil() + this.storageUtil = new V2NIMStorageUtil() + this.loginService = new V2NIMLoginService() + this.conversationService = new V2NIMConversationService() + this.conversationGroupService = new V2NIMConversationGroupService() + this.messageService = new V2NIMMessageService() + this.notificationService = new V2NIMNotificationService() + this.storageService = new V2NIMStorageService() + this.teamService = new V2NIMTeamService() + this.settingService = new V2NIMSettingService() + this.userService = new V2NIMUserService() + this.friendService = new V2NIMFriendService() + this.aiService = new V2NIMAIService() + this.signallingService = new V2NIMSignallingService() + this.subscriptionService = new V2NIMSubscriptionService() + this.passthroughService = new V2NIMPassthroughService() + return null + } - /** @brief 获取登录服务 - * @return V2NIMLoginService - */ - getLoginService(): V2NIMLoginService | null { - return this.loginService - } + /** + * @brief 反初始化 + * @returns V2NIMError | null + * @example + * ```javascript + * await client.uninit() + * if (error) { + * console.error(error) + * } + * ``` + */ + uninit (): V2NIMError | null { + this.conversationIdUtil = null + this.messageCreator = null + this.messageAttachmentCreator = null + this.clientAntispamUtil = null + this.loginService = null + this.conversationService = null + this.conversationGroupService = null + this.messageService = null + this.notificationService = null + this.storageService = null + this.teamService = null + this.settingService = null + this.userService = null + this.friendService = null + this.aiService = null + this.signallingService = null + this.subscriptionService = null + this.passthroughService = null + return this.instance.uninit() + } - /** @brief 获取会话服务 - /* @return V2NIMConversationService - */ - getConversationService(): V2NIMConversationService | null { - return this.conversationService - } + /** + * @brief 更新 appKey + * @param appKey - 新的 App key + * @returns V2NIMError | null + * @example + * ```javascript + * await client.updateAppKey('your new app key') + * if (error) { + * console.error(error) + * } + * ``` + */ + updateAppKey (appKey: string): V2NIMError | null { + return this.instance.updateAppKey(appKey) + } - /** @brief 获取会话分组服务 - * @return V2NIMConversationGroupService - */ - getConversationGroupService(): V2NIMConversationGroupService | null { - return this.conversationGroupService - } + /** + * @brief 获取登录服务 + * @returns V2NIMLoginService + * @example + * ```javascript + * const loginService = client.getLoginService() + * ``` + */ + getLoginService (): V2NIMLoginService | null { + return this.loginService + } - /** @brief 获取消息服务 - * @return V2NIMMessageService - */ - getMessageService(): V2NIMMessageService | null { - return this.messageService - } + /** + * @brief 获取会话服务 + * @returns V2NIMConversationService + * @example + * ```javascript + * const conversationService = client.getConversationService() + * ``` + */ + getConversationService (): V2NIMConversationService | null { + return this.conversationService + } - /** @brief 获取ai服务 - * @return V2NIMAIService - */ - getAIService(): V2NIMAIService | null { - return this.aiService - } + /** + * @brief 获取会话分组服务 + * @returns V2NIMConversationGroupService + * @example + * ```javascript + * const conversationGroupService = client.getConversationGroupService() + * ``` + */ + getConversationGroupService (): V2NIMConversationGroupService | null { + return this.conversationGroupService + } - /** @brief 获取通知服务 - * @return V2NIMNotificationService - */ - getNotificationService(): V2NIMNotificationService | null { - return this.notificationService - } + /** + * @brief 获取消息服务 + * @returns V2NIMMessageService + * @example + * ```javascript + * const messageService = client.getMessageService() + * ``` + */ + getMessageService (): V2NIMMessageService | null { + return this.messageService + } - /** @brief 获取存储服务 - * @return V2NIMStorageService - */ - getStorageService(): V2NIMStorageService | null { - return this.storageService - } + /** + * @brief 获取ai服务 + * @returns V2NIMAIService + * @example + * ```javascript + * const aiService = client.getAIService() + * ``` + */ + getAIService (): V2NIMAIService | null { + return this.aiService + } - /** @brief 获取群组服务 - * @return V2NIMTeamService - */ - getTeamService(): V2NIMTeamService | null { - return this.teamService - } + /** + * @brief 获取通知服务 + * @returns V2NIMNotificationService + * @example + * ```javascript + * const notificationService = client.getNotificationService() + * ``` + */ + getNotificationService (): V2NIMNotificationService | null { + return this.notificationService + } - /** @brief 获取设置服务 - * @return V2NIMSettingService - */ - getSettingService(): V2NIMSettingService | null { - return this.settingService - } + /** + * @brief 获取存储服务 + * @returns V2NIMStorageService + * @example + * ```javascript + * const storageService = client.getStorageService() + * ``` + */ + getStorageService (): V2NIMStorageService | null { + return this.storageService + } - /** - * @brief 获取独立信令服务 - * @return V2NIMSignallingService - */ - getSignallingService(): V2NIMSignallingService | null { - return this.signallingService - } + /** + * @brief 获取群组服务 + * @returns V2NIMTeamService + * @example + * ```javascript + * const teamService = client.getTeamService() + * ``` + */ + getTeamService (): V2NIMTeamService | null { + return this.teamService + } - /** - * @brief 获取订阅服务 - * @return V2NIMSubscriptionService - */ - getSubscriptionService(): V2NIMSubscriptionService | null { - return this.subscriptionService - } + /** + * @brief 获取设置服务 + * @returns V2NIMSettingService + * @example + * ```javascript + * const settingService = client.getSettingService() + * ``` + */ + getSettingService (): V2NIMSettingService | null { + return this.settingService + } + + /** + * @brief 获取独立信令服务 + * @returns V2NIMSignallingService + * @example + * ```javascript + * const signallingService = client.getSignallingService() + * ``` + */ + getSignallingService (): V2NIMSignallingService | null { + return this.signallingService + } + + /** + * @brief 获取订阅服务 + * @returns V2NIMSubscriptionService + * @example + * ```javascript + * const subscriptionService = client.getSubscriptionService() + * ``` + */ + getSubscriptionService (): V2NIMSubscriptionService | null { + return this.subscriptionService + } + + /** + * @brief 获取透传服务 + * @returns V2NIMPassthroughService + * @example + * ```javascript + * const passthroughService = client.getPasseThroughService() + * ``` + */ + getPasseThroughService (): V2NIMPassthroughService | null { + return this.passthroughService + } } diff --git a/ts/v2/v2_nim_conversation_group_service.ts b/ts/v2/v2_nim_conversation_group_service.ts index 6e77cd7..59d291d 100644 --- a/ts/v2/v2_nim_conversation_group_service.ts +++ b/ts/v2/v2_nim_conversation_group_service.ts @@ -1,175 +1,224 @@ import { - V2NIMConversationGroup, - V2NIMConversation, - V2NIMConversationGroupResult, - V2NIMError, - V2NIMConversationOperationResult + V2NIMConversationGroup, + V2NIMConversation, + V2NIMConversationGroupResult, + V2NIMError, + V2NIMConversationOperationResult } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' import { EventEmitter } from 'eventemitter3' -export declare interface V2NIMConversationGroupServiceEvents { - /** 会话分组创建通知 */ - conversationGroupCreated: [V2NIMConversationGroup] - /** 会话分组删除通知 */ - conversationGroupDeleted: [string] - /** 会话分组更新通知 */ - conversationGroupChanged: [V2NIMConversationGroup] - /** 会话加入会话分组通知 */ - conversationsAddedToGroup: [string, Array] - /** 会话移出会话分组通知 */ - conversationsRemovedFromGroup: [string, string[]] +export declare interface V2NIMConversationGroupListener { + /** 会话分组创建通知 */ + conversationGroupCreated: [V2NIMConversationGroup] + /** 会话分组删除通知 */ + conversationGroupDeleted: [string] + /** 会话分组更新通知 */ + conversationGroupChanged: [V2NIMConversationGroup] + /** 会话加入会话分组通知 */ + conversationsAddedToGroup: [string, Array] + /** 会话移出会话分组通知 */ + conversationsRemovedFromGroup: [string, string[]] } -export class V2NIMConversationGroupService extends EventEmitter { - instance: any - constructor() { - super() - this.instance = new sdk.V2NIMConversationGroupService({ emit: this.emit.bind(this) }) - } +export class V2NIMConversationGroupService extends EventEmitter { + instance: any - /** @brief 创建会话分组 - * @param name 会话分组名称 - * @param conversationIds 会话 ID 列表 - */ - createConversationGroup(name: string, serverExtension?: string, conversationIds?: string[]): Promise { - return new Promise((resolve, reject) => { - this.instance.createConversationGroup( - name, - serverExtension, - conversationIds, - (result: V2NIMConversationGroupResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + constructor () { + super() + this.instance = new sdk.V2NIMConversationGroupService({ emit: this.emit.bind(this) }) + } - /** @brief 删除会话分组 - * @param groupId 会话分组 ID - */ - deleteConversationGroup(groupId: string): Promise { - return new Promise((resolve, reject) => { - this.instance.deleteConversationGroup( - groupId, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 创建会话分组 + * @param name 会话分组名称 + * @param conversationIds 会话 ID 列表 + * @returns V2NIMConversationGroupResult + * @example + * ```javascript + * const result = await v2.conversationGroupService.createConversationGroup('group1', 'extension', ['conversation1', 'conversation2']) + * ``` + */ + createConversationGroup (name: string, serverExtension?: string, conversationIds?: string[]): Promise { + return new Promise((resolve, reject) => { + this.instance.createConversationGroup( + name, + serverExtension, + conversationIds, + (result: V2NIMConversationGroupResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 更新会话分组 - * @param groupId 会话分组 ID - * @param name 新的会话分组名称 - * @param serverExtension 扩展字段 - */ - updateConversationGroup(groupId: string, name?: string, serverExtension?: string): Promise { - return new Promise((resolve, reject) => { - this.instance.updateConversationGroup( - groupId, - name, - serverExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 删除会话分组 + * @param groupId 会话分组 ID + * @returns void + * @example + * ```javascript + * await v2.conversationGroupService.deleteConversationGroup('group1') + * ``` + */ + deleteConversationGroup (groupId: string): Promise { + return new Promise((resolve, reject) => { + this.instance.deleteConversationGroup( + groupId, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 添加会话到会话分组 - * @param groupId 会话分组 ID - * @param conversationIds 会话 ID 列表 - */ - addConversationsToGroup(groupId: string, conversationIds: string[]): Promise> { - return new Promise((resolve, reject) => { - this.instance.addConversationsToGroup( - groupId, - conversationIds, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 更新会话分组 + * @param groupId 会话分组 ID + * @param name 新的会话分组名称 + * @param serverExtension 扩展字段 + * @returns void + * @example + * ```javascript + * await v2.conversationGroupService.updateConversationGroup('group1', 'newName', 'newExtension') + * ``` + */ + updateConversationGroup (groupId: string, name?: string, serverExtension?: string): Promise { + return new Promise((resolve, reject) => { + this.instance.updateConversationGroup( + groupId, + name, + serverExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 从会话分组中移除会话 - * @param groupId 会话分组 ID - * @param conversationIds 会话 ID 列表 - */ - removeConversationsFromGroup(groupId: string, conversationIds: string[]): Promise> { - return new Promise((resolve, reject) => { - this.instance.removeConversationsFromGroup( - groupId, - conversationIds, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 添加会话到会话分组 + * @param groupId 会话分组 ID + * @param conversationIds 会话 ID 列表 + * @returns Array + * @example + * ```javascript + * const result = await v2.conversationGroupService.addConversationsToGroup('group1', ['conversation1', 'conversation2']) + * ``` + */ + addConversationsToGroup (groupId: string, conversationIds: string[]): Promise> { + return new Promise((resolve, reject) => { + this.instance.addConversationsToGroup( + groupId, + conversationIds, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 获取会话分组信息 - * @param groupId 会话分组 ID - */ - getConversationGroup(groupId: string): Promise { - return new Promise((resolve, reject) => { - this.instance.getConversationGroup( - groupId, - (group: V2NIMConversationGroup) => { - resolve(group) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 从会话分组中移除会话 + * @param groupId 会话分组 ID + * @param conversationIds 会话 ID 列表 + * @returns Array + * @example + * ```javascript + * const result = await v2.conversationGroupService.removeConversationsFromGroup('group1', ['conversation1', 'conversation2']) + * ``` + */ + removeConversationsFromGroup (groupId: string, conversationIds: string[]): Promise> { + return new Promise((resolve, reject) => { + this.instance.removeConversationsFromGroup( + groupId, + conversationIds, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 获取会话分组列表 - */ - getConversationGroupList(): Promise> { - return new Promise((resolve, reject) => { - this.instance.getConversationGroupList( - (list: Array) => { - resolve(list) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 获取会话分组信息 + * @param groupId 会话分组 ID + * @returns V2NIMConversationGroup + * @example + * ```javascript + * const group = await v2.conversationGroupService.getConversationGroup('group1') + * ``` + */ + getConversationGroup (groupId: string): Promise { + return new Promise((resolve, reject) => { + this.instance.getConversationGroup( + groupId, + (group: V2NIMConversationGroup) => { + resolve(group) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 根据会话分组 ID 获取会话分组 - * @param groupId 会话分组 ID - */ - getConversationGroupListByIds(groupIds: string[]): Promise> { - return new Promise((resolve, reject) => { - this.instance.getConversationGroupListByIds( - groupIds, - (list: Array) => { - resolve(list) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 获取会话分组列表 + * @returns Array + * @example + * ```javascript + * const list = await v2.conversationGroupService.getConversationGroupList() + * ``` + */ + getConversationGroupList (): Promise> { + return new Promise((resolve, reject) => { + this.instance.getConversationGroupList( + (list: Array) => { + resolve(list) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据会话分组 ID 获取会话分组 + * @param groupIds 会话分组 ID 列表 + * @returns Array + * @example + * ```javascript + * const list = await v2.conversationGroupService.getConversationGroupListByIds(['group1', 'group2']) + * ``` + */ + getConversationGroupListByIds (groupIds: string[]): Promise> { + return new Promise((resolve, reject) => { + this.instance.getConversationGroupListByIds( + groupIds, + (list: Array) => { + resolve(list) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } } diff --git a/ts/v2/v2_nim_conversation_service.ts b/ts/v2/v2_nim_conversation_service.ts index 659f52f..370fd0b 100644 --- a/ts/v2/v2_nim_conversation_service.ts +++ b/ts/v2/v2_nim_conversation_service.ts @@ -1,385 +1,508 @@ import { - V2NIMError, - V2NIMConversation, - V2NIMConversationFilter, - V2NIMConversationOperationResult, - V2NIMConversationUpdate, - V2NIMConversationResult, - V2NIMConversationOption + V2NIMError, + V2NIMConversation, + V2NIMConversationFilter, + V2NIMConversationOperationResult, + V2NIMConversationUpdate, + V2NIMConversationResult, + V2NIMConversationOption } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' import { EventEmitter } from 'eventemitter3' import { V2NIMConversationType } from 'ts/v2_def/v2_nim_enum_def' -export declare interface V2NIMConversationServiceEvents { - /** 会话同步开始通知 */ - syncStarted: [] - /** 会话同步完成通知 */ - syncFinished: [] - /** 会话同步错误通知 */ - syncFailed: [V2NIMError] - /** 会话创建通知 */ - conversationCreated: [V2NIMConversation] - /** 会话删除通知 */ - conversationDeleted: [Array] - /** 会话更新通知 */ - conversationChanged: [Array] - /** 会话总未读数变更通知 */ - totalUnreadCountChanged: [number] - /** 根据过滤条件订阅的会话未读数变更通知 */ - unreadCountChangedByFilter: [V2NIMConversationFilter, number] - /** 同账号多端标记会话 ACK 通知时间戳变更 */ - conversationReadTimeUpdated: [string, number] +export declare interface V2NIMConversationListener { + /** 会话同步开始通知 */ + syncStarted: [] + /** 会话同步完成通知 */ + syncFinished: [] + /** 会话同步错误通知 */ + syncFailed: [V2NIMError] + /** 会话创建通知 */ + conversationCreated: [V2NIMConversation] + /** 会话删除通知 */ + conversationDeleted: [Array] + /** 会话更新通知 */ + conversationChanged: [Array] + /** 会话总未读数变更通知 */ + totalUnreadCountChanged: [number] + /** 根据过滤条件订阅的会话未读数变更通知 */ + unreadCountChangedByFilter: [V2NIMConversationFilter, number] + /** 同账号多端标记会话 ACK 通知时间戳变更 */ + conversationReadTimeUpdated: [string, number] } -export class V2NIMConversationService extends EventEmitter { - instance: any - constructor() { - super() - this.instance = new sdk.V2NIMConversationService({ emit: this.emit.bind(this) }) - } +export class V2NIMConversationService extends EventEmitter { + instance: any - /** @brief 创建空会话 - * @param conversationId 会话 ID - */ - createConversation(conversationId: string): Promise { - return new Promise((resolve, reject) => { - this.instance.createConversation( - conversationId, - (conversation: V2NIMConversation) => { - resolve(conversation) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + constructor () { + super() + this.instance = new sdk.V2NIMConversationService({ emit: this.emit.bind(this) }) + } - /** @brief 删除会话 - * @param conversationId 会话 ID - * @param clearMessage 是否清除会话消息 - */ - deleteConversation(conversationId: string, clearMessage: boolean): Promise { - return new Promise((resolve, reject) => { - this.instance.deleteConversation( - conversationId, - clearMessage, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 创建空会话 + * @param conversationId 会话 ID + * @returns V2NIMConversation + * @example + * ```javascript + * const conversation = await v2.conversationService.createConversation('conversation1') + * ``` + */ + createConversation (conversationId: string): Promise { + return new Promise((resolve, reject) => { + this.instance.createConversation( + conversationId, + (conversation: V2NIMConversation) => { + resolve(conversation) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 批量删除会话 - * @param conversationIds 会话ID列表 - * @param clearMessage 是否清除会话消息 - */ - deleteConversationListByIds(conversationIds: string[], clearMessage: boolean): Promise> { - return new Promise((resolve, reject) => { - this.instance.deleteConversationListByIds( - conversationIds, - clearMessage, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 删除会话 + * @param conversationId 会话 ID + * @param clearMessage 是否清除会话消息 + * @returns void + * @example + * ```javascript + * await v2.conversationService.deleteConversation('conversation1', true) + * ``` + */ + deleteConversation (conversationId: string, clearMessage: boolean): Promise { + return new Promise((resolve, reject) => { + this.instance.deleteConversation( + conversationId, + clearMessage, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 置顶会话 - * @param conversationId 会话 ID - * @param stickTop 是否置顶 - */ - stickTopConversation(conversationId: string, stickTop: boolean): Promise { - return new Promise((resolve, reject) => { - this.instance.stickTopConversation( - conversationId, - stickTop, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 批量删除会话 + * @param conversationIds 会话ID列表 + * @param clearMessage 是否清除会话消息 + * @returns Array + * @example + * ```javascript + * const result = await v2.conversationService.deleteConversationListByIds(['conversation1', 'conversation2'], true) + * ``` + */ + deleteConversationListByIds (conversationIds: string[], clearMessage: boolean): Promise> { + return new Promise((resolve, reject) => { + this.instance.deleteConversationListByIds( + conversationIds, + clearMessage, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 更新会话 - * @param conversationId 会话 ID - * @param updateInfo 更新参数 - */ - updateConversation(conversationId: string, updateInfo: V2NIMConversationUpdate): Promise { - return new Promise((resolve, reject) => { - this.instance.updateConversation( - conversationId, - updateInfo, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 置顶会话 + * @param conversationId 会话 ID + * @param stickTop 是否置顶 + * @returns void + * @example + * ```javascript + * await v2.conversationService.stickTopConversation('conversation1', true) + * ``` + */ + stickTopConversation (conversationId: string, stickTop: boolean): Promise { + return new Promise((resolve, reject) => { + this.instance.stickTopConversation( + conversationId, + stickTop, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 更新会话本地扩展 - * @param conversationId 会话 ID - * @param localExtension 本地扩展 - */ - updateConversationLocalExtension(conversationId: string, localExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.updateConversationLocalExtension( - conversationId, - localExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 更新会话 + * @param conversationId 会话 ID + * @param updateInfo 更新参数 + * @returns void + * @example + * ```javascript + * await v2.conversationService.updateConversation('conversation1', { name: 'newName' }) + * ``` + */ + updateConversation (conversationId: string, updateInfo: V2NIMConversationUpdate): Promise { + return new Promise((resolve, reject) => { + this.instance.updateConversation( + conversationId, + updateInfo, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 获取会话 - * @param conversationId 会话 ID - */ - getConversation(conversationId: string): Promise { - return new Promise((resolve, reject) => { - this.instance.getConversation( - conversationId, - (conversation: V2NIMConversation) => { - resolve(conversation) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 更新会话本地扩展 + * @param conversationId 会话 ID + * @param localExtension 本地扩展 + * @returns void + * @example + * ```javascript + * await v2.conversationService.updateConversationLocalExtension('conversation1', 'newExtension') + * ``` + */ + updateConversationLocalExtension (conversationId: string, localExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.updateConversationLocalExtension( + conversationId, + localExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 分页获取会话列表 - * @param offset 分页偏移, 首页传 0, 后续拉取采用上一次返还的 offset - * @param limit 分页数量 - */ - getConversationList(offset: number, limit: number): Promise { - return new Promise((resolve, reject) => { - this.instance.getConversationList( - offset, - limit, - (result: V2NIMConversationResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** @brief 获取会话 + * @param conversationId 会话 ID + * @returns V2NIMConversation + * @example + * ```javascript + * const conversation = await v2.conversationService.getConversation('conversation1') + * ``` + */ + getConversation (conversationId: string): Promise { + return new Promise((resolve, reject) => { + this.instance.getConversation( + conversationId, + (conversation: V2NIMConversation) => { + resolve(conversation) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 根据会话ID获取会话列表 - * @param conversationIds 会话ID列表 - */ - getConversationListByIds(conversationIds: string[]): Promise> { - return new Promise((resolve, reject) => { - this.instance.getConversationListByIds( - conversationIds, - (list: Array) => { - resolve(list) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 分页获取会话列表 + * @param offset 分页偏移, 首页传 0, 后续拉取采用上一次返还的 offset + * @param limit 分页数量 + * @returns V2NIMConversationResult + * @example + * ```javascript + * const result = await v2.conversationService.getConversationList(0, 10) + * ``` + */ + getConversationList (offset: number, limit: number): Promise { + return new Promise((resolve, reject) => { + this.instance.getConversationList( + offset, + limit, + (result: V2NIMConversationResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 根据条件筛选分页获取会话列表 - * @param offset 分页偏移, 首页传 0, 后续拉取采用上一次返还的 offset - * @param limit 分页数量 - * @param option 查询参数 - */ - getConversationListByOption(offset: number, limit: number, option: V2NIMConversationOption): Promise { - return new Promise((resolve, reject) => { - this.instance.getConversationListByOption( - offset, - limit, - option, - (result: V2NIMConversationResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 根据会话ID获取会话列表 + * @param conversationIds 会话ID列表 + * @returns Array + * @example + * ```javascript + * const list = await v2.conversationService.getConversationListByIds(['conversation1', 'conversation2']) + * ``` + */ + getConversationListByIds (conversationIds: string[]): Promise> { + return new Promise((resolve, reject) => { + this.instance.getConversationListByIds( + conversationIds, + (list: Array) => { + resolve(list) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 获取会话未读总数 - * @param conversationId 会话 ID - * @return uint32_t 未读总数 - */ - getTotalUnreadCount(): number { - return this.instance.getTotalUnreadCount() - } + /** + * @brief 根据条件筛选分页获取会话列表 + * @param offset 分页偏移, 首页传 0, 后续拉取采用上一次返还的 offset + * @param limit 分页数量 + * @param option 查询参数 + * @returns V2NIMConversationResult + * @example + * ```javascript + * const result = await v2.conversationService.getConversationListByOption(0, 10, { + * conversationTypes: [1, 2] + * }) + * ``` + */ + getConversationListByOption (offset: number, limit: number, option: V2NIMConversationOption): Promise { + return new Promise((resolve, reject) => { + this.instance.getConversationListByOption( + offset, + limit, + option, + (result: V2NIMConversationResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 根据会话 ID 列表获取未读总数 - * @param conversationIds 会话 ID 列表 - */ - getUnreadCountByIds(conversationIds: string[]): Promise { - return new Promise((resolve, reject) => { - this.instance.getUnreadCountByIds( - conversationIds, - (count: number) => { - resolve(count) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 获取会话未读总数 + * @returns number + * @example + * ```javascript + * const count = await v2.conversationService.getTotalUnreadCount() + * ``` + */ + getTotalUnreadCount (): number { + return this.instance.getTotalUnreadCount() + } - /** @brief 根据过滤条件获取会话未读总数 - * @param filter 过滤条件 - */ - getUnreadCountByFilter(filter: V2NIMConversationFilter): Promise { - return new Promise((resolve, reject) => { - this.instance.getUnreadCountByFilter( - filter, - (count: number) => { - resolve(count) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** @brief 根据会话 ID 列表获取未读总数 + * @param conversationIds 会话 ID 列表 + * @returns number + * @example + * ```javascript + * const count = await v2.conversationService.getUnreadCountByIds(['conversation1', 'conversation2']) + * ``` + */ + getUnreadCountByIds (conversationIds: string[]): Promise { + return new Promise((resolve, reject) => { + this.instance.getUnreadCountByIds( + conversationIds, + (count: number) => { + resolve(count) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 清除会话总未读数 - */ - clearTotalUnreadCount(): Promise { - return new Promise((resolve, reject) => { - this.instance.clearTotalUnreadCount( - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 根据过滤条件获取会话未读总数 + * @param filter 过滤条件 + * @returns number + * @example + * ```javascript + * const count = await v2.conversationService.getUnreadCountByFilter({ conversationTypes: [1, 2] }) + * ``` + */ + getUnreadCountByFilter (filter: V2NIMConversationFilter): Promise { + return new Promise((resolve, reject) => { + this.instance.getUnreadCountByFilter( + filter, + (count: number) => { + resolve(count) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 根据会话 ID 列表清除会话未读数 - * @param conversationIds 会话 ID 列表 - */ - clearUnreadCountByIds(conversationIds: string[]): Promise> { - return new Promise((resolve, reject) => { - this.instance.clearUnreadCountByIds( - conversationIds, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 清除会话总未读数 + * @returns void + * @example + * ```javascript + * await v2.conversationService.clearTotalUnreadCount() + * ``` + */ + clearTotalUnreadCount (): Promise { + return new Promise((resolve, reject) => { + this.instance.clearTotalUnreadCount( + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 根据会话类型清除会话未读数 - * @param conversationTypes 会话类型列表 - */ - clearUnreadCountByTypes(conversationTypes: V2NIMConversationType[]): Promise { - return new Promise((resolve, reject) => { - this.instance.clearUnreadCountByTypes( - conversationTypes, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 根据会话 ID 列表清除会话未读数 + * @param conversationIds 会话 ID 列表 + * @returns Array + * @example + * ```javascript + * const result = await v2.conversationService.clearUnreadCountByIds(['conversation1', 'conversation2']) + * ``` + */ + clearUnreadCountByIds (conversationIds: string[]): Promise> { + return new Promise((resolve, reject) => { + this.instance.clearUnreadCountByIds( + conversationIds, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 根据会话分组清除会话未读数 - * @param groupId 会话分组ID - */ - clearUnreadCountByGroupId(groupId: string): Promise { - return new Promise((resolve, reject) => { - this.instance.clearUnreadCountByGroupId( - groupId, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 根据会话类型清除会话未读数 + * @param conversationTypes 会话类型列表 + * @returns void + * @example + * ```javascript + * await v2.conversationService.clearUnreadCountByTypes([1, 2]) + * ``` + */ + clearUnreadCountByTypes (conversationTypes: V2NIMConversationType[]): Promise { + return new Promise((resolve, reject) => { + this.instance.clearUnreadCountByTypes( + conversationTypes, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 标记会话已读时间戳 */ - /** @param conversationId 要标记的会话 ID */ - /** @return void */ - markConversationRead(conversationId: string): Promise { - return new Promise((resolve, reject) => { - this.instance.markConversationRead( - conversationId, - (ackTime: number) => { - resolve(ackTime) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 根据会话分组清除会话未读数 + * @param groupId 会话分组ID + * @returns void + * @example + * ```javascript + * await v2.conversationService.clearUnreadCountByGroupId('groupId') + * ``` + */ + clearUnreadCountByGroupId (groupId: string): Promise { + return new Promise((resolve, reject) => { + this.instance.clearUnreadCountByGroupId( + groupId, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** 获取会话已读时间戳 */ - /** @param conversationId 会话 ID */ - /** @return Promise 时间戳 */ - getConversationReadTime(conversationId: string): Promise { - return new Promise((resolve, reject) => { - this.instance.getConversationReadTime( - conversationId, - (time: number) => { - resolve(time) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 标记会话已读时间戳 + * @param conversationId 要标记的会话 ID + * @returns number + * @example + * ```javascript + * const time = await v2.conversationService.markConversationRead('conversation1') + * ``` + */ + markConversationRead (conversationId: string): Promise { + return new Promise((resolve, reject) => { + this.instance.markConversationRead( + conversationId, + (ackTime: number) => { + resolve(ackTime) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 订阅指定过滤条件的会话未读数 - * @param filter 过滤条件 - * @return void - */ - subscribeUnreadCountByFilter(filter: V2NIMConversationFilter): null | V2NIMError { - return this.instance.subscribeUnreadCountByFilter(filter) - } + /** + * @brief 获取会话已读时间戳 + * @param conversationId 会话 ID + * @returns Promise 时间戳 + * @example + * ```javascript + * const time = await v2.conversationService.getConversationReadTime('conversation1') + * ``` + */ + getConversationReadTime (conversationId: string): Promise { + return new Promise((resolve, reject) => { + this.instance.getConversationReadTime( + conversationId, + (time: number) => { + resolve(time) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 取消订阅指定过滤条件的会话未读数 - * @param filter 过滤条件 - * @return void - */ - unsubscribeUnreadCountByFilter(filter: V2NIMConversationFilter): null | V2NIMError { - return this.instance.unsubscribeUnreadCountByFilter(filter) - } + /** + * @brief 订阅指定过滤条件的会话未读数 + * @param filter 过滤条件 + * @returns null | V2NIMError + * @example + * ```javascript + * await v2.conversationService.subscribeUnreadCountByFilter({ conversationTypes: [1, 2] }) + * ``` + */ + subscribeUnreadCountByFilter (filter: V2NIMConversationFilter): null | V2NIMError { + return this.instance.subscribeUnreadCountByFilter(filter) + } + + /** + * @brief 取消订阅指定过滤条件的会话未读数 + * @param filter 过滤条件 + * @returns null | V2NIMError + * @example + * ```javascript + * await v2.conversationService.unsubscribeUnreadCountByFilter({ conversationTypes: [1, 2] }) + * ``` + */ + unsubscribeUnreadCountByFilter (filter: V2NIMConversationFilter): null | V2NIMError { + return this.instance.unsubscribeUnreadCountByFilter(filter) + } } diff --git a/ts/v2/v2_nim_friend_service.ts b/ts/v2/v2_nim_friend_service.ts index 1ceb69e..111c915 100644 --- a/ts/v2/v2_nim_friend_service.ts +++ b/ts/v2/v2_nim_friend_service.ts @@ -1,248 +1,375 @@ import { - V2NIMError, - V2NIMFriend, - V2NIMFriendAddApplication, - V2NIMFriendAddParams, - V2NIMFriendDeleteParams, - V2NIMFriendSetParams, - V2NIMFriendAddApplicationQueryOption, - V2NIMFriendAddApplicationResult, - V2NIMFriendSearchOption, + V2NIMError, + V2NIMFriend, + V2NIMFriendAddApplication, + V2NIMFriendAddApplicationQueryOption, + V2NIMFriendAddApplicationResult, + V2NIMFriendAddParams, + V2NIMFriendDeleteParams, + V2NIMFriendSearchOption, + V2NIMFriendSetParams, } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' import { EventEmitter } from 'eventemitter3' import { V2NIMFriendDeletionType } from 'ts/v2_def/v2_nim_enum_def' -export declare interface V2NIMFriendServiceEvents { - /** 添加好友 */ - friendAdded: [V2NIMFriend] - /** 删除好友 */ - friendDeleted: [string, V2NIMFriendDeletionType] - /** 添加好友申请 */ - friendAddApplication: [V2NIMFriendAddApplication] - /** 添加好友申请被拒绝 */ - friendAddRejected: [V2NIMFriendAddApplication] - /** 更新好友信息 */ - friendInfoChanged: [V2NIMFriend] +export declare interface V2NIMFriendListener { + /** 添加好友 */ + friendAdded: [V2NIMFriend] + /** 删除好友 */ + friendDeleted: [string, V2NIMFriendDeletionType] + /** 添加好友申请 */ + friendAddApplication: [V2NIMFriendAddApplication] + /** 添加好友申请被拒绝 */ + friendAddRejected: [V2NIMFriendAddApplication] + /** 更新好友信息 */ + friendInfoChanged: [V2NIMFriend] } /** @brief 好友服务 */ -export class V2NIMFriendService extends EventEmitter { - instance: any - constructor() { - super() - this.instance = new sdk.V2NIMFriendService({ emit: this.emit.bind(this) }) - } - /** @brief 添加好友 */ - /** @param accountId 账号 ID */ - /** @param params 添加好友参数 */ - /** @return void */ - addFriend(accountId: string, params: V2NIMFriendAddParams): Promise { - return new Promise((resolve, reject) => { - this.instance.addFriend( - accountId, - params, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 删除好友 */ - /** @param accountId 账号 ID */ - /** @param params 删除好友参数 */ - /** @return void */ - deleteFriend(accountId: string, params: V2NIMFriendDeleteParams): Promise { - return new Promise((resolve, reject) => { - this.instance.deleteFriend( - accountId, - params, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 接受好友申请 */ - /** @param application 好友申请 */ - /** @return void */ - acceptAddApplication(application: V2NIMFriendAddApplication): Promise { - return new Promise((resolve, reject) => { - this.instance.acceptAddApplication( - application, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 拒绝好友申请 */ - /** @param application 好友申请 */ - /** @param postscript 拒绝理由 */ - /** @return void */ - rejectAddApplication(application: V2NIMFriendAddApplication, postscript: String): Promise { - return new Promise((resolve, reject) => { - this.instance.rejectAddApplication( - application, - postscript, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 设置好友信息 */ - /** @param accountId 账号 ID */ - /** @param params 设置好友信息参数 */ - /** @return void */ - setFriendInfo(accountId: string, params: V2NIMFriendSetParams): Promise { - return new Promise((resolve, reject) => { - this.instance.setFriendInfo( - accountId, - params, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取好友列表 */ - /** @return void */ - getFriendList(): Promise> { - return new Promise((resolve, reject) => { - this.instance.getFriendList( - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 根据账号 ID 获取好友信息 */ - /** @param accountIds 账号 ID 列表 */ - /** @return void */ - getFriendByIds(accountIds: Array): Promise> { - return new Promise((resolve, reject) => { - this.instance.getFriendByIds( - accountIds, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 根据账号 ID 检查好友状态 */ - /** @param accountIds 账号 ID 列表 */ - /** @return void */ - checkFriend(accountIds: Array): Promise> { - return new Promise((resolve, reject) => { - this.instance.checkFriend( - accountIds, - (result: Map) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取申请添加好友信息列表 */ - /** @param option 查询申请添加好友相关信息参数 */ - /** @return void */ - getAddApplicationList(option: V2NIMFriendAddApplicationQueryOption): Promise { - return new Promise((resolve, reject) => { - this.instance.getAddApplicationList( - option, - (result: V2NIMFriendAddApplicationResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取申请添加好友未读数量 */ - /** @return void */ - getAddApplicationUnreadCount(): Promise { - return new Promise((resolve, reject) => { - this.instance.getAddApplicationUnreadCount( - (result: number) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 设置申请添加好友已读 */ - /** @return void */ - setAddApplicationRead(): Promise { - return new Promise((resolve, reject) => { - this.instance.setAddApplicationRead( - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** - * 根据关键字搜索用户信息 - * @param option 搜索选项 @see V2NIMFriendSearchOption - * @return Promise> - */ - searchFriendByOption(option: V2NIMFriendSearchOption): Promise> { - return new Promise((resolve, reject) => { - let defaultOption = { - searchAlias: true, - searchAccountId: false - } - let mergedOption = Object.assign({}, defaultOption, option) - this.instance.searchFriendByOption( - mergedOption, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } +export class V2NIMFriendService extends EventEmitter { + instance: any + + constructor () { + super() + this.instance = new sdk.V2NIMFriendService({ emit: this.emit.bind(this) }) + } + + /** + * @brief 添加好友 + * @param accountId 账号 ID + * @param params 添加好友参数 + * @returns void + * @example + * ```javascript + * await v2.friendService.addFriend('accountId', { + * addMode: 1 + * }) + * ``` + */ + addFriend (accountId: string, params: V2NIMFriendAddParams): Promise { + return new Promise((resolve, reject) => { + this.instance.addFriend( + accountId, + params, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 删除好友 + * @param accountId 账号 ID + * @param params 删除好友参数 + * @returns void + * @example + * ```javascript + * await v2.friendService.deleteFriend('accountId', { + * deleteAlias: true + * }) + * ``` + */ + deleteFriend (accountId: string, params: V2NIMFriendDeleteParams): Promise { + return new Promise((resolve, reject) => { + this.instance.deleteFriend( + accountId, + params, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 接受好友申请 + * @param application 好友申请 + * @returns void + * @example + * ```javascript + * await v2.friendService.acceptAddApplication(application) + * ``` + */ + acceptAddApplication (application: V2NIMFriendAddApplication): Promise { + return new Promise((resolve, reject) => { + this.instance.acceptAddApplication( + application, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 拒绝好友申请 + * @param application 好友申请 + * @param postscript 拒绝理由 + * @returns void + * @example + * ```javascript + * await v2.friendService.rejectAddApplication(application, 'reason') + * ``` + */ + rejectAddApplication (application: V2NIMFriendAddApplication, postscript: String): Promise { + return new Promise((resolve, reject) => { + this.instance.rejectAddApplication( + application, + postscript, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 设置好友信息 + * @param accountId 账号 ID + * @param params 设置好友信息参数 + * @returns void + * @example + * ```javascript + * await v2.friendService.setFriendInfo('accountId', { + * alias: 'alias' + * }) + * ``` + */ + setFriendInfo (accountId: string, params: V2NIMFriendSetParams): Promise { + return new Promise((resolve, reject) => { + this.instance.setFriendInfo( + accountId, + params, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 获取好友列表 + * @returns void + * @example + * ```javascript + * await v2.friendService.getFriendList() + * ``` + */ + getFriendList (): Promise> { + return new Promise((resolve, reject) => { + this.instance.getFriendList( + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据账号 ID 获取好友信息 + * @param accountIds 账号 ID 列表 + * @returns void + * @example + * ```javascript + * await v2.friendService.getFriendByIds(['accountId1', 'accountId2']) + * ``` + */ + getFriendByIds (accountIds: Array): Promise> { + return new Promise((resolve, reject) => { + this.instance.getFriendByIds( + accountIds, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据账号 ID 检查好友状态 + * @param accountIds 账号 ID 列表 + * @returns void + * @example + * ```javascript + * await v2.friendService.checkFriend(['accountId1', 'accountId2']) + * ``` + */ + checkFriend (accountIds: Array): Promise> { + return new Promise((resolve, reject) => { + this.instance.checkFriend( + accountIds, + (result: Map) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 获取申请添加好友信息列表 + * @param option 查询申请添加好友相关信息参数 + * @returns void + * @example + * ```javascript + * await v2.friendService.getAddApplicationList({ + * offset: 0, + * limit: 10 + * }) + * ``` + */ + getAddApplicationList (option: V2NIMFriendAddApplicationQueryOption): Promise { + return new Promise((resolve, reject) => { + this.instance.getAddApplicationList( + option, + (result: V2NIMFriendAddApplicationResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 获取申请添加好友未读数量 + * @returns void + * @example + * ```javascript + * await v2.friendService.getAddApplicationUnreadCount() + * ``` + */ + getAddApplicationUnreadCount (): Promise { + return new Promise((resolve, reject) => { + this.instance.getAddApplicationUnreadCount( + (result: number) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 设置申请添加好友已读 + * @returns void + * @example + * ```javascript + * await v2.friendService.setAddApplicationRead() + * ``` + */ + setAddApplicationRead (): Promise { + return new Promise((resolve, reject) => { + this.instance.setAddApplicationRead( + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据关键字搜索用户信息 + * @param option 搜索选项 @see V2NIMFriendSearchOption + * @returns Promise> + * @example + * ```javascript + * await v2.friendService.searchFriendByOption({ + * keyword: 'keyword' + * }) + * ``` + */ + searchFriendByOption (option: V2NIMFriendSearchOption): Promise> { + return new Promise((resolve, reject) => { + let defaultOption = { + searchAlias: true, + searchAccountId: false + } + let mergedOption = Object.assign({}, defaultOption, option) + this.instance.searchFriendByOption( + mergedOption, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 清空所有添加好友申请 + * @returns Promise + * @example + * ```javascript + * await v2.friendService.clearAllAddApplication() + * ``` + */ + clearAllAddApplication (): Promise { + return new Promise((resolve, reject) => { + this.instance.clearAllAddApplication( + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 删除添加好友申请 + * @param application 添加好友申请 + * @returns Promise + * @example + * ```javascript + * await v2.friendService.deleteAddApplication(application) + * ``` + */ + deleteAddApplication (application: V2NIMFriendAddApplication): Promise { + return new Promise((resolve, reject) => { + this.instance.deleteAddApplication( + application, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } } diff --git a/ts/v2/v2_nim_login_service.ts b/ts/v2/v2_nim_login_service.ts index fe8f71c..a766f27 100644 --- a/ts/v2/v2_nim_login_service.ts +++ b/ts/v2/v2_nim_login_service.ts @@ -1,171 +1,237 @@ -import { V2NIMDataSyncDetail, V2NIMError, V2NIMKickedOfflineDetail, V2NIMLoginClient, V2NIMLoginOption } from 'ts/v2_def/v2_nim_struct_def' +import { + V2NIMDataSyncDetail, + V2NIMError, + V2NIMKickedOfflineDetail, + V2NIMLoginClient, + V2NIMLoginOption +} from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' import { EventEmitter } from 'eventemitter3' import { V2NIMReconnectDelayProvider } from 'ts/v2_def/v2_nim_callback_def' -import { V2NIMConnectStatus, V2NIMDataSyncState, V2NIMDataSyncType, V2NIMLoginClientChange, V2NIMLoginStatus } from 'ts/v2_def/v2_nim_enum_def' +import { + V2NIMConnectStatus, + V2NIMDataSyncState, + V2NIMDataSyncType, + V2NIMLoginClientChange, + V2NIMLoginStatus +} from 'ts/v2_def/v2_nim_enum_def' -export declare interface V2NIMLoginServiceEvents { - /** 登录状态变更回调 */ - loginStatus: [V2NIMLoginStatus] - /** 登录失败回调 */ - loginFailed: [V2NIMError] - /** 被踢下线回调 */ - kickedOffline: [V2NIMKickedOfflineDetail] - /** 登录客户端变更回调 */ - loginClientChanged: [V2NIMLoginClientChange, V2NIMLoginClient[]] - /** 连接状态变更回调 */ - connectStatus: [V2NIMConnectStatus] - /** 连接断开回调 */ - disconnected: [V2NIMError | null] - /** 连接失败回调 */ - connectFailed: [V2NIMError] - /** 数据同步回调 */ - dataSync: [V2NIMDataSyncType, V2NIMDataSyncState, V2NIMError | null] +export declare interface V2NIMLoginListener { + /** 登录状态变更回调 */ + loginStatus: [V2NIMLoginStatus] + /** 登录失败回调 */ + loginFailed: [V2NIMError] + /** 被踢下线回调 */ + kickedOffline: [V2NIMKickedOfflineDetail] + /** 登录客户端变更回调 */ + loginClientChanged: [V2NIMLoginClientChange, V2NIMLoginClient[]] + /** 连接状态变更回调 */ + connectStatus: [V2NIMConnectStatus] + /** 连接断开回调 */ + disconnected: [V2NIMError | null] + /** 连接失败回调 */ + connectFailed: [V2NIMError] + /** 数据同步回调 */ + dataSync: [V2NIMDataSyncType, V2NIMDataSyncState, V2NIMError | null] } -export class V2NIMLoginService extends EventEmitter { - instance: any - constructor() { - super() - this.instance = new sdk.V2NIMLoginService({ emit: this.emit.bind(this) }) - } - /** - * 登录接口 - * @param accountId 账号 - * @param token 密码 - * @param option 登录选项 - * @returns Promise - */ - login(accountId: string, token: string, option: V2NIMLoginOption): Promise { - return new Promise((resolve, reject) => { - this.instance.login( - accountId, - token, - option, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } +export class V2NIMLoginService extends EventEmitter { + instance: any - /** - * 登出接口 - * @returns Promise - */ - logout(): Promise { - return new Promise((resolve, reject) => { - this.instance.logout( - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + constructor () { + super() + this.instance = new sdk.V2NIMLoginService({ emit: this.emit.bind(this) }) + } - /** - * 获取当前登录用户 - * @returns string 当前登录用户 - */ - getLoginUser(): string { - return this.instance.getLoginUser() - } + /** + * @brief 登录接口 + * @param accountId 账号 + * @param token 密码 + * @param option 登录选项 + * @returns Promise + * @example + * ```javascript + * await v2.loginService.login('accountId', 'token', {}) + * ``` + */ + login (accountId: string, token: string, option: V2NIMLoginOption): Promise { + return new Promise((resolve, reject) => { + this.instance.login( + accountId, + token, + option, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** - * 获取登录状态 - * @returns V2NIMLoginStatus 登录状态 - */ - getLoginStatus(): V2NIMLoginStatus { - return this.instance.getLoginStatus() - } + /** + * @brief 登出接口 + * @returns Promise + * @example + * ```javascript + * await v2.loginService.logout() + * ``` + */ + logout (): Promise { + return new Promise((resolve, reject) => { + this.instance.logout( + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** - * 获取登录客户端列表 - * @returns V2NIMLoginClient[] 登录客户端列表 - */ - getLoginClients(): V2NIMLoginClient[] { - return this.instance.getLoginClients() - } + /** + * @brief 获取当前登录用户 + * @returns string 当前登录用户 + * @example + * ```javascript + * const user = v2.loginService.getLoginUser() + * ``` + */ + getLoginUser (): string { + return this.instance.getLoginUser() + } - /** - * 获取当前登录客户端 - * @returns V2NIMLoginClient 当前登录客户端 - */ - getCurrentLoginClient(): V2NIMLoginClient { - return this.instance.getCurrentLoginClient() - } + /** + * @brief 获取登录状态 + * @returns V2NIMLoginStatus 登录状态 + * @example + * ```javascript + * const status = v2.loginService.getLoginStatus() + * ``` + */ + getLoginStatus (): V2NIMLoginStatus { + return this.instance.getLoginStatus() + } - /** - * 踢掉登录客户端下线 - * @param client 登录客户端 - * @returns Promise - */ - kickOffline(client: V2NIMLoginClient): Promise { - return new Promise((resolve, reject) => { - this.instance.kickOffline( - client, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 获取登录客户端列表 + * @returns V2NIMLoginClient[] 登录客户端列表 + * @example + * ```javascript + * const clients = v2.loginService.getLoginClients() + * ``` + */ + getLoginClients (): V2NIMLoginClient[] { + return this.instance.getLoginClients() + } - /** - * 获取被踢下线原因 - * @returns V2NIMKickedOfflineDetail 被踢下线原因 - */ - getKickedOfflineDetail(): V2NIMKickedOfflineDetail { - return this.instance.getKickedOfflineDetail() - } + /** + * @brief 获取当前登录客户端 + * @returns V2NIMLoginClient 当前登录客户端 + * @example + * ```javascript + * const client = v2.loginService.getCurrentLoginClient() + * ``` + */ + getCurrentLoginClient (): V2NIMLoginClient { + return this.instance.getCurrentLoginClient() + } - /* 获取连接状态 - * @returns V2NIMConnectStatus 连接状态 - */ - getConnectStatus(): V2NIMConnectStatus { - return this.instance.getConnectStatus() - } + /** + * @brief 踢掉登录客户端下线 + * @param client 登录客户端 + * @returns Promise + * @example + * ```javascript + * const otherClients = v2.loginService.getLoginClients() + * await v2.loginService.kickOffline(otherClients[0]) + * ``` + */ + kickOffline (client: V2NIMLoginClient): Promise { + return new Promise((resolve, reject) => { + this.instance.kickOffline( + client, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** - * 获取数据同步状态 - * @returns V2NIMDataSyncDetail[] 数据同步状态列表 - */ - getDataSync(): V2NIMDataSyncDetail[] { - return this.instance.getDataSync() - } + /** + * @brief 获取被踢下线原因 + * @returns V2NIMKickedOfflineDetail 被踢下线原因 + * @example + * ```javascript + * const detail = v2.loginService.getKickedOfflineDetail() + * ``` + */ + getKickedOfflineDetail (): V2NIMKickedOfflineDetail { + return this.instance.getKickedOfflineDetail() + } - /** @brief 获取聊天室 link 地址 */ - /** @param roomId 聊天室 ID */ - /** @return void */ - getChatroomLinkAddress(roomId: string): Promise> { - return new Promise((resolve, reject) => { - this.instance.getChatroomLinkAddress( - roomId, - (linkAddresses: Array) => { - resolve(linkAddresses) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 获取连接状态 + * @returns V2NIMConnectStatus 连接状态 + * @example + * ```javascript + * const status = v2.loginService.getConnectStatus() + * ``` + */ + getConnectStatus (): V2NIMConnectStatus { + return this.instance.getConnectStatus() + } - /** - * 设置获取重连延时回调 - * @param provider 获取重连延时回调 - * @returns void - */ - setReconnectDelayProvider(provider: V2NIMReconnectDelayProvider): void { - this.instance.setReconnectDelayProvider(provider) - } + /** + * @brief 获取数据同步状态 + * @returns V2NIMDataSyncDetail[] 数据同步状态列表 + * @example + * ```javascript + * const details = v2.loginService.getDataSync() + * ``` + */ + getDataSync (): V2NIMDataSyncDetail[] { + return this.instance.getDataSync() + } + + /** + * @brief 获取聊天室 link 地址 + * @param roomId 聊天室 ID + * @returns Promise> + * @example + * ```javascript + * const linkAddresses = await v2.loginService.getChatroomLinkAddress('roomId') + * ``` + */ + getChatroomLinkAddress (roomId: string): Promise> { + return new Promise((resolve, reject) => { + this.instance.getChatroomLinkAddress( + roomId, + (linkAddresses: Array) => { + resolve(linkAddresses) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 设置获取重连延时回调 + * @param provider 获取重连延时回调 + * @returns void + * @example + * ```javascript + * v2.loginService.setReconnectDelayProvider(provider) + * ``` + */ + setReconnectDelayProvider (provider: V2NIMReconnectDelayProvider): void { + this.instance.setReconnectDelayProvider(provider) + } } diff --git a/ts/v2/v2_nim_message_service.ts b/ts/v2/v2_nim_message_service.ts index 02bc365..2c656e4 100644 --- a/ts/v2/v2_nim_message_service.ts +++ b/ts/v2/v2_nim_message_service.ts @@ -1,686 +1,912 @@ import { - V2NIMMessage, - V2NIMSendMessageParams, - V2NIMSendMessageResult, - V2NIMError, - V2NIMMessageRevokeParams, - V2NIMMessageListOption, - V2NIMMessageRefer, - V2NIMThreadMessageListOption, - V2NIMThreadMessageListResult, - V2NIMClearHistoryMessageOption, - V2NIMMessagePin, - V2NIMMessageQuickCommentPushConfig, - V2NIMMessageQuickComment, - V2NIMAddCollectionParams, - V2NIMCollection, - V2NIMCollectionOption, - V2NIMP2PMessageReadReceipt, - V2NIMTeamMessageReadReceipt, - V2NIMTeamMessageReadReceiptDetail, - V2NIMVoiceToTextParams, - V2NIMMessageSearchParams, - V2NIMClearHistoryNotification, - V2NIMMessageDeletedNotification, - V2NIMMessagePinNotification, - V2NIMMessageQuickCommentNotification, - V2NIMMessageRevokeNotification, - V2NIMModifyMessageParams, - V2NIMModifyMessageResult + V2NIMMessage, + V2NIMSendMessageParams, + V2NIMSendMessageResult, + V2NIMError, + V2NIMMessageRevokeParams, + V2NIMMessageListOption, + V2NIMMessageRefer, + V2NIMThreadMessageListOption, + V2NIMThreadMessageListResult, + V2NIMClearHistoryMessageOption, + V2NIMMessagePin, + V2NIMMessageQuickCommentPushConfig, + V2NIMMessageQuickComment, + V2NIMAddCollectionParams, + V2NIMCollection, + V2NIMCollectionOption, + V2NIMP2PMessageReadReceipt, + V2NIMTeamMessageReadReceipt, + V2NIMTeamMessageReadReceiptDetail, + V2NIMVoiceToTextParams, + V2NIMMessageSearchParams, + V2NIMClearHistoryNotification, + V2NIMMessageDeletedNotification, + V2NIMMessagePinNotification, + V2NIMMessageQuickCommentNotification, + V2NIMMessageRevokeNotification, + V2NIMModifyMessageParams, + V2NIMModifyMessageResult } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' -import {EventEmitter} from 'eventemitter3' -import {V2NIMProgressCallback} from 'ts/v2_def/v2_nim_callback_def' - -export declare interface V2NIMMessageServiceEvents { - /** 收到一条新消息 */ - receiveMessages: [Array] - /** 点对点已读回执 */ - receiveP2PMessageReadReceipts: [Array] - /** 群已读回执 */ - receiveTeamMessageReadReceipts: [Array] - /** 消息撤回通知 */ - messageRevokeNotifications: [Array] - /** 消息 pin 状态通知 */ - messagePinNotification: [V2NIMMessagePinNotification] - /** 消息快捷评论通知 */ - messageQuickCommentNotification: [V2NIMMessageQuickCommentNotification] - /** 消息被删除通知 */ - messageDeletedNotifications: [Array] - /** 清空会话历史消息通知 */ - clearHistoryNotifications: [Array] - /** 本端发送消息状态回调 */ - sendMessage: [V2NIMMessage] - /** 本端更新消息状态回调 */ - receiveMessagesModified: [Array] +import { EventEmitter } from 'eventemitter3' +import { V2NIMProgressCallback } from 'ts/v2_def/v2_nim_callback_def' + +export declare interface V2NIMMessageListener { + /** 收到一条新消息 */ + receiveMessages: [Array] + /** 点对点已读回执 */ + receiveP2PMessageReadReceipts: [Array] + /** 群已读回执 */ + receiveTeamMessageReadReceipts: [Array] + /** 消息撤回通知 */ + messageRevokeNotifications: [Array] + /** 消息 pin 状态通知 */ + messagePinNotification: [V2NIMMessagePinNotification] + /** 消息快捷评论通知 */ + messageQuickCommentNotification: [V2NIMMessageQuickCommentNotification] + /** 消息被删除通知 */ + messageDeletedNotifications: [Array] + /** 清空会话历史消息通知 */ + clearHistoryNotifications: [Array] + /** 本端发送消息状态回调 */ + sendMessage: [V2NIMMessage] + /** 本端更新消息状态回调 */ + receiveMessagesModified: [Array] } /** @brief 消息服务 */ -export class V2NIMMessageService extends EventEmitter { - instance: any - - constructor() { - super() - this.instance = new sdk.V2NIMMessageService({emit: this.emit.bind(this)}) - } - - /** @brief 发送消息 */ - /** @param message 要发送的消息 */ - - /** @param conversationId 发送目标会话 */ - /** @param params 发送参数 */ - sendMessage( - message: V2NIMMessage, - conversationId: string, - params: V2NIMSendMessageParams, - progressCallback: V2NIMProgressCallback - ): Promise { - return new Promise((resolve, reject) => { - this.instance.sendMessage( - message, - conversationId, - params, - (result: V2NIMSendMessageResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - }, - (progress: number) => { - if (progressCallback) { - progressCallback(progress) - } - } - ) - }) - } - - /** @brief 回复消息 */ - /** @param message 要发送的消息 */ - - /** @param replyMessage 被回复的消息 */ - /** @param params 发送参数 */ - replyMessage( - message: V2NIMMessage, - replyMessage: V2NIMMessage, - params: V2NIMSendMessageParams, - progressCallback: V2NIMProgressCallback - ): Promise { - return new Promise((resolve, reject) => { - this.instance.replyMessage( - message, - replyMessage, - params, - (result: V2NIMSendMessageResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - }, - (progress: number) => { - progressCallback(progress) - } - ) - }) - } - - /** @brief 更新消息 */ - /** @param message 要更新的消息 */ - /** @param params 发送参数 */ - modifyMessage( - message: V2NIMMessage, - params: V2NIMModifyMessageParams, - ): Promise { - return new Promise((resolve, reject) => { - this.instance.modifyMessage( - message, - params, - (result: V2NIMModifyMessageResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 撤回消息 */ - /** @param message 要撤回的消息 */ - revokeMessage(message: V2NIMMessage, params: V2NIMMessageRevokeParams): Promise { - return new Promise((resolve, reject) => { - this.instance.revokeMessage( - message, - params, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 查询消息 */ - /** @param option 查询消息配置选项 */ - getMessageList(option: V2NIMMessageListOption): Promise> { - return new Promise((resolve, reject) => { - this.instance.getMessageList( - option, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 根据 ID 列表查询消息 */ - /** @param messageClientIds 消息客户端 ID 列表 */ - getMessageListByIds(messageClientIds: Array): Promise> { - return new Promise((resolve, reject) => { - this.instance.getMessageListByIds( - messageClientIds, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 根据消息引用列表查询消息 */ - /** @param messageRefers 消息引用列表 */ - getMessageListByRefers(messageRefers: Array): Promise> { - return new Promise((resolve, reject) => { - this.instance.getMessageListByRefers( - messageRefers, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 查询 thread 聊天云端消息列表 */ - /** @param threadMessageListOption threadMessageListOption 消息查询选项 */ - getThreadMessageList(threadMessageListOption: V2NIMThreadMessageListOption): Promise { - return new Promise((resolve, reject) => { - this.instance.getThreadMessageList( - threadMessageListOption, - (result: V2NIMThreadMessageListResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 查询 thread 聊天本地消息列表 */ - /** @param V2NIMMessageRefer messageRefer 消息查询选项 */ - getLocalThreadMessageList(messageRefer: V2NIMMessageRefer): Promise { - return new Promise((resolve, reject) => { - this.instance.getLocalThreadMessageList( - messageRefer, - (result: V2NIMThreadMessageListResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - - /** @brief 删除消息 */ - /** @param message 需要删除的消息 */ - - /** @param serverExtension 服务器扩展字段 */ - /** @param onlyDeleteLocal 是否只删除本地消息 */ - deleteMessage(message: V2NIMMessage, serverExtension: string, onlyDeleteLocal: boolean): Promise { - return new Promise((resolve, reject) => { - this.instance.deleteMessage( - message, - serverExtension, - onlyDeleteLocal, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 批量删除消息 */ - /** @param messages 需要删除的消息列表 */ - - /** @param serverExtension 服务器扩展字段 */ - /** @param onlyDeleteLocal 是否只删除本地消息 */ - deleteMessages(messages: Array, serverExtension: string, onlyDeleteLocal: boolean): Promise { - return new Promise((resolve, reject) => { - this.instance.deleteMessages( - messages, - serverExtension, - onlyDeleteLocal, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 清空历史消息 */ - /** @param option 清空历史消息配置选项 */ - clearHistoryMessage(option: V2NIMClearHistoryMessageOption): Promise { - return new Promise((resolve, reject) => { - this.instance.clearHistoryMessage( - option, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 更新消息本地扩展 */ - - /** @param message 要更新的消息 */ - /** @param localExtension 本地扩展字段 */ - updateMessageLocalExtension(message: V2NIMMessage, localExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.updateMessageLocalExtension( - message, - localExtension, - (result: V2NIMMessage) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 插入本地消息 */ - /** @param message 要插入的消息 */ - /** @param conversationId 会话 ID */ - - /** @param senderId 发送者 ID, 传空表示当前用户 */ - /** @param createTime 消息创建时间, 0 表示使用当前时间 */ - insertMessageToLocal(message: V2NIMMessage, conversationId: string, senderId: string, createTime: number): Promise { - return new Promise((resolve, reject) => { - this.instance.insertMessageToLocal( - message, - conversationId, - senderId, - createTime, - (result: V2NIMMessage) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief pin 消息 */ - - /** @param message 要 pin 的消息 */ - /** @param serverExtension 扩展字段 */ - pinMessage(message: V2NIMMessage, serverExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.pinMessage( - message, - serverExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 取消 pin 消息 */ - - /** @param message 要 unpin 的消息引用 */ - /** @param serverExtension 扩展字段 */ - unpinMessage(messageRefer: V2NIMMessageRefer, serverExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.unpinMessage( - messageRefer, - serverExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 更新 pin 消息 */ - - /** @param message 要更新的 pin 消息 */ - /** @param serverExtension 扩展字段 */ - updatePinMessage(message: V2NIMMessage, serverExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.updatePinMessage( - message, - serverExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取 pin 消息列表 */ - /** @param conversationId 会话 ID */ - getPinnedMessageList(conversationId: string): Promise> { - return new Promise((resolve, reject) => { - this.instance.getPinnedMessageList( - conversationId, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 添加快捷评论 */ - /** @param message 要添加快捷评论的消息 */ - /** @param index 快捷评论索引 */ - - /** @param serverExtension 服务器扩展字段 */ - /** @param pushConfig 推送配置 */ - addQuickComment(message: V2NIMMessage, index: string, serverExtension: string, pushConfig: V2NIMMessageQuickCommentPushConfig): Promise { - return new Promise((resolve, reject) => { - this.instance.addQuickComment( - message, - index, - serverExtension, - pushConfig, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 移除快捷评论 */ - /** @param messageRefer 要移除快捷评论的消息引用 */ - - /** @param index 快捷评论索引 */ - /** @param serverExtension 服务器扩展字段 */ - removeQuickComment(messageRefer: V2NIMMessageRefer, index: number, serverExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.removeQuickComment( - messageRefer, - index, - serverExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取快捷评论列表 */ - - /** @param messages 要获取快捷评论的消息列表 */ - /** @note return result, key: clientMessasgeId */ - getQuickCommentList(messages: Array): Promise>> { - return new Promise((resolve, reject) => { - this.instance.getQuickCommentList( - messages, - (result: Map>) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 添加收藏 */ - /** @param params 添加收藏相关参数 */ - addCollection(params: V2NIMAddCollectionParams): Promise { - return new Promise((resolve, reject) => { - this.instance.addCollection( - params, - (result: V2NIMCollection) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 移除收藏 */ - /** @param collections 要移除的收藏列表 */ - removeCollections(collections: Array): Promise { - return new Promise((resolve, reject) => { - this.instance.removeCollections( - collections, - (count: number) => { - resolve(count) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 更新收藏扩展字段 */ - - /** @param collection 要更新的收藏 */ - /** @param serverExtension 服务器扩展字段, 传空表示删除扩展字段 */ - updateCollectionExtension(collection: V2NIMCollection, serverExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.updateCollectionExtension( - collection, - serverExtension, - (result: V2NIMCollection) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 分页获取收藏列表 */ - /** @param option 获取收藏列表查询参数 */ - getCollectionListByOption(option: V2NIMCollectionOption): Promise> { - return new Promise((resolve, reject) => { - this.instance.getCollectionListByOption( - option, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 发送 P2P 消息已读回执 */ - /** @param message 要发送已读回执的消息 */ - sendP2PMessageReceipt(message: V2NIMMessage): Promise { - return new Promise((resolve, reject) => { - this.instance.sendP2PMessageReceipt( - message, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 查询 P2P 消息已读回执状态 */ - /** @param conversationId 会话 ID */ - getP2PMessageReceipt(conversationId: string): Promise { - return new Promise((resolve, reject) => { - this.instance.getP2PMessageReceipt( - conversationId, - (result: V2NIMP2PMessageReadReceipt) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 查询 P2P 消息对方是否已读 */ - - /** @param message 要查询的消息 */ - /** @return boolean 是否已读 */ - isPeerRead(message: V2NIMMessage): boolean { - return this.instance.isPeerRead(message) - } - - /** @brief 发送群消息已读回执 */ - /** @param messages 要发送已读回执的消息列表 */ - sendTeamMessageReceipts(messages: Array): Promise { - return new Promise((resolve, reject) => { - this.instance.sendTeamMessageReceipts( - messages, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取群消息已读回执状态 */ - /** @param messages 要查询的消息列表 */ - getTeamMessageReceipts(messages: Array): Promise> { - return new Promise((resolve, reject) => { - this.instance.getTeamMessageReceipts( - messages, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取群消息已读回执详情 */ - - /** @param message 要查询的消息 */ - /** @param memberAccountIds 指定的账号列表, 为空表示查询全部 */ - getTeamMessageReceiptDetail(message: V2NIMMessage, memberAccountIds: Array): Promise { - return new Promise((resolve, reject) => { - this.instance.getTeamMessageReceiptDetail( - message, - memberAccountIds, - (result: V2NIMTeamMessageReadReceiptDetail) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 语音转文字 */ - /** @param params 语音转文字参数 */ - voiceToText(params: V2NIMVoiceToTextParams): Promise { - return new Promise((resolve, reject) => { - this.instance.voiceToText( - params, - (result: string) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 取消文件消息附件上传 */ - /** @param message 要取消上传的文件消息 */ - cancelMessageAttachmentUpload(message: V2NIMMessage): Promise { - return new Promise((resolve, reject) => { - this.instance.cancelMessageAttachmentUpload( - message, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 搜索云端消息 */ - /** @param params 消息检索参数 */ - searchCloudMessages(params: V2NIMMessageSearchParams): Promise> { - return new Promise((resolve, reject) => { - this.instance.searchCloudMessages( - params, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } +export class V2NIMMessageService extends EventEmitter { + instance: any + + constructor () { + super() + this.instance = new sdk.V2NIMMessageService({ emit: this.emit.bind(this) }) + } + + /** + * @brief 发送消息 + * @param message 要发送的消息 + * @param conversationId 发送目标会话 + * @returns V2NIMSendMessageResult + * @example + * ```javascript + * const message = v2.messageCreator.createTextMessage('Hello NTES IM') + * const result = await v2.messageService.sendMessage(message, conversationId, params, progressCallback) + * ``` + */ + sendMessage ( + message: V2NIMMessage, + conversationId: string, + params: V2NIMSendMessageParams, + progressCallback: V2NIMProgressCallback + ): Promise { + return new Promise((resolve, reject) => { + this.instance.sendMessage( + message, + conversationId, + params, + (result: V2NIMSendMessageResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + }, + (progress: number) => { + if (progressCallback) { + progressCallback(progress) + } + } + ) + }) + } + + /** + * @param message 要发送的消息 + * @param replyMessage 被回复的消息 + * @param params 发送参数 + * @param progressCallback 发送进度回调 + * @returns V2NIMSendMessageResult + * @example + * ```javascript + * const replyMessage = v2.messageCreator.createTextMessage('Hello NTES IM') + * const result = await v2.messageService.replyMessage(message, replyMessage, params, progressCallback) + * ``` + */ + replyMessage ( + message: V2NIMMessage, + replyMessage: V2NIMMessage, + params: V2NIMSendMessageParams, + progressCallback: V2NIMProgressCallback + ): Promise { + return new Promise((resolve, reject) => { + this.instance.replyMessage( + message, + replyMessage, + params, + (result: V2NIMSendMessageResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + }, + (progress: number) => { + progressCallback(progress) + } + ) + }) + } + + /** + * @brief 更新消息 + * @param message 要更新的消息 + * @param params 发送参数 + * @returns V2NIMModifyMessageResult + * @example + * ```javascript + * const result = await v2.messageService.modifyMessage(message, { + * text: 'Hello NTES IM' + * }) + * ``` + */ + modifyMessage ( + message: V2NIMMessage, + params: V2NIMModifyMessageParams, + ): Promise { + return new Promise((resolve, reject) => { + this.instance.modifyMessage( + message, + params, + (result: V2NIMModifyMessageResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 撤回消息 + * @param message 要撤回的消息 + * @param params 撤回参数 + * @returns void + * @example + * ```javascript + * await v2.messageService.revokeMessage(message, {}) + * ``` + */ + revokeMessage (message: V2NIMMessage, params: V2NIMMessageRevokeParams): Promise { + return new Promise((resolve, reject) => { + this.instance.revokeMessage( + message, + params, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 查询消息 + * @param option 查询消息配置选项 + * @returns Array + * @example + * ```javascript + * const messages = await v2.messageService.getMessageList({ + * conversationId: 'conversationId' + * }) + * ``` + */ + getMessageList (option: V2NIMMessageListOption): Promise> { + return new Promise((resolve, reject) => { + this.instance.getMessageList( + option, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据 ID 列表查询消息 + * @param messageClientIds 消息客户端 ID 列表 + * @returns Array + * @example + * ```javascript + * const messages = await v2.messageService.getMessageListByIds(messageClientIds) + * ``` + */ + getMessageListByIds (messageClientIds: Array): Promise> { + return new Promise((resolve, reject) => { + this.instance.getMessageListByIds( + messageClientIds, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据消息引用列表查询消息 + * @param messageRefers 消息引用列表 + * @returns Array + * @example + * ```javascript + * const messages = await v2.messageService.getMessageListByRefers(messageRefers) + * ``` + */ + getMessageListByRefers (messageRefers: Array): Promise> { + return new Promise((resolve, reject) => { + this.instance.getMessageListByRefers( + messageRefers, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 查询 thread 聊天云端消息列表 + * @param threadMessageListOption threadMessageListOption 消息查询选项 + * @returns V2NIMThreadMessageListResult + * @example + * ```javascript + * const result = await v2.messageService.getThreadMessageList(threadMessageListOption) + * ``` + */ + getThreadMessageList (threadMessageListOption: V2NIMThreadMessageListOption): Promise { + return new Promise((resolve, reject) => { + this.instance.getThreadMessageList( + threadMessageListOption, + (result: V2NIMThreadMessageListResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 查询 thread 聊天本地消息列表 + * @param messageRefer 消息查询选项 + * @returns V2NIMThreadMessageListResult + * @example + * ```javascript + * const result = await v2.messageService.getLocalThreadMessageList(messageRefer) + * ``` + */ + getLocalThreadMessageList (messageRefer: V2NIMMessageRefer): Promise { + return new Promise((resolve, reject) => { + this.instance.getLocalThreadMessageList( + messageRefer, + (result: V2NIMThreadMessageListResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 删除消息 + * @param message 需要删除的消息 + * @param serverExtension 服务器扩展字段 + * @param onlyDeleteLocal 是否只删除本地消息 + * @returns void + * @example + * ```javascript + * await v2.messageService.deleteMessage(message, 'serverExtension', true) + * ``` + */ + deleteMessage (message: V2NIMMessage, serverExtension: string, onlyDeleteLocal: boolean): Promise { + return new Promise((resolve, reject) => { + this.instance.deleteMessage( + message, + serverExtension, + onlyDeleteLocal, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 批量删除消息 + * @param messages 需要删除的消息列表 + * @param serverExtension 服务器扩展字段 + * @param onlyDeleteLocal 是否只删除本地消息 + * @returns void + * @example + * ```javascript + * await v2.messageService.deleteMessages(messages, 'serverExtension', true) + * ``` + */ + deleteMessages (messages: Array, serverExtension: string, onlyDeleteLocal: boolean): Promise { + return new Promise((resolve, reject) => { + this.instance.deleteMessages( + messages, + serverExtension, + onlyDeleteLocal, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 清空历史消息 + * @param option 清空历史消息配置选项 + * @returns void + * @example + * ```javascript + * await v2.messageService.clearHistoryMessage(option) + * ``` + */ + clearHistoryMessage (option: V2NIMClearHistoryMessageOption): Promise { + return new Promise((resolve, reject) => { + this.instance.clearHistoryMessage( + option, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 更新消息本地扩展 + * @param message 要更新的消息 + * @param localExtension 本地扩展字段 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = await v2.messageService.updateMessageLocalExtension(message, 'localExtension') + * ``` + */ + updateMessageLocalExtension (message: V2NIMMessage, localExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.updateMessageLocalExtension( + message, + localExtension, + (result: V2NIMMessage) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 插入本地消息 + * @param message 要插入的消息 + * @param conversationId 会话 ID + * @param senderId 发送者 ID, 传空表示当前用户 + * @param createTime 消息创建时间, 0 表示使用当前时间 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = await v2.messageService.insertMessageToLocal(message, conversationId, senderId, createTime) + * ``` + */ + insertMessageToLocal (message: V2NIMMessage, conversationId: string, senderId: string, createTime: number): Promise { + return new Promise((resolve, reject) => { + this.instance.insertMessageToLocal( + message, + conversationId, + senderId, + createTime, + (result: V2NIMMessage) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief PIN 消息 + * @param message 要 PIN 的消息 + * @param serverExtension 扩展字段 + * @returns void + * @example + * ```javascript + * await v2.messageService.pinMessage(message, 'serverExtension') + * ``` + */ + pinMessage (message: V2NIMMessage, serverExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.pinMessage( + message, + serverExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 取消 PIN 消息 + * @param messageRefer 要取消 PIN 的消息引用 + * @param serverExtension 扩展字段 + * @returns void + * @example + * ```javascript + * await v2.messageService.unpinMessage(messageRefer, 'serverExtension') + * ``` + */ + unpinMessage (messageRefer: V2NIMMessageRefer, serverExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.unpinMessage( + messageRefer, + serverExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 更新 PIN 消息 + * @param message 要更新的 PIN 消息 + * @param serverExtension 扩展字段 + * @returns void + * @example + * ```javascript + * await v2.messageService.updatePinMessage(message, 'serverExtension') + * ``` + */ + updatePinMessage (message: V2NIMMessage, serverExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.updatePinMessage( + message, + serverExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 获取 PIN 消息列表 + * @param conversationId 会话 ID + * @returns Array + * @example + * ```javascript + * const result = await v2.messageService.getPinnedMessageList(conversationId) + * ``` + */ + getPinnedMessageList (conversationId: string): Promise> { + return new Promise((resolve, reject) => { + this.instance.getPinnedMessageList( + conversationId, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 添加快捷评论 + * @param message 要添加快捷评论的消息 + * @param index 快捷评论索引 + * @param serverExtension 服务器扩展字段 + * @param pushConfig 推送配置 + * @returns void + * @example + * ```javascript + * await v2.messageService.addQuickComment(message, index, 'serverExtension', pushConfig) + * ``` + */ + addQuickComment (message: V2NIMMessage, index: string, serverExtension: string, pushConfig: V2NIMMessageQuickCommentPushConfig): Promise { + return new Promise((resolve, reject) => { + this.instance.addQuickComment( + message, + index, + serverExtension, + pushConfig, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 移除快捷评论 + * @param messageRefer 要移除快捷评论的消息引用 + * @param index 快捷评论索引 + * @param serverExtension 服务器扩展字段 + * @returns void + * @example + * ```javascript + * await v2.messageService.removeQuickComment(messageRefer, index, 'serverExtension') + * ``` + */ + removeQuickComment (messageRefer: V2NIMMessageRefer, index: number, serverExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.removeQuickComment( + messageRefer, + index, + serverExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 获取快捷评论列表 + * @param messages 要获取快捷评论的消息列表 + * @returns Map> + * @example + * ```javascript + * const result = await v2.messageService.getQuickCommentList(messages) + * ``` + */ + getQuickCommentList (messages: Array): Promise>> { + return new Promise((resolve, reject) => { + this.instance.getQuickCommentList( + messages, + (result: Map>) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 添加收藏 + * @param params 添加收藏相关参数 + * @returns V2NIMCollection + * @example + * ```javascript + * const result = await v2.messageService.addCollection(params) + * ``` + */ + addCollection (params: V2NIMAddCollectionParams): Promise { + return new Promise((resolve, reject) => { + this.instance.addCollection( + params, + (result: V2NIMCollection) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 移除收藏 + * @param collections 要移除的收藏列表 + * @returns number + * @example + * ```javascript + * const count = await v2.messageService.removeCollections(collections) + * ``` + */ + removeCollections (collections: Array): Promise { + return new Promise((resolve, reject) => { + this.instance.removeCollections( + collections, + (count: number) => { + resolve(count) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 更新收藏扩展字段 + * @param collection 要更新的收藏 + * @param serverExtension 服务器扩展字段, 传空表示删除扩展字段 + * @returns V2NIMCollection + * @example + * ```javascript + * const result = await v2.messageService.updateCollectionExtension(collection, 'serverExtension') + * ``` + */ + updateCollectionExtension (collection: V2NIMCollection, serverExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.updateCollectionExtension( + collection, + serverExtension, + (result: V2NIMCollection) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 分页获取收藏列表 + * @param option 获取收藏列表查询参数 + * @returns Array + * @example + * ```javascript + * const result = await v2.messageService.getCollectionListByOption(option) + * ``` + */ + getCollectionListByOption (option: V2NIMCollectionOption): Promise> { + return new Promise((resolve, reject) => { + this.instance.getCollectionListByOption( + option, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 发送 P2P 消息已读回执 + * @param message 要发送已读回执的消息 + * @returns void + * @example + * ```javascript + * await v2.messageService.sendP2PMessageReceipt(message) + * ``` + */ + sendP2PMessageReceipt (message: V2NIMMessage): Promise { + return new Promise((resolve, reject) => { + this.instance.sendP2PMessageReceipt( + message, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 查询 P2P 消息已读回执状态 + * @param conversationId 会话 ID + * @returns V2NIMP2PMessageReadReceipt + * @example + * ```javascript + * const result = await v2.messageService.getP2PMessageReceipt(conversationId) + * ``` + */ + getP2PMessageReceipt (conversationId: string): Promise { + return new Promise((resolve, reject) => { + this.instance.getP2PMessageReceipt( + conversationId, + (result: V2NIMP2PMessageReadReceipt) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 查询 P2P 消息对方是否已读 + * @param message 要查询的消息 + * @returns boolean 是否已读 + * @example + * ```javascript + * const result = v2.messageService.isPeerRead(message) + * ``` + */ + isPeerRead (message: V2NIMMessage): boolean { + return this.instance.isPeerRead(message) + } + + /** + * @brief 发送群消息已读回执 + * @param messages 要发送已读回执的消息列表 + * @returns void + * @example + * ```javascript + * await v2.messageService.sendTeamMessageReceipts(messages) + * ``` + */ + sendTeamMessageReceipts (messages: Array): Promise { + return new Promise((resolve, reject) => { + this.instance.sendTeamMessageReceipts( + messages, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 获取群消息已读回执状态 + * @param messages 要查询的消息列表 + * @returns Array + * @example + * ```javascript + * const result = await v2.messageService.getTeamMessageReceipts(messages) + * ``` + */ + getTeamMessageReceipts (messages: Array): Promise> { + return new Promise((resolve, reject) => { + this.instance.getTeamMessageReceipts( + messages, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 获取群消息已读回执详情 + * @param message 要查询的消息 + * @param memberAccountIds 指定的账号列表, 为空表示查询全部 + * @returns V2NIMTeamMessageReadReceiptDetail + * @example + * ```javascript + * const result = await v2.messageService.getTeamMessageReceiptDetail(message, memberAccountIds) + * ``` + */ + getTeamMessageReceiptDetail (message: V2NIMMessage, memberAccountIds: Array): Promise { + return new Promise((resolve, reject) => { + this.instance.getTeamMessageReceiptDetail( + message, + memberAccountIds, + (result: V2NIMTeamMessageReadReceiptDetail) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 语音转文字 + * @param params 语音转文字参数 + * @returns string + * @example + * ```javascript + * const result = await v2.messageService.voiceToText(params) + * ``` + */ + voiceToText (params: V2NIMVoiceToTextParams): Promise { + return new Promise((resolve, reject) => { + this.instance.voiceToText( + params, + (result: string) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 取消文件消息附件上传 + * @param message 要取消上传的文件消息 + * @returns void + * @example + * ```javascript + * await v2.messageService.cancelMessageAttachmentUpload(message) + * ``` + */ + cancelMessageAttachmentUpload (message: V2NIMMessage): Promise { + return new Promise((resolve, reject) => { + this.instance.cancelMessageAttachmentUpload( + message, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 搜索云端消息 + * @param params 消息检索参数 + * @returns Array + * @example + * ```javascript + * const result = await v2.messageService.searchCloudMessages(params) + * ``` + */ + searchCloudMessages (params: V2NIMMessageSearchParams): Promise> { + return new Promise((resolve, reject) => { + this.instance.searchCloudMessages( + params, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } } diff --git a/ts/v2/v2_nim_notification_service.ts b/ts/v2/v2_nim_notification_service.ts index 8b926b0..9c7ecf2 100644 --- a/ts/v2/v2_nim_notification_service.ts +++ b/ts/v2/v2_nim_notification_service.ts @@ -1,38 +1,52 @@ -import { V2NIMBroadcastNotification, V2NIMCustomNotification, V2NIMError, V2NIMSendCustomNotificationParams } from 'ts/v2_def/v2_nim_struct_def' +import { + V2NIMBroadcastNotification, + V2NIMCustomNotification, + V2NIMError, + V2NIMSendCustomNotificationParams +} from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' import { EventEmitter } from 'eventemitter3' -export declare interface V2NIMNotificationServiceEvents { - /** 收到自定义通知 */ - receiveCustomNotifications: [Array] - /** 收到广播通知 */ - receiveBroadcastNotifications: [Array] +export declare interface V2NIMNotificationListener { + /** 收到自定义通知 */ + receiveCustomNotifications: [Array] + /** 收到广播通知 */ + receiveBroadcastNotifications: [Array] } /** @brief 通知服务 */ -export class V2NIMNotificationService extends EventEmitter { - instance: any - constructor() { - super() - this.instance = new sdk.V2NIMNotificationService({ emit: this.emit.bind(this) }) - } - /** @brief 发送自定义通知 */ - /** @param conversationId 会话 ID */ - /** @param content 通知内容 */ - /** @param params 发送通知相关配置参数 */ - sendCustomNotification(conversationId: string, content: string, params: V2NIMSendCustomNotificationParams): Promise { - return new Promise((resolve, reject) => { - this.instance.sendCustomNotification( - conversationId, - content, - params, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } +export class V2NIMNotificationService extends EventEmitter { + instance: any + + constructor () { + super() + this.instance = new sdk.V2NIMNotificationService({ emit: this.emit.bind(this) }) + } + + /** + * @brief 发送自定义通知 + * @param conversationId 会话 ID + * @param content 通知内容 + * @param params 发送通知相关配置参数 + * @returns void + * @example + * ```javascript + * await v2.notificationService.sendCustomNotification(conversationId, content, params) + * ``` + */ + sendCustomNotification (conversationId: string, content: string, params: V2NIMSendCustomNotificationParams): Promise { + return new Promise((resolve, reject) => { + this.instance.sendCustomNotification( + conversationId, + content, + params, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } } diff --git a/ts/v2/v2_nim_passthrough_service.ts b/ts/v2/v2_nim_passthrough_service.ts new file mode 100644 index 0000000..2ce29c8 --- /dev/null +++ b/ts/v2/v2_nim_passthrough_service.ts @@ -0,0 +1,45 @@ +import sdk from '../loader' +import { EventEmitter } from 'eventemitter3' +import { V2NIMProxyRequest, V2NIMProxyResponse, V2NIMError, V2NIMProxyNotify } from '../v2_def/v2_nim_struct_def' + +export declare interface V2NIMPassthroughListener { + /** 收到透传消息 */ + onProxyNotify: [V2NIMProxyNotify] +} + +export class V2NIMPassthroughService extends EventEmitter { + instance: any + + constructor () { + super() + this.instance = new sdk.V2NIMPassthroughService({ emit: this.emit.bind(this) }) + } + + /** + * @brief 发送 HTTP 代理请求,该请求将通过服务器透传给目标地址 + * @param request 请求参数 + * @returns Promise + * @example + * ```javascript + * const response = await v2.passthroughService.httpProxy({ + * path: '/', + * method: '1', + * header: '{"Content-Type": "application/json"}', + * body: 'body' + * }) + * ``` + */ + httpProxy (request: V2NIMProxyRequest): Promise { + return new Promise((resolve, reject) => { + this.instance.httpProxy( + request, + (response: V2NIMProxyResponse) => { + resolve(response) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } +} diff --git a/ts/v2/v2_nim_setting_service.ts b/ts/v2/v2_nim_setting_service.ts index b06476f..e7894bd 100644 --- a/ts/v2/v2_nim_setting_service.ts +++ b/ts/v2/v2_nim_setting_service.ts @@ -1,138 +1,192 @@ -import {V2NIMDndConfig, V2NIMError} from 'ts/v2_def/v2_nim_struct_def' +import { V2NIMDndConfig, V2NIMError } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' import { EventEmitter } from 'eventemitter3' import { V2NIMP2PMessageMuteMode, V2NIMTeamMessageMuteMode, V2NIMTeamType } from 'ts/v2_def/v2_nim_enum_def' -export declare interface V2NIMSettingServiceEvents { - /** 群组消息免打扰回调 */ - teamMessageMuteModeChanged: [string, V2NIMTeamType, V2NIMTeamMessageMuteMode] - /** 点对点消息免打扰回调 */ - p2pMessageMuteModeChanged: [string, V2NIMP2PMessageMuteMode] +export declare interface V2NIMSettingListener { + /** 群组消息免打扰回调 */ + teamMessageMuteModeChanged: [string, V2NIMTeamType, V2NIMTeamMessageMuteMode] + /** 点对点消息免打扰回调 */ + p2pMessageMuteModeChanged: [string, V2NIMP2PMessageMuteMode] } /** @brief 设置服务 */ -export class V2NIMSettingService extends EventEmitter { - instance: any - constructor() { - super() - this.instance = new sdk.V2NIMSettingService({ emit: this.emit.bind(this) }) - } - /** @brief 获取会话消息免打扰状态 */ - /** @param conversationId 会话 ID */ - /** @return boolean 会话消息免打扰状态 */ - getConversationMuteStatus(conversationId: string): boolean { - return this.instance.getConversationMuteStatus(conversationId) - } +export class V2NIMSettingService extends EventEmitter { + instance: any - /** @brief 设置群消息免打扰模式 */ - /** @param teamId 群组 ID */ - /** @param teamType 群组类型 */ - /** @param muteMode 免打扰模式 */ - /** @return void */ - setTeamMessageMuteMode(teamId: string, teamType: V2NIMTeamType, muteMode: V2NIMTeamMessageMuteMode): Promise { - return new Promise((resolve, reject) => { - this.instance.setTeamMessageMuteMode( - teamId, - teamType, - muteMode, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + constructor () { + super() + this.instance = new sdk.V2NIMSettingService({ emit: this.emit.bind(this) }) + } - /** @brief 获取群消息免打扰模式 */ - /** @param teamId 群组 ID */ - /** @param teamType 群组类型 */ - /** @return V2NIMTeamMessageMuteMode 群消息免打扰模式 */ - getTeamMessageMuteMode(teamId: string, teamType: V2NIMTeamType): V2NIMTeamMessageMuteMode { - return this.instance.getTeamMessageMuteMode(teamId, teamType) - } + /** + * @brief 获取会话消息免打扰状态 + * @param conversationId 会话 ID + * @returns boolean 会话消息免打扰状态 + * @example + * ```javascript + * const status = v2.settingService.getConversationMuteStatus(conversationId) + * ``` + */ + getConversationMuteStatus (conversationId: string): boolean { + return this.instance.getConversationMuteStatus(conversationId) + } - /** @brief 设置点对点消息免打扰模式 */ - /** @param accountId 账号 */ - /** @param muteMode 免打扰模式 */ - /** @return void */ - setP2PMessageMuteMode(accountId: string, muteMode: V2NIMP2PMessageMuteMode): Promise { - return new Promise((resolve, reject) => { - this.instance.setP2PMessageMuteMode( - accountId, - muteMode, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 设置群消息免打扰模式 + * @param teamId 群组 ID + * @param teamType 群组类型 + * @param muteMode 免打扰模式 + * @returns void + * @example + * ```javascript + * await v2.settingService.setTeamMessageMuteMode(teamId, teamType, muteMode) + * ``` + */ + setTeamMessageMuteMode (teamId: string, teamType: V2NIMTeamType, muteMode: V2NIMTeamMessageMuteMode): Promise { + return new Promise((resolve, reject) => { + this.instance.setTeamMessageMuteMode( + teamId, + teamType, + muteMode, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 获取点对点消息免打扰模式 */ - /** @param accountId 账号 */ - /** @return V2NIMP2PMessageMuteMode 点对点消息免打扰模式 */ - getP2PMessageMuteMode(accountId: string): V2NIMP2PMessageMuteMode { - return this.instance.getP2PMessageMuteMode(accountId) - } + /** + * @brief 获取群消息免打扰模式 + * @param teamId 群组 ID + * @param teamType 群组类型 + * @returns V2NIMTeamMessageMuteMode 群消息免打扰模式 + * @example + * ```javascript + * const muteMode = v2.settingService.getTeamMessageMuteMode(teamId, teamType) + * ``` + */ + getTeamMessageMuteMode (teamId: string, teamType: V2NIMTeamType): V2NIMTeamMessageMuteMode { + return this.instance.getTeamMessageMuteMode(teamId, teamType) + } - /** @brief 获取点对点消息免打扰列表 */ - /** @return Array 点对点消息免打扰列表 */ - getP2PMessageMuteList(): Promise> { - return new Promise((resolve, reject) => { - this.instance.getP2PMessageMuteList( - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 设置点对点消息免打扰模式 + * @param accountId 账号 + * @param muteMode 免打扰模式 + * @returns void + * @example + * ```javascript + * await v2.settingService.setP2PMessageMuteMode(accountId, muteMode) + * ``` + */ + setP2PMessageMuteMode (accountId: string, muteMode: V2NIMP2PMessageMuteMode): Promise { + return new Promise((resolve, reject) => { + this.instance.setP2PMessageMuteMode( + accountId, + muteMode, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 设置当桌面端在线时, 移动端是否需要推送 */ - /** @param need 是否需要推送 */ - /** @return void */ - setPushMobileOnDesktopOnline(need: boolean): Promise { - return new Promise((resolve, reject) => { - this.instance.setPushMobileOnDesktopOnline( - need, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 获取点对点消息免打扰模式 + * @param accountId 账号 + * @returns V2NIMP2PMessageMuteMode 点对点消息免打扰模式 + * @example + * ```javascript + * const muteMode = v2.settingService.getP2PMessageMuteMode(accountId) + * ``` + */ + getP2PMessageMuteMode (accountId: string): V2NIMP2PMessageMuteMode { + return this.instance.getP2PMessageMuteMode(accountId) + } - /** @brief 设置免打扰与详情显示 */ - /** @param config 是否需要推送 */ - /** @return void */ - setDndConfig(config: V2NIMDndConfig): Promise { - return new Promise((resolve, reject) => { - this.instance.setDndConfig( - config, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 获取点对点消息免打扰列表 + * @returns Array 点对点消息免打扰列表 + * @example + * ```javascript + * const muteList = await v2.settingService.getP2PMessageMuteList() + * ``` + */ + getP2PMessageMuteList (): Promise> { + return new Promise((resolve, reject) => { + this.instance.getP2PMessageMuteList( + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** - * 读取免打扰与详情显示接口 - * @returns V2NIMDndConfig 设置免打扰配置 - */ - getDndConfig(): V2NIMDndConfig { - return this.instance.getDndConfig(); - } + /** + * @brief 设置当桌面端在线时, 移动端是否需要推送 + * @param need 是否需要推送 + * @returns void + * @example + * ```javascript + * await v2.settingService.setPushMobileOnDesktopOnline(need) + * ``` + */ + setPushMobileOnDesktopOnline (need: boolean): Promise { + return new Promise((resolve, reject) => { + this.instance.setPushMobileOnDesktopOnline( + need, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 设置免打扰与详情显示 + * @param config 免打扰配置 + * @returns void + * @example + * ```javascript + * await v2.settingService.setDndConfig(config) + * ``` + */ + setDndConfig (config: V2NIMDndConfig): Promise { + return new Promise((resolve, reject) => { + this.instance.setDndConfig( + config, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 读取免打扰与详情显示接口 + * @returns V2NIMDndConfig 免打扰配置 + * @example + * ```javascript + * const config = v2.settingService.getDndConfig() + * ``` + */ + getDndConfig (): V2NIMDndConfig { + return this.instance.getDndConfig() + } } diff --git a/ts/v2/v2_nim_signalling_service.ts b/ts/v2/v2_nim_signalling_service.ts index 884931e..50fb6b2 100644 --- a/ts/v2/v2_nim_signalling_service.ts +++ b/ts/v2/v2_nim_signalling_service.ts @@ -1,251 +1,381 @@ import { - V2NIMSignallingCallParams, - V2NIMSignallingChannelInfo, - V2NIMSignallingRoomInfo, - V2NIMSignallingCallResult, - V2NIMSignallingCallSetupParams, - V2NIMSignallingCallSetupResult, - V2NIMSignallingJoinParams, - V2NIMSignallingInviteParams, - V2NIMSignallingCancelInviteParams, - V2NIMSignallingRejectInviteParams, - V2NIMSignallingAcceptInviteParams, - V2NIMSignallingEvent, - V2NIMError + V2NIMSignallingCallParams, + V2NIMSignallingChannelInfo, + V2NIMSignallingRoomInfo, + V2NIMSignallingCallResult, + V2NIMSignallingCallSetupParams, + V2NIMSignallingCallSetupResult, + V2NIMSignallingJoinParams, + V2NIMSignallingInviteParams, + V2NIMSignallingCancelInviteParams, + V2NIMSignallingRejectInviteParams, + V2NIMSignallingAcceptInviteParams, + V2NIMSignallingEvent, + V2NIMError } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' import { EventEmitter } from 'eventemitter3' -export declare interface V2NIMSignallingServiceEvents { - onlineEvent: [V2NIMSignallingEvent] - offlineEvent: [V2NIMSignallingEvent[]] - multiClientEvent: [V2NIMSignallingEvent] - syncRoomInfoList: [V2NIMSignallingRoomInfo[]] +export declare interface V2NIMSignallingListener { + onlineEvent: [V2NIMSignallingEvent] + offlineEvent: [V2NIMSignallingEvent[]] + multiClientEvent: [V2NIMSignallingEvent] + syncRoomInfoList: [V2NIMSignallingRoomInfo[]] } -export class V2NIMSignallingService extends EventEmitter { - instance: any - constructor() { - super() - this.instance = new sdk.V2NIMSignallingService({ emit: this.emit.bind(this) }) - } - /** @brief 直接呼叫对方加入房间 */ - /** @param params 呼叫参数 */ - /** @return Promise */ - call(params: V2NIMSignallingCallParams): Promise { - return new Promise((resolve, reject) => { - this.instance.call( - params, - (result: V2NIMSignallingCallResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } +export class V2NIMSignallingService extends EventEmitter { + instance: any - /** @brief 呼叫建立,包括加入信令频道房间,同时接受对方呼叫 */ - /** @param params 建立呼叫参数 */ - /** @return Promise */ - callSetup(params: V2NIMSignallingCallSetupParams): Promise { - return new Promise((resolve, reject) => { - this.instance.callSetup( - params, - (result: V2NIMSignallingCallSetupResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + constructor () { + super() + this.instance = new sdk.V2NIMSignallingService({ emit: this.emit.bind(this) }) + } - /** @brief 创建信令房间 */ - /** @param channelType 频道类型 */ - /** @param channelName 频道名称 */ - /** @param channelExtension 频道相关扩展字段 */ - /** @return Promise */ - createRoom(channelType: number, channelName: string, channelExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.createRoom( - channelType, - channelName, - channelExtension, - (result: V2NIMSignallingChannelInfo) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 直接呼叫对方加入房间 + * @param params 呼叫参数 + * @returns Promise + * @example + * ```javascript + * const result = await v2.signallingService.call({ + * calleeAccountId: 'calleeAccountId', + * requestId: 'requestId', + * channelType: 1, + * channelName: 'channelName', + * channelExtension: 'channelExtension', + * serverExtension: 'serverExtension', + * signallingConfig: { + * // ... + * }, + * rtcConfig: { + * // ... + * } + * }) + * ``` + */ + call (params: V2NIMSignallingCallParams): Promise { + return new Promise((resolve, reject) => { + this.instance.call( + params, + (result: V2NIMSignallingCallResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 关闭信令房间接口 */ - /** @param channelId 频道 ID */ - /** @param offlineEnabled 是否支持离线推送 */ - /** @param serverExtension 服务器扩展字段 */ - /** @return Promise */ - closeRoom(channelId: string, offlineEnabled: boolean, serverExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.closeRoom( - channelId, - offlineEnabled, - serverExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 呼叫建立,包括加入信令频道房间,同时接受对方呼叫 + * @param params 建立呼叫参数 + * @returns Promise + * @example + * ```javascript + * const result = await v2.signallingService.callSetup({ + * channelId: 'channelId', + * callerAccountId: 'callerAccountId', + * requestId: 'requestId', + * serverExtension: 'serverExtension', + * signallingConfig: { + * // ... + * }, + * rtcConfig: { + * // ... + * } + * }) + * ``` + */ + callSetup (params: V2NIMSignallingCallSetupParams): Promise { + return new Promise((resolve, reject) => { + this.instance.callSetup( + params, + (result: V2NIMSignallingCallSetupResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 加入信令房间接口 */ - /** @param params 加入房间参数 */ - /** @return Promise */ - joinRoom(params: V2NIMSignallingJoinParams): Promise { - return new Promise((resolve, reject) => { - this.instance.joinRoom( - params, - (result: V2NIMSignallingRoomInfo) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 创建信令房间 + * @param channelType 频道类型 + * @param channelName 频道名称 + * @param channelExtension 频道相关扩展字段 + * @returns Promise + * @example + * ```javascript + * const result = await v2.signallingService.createRoom(channelType, channelName, channelExtension) + * ``` + */ + createRoom (channelType: number, channelName: string, channelExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.createRoom( + channelType, + channelName, + channelExtension, + (result: V2NIMSignallingChannelInfo) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 离开信令房间接口 */ - /** @param channelId 频道 ID */ - /** @param offlineEnabled 是否支持离线推送 */ - /** @param serverExtension 服务器扩展字段 */ - /** @return Promise */ - leaveRoom(channelId: string, offlineEnabled: boolean, serverExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.leaveRoom( - channelId, - offlineEnabled, - serverExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 关闭信令房间接口 + * @param channelId 频道 ID + * @param offlineEnabled 是否支持离线推送 + * @param serverExtension 服务器扩展字段 + * @returns Promise + * @example + * ```javascript + * await v2.signallingService.closeRoom(channelId, offlineEnabled, serverExtension) + * ``` + */ + closeRoom (channelId: string, offlineEnabled: boolean, serverExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.closeRoom( + channelId, + offlineEnabled, + serverExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 邀请成员加入信令房间接口 */ - /** @param params 邀请参数 */ - /** @return Promise */ - invite(params: V2NIMSignallingInviteParams): Promise { - return new Promise((resolve, reject) => { - this.instance.invite( - params, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 加入信令房间接口 + * @param params 加入房间参数 + * @returns Promise + * @example + * ```javascript + * const result = await v2.signallingService.joinRoom({ + * channelId: 'channelId', + * serverExtension: 'serverExtension', + * signallingConfig: { + * // ... + * }, + * rtcConfig: { + * // ... + * } + * }) + * ``` + */ + joinRoom (params: V2NIMSignallingJoinParams): Promise { + return new Promise((resolve, reject) => { + this.instance.joinRoom( + params, + (result: V2NIMSignallingRoomInfo) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 取消之前的邀请成员加入信令房间接口 */ - /** @param params 取消邀请参数 */ - /** @return Promise */ - cancelInvite(params: V2NIMSignallingCancelInviteParams): Promise { - return new Promise((resolve, reject) => { - this.instance.cancelInvite( - params, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 离开信令房间接口 + * @param channelId 频道 ID + * @param offlineEnabled 是否支持离线推送 + * @param serverExtension 服务器扩展字段 + * @returns Promise + * @example + * ```javascript + * await v2.signallingService.leaveRoom(channelId, offlineEnabled, serverExtension) + * ``` + */ + leaveRoom (channelId: string, offlineEnabled: boolean, serverExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.leaveRoom( + channelId, + offlineEnabled, + serverExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 拒绝别人的邀请加入信令房间请求 */ - /** @param params 拒绝邀请参数 */ - /** @return Promise */ - rejectInvite(params: V2NIMSignallingRejectInviteParams): Promise { - return new Promise((resolve, reject) => { - this.instance.rejectInvite( - params, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 邀请成员加入信令房间接口 + * @param params 邀请参数 + * @returns Promise + * @example + * ```javascript + * await v2.signallingService.invite({ + * channelId: 'channelId', + * inviteeAccountId: 'inviteeAccountId', + * requestId: 'requestId', + * serverExtension: 'serverExtension', + * signallingConfig: { + * // ... + * }, + * pushConfig: { + * // ... + * } + * }) + * ``` + */ + invite (params: V2NIMSignallingInviteParams): Promise { + return new Promise((resolve, reject) => { + this.instance.invite( + params, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 接受别人的邀请加入信令房间请求 */ - /** @param params 接受邀请参数 */ - /** @return Promise */ - acceptInvite(params: V2NIMSignallingAcceptInviteParams): Promise { - return new Promise((resolve, reject) => { - this.instance.acceptInvite( - params, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 取消之前的邀请成员加入信令房间接口 + * @param params 取消邀请参数 + * @returns Promise + * @example + * ```javascript + * await v2.signallingService.cancelInvite({ + * channelId: 'channelId', + * inviteeAccountId: 'inviteeAccountId', + * requestId: 'requestId' + * }) + * ``` + */ + cancelInvite (params: V2NIMSignallingCancelInviteParams): Promise { + return new Promise((resolve, reject) => { + this.instance.cancelInvite( + params, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 发送自定义控制指令 */ - /** @param channelId 频道 ID */ - /** @param receiverAccountId 接受者账号 ID */ - /** @param serverExtension 服务器扩展字段 */ - /** @return Promise */ - sendControl(channelId: string, receiverAccountId: string, serverExtension: string): Promise { - return new Promise((resolve, reject) => { - this.instance.sendControl( - channelId, - receiverAccountId, - serverExtension, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 拒绝别人的邀请加入信令房间请求 + * @param params 拒绝邀请参数 + * @returns Promise + * @example + * ```javascript + * await v2.signallingService.rejectInvite({ + * channelId: 'channelId', + * inviterAccountId: 'inviterAccountId', + * requestId: 'requestId' + * }) + * ``` + */ + rejectInvite (params: V2NIMSignallingRejectInviteParams): Promise { + return new Promise((resolve, reject) => { + this.instance.rejectInvite( + params, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 根据频道名称查询频道房间信息 */ - /** @param channelName 频道名称 */ - /** @return Promise */ - getRoomInfoByChannelName(channelName: string): Promise { - return new Promise((resolve, reject) => { - this.instance.getRoomInfoByChannelName( - channelName, - (result: V2NIMSignallingRoomInfo) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 接受别人的邀请加入信令房间请求 + * @param params 接受邀请参数 + * @returns Promise + * @example + * ```javascript + * await v2.signallingService.acceptInvite({ + * channelId: 'channelId', + * inviterAccountId: 'inviterAccountId', + * requestId: 'requestId' + * }) + * ``` + */ + acceptInvite (params: V2NIMSignallingAcceptInviteParams): Promise { + return new Promise((resolve, reject) => { + this.instance.acceptInvite( + params, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 发送自定义控制指令 + * @param channelId 频道 ID + * @param receiverAccountId 接受者账号 ID + * @param serverExtension 服务器扩展字段 + * @returns Promise + * @example + * ```javascript + * await v2.signallingService.sendControl(channelId, receiverAccountId, serverExtension) + * ``` + */ + sendControl (channelId: string, receiverAccountId: string, serverExtension: string): Promise { + return new Promise((resolve, reject) => { + this.instance.sendControl( + channelId, + receiverAccountId, + serverExtension, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据频道名称查询频道房间信息 + * @param channelName 频道名称 + * @returns Promise + * @example + * ```javascript + * const result = await v2.signallingService.getRoomInfoByChannelName(channelName) + * ``` + */ + getRoomInfoByChannelName (channelName: string): Promise { + return new Promise((resolve, reject) => { + this.instance.getRoomInfoByChannelName( + channelName, + (result: V2NIMSignallingRoomInfo) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } } diff --git a/ts/v2/v2_nim_storage_service.ts b/ts/v2/v2_nim_storage_service.ts index e9292ca..2ad40ba 100644 --- a/ts/v2/v2_nim_storage_service.ts +++ b/ts/v2/v2_nim_storage_service.ts @@ -1,196 +1,275 @@ import { - V2NIMUploadFileParams, - V2NIMUploadFileTask, - V2NIMError, - V2NIMStorageScene, - V2NIMDownloadMessageAttachmentParams, - V2NIMMessageAttachment, - V2NIMGetMediaResourceInfoResult, - V2NIMSize + V2NIMUploadFileParams, + V2NIMUploadFileTask, + V2NIMError, + V2NIMStorageScene, + V2NIMDownloadMessageAttachmentParams, + V2NIMMessageAttachment, + V2NIMGetMediaResourceInfoResult, + V2NIMSize } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' -import {EventEmitter} from 'eventemitter3' -import {V2NIMProgressCallback} from "../v2_def/v2_nim_callback_def"; +import { EventEmitter } from 'eventemitter3' +import { V2NIMProgressCallback } from '../v2_def/v2_nim_callback_def' -export declare interface V2NIMStorageServiceEvents { +export declare interface V2NIMStorageListener { } /** @brief 存储服务 */ -export class V2NIMStorageService extends EventEmitter { - instance: any +export class V2NIMStorageService extends EventEmitter { + instance: any - constructor(instanceId?: number) { - super() - this.instance = new sdk.V2NIMStorageService({emit: this.emit.bind(this)}, instanceId) - } + constructor (instanceId?: number) { + super() + this.instance = new sdk.V2NIMStorageService({ emit: this.emit.bind(this) }, instanceId) + } - /** @brief 添加自定义存储场景, 需在登录前调用 */ - /** @param sceneName 自定义存储场景 */ - /** @return void */ - addCustomStorageScene(sceneName: string, expireTime: number): void { - this.instance.addCustomStorageScene(sceneName, expireTime) - } + /** + * @brief 添加自定义存储场景, 需在登录前调用 + * @param sceneName 自定义存储场景 + * @return void + * @example + * ```javascript + * v2.storageService.addCustomStorageScene(sceneName, expireTime) + * ``` + */ + addCustomStorageScene (sceneName: string, expireTime: number): void { + this.instance.addCustomStorageScene(sceneName, expireTime) + } - /** @brief 创建文件上传任务 */ - /** @param fileParams 文件上传的相关参数 */ - /** @return V2NIMUploadFileTask */ - createUploadFileTask(fileParams: V2NIMUploadFileParams): V2NIMUploadFileTask { - return this.instance.createUploadFileTask(fileParams) - } + /** + * @brief 创建文件上传任务 + * @param fileParams 文件上传的相关参数 + * @return V2NIMUploadFileTask + * @example + * ```javascript + * const task = v2.storageService.createUploadFileTask({ + * filePath: 'file_path' + * }) + * ``` + */ + createUploadFileTask (fileParams: V2NIMUploadFileParams): V2NIMUploadFileTask { + return this.instance.createUploadFileTask(fileParams) + } - /** @brief 文件上传 */ - /** @param fileParams 文件上传的相关参数 */ - /** @return Primise */ - uploadFile(fileTask: V2NIMUploadFileTask): Promise { - return new Promise((resolve, reject) => { - this.instance.uploadFile( - fileTask, - (url: string) => { - resolve(url) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 文件上传 + * @param fileTask 文件上传任务 + * @returns Promise + * @example + * ```javascript + * const url = await v2.storageService.uploadFile({ + * taskId: 'task_id', + * uploadParams: { + * filePath: 'file_path' + * } + * }) + * ``` + */ + uploadFile (fileTask: V2NIMUploadFileTask): Promise { + return new Promise((resolve, reject) => { + this.instance.uploadFile( + fileTask, + (url: string) => { + resolve(url) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 取消文件上传 */ - /** @param uploadId 文件上传任务 id */ - /** @return void */ - cancelUploadFile(fileTask: V2NIMUploadFileTask): Promise { - return new Promise((resolve, reject) => { - this.instance.cancelUploadFile( - fileTask, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 取消文件上传 + * @param fileTask 文件上传任务 + * @returns Promise + * @example + * ```javascript + * await v2.storageService.cancelUploadFile({ + * taskId: 'task_id' + * }) + * ``` + */ + cancelUploadFile (fileTask: V2NIMUploadFileTask): Promise { + return new Promise((resolve, reject) => { + this.instance.cancelUploadFile( + fileTask, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 下载文件 */ - /** @param url 文件下载地址 */ - /** @param filePath 文件保存路径 */ - /** @param progressCallback 下载进度回调 */ - /** @return Promise 下载文件的 Promise 对象 */ - downloadFile(url: string, filePath: string, progressCallback: V2NIMProgressCallback): Promise { - return new Promise((resolve, reject) => { - this.instance.downloadFile( - url, - filePath, - (savePath: string) => { - resolve(savePath) - }, - (error: V2NIMError) => { - reject(error) - }, - (progress: number) => { - progressCallback(progress) - } - ) - }) - } + /** + * @brief 下载文件 + * @param url 文件下载地址 + * @param filePath 文件保存路径 + * @param progressCallback 下载进度回调 + * @returns Promise 下载文件的 Promise 对象 + * @example + * ```javascript + * const savePath = await v2.storageService.downloadFile(url, filePath, progressCallback) + * ``` + */ + downloadFile (url: string, filePath: string, progressCallback: V2NIMProgressCallback): Promise { + return new Promise((resolve, reject) => { + this.instance.downloadFile( + url, + filePath, + (savePath: string) => { + resolve(savePath) + }, + (error: V2NIMError) => { + reject(error) + }, + (progress: number) => { + progressCallback(progress) + } + ) + }) + } - /** @brief 取消下载文件 */ - /** @param url 文件下载地址 */ - /** @return Promise 取消下载文件的 Promise 对象 */ - cancelDownloadFile(url: string): Promise { - return new Promise((resolve, reject) => { - this.instance.cancelDownloadFile( - url, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 取消下载文件 + * @param url 文件下载地址 + * @returns Promise 取消下载文件的 Promise 对象 + * @example + * ```javascript + * await v2.storageService.cancelDownloadFile(url) + * ``` + */ + cancelDownloadFile (url: string): Promise { + return new Promise((resolve, reject) => { + this.instance.cancelDownloadFile( + url, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 查询存储场景列表 */ - /** @return Array */ - getStorageSceneList(): Array { - return this.instance.getStorageSceneList() - } + /** + * @brief 查询存储场景列表 + * @returns Array + * @example + * ```javascript + * const scenes = v2.storageService.getStorageSceneList() + * ``` + */ + getStorageSceneList (): Array { + return this.instance.getStorageSceneList() + } - /** @brief 长链接转短链接 */ - /** @param shortUrl 短链接地址 */ - /** @return Promise 长链接的 Promise 对象 */ - shortUrlToLong(shortUrl: string): Promise { - return new Promise((resolve, reject) => { - this.instance.shortUrlToLong( - shortUrl, - (longUrl: string) => { - resolve(longUrl) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** @brief 长链接转短链接 + * @param shortUrl 短链接地址 + * @returns Promise 长链接的 Promise 对象 + * @example + * ```javascript + * const longUrl = await v2.storageService.shortUrlToLong(shortUrl) + * ``` + */ + shortUrlToLong (shortUrl: string): Promise { + return new Promise((resolve, reject) => { + this.instance.shortUrlToLong( + shortUrl, + (longUrl: string) => { + resolve(longUrl) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 下载消息附件 */ - /** @param downloadParam 下载参数 */ - /** @param progress 下载进度回调 */ - /** @return Promise 下载文件的 Promise 对象 */ - downloadAttachment(downloadParam: V2NIMDownloadMessageAttachmentParams, progress: V2NIMProgressCallback): Promise { - return new Promise((resolve, reject) => { - this.instance.downloadAttachment( - downloadParam, - (savePath: string) => { - resolve(savePath) - }, - (error: V2NIMError) => { - reject(error) - }, - (prog: number) => { - progress(prog) - } - ) - }) - } + /** + * @brief 下载消息附件 + * @param downloadParam 下载参数 + * @param progress 下载进度回调 + * @returns Promise 下载文件的 Promise 对象 + * @example + * ```javascript + * const savePath = await v2.storageService.downloadAttachment({ + * attachment, + * type: 0, + * }, (progress) => { + * console.log(progress) + * }) + * ``` + */ + downloadAttachment (downloadParam: V2NIMDownloadMessageAttachmentParams, progress: V2NIMProgressCallback): Promise { + return new Promise((resolve, reject) => { + this.instance.downloadAttachment( + downloadParam, + (savePath: string) => { + resolve(savePath) + }, + (error: V2NIMError) => { + reject(error) + }, + (prog: number) => { + progress(prog) + } + ) + }) + } - /** @brief 获取图片消息中的图片缩略图 */ - /** @param attachment 消息附件 */ - /** @param thumbSize 图片缩略图的尺寸,若不指定则使用默认 150x150 */ - /** @return Promise 获取图片缩略图的 Promise 对象 */ - getImageThumbUrl(attachment: V2NIMMessageAttachment, thumbSize?: V2NIMSize): Promise { - return new Promise((resolve, reject) => { - this.instance.getImageThumbUrl( - attachment, - thumbSize, - (result: V2NIMGetMediaResourceInfoResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 获取图片消息中的图片缩略图 + * @param attachment 消息附件 + * @param thumbSize 图片缩略图的尺寸,若不指定则使用默认 150x150 + * @returns Promise 获取图片缩略图的 Promise 对象 + * @example + * ```javascript + * const result = await v2.storageService.getImageThumbUrl(attachment, thumbSize) + * ``` + */ + getImageThumbUrl (attachment: V2NIMMessageAttachment, thumbSize?: V2NIMSize): Promise { + return new Promise((resolve, reject) => { + this.instance.getImageThumbUrl( + attachment, + thumbSize, + (result: V2NIMGetMediaResourceInfoResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 获取视频消息中的视频缩略图 */ - /** @param attachment 消息附件 */ - /** @param thumbSize 视频缩略图的尺寸,若不指定则使用默认 150x150 */ - /** @return Promise 获取视频缩略图的 Promise 对象 */ - getVideoCoverUrl(attachment: V2NIMMessageAttachment, thumbSize?: V2NIMSize): Promise { - return new Promise((resolve, reject) => { - this.instance.getVideoCoverUrl( - attachment, - thumbSize, - (result: V2NIMGetMediaResourceInfoResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 获取视频消息中的视频缩略图 + * @param attachment 消息附件 + * @param thumbSize 视频缩略图的尺寸,若不指定则使用默认 150x150 + * @returns Promise 获取视频缩略图的 Promise 对象 + * @example + * ```javascript + * const result = await v2.storageService.getVideoCoverUrl(attachment, thumbSize) + * ``` + */ + getVideoCoverUrl (attachment: V2NIMMessageAttachment, thumbSize?: V2NIMSize): Promise { + return new Promise((resolve, reject) => { + this.instance.getVideoCoverUrl( + attachment, + thumbSize, + (result: V2NIMGetMediaResourceInfoResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } } diff --git a/ts/v2/v2_nim_subscription_service.ts b/ts/v2/v2_nim_subscription_service.ts index 6e9e7ea..efb2925 100644 --- a/ts/v2/v2_nim_subscription_service.ts +++ b/ts/v2/v2_nim_subscription_service.ts @@ -1,93 +1,123 @@ import { - V2NIMSubscribeUserStatusOption, - V2NIMUnsubscribeUserStatusOption, - V2NIMError, - V2NIMCustomUserStatusParams, - V2NIMCustomUserStatusPublishResult, - V2NIMUserStatusSubscribeResult, - V2NIMUserStatus, + V2NIMSubscribeUserStatusOption, + V2NIMUnsubscribeUserStatusOption, + V2NIMError, + V2NIMCustomUserStatusParams, + V2NIMCustomUserStatusPublishResult, + V2NIMUserStatusSubscribeResult, + V2NIMUserStatus, } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' -import {EventEmitter} from 'eventemitter3' +import { EventEmitter } from 'eventemitter3' -export declare interface V2NIMSubscriptionServiceEvents { - userStatusChanged: [V2NIMUserStatus] +export declare interface V2NIMSubscriptionListener { + userStatusChanged: [V2NIMUserStatus] } /** @brief 订阅服务 */ -export class V2NIMSubscriptionService extends EventEmitter { - instance: any +export class V2NIMSubscriptionService extends EventEmitter { + instance: any - constructor() { - super() - this.instance = new sdk.V2NIMSubscriptionService({emit: this.emit.bind(this)}) - } + constructor () { + super() + this.instance = new sdk.V2NIMSubscriptionService({ emit: this.emit.bind(this) }) + } - /** @brief 订阅用户状态 */ - /** @param option 订阅用户状态选项 */ - /** @return Promise */ - subscribeUserStatus(option: V2NIMSubscribeUserStatusOption): Promise { - return new Promise((resolve, reject) => { - this.instance.subscribeUserStatus( - option, - (result: string[]) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 订阅用户状态 + * @param option 订阅用户状态选项 + * @returns Promise + * @example + * ```javascript + * const result = await v2.subscriptionService.subscribeUserStatus({ + * accountIds: ['account1', 'account2'], + * }) + * ``` + */ + subscribeUserStatus (option: V2NIMSubscribeUserStatusOption): Promise { + return new Promise((resolve, reject) => { + this.instance.subscribeUserStatus( + option, + (result: string[]) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 取消用户状态订阅 */ - /** @param option 取消订阅用户状态选项 */ - /** @return Promise */ - unsubscribeUserStatus(option: V2NIMUnsubscribeUserStatusOption): Promise { - return new Promise((resolve, reject) => { - this.instance.unsubscribeUserStatus( - option, - (result: string[]) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 取消用户状态订阅 + * @param option 取消订阅用户状态选项 + * @returns Promise + * @example + * ```javascript + * const result = await v2.subscriptionService.unsubscribeUserStatus({ + * accountIds: ['account1', 'account2'], + * }) + * ``` + */ + unsubscribeUserStatus (option: V2NIMUnsubscribeUserStatusOption): Promise { + return new Promise((resolve, reject) => { + this.instance.unsubscribeUserStatus( + option, + (result: string[]) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 发布用户自定义状态 */ - /** @param params 发布自定义用户状态参数 */ - /** @return Promise */ - publishCustomUserStatus(params: V2NIMCustomUserStatusParams): Promise { - return new Promise((resolve, reject) => { - this.instance.publishCustomUserStatus( - params, - (result: V2NIMCustomUserStatusPublishResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 发布用户自定义状态 + * @param params 发布自定义用户状态参数 + * @returns Promise + * @example + * ```javascript + * const result = await v2.subscriptionService.publishCustomUserStatus({ + * statusType: 10001, + * duration: 60 + * }) + * ``` + */ + publishCustomUserStatus (params: V2NIMCustomUserStatusParams): Promise { + return new Promise((resolve, reject) => { + this.instance.publishCustomUserStatus( + params, + (result: V2NIMCustomUserStatusPublishResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 查询用户状态订阅关系 */ - /** @param accountIds 账号列表 */ - /** @return Promise */ - queryUserStatusSubscriptions(accountIds: string[]): Promise { - return new Promise((resolve, reject) => { - this.instance.queryUserStatusSubscriptions( - accountIds, - (result: V2NIMUserStatusSubscribeResult[]) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** @brief 查询用户状态订阅关系 + * @param accountIds 账号列表 + * @returns Promise + * @example + * ```javascript + * const result = await v2.subscriptionService.queryUserStatusSubscriptions(['account1', 'account2']) + * ``` + */ + queryUserStatusSubscriptions (accountIds: string[]): Promise { + return new Promise((resolve, reject) => { + this.instance.queryUserStatusSubscriptions( + accountIds, + (result: V2NIMUserStatusSubscribeResult[]) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } } diff --git a/ts/v2/v2_nim_team_service.ts b/ts/v2/v2_nim_team_service.ts index 40b19cb..425e249 100644 --- a/ts/v2/v2_nim_team_service.ts +++ b/ts/v2/v2_nim_team_service.ts @@ -1,677 +1,867 @@ import { - V2NIMCreateTeamParams, - V2NIMAntispamConfig, - V2NIMCreateTeamResult, - V2NIMError, - V2NIMUpdateTeamInfoParams, - V2NIMTeam, - V2NIMUpdateSelfMemberInfoParams, - V2NIMTeamMemberQueryOption, - V2NIMTeamMemberListResult, - V2NIMTeamMember, - V2NIMTeamJoinActionInfo, - V2NIMTeamJoinActionInfoResult, - V2NIMTeamJoinActionInfoQueryOption, - V2NIMTeamMemberSearchOption + V2NIMCreateTeamParams, + V2NIMAntispamConfig, + V2NIMCreateTeamResult, + V2NIMError, + V2NIMUpdateTeamInfoParams, + V2NIMTeam, + V2NIMUpdateSelfMemberInfoParams, + V2NIMTeamMemberQueryOption, + V2NIMTeamMemberListResult, + V2NIMTeamMember, + V2NIMTeamJoinActionInfo, + V2NIMTeamJoinActionInfoResult, + V2NIMTeamJoinActionInfoQueryOption, + V2NIMTeamMemberSearchOption } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' -import {EventEmitter} from 'eventemitter3' +import { EventEmitter } from 'eventemitter3' import { V2NIMTeamChatBannedMode, V2NIMTeamMemberRole, V2NIMTeamType } from 'ts/v2_def/v2_nim_enum_def' -export declare interface V2NIMTeamServiceEvents { - /** 群组信息同步开始 */ - syncStarted: [] - /** 群组信息同步完成 */ - syncFinished: [] - /** 群组信息同步失败 */ - syncFailed: [V2NIMError] - /** 群组创建 */ - teamCreated: [V2NIMTeam] - /** 加入群组 */ - teamDismissed: [V2NIMTeam] - /** 群组创建 */ - teamJoined: [V2NIMTeam] - /** 离开群组 */ - teamLeft: [team: V2NIMTeam, isKicked: boolean] - /** 群组信息更新 */ - teamInfoUpdated: [V2NIMTeam] - /** 群组成员加入 */ - teamMemberJoined: [Array] - /** 群组成员被踢 */ - teamMemberKicked: [operateAccountId: string, teamMembers: Array] - /** 群组成员退出群组 */ - teamMemberLeft: [Array] - /** 群组成员信息变更 */ - teamMemberInfoUpdated: [Array] - /** 收到入群信息 */ - receiveTeamJoinActionInfo: [V2NIMTeamJoinActionInfo] +export declare interface V2NIMTeamListener { + /** 群组信息同步开始 */ + syncStarted: [] + /** 群组信息同步完成 */ + syncFinished: [] + /** 群组信息同步失败 */ + syncFailed: [V2NIMError] + /** 群组创建 */ + teamCreated: [V2NIMTeam] + /** 加入群组 */ + teamDismissed: [V2NIMTeam] + /** 群组创建 */ + teamJoined: [V2NIMTeam] + /** 离开群组 */ + teamLeft: [team: V2NIMTeam, isKicked: boolean] + /** 群组信息更新 */ + teamInfoUpdated: [V2NIMTeam] + /** 群组成员加入 */ + teamMemberJoined: [Array] + /** 群组成员被踢 */ + teamMemberKicked: [operateAccountId: string, teamMembers: Array] + /** 群组成员退出群组 */ + teamMemberLeft: [Array] + /** 群组成员信息变更 */ + teamMemberInfoUpdated: [Array] + /** 收到入群信息 */ + receiveTeamJoinActionInfo: [V2NIMTeamJoinActionInfo] } /** @brief 存储服务 */ -export class V2NIMTeamService extends EventEmitter { - instance: any - - constructor() { - super() - this.instance = new sdk.V2NIMTeamService({emit: this.emit.bind(this)}) - } - - /** @brief 创建群组 */ - /** @param createTeamParams 创建群组参数 */ - /** @param inviteeAccountIds 群组创建时, 同时被邀请加入群的成员列表 */ - /** @param postscript 群组创建时, 邀请入群的附言 */ - - /** @param antispamConfig 反垃圾配置 */ - /** @return void */ - createTeam( - createTeamParams: V2NIMCreateTeamParams, - inviteeAccountIds: Array, - postscript: string, - antispamConfig: V2NIMAntispamConfig - ): Promise { - return new Promise((resolve, reject) => { - this.instance.createTeam( - createTeamParams, - inviteeAccountIds, - postscript, - antispamConfig, - (result: V2NIMCreateTeamResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 修改群组信息 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - /** @param updateTeamInfoParams 修改群组信息参数 */ - - /** @param antispamConfig 反垃圾配置 */ - /** @return void */ - updateTeamInfo( - teamId: string, - teamType: V2NIMTeamType, - updateTeamInfoParams: V2NIMUpdateTeamInfoParams, - antispamConfig: V2NIMAntispamConfig - ): Promise { - return new Promise((resolve, reject) => { - this.instance.updateTeamInfo( - teamId, - teamType, - updateTeamInfoParams, - antispamConfig, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 退出群组 */ - /** @param teamId 群组 id */ - - /** @param teamType 群组类型 */ - /** @return void */ - leaveTeam(teamId: string, teamType: V2NIMTeamType): Promise { - return new Promise((resolve, reject) => { - this.instance.leaveTeam( - teamId, - teamType, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取群组信息 */ - /** @param teamId 群组 id */ - - /** @param teamType 群组类型 */ - /** @return void */ - getTeamInfo(teamId: string, teamType: V2NIMTeamType): Promise { - return new Promise((resolve, reject) => { - this.instance.getTeamInfo( - teamId, - teamType, - (team: V2NIMTeam) => { - resolve(team) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 根据群组 ID 获取群组信息 */ - /** @param teamIds 群组 id 列表 */ - - /** @param teamType 群组类型 */ - /** @return void */ - getTeamInfoByIds(teamIds: Array, teamType: V2NIMTeamType): Promise> { - return new Promise((resolve, reject) => { - this.instance.getTeamInfoByIds( - teamIds, - teamType, - (teams: Array) => { - resolve(teams) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 解散群组 */ - /** @param teamId 群组 id */ - - /** @param teamType 群组类型 */ - /** @return void */ - dismissTeam(teamId: string, teamType: V2NIMTeamType): Promise { - return new Promise((resolve, reject) => { - this.instance.dismissTeam( - teamId, - teamType, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 邀请成员加入群组 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - /** @param inviteeAccountIds 被邀请人 id 列表 */ - - /** @param postscript 邀请附言 */ - /** @return void */ - inviteMember(teamId: string, teamType: V2NIMTeamType, inviteeAccountIds: Array, postscript: string): Promise> { - return new Promise((resolve, reject) => { - this.instance.inviteMember( - teamId, - teamType, - inviteeAccountIds, - postscript, - (accountIds: Array) => { - resolve(accountIds) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 同意邀请入群 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - - /** @param invitorAccountId 邀请人 id */ - /** @return void */ - acceptInvitation(invitationInfo: V2NIMTeamJoinActionInfo): Promise { - return new Promise((resolve, reject) => { - this.instance.acceptInvitation( - invitationInfo, - (team: V2NIMTeam) => { - resolve(team) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 拒绝邀请入群 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - /** @param invitorAccountId 邀请人 id */ - - /** @param postscript 拒绝邀请的理由附言 */ - /** @return void */ - rejectInvitation(invitationInfo: V2NIMTeamJoinActionInfo, postscript: string): Promise { - return new Promise((resolve, reject) => { - this.instance.rejectInvitation( - invitationInfo, - postscript, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 踢出群组成员 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - - /** @param memberAccountIds 踢出群组的成员账号列表 */ - /** @return void */ - kickMember(teamId: string, teamType: V2NIMTeamType, memberAccountIds: Array): Promise { - return new Promise((resolve, reject) => { - this.instance.kickMember( - teamId, - teamType, - memberAccountIds, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 申请加入群组 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - - /** @param postscript 申请入群的附言 */ - /** @return void */ - applyJoinTeam(teamId: string, teamType: V2NIMTeamType, postscript: string): Promise { - return new Promise((resolve, reject) => { - this.instance.applyJoinTeam( - teamId, - teamType, - postscript, - (team: V2NIMTeam) => { - resolve(team) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 接受入群申请 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - - /** @param applyAccountId 申请人 id */ - /** @return void */ - acceptJoinApplication(applicationInfo: V2NIMTeamJoinActionInfo): Promise { - return new Promise((resolve, reject) => { - this.instance.acceptJoinApplication( - applicationInfo, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 拒绝入群申请 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - /** @param applyAccountId 申请人 id */ - - /** @param postscript 拒绝入群申请的附言 */ - /** @return void */ - rejectJoinApplication(applicationInfo: V2NIMTeamJoinActionInfo, postscript: string): Promise { - return new Promise((resolve, reject) => { - this.instance.rejectJoinApplication( - applicationInfo, - postscript, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 设置成员角色 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - /** @param memberAccountId 成员 id */ - - /** @param memberRole 设置新的角色类型 */ - /** @return void */ - updateTeamMemberRole(teamId: string, teamType: V2NIMTeamType, memberAccountIds: Array, memberRole: V2NIMTeamMemberRole): Promise { - return new Promise((resolve, reject) => { - this.instance.updateTeamMemberRole( - teamId, - teamType, - memberAccountIds, - memberRole, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 移交群主 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - /** @param accountId 新群主 id */ - - /** @param leave 是否同时退出群组 */ - /** @return void */ - transferTeamOwner(teamId: string, teamType: V2NIMTeamType, accountId: string, leave: boolean): Promise { - return new Promise((resolve, reject) => { - this.instance.transferTeamOwner( - teamId, - teamType, - accountId, - leave, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 修改自己的群成员信息 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - - /** @param memberInfoParams 修改群成员信息参数 */ - /** @return void */ - updateSelfTeamMemberInfo(teamId: string, teamType: V2NIMTeamType, memberInfoParams: V2NIMUpdateSelfMemberInfoParams): Promise { - return new Promise((resolve, reject) => { - this.instance.updateSelfTeamMemberInfo( - teamId, - teamType, - memberInfoParams, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 修改群成员昵称 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - /** @param accountId 群成员 id */ - - /** @param nick 群成员昵称 */ - /** @return void */ - updateTeamMemberNick(teamId: string, teamType: V2NIMTeamType, accountId: string, teamNick: string): Promise { - return new Promise((resolve, reject) => { - this.instance.updateTeamMemberNick( - teamId, - teamType, - accountId, - teamNick, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 设置群组禁言模式 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - - /** @param chatBannedMode 群组禁言模式 */ - /** @return void */ - setTeamChatBannedMode(teamId: string, teamType: V2NIMTeamType, chatBannedMode: V2NIMTeamChatBannedMode): Promise { - return new Promise((resolve, reject) => { - this.instance.setTeamChatBannedMode( - teamId, - teamType, - chatBannedMode, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 设置群组成员聊天禁言状态 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - /** @param accountId 群成员 id */ - - /** @param chatBanned 是否禁言 */ - /** @return void */ - setTeamMemberChatBannedStatus(teamId: string, teamType: V2NIMTeamType, accountId: string, chatBanned: boolean): Promise { - return new Promise((resolve, reject) => { - this.instance.setTeamMemberChatBannedStatus( - teamId, - teamType, - accountId, - chatBanned, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取当前已经加入的群组列表 */ - - /** @param teamType 群组类型 */ - /** @return void */ - getJoinedTeamList(teamTypes: Array): Promise> { - return new Promise((resolve, reject) => { - this.instance.getJoinedTeamList( - teamTypes, - (teams: Array) => { - resolve(teams) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取当前已经加入的群组数量 */ - - /** @param teamTypes 群组类型列表, 为空表示查询所有群类型 */ - /** @return number */ - getJoinedTeamCount(teamTypes: Array): number { - return this.instance.getJoinedTeamCount(teamTypes) - } - - /** @brief 获取群组成员列表 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - - /** @param queryOption 群组成员查询选项 */ - /** @return void */ - getTeamMemberList(teamId: string, teamType: V2NIMTeamType, queryOption: V2NIMTeamMemberQueryOption): Promise { - return new Promise((resolve, reject) => { - this.instance.getTeamMemberList( - teamId, - teamType, - queryOption, - (result: V2NIMTeamMemberListResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 根据账号 ID 列表获取群组成员列表 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - - /** @param accountIds 账号 ID 列表 */ - /** @return void */ - getTeamMemberListByIds(teamId: string, teamType: V2NIMTeamType, accountIds: Array): Promise> { - return new Promise((resolve, reject) => { - this.instance.getTeamMemberListByIds( - teamId, - teamType, - accountIds, - (members: Array) => { - resolve(members) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 根据账号 ID 列表获取群组成员邀请人 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - - /** @param accountIds 账号 ID 列表 */ - /** @return void */ - getTeamMemberInvitor(teamId: string, teamType: V2NIMTeamType, accountIds: Array): Promise> { - return new Promise((resolve, reject) => { - this.instance.getTeamMemberInvitor( - teamId, - teamType, - accountIds, - (invitorMap: Map) => { - resolve(invitorMap) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取群加入相关信息 */ - - /** @param option 查询参数 */ - /** @return void */ - getTeamJoinActionInfoList(option: V2NIMTeamJoinActionInfoQueryOption): Promise { - return new Promise((resolve, reject) => { - this.instance.getTeamJoinActionInfoList( - option, - (result: V2NIMTeamJoinActionInfoResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 根据关键字搜索群组,混合搜索高级群和超大群,使用 LIKE 方式匹配,只搜索群名称 */ - - /** @param keyword 关键字 */ - /** @return Promise> */ - searchTeamByKeyword(keyword: string): Promise> { - return new Promise((resolve, reject) => { - this.instance.searchTeamByKeyword( - keyword, - (teams: Array) => { - resolve(teams) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 根据关键字搜索群组成员 */ - - /** @param option 搜索选项 */ - /** @return Promise */ - searchTeamMembers(option: V2NIMTeamMemberSearchOption): Promise { - return new Promise((resolve, reject) => { - this.instance.searchTeamMembers( - option, - (result: V2NIMTeamMemberListResult) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 添加特别关注群成员列表 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - - /** @param accountIds 账号 id 列表 */ - /** @return void */ - addTeamMembersFollow(teamId: string, teamType: V2NIMTeamType, accountIds: Array): Promise { - return new Promise((resolve, reject) => { - this.instance.addTeamMembersFollow( - teamId, - teamType, - accountIds, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 移除特别关注群成员列表 */ - /** @param teamId 群组 id */ - /** @param teamType 群组类型 */ - /** @param accountIds 账号 id 列表 */ - /** @return void */ - removeTeamMembersFollow(teamId: string, teamType: V2NIMTeamType, accountIds: Array): Promise { - return new Promise((resolve, reject) => { - this.instance.removeTeamMembersFollow( - teamId, - teamType, - accountIds, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } +export class V2NIMTeamService extends EventEmitter { + instance: any + + constructor () { + super() + this.instance = new sdk.V2NIMTeamService({ emit: this.emit.bind(this) }) + } + + /** + * @brief 创建群组 + * @param createTeamParams 创建群组参数 + * @param inviteeAccountIds 群组创建时, 同时被邀请加入群的成员列表 + * @param postscript 群组创建时, 邀请入群的附言 + * @param antispamConfig 反垃圾配置 + * @returns Promise + * @example + * ```javascript + * const result = await v2.teamService.createTeam({ + * name: 'team1', + * teamType: 0, + * }, inviteeAccountIds, postscript, antispamConfig) + * ``` + */ + createTeam ( + createTeamParams: V2NIMCreateTeamParams, + inviteeAccountIds: Array, + postscript: string, + antispamConfig: V2NIMAntispamConfig + ): Promise { + return new Promise((resolve, reject) => { + this.instance.createTeam( + createTeamParams, + inviteeAccountIds, + postscript, + antispamConfig, + (result: V2NIMCreateTeamResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 修改群组信息 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param updateTeamInfoParams 修改群组信息参数 + * @param antispamConfig 反垃圾配置 + * @returns void + * @example + * ```javascript + * await v2.teamService.updateTeamInfo(teamId, teamType, { + * name: 'team1', + * }, antispamConfig) + * ``` + */ + updateTeamInfo ( + teamId: string, + teamType: V2NIMTeamType, + updateTeamInfoParams: V2NIMUpdateTeamInfoParams, + antispamConfig: V2NIMAntispamConfig + ): Promise { + return new Promise((resolve, reject) => { + this.instance.updateTeamInfo( + teamId, + teamType, + updateTeamInfoParams, + antispamConfig, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 退出群组 + * @param teamId 群组 id + * @param teamType 群组类型 + * @returns void + * @example + * ```javascript + * await v2.teamService.leaveTeam(teamId, teamType) + * ``` + */ + leaveTeam (teamId: string, teamType: V2NIMTeamType): Promise { + return new Promise((resolve, reject) => { + this.instance.leaveTeam( + teamId, + teamType, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 获取群组信息 + * @param teamId 群组 id + * @param teamType 群组类型 + * @returns Promise + * @example + * ```javascript + * const team = await v2.teamService.getTeamInfo(teamId, teamType) + * ``` + */ + getTeamInfo (teamId: string, teamType: V2NIMTeamType): Promise { + return new Promise((resolve, reject) => { + this.instance.getTeamInfo( + teamId, + teamType, + (team: V2NIMTeam) => { + resolve(team) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据群组 ID 获取群组信息 + * @param teamIds 群组 id 列表 + * @param teamType 群组类型 + * @returns Promise> + * @example + * ```javascript + * const teams = await v2.teamService.getTeamInfoByIds(teamIds, teamType) + * ``` + */ + getTeamInfoByIds (teamIds: Array, teamType: V2NIMTeamType): Promise> { + return new Promise((resolve, reject) => { + this.instance.getTeamInfoByIds( + teamIds, + teamType, + (teams: Array) => { + resolve(teams) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 解散群组 + * @param teamId 群组 id + * @param teamType 群组类型 + * @returns void + * @example + * ```javascript + * await v2.teamService.dismissTeam(teamId, teamType) + * ``` + */ + dismissTeam (teamId: string, teamType: V2NIMTeamType): Promise { + return new Promise((resolve, reject) => { + this.instance.dismissTeam( + teamId, + teamType, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 邀请成员加入群组 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param inviteeAccountIds 被邀请人 id 列表 + * @param postscript 邀请附言 + * @returns Promise> + * @example + * ```javascript + * const accountIds = await v2.teamService.inviteMember(teamId, teamType, inviteeAccountIds, postscript) + * ``` + */ + inviteMember (teamId: string, teamType: V2NIMTeamType, inviteeAccountIds: Array, postscript: string): Promise> { + return new Promise((resolve, reject) => { + this.instance.inviteMember( + teamId, + teamType, + inviteeAccountIds, + postscript, + (accountIds: Array) => { + resolve(accountIds) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 同意邀请入群 + * @param invitationInfo 邀请信息 + * @returns Promise + * @example + * ```javascript + * const team = await v2.teamService.acceptInvitation(invitationInfo) + * ``` + */ + acceptInvitation (invitationInfo: V2NIMTeamJoinActionInfo): Promise { + return new Promise((resolve, reject) => { + this.instance.acceptInvitation( + invitationInfo, + (team: V2NIMTeam) => { + resolve(team) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 拒绝邀请入群 + * @param invitationInfo 邀请信息 + * @param postscript 拒绝邀请的理由附言 + * @returns void + * @example + * ```javascript + * await v2.teamService.rejectInvitation(invitationInfo, postscript) + * ``` + */ + rejectInvitation (invitationInfo: V2NIMTeamJoinActionInfo, postscript: string): Promise { + return new Promise((resolve, reject) => { + this.instance.rejectInvitation( + invitationInfo, + postscript, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 踢出群组成员 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param memberAccountIds 踢出群组的成员账号列表 + * @returns void + * @example + * ```javascript + * await v2.teamService.kickMember(teamId, teamType, memberAccountIds) + * ``` + */ + kickMember (teamId: string, teamType: V2NIMTeamType, memberAccountIds: Array): Promise { + return new Promise((resolve, reject) => { + this.instance.kickMember( + teamId, + teamType, + memberAccountIds, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 申请加入群组 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param postscript 申请入群的附言 + * @returns Promise + * @example + * ```javascript + * const team = await v2.teamService.applyJoinTeam(teamId, teamType, postscript) + * ``` + */ + applyJoinTeam (teamId: string, teamType: V2NIMTeamType, postscript: string): Promise { + return new Promise((resolve, reject) => { + this.instance.applyJoinTeam( + teamId, + teamType, + postscript, + (team: V2NIMTeam) => { + resolve(team) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 接受入群申请 + * @param applicationInfo 申请信息 + * @returns void + * @example + * ```javascript + * await v2.teamService.acceptJoinApplication(applicationInfo) + * ``` + */ + acceptJoinApplication (applicationInfo: V2NIMTeamJoinActionInfo): Promise { + return new Promise((resolve, reject) => { + this.instance.acceptJoinApplication( + applicationInfo, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 拒绝入群申请 + * @param applicationInfo 申请信息 + * @param postscript 拒绝入群申请的附言 + * @returns void + * @example + * ```javascript + * await v2.teamService.rejectJoinApplication(applicationInfo, postscript) + * ``` + */ + rejectJoinApplication (applicationInfo: V2NIMTeamJoinActionInfo, postscript: string): Promise { + return new Promise((resolve, reject) => { + this.instance.rejectJoinApplication( + applicationInfo, + postscript, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 设置成员角色 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param memberAccountIds 成员 id 列表 + * @param memberRole 设置新的角色类型 + * @returns void + * @example + * ```javascript + * await v2.teamService.updateTeamMemberRole(teamId, teamType, memberAccountIds, memberRole) + * ``` + */ + updateTeamMemberRole (teamId: string, teamType: V2NIMTeamType, memberAccountIds: Array, memberRole: V2NIMTeamMemberRole): Promise { + return new Promise((resolve, reject) => { + this.instance.updateTeamMemberRole( + teamId, + teamType, + memberAccountIds, + memberRole, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 移交群主 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param accountId 新群主 id + * @param leave 是否同时退出群组 + * @returns void + * @example + * ```javascript + * await v2.teamService.transferTeamOwner(teamId, teamType, accountId, leave) + * ``` + */ + transferTeamOwner (teamId: string, teamType: V2NIMTeamType, accountId: string, leave: boolean): Promise { + return new Promise((resolve, reject) => { + this.instance.transferTeamOwner( + teamId, + teamType, + accountId, + leave, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 修改自己的群成员信息 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param memberInfoParams 修改群成员信息参数 + * @returns void + * @example + * ```javascript + * await v2.teamService.updateSelfTeamMemberInfo(teamId, teamType, memberInfoParams) + * ``` + */ + updateSelfTeamMemberInfo (teamId: string, teamType: V2NIMTeamType, memberInfoParams: V2NIMUpdateSelfMemberInfoParams): Promise { + return new Promise((resolve, reject) => { + this.instance.updateSelfTeamMemberInfo( + teamId, + teamType, + memberInfoParams, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 修改群成员昵称 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param accountId 群成员 id + * @param nick 群成员昵称 + * @returns void + * @example + * ```javascript + * await v2.teamService.updateTeamMemberNick(teamId, teamType, accountId, teamNick) + * ``` + */ + updateTeamMemberNick (teamId: string, teamType: V2NIMTeamType, accountId: string, teamNick: string): Promise { + return new Promise((resolve, reject) => { + this.instance.updateTeamMemberNick( + teamId, + teamType, + accountId, + teamNick, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 设置群组禁言模式 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param chatBannedMode 群组禁言模式 + * @returns void + * @example + * ```javascript + * await v2.teamService.setTeamChatBannedMode(teamId, teamType, chatBannedMode) + * ``` + */ + setTeamChatBannedMode (teamId: string, teamType: V2NIMTeamType, chatBannedMode: V2NIMTeamChatBannedMode): Promise { + return new Promise((resolve, reject) => { + this.instance.setTeamChatBannedMode( + teamId, + teamType, + chatBannedMode, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 设置群组成员聊天禁言状态 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param accountId 群成员 id + * @param chatBanned 是否禁言 + * @returns void + * @example + * ```javascript + * await v2.teamService.setTeamMemberChatBannedStatus(teamId, teamType, accountId, chatBanned) + * ``` + */ + setTeamMemberChatBannedStatus (teamId: string, teamType: V2NIMTeamType, accountId: string, chatBanned: boolean): Promise { + return new Promise((resolve, reject) => { + this.instance.setTeamMemberChatBannedStatus( + teamId, + teamType, + accountId, + chatBanned, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 获取当前已经加入的群组列表 + * @param teamType 群组类型 + * @returns Promise> + * @example + * ```javascript + * const teams = await v2.teamService.getJoinedTeamList(teamTypes) + * ``` + */ + getJoinedTeamList (teamTypes: Array): Promise> { + return new Promise((resolve, reject) => { + this.instance.getJoinedTeamList( + teamTypes, + (teams: Array) => { + resolve(teams) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 获取当前已经加入的群组数量 + * @param teamTypes 群组类型列表, 为空表示查询所有群类型 + * @returns number + * @example + * ```javascript + * const count = v2.teamService.getJoinedTeamCount(teamTypes) + * ``` + */ + getJoinedTeamCount (teamTypes: Array): number { + return this.instance.getJoinedTeamCount(teamTypes) + } + + /** + * @brief 获取群组成员列表 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param queryOption 群组成员查询选项 + * @returns Promise + * @example + * ```javascript + * const result = await v2.teamService.getTeamMemberList(teamId, teamType, { + * limit: 10, + * nextToken: '' + * }) + * ``` + */ + getTeamMemberList (teamId: string, teamType: V2NIMTeamType, queryOption: V2NIMTeamMemberQueryOption): Promise { + return new Promise((resolve, reject) => { + this.instance.getTeamMemberList( + teamId, + teamType, + queryOption, + (result: V2NIMTeamMemberListResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据账号 ID 列表获取群组成员列表 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param accountIds 账号 ID 列表 + * @returns Promise> + * @example + * ```javascript + * const members = await v2.teamService.getTeamMemberListByIds(teamId, teamType, accountIds) + * ``` + */ + getTeamMemberListByIds (teamId: string, teamType: V2NIMTeamType, accountIds: Array): Promise> { + return new Promise((resolve, reject) => { + this.instance.getTeamMemberListByIds( + teamId, + teamType, + accountIds, + (members: Array) => { + resolve(members) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据账号 ID 列表获取群组成员邀请人 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param accountIds 账号 ID 列表 + * @returns Promise> + * @example + * ```javascript + * const invitorMap = await v2.teamService.getTeamMemberInvitor(teamId, teamType, accountIds) + * ``` + */ + getTeamMemberInvitor (teamId: string, teamType: V2NIMTeamType, accountIds: Array): Promise> { + return new Promise((resolve, reject) => { + this.instance.getTeamMemberInvitor( + teamId, + teamType, + accountIds, + (invitorMap: Map) => { + resolve(invitorMap) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 获取群加入相关信息 + * @param option 查询参数 + * @returns Promise + * @example + * ```javascript + * const result = await v2.teamService.getTeamJoinActionInfoList(option) + * ``` + */ + getTeamJoinActionInfoList (option: V2NIMTeamJoinActionInfoQueryOption): Promise { + return new Promise((resolve, reject) => { + this.instance.getTeamJoinActionInfoList( + option, + (result: V2NIMTeamJoinActionInfoResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据关键字搜索群组,混合搜索高级群和超大群,使用 LIKE 方式匹配,只搜索群名称 + * @param keyword 关键字 + * @returns Promise> + * @example + * ```javascript + * const teams = await v2.teamService.searchTeamByKeyword(keyword) + * ``` + */ + searchTeamByKeyword (keyword: string): Promise> { + return new Promise((resolve, reject) => { + this.instance.searchTeamByKeyword( + keyword, + (teams: Array) => { + resolve(teams) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 根据关键字搜索群组成员 + * @param option 搜索选项 + * @returns Promise + * @example + * ```javascript + * const result = await v2.teamService.searchTeamMembers(option) + * ``` + */ + searchTeamMembers (option: V2NIMTeamMemberSearchOption): Promise { + return new Promise((resolve, reject) => { + this.instance.searchTeamMembers( + option, + (result: V2NIMTeamMemberListResult) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 添加特别关注群成员列表 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param accountIds 账号 id 列表 + * @returns void + * @example + * ```javascript + * await v2.teamService.addTeamMembersFollow(teamId, teamType, accountIds) + * ``` + */ + addTeamMembersFollow (teamId: string, teamType: V2NIMTeamType, accountIds: Array): Promise { + return new Promise((resolve, reject) => { + this.instance.addTeamMembersFollow( + teamId, + teamType, + accountIds, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 移除特别关注群成员列表 + * @param teamId 群组 id + * @param teamType 群组类型 + * @param accountIds 账号 id 列表 + * @returns void + * @example + * ```javascript + * await v2.teamService.removeTeamMembersFollow(teamId, teamType, accountIds) + * ``` + */ + removeTeamMembersFollow (teamId: string, teamType: V2NIMTeamType, accountIds: Array): Promise { + return new Promise((resolve, reject) => { + this.instance.removeTeamMembersFollow( + teamId, + teamType, + accountIds, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 清空所有群申请 + * @returns void + * @example + * ```javascript + * await v2.teamService.clearAllTeamJoinActionInfo() + * ``` + */ + clearAllTeamJoinActionInfo (): Promise { + return new Promise((resolve, reject) => { + this.instance.clearAllTeamJoinActionInfo( + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } + + /** + * @brief 删除群申请 + * @param applicationInfo 群申请信息 + * @returns void + * @example + * ```javascript + * await v2.teamService.deleteTeamJoinActionInfo(applicationInfo) + * ``` + */ + deleteTeamJoinActionInfo (applicationInfo: V2NIMTeamJoinActionInfo): Promise { + return new Promise((resolve, reject) => { + this.instance.deleteTeamJoinActionInfo( + applicationInfo, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } } diff --git a/ts/v2/v2_nim_user_service.ts b/ts/v2/v2_nim_user_service.ts index 3896cb6..1cb6818 100644 --- a/ts/v2/v2_nim_user_service.ts +++ b/ts/v2/v2_nim_user_service.ts @@ -1,152 +1,190 @@ -import {V2NIMUser, V2NIMError, V2NIMUserUpdateParams, V2NIMUserSearchOption} from 'ts/v2_def/v2_nim_struct_def' +import { V2NIMUser, V2NIMError, V2NIMUserUpdateParams, V2NIMUserSearchOption } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' -import {EventEmitter} from 'eventemitter3' +import { EventEmitter } from 'eventemitter3' -export declare interface V2NIMUserServiceEvents { - /** 用户资料变更 */ - userProfileChanged: [Array] - /** 添加黑名单 */ - blockListAdded: [V2NIMUser] - /** 移除黑名单 */ - blockListRemoved: [string] +export declare interface V2NIMUserListener { + /** 用户资料变更 */ + userProfileChanged: [Array] + /** 添加黑名单 */ + blockListAdded: [V2NIMUser] + /** 移除黑名单 */ + blockListRemoved: [string] } /** @brief 用户资料服务 */ -export class V2NIMUserService extends EventEmitter { - instance: any +export class V2NIMUserService extends EventEmitter { + instance: any - constructor() { - super() - this.instance = new sdk.V2NIMUserService({emit: this.emit.bind(this)}) - } + constructor () { + super() + this.instance = new sdk.V2NIMUserService({ emit: this.emit.bind(this) }) + } - /** @brief 根据用户账号列表获取用户资料 */ + /** + * @brief 根据用户账号列表获取用户资料 + * @param accountIds 用户账号列表 + * @returns void + * @example + * ```javascript + * const users = await v2.userService.getUserList(accountIds) + * ``` + */ + getUserList (accountIds: Array): Promise> { + return new Promise((resolve, reject) => { + this.instance.getUserList( + accountIds, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @param accountIds 用户账号列表 */ - /** @return void */ - getUserList(accountIds: Array): Promise> { - return new Promise((resolve, reject) => { - this.instance.getUserList( - accountIds, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 更新自己的用户资料 + * @param updateParams 更新参数 + * @returns void + * @example + * ```javascript + * await v2.userService.updateSelfUserProfile(updateParams) + * ``` + */ + updateSelfUserProfile (updateParams: V2NIMUserUpdateParams): Promise { + return new Promise((resolve, reject) => { + this.instance.updateSelfUserProfile( + updateParams, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 更新自己的用户资料 */ + /** + * @brief 添加用户到黑名单中 + * @param accountId 用户账号 + * @returns void + * @example + * ```javascript + * await v2.userService.addUserToBlockList(accountId) + * ``` + */ + addUserToBlockList (accountId: string): Promise { + return new Promise((resolve, reject) => { + this.instance.addUserToBlockList( + accountId, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @param updateParams 更新参数 */ - /** @return void */ - updateSelfUserProfile(updateParams: V2NIMUserUpdateParams): Promise { - return new Promise((resolve, reject) => { - this.instance.updateSelfUserProfile( - updateParams, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 从黑名单中移除用户 + * @param accountId 用户账号 + * @returns void + * @example + * ```javascript + * await v2.userService.removeUserFromBlockList(accountId) + * ``` + */ + removeUserFromBlockList (accountId: string): Promise { + return new Promise((resolve, reject) => { + this.instance.removeUserFromBlockList( + accountId, + () => { + resolve() + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 添加用户到黑名单中 */ + /** + * @brief 获取黑名单列表 + * @returns void + * @example + * ```javascript + * const blockList = await v2.userService.getBlockList() + * ``` + */ + getBlockList (): Promise> { + return new Promise((resolve, reject) => { + this.instance.getBlockList( + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @param accountId 用户账号 */ - /** @return void */ - addUserToBlockList(accountId: string): Promise { - return new Promise((resolve, reject) => { - this.instance.addUserToBlockList( - accountId, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 根据用户账号列表从服务器获取用户资料, 主要使用 getUserList ,只有强制需要拉取最新用户信息才需要使用该接口 + * @param accountIds 用户账号列表 + * @returns void + * @example + * ```javascript + * const users = await v2.userService.getUserListFromCloud(accountIds) + * ``` + */ + getUserListFromCloud (accountIds: Array): Promise> { + return new Promise((resolve, reject) => { + this.instance.getUserListFromCloud( + accountIds, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } - /** @brief 从黑名单中移除用户 */ - - /** @param accountId 用户账号 */ - /** @return void */ - removeUserFromBlockList(accountId: string): Promise { - return new Promise((resolve, reject) => { - this.instance.removeUserFromBlockList( - accountId, - () => { - resolve() - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 获取黑名单列表 */ - /** @return void */ - getBlockList(): Promise> { - return new Promise((resolve, reject) => { - this.instance.getBlockList( - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** @brief 根据用户账号列表从服务器获取用户资料, 主要使用 getUserList ,只有强制需要拉取最新用户信息才需要使用该接口 */ - - /** @param accountIds 用户账号列表 */ - /** @return void */ - getUserListFromCloud(accountIds: Array): Promise> { - return new Promise((resolve, reject) => { - this.instance.getUserListFromCloud( - accountIds, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } - - /** - * 根据关键字搜索好友信息 - * @param option 搜索选项 @see V2NIMUserSearchOption - * @return Promise> - */ - searchUserByOption(option: V2NIMUserSearchOption): Promise> { - return new Promise((resolve, reject) => { - let defaultOption = { - searchName: true, - searchAccountId: false, - searchMobile: false - } - let mergedOption = Object.assign({}, defaultOption, option) - this.instance.searchUserByOption( - mergedOption, - (result: Array) => { - resolve(result) - }, - (error: V2NIMError) => { - reject(error) - } - ) - }) - } + /** + * @brief 根据关键字搜索好友信息 + * @param option 搜索选项 @see V2NIMUserSearchOption + * @returns Promise> + * @example + * ```javascript + * const users = await v2.userService.searchUserByOption({ + * keyword: 'Alice', + * searchName: true + * }) + * ``` + */ + searchUserByOption (option: V2NIMUserSearchOption): Promise> { + return new Promise((resolve, reject) => { + let defaultOption = { + searchName: true, + searchAccountId: false, + searchMobile: false + } + let mergedOption = Object.assign({}, defaultOption, option) + this.instance.searchUserByOption( + mergedOption, + (result: Array) => { + resolve(result) + }, + (error: V2NIMError) => { + reject(error) + } + ) + }) + } } diff --git a/ts/v2/v2_nim_utilities.ts b/ts/v2/v2_nim_utilities.ts index cbd93df..9802c92 100644 --- a/ts/v2/v2_nim_utilities.ts +++ b/ts/v2/v2_nim_utilities.ts @@ -1,371 +1,574 @@ import { - V2NIMMessage, - V2NIMMessageAttachment, - V2NIMClientAntispamResult, - V2NIMError, - V2NIMChatroomMessage, - V2NIMMessageCallDuration, - V2NIMMessageLocationAttachment + V2NIMMessage, + V2NIMMessageAttachment, + V2NIMClientAntispamResult, + V2NIMError, + V2NIMChatroomMessage, + V2NIMMessageCallDuration, + V2NIMMessageLocationAttachment } from 'ts/v2_def/v2_nim_struct_def' import sdk from '../loader' import { EventEmitter } from 'eventemitter3' import { V2NIMConversationType } from 'ts/v2_def/v2_nim_enum_def' + let utilities: any = new sdk.V2NIMUtilities() + /** @brief 消息创建器 */ export class V2NIMMessageCreator { - /** @brief 创建文本消息 */ - /** @param text 文本内容 */ - /** @return V2NIMMessage */ - static createTextMessage(text: string): V2NIMMessage | null { - return utilities.createTextMessage(text) - } - createTextMessage(text: string): V2NIMMessage | null { - return utilities.createTextMessage(text) - } - - /** @brief 创建图片消息 */ - /** @param imagePath 图片路径 */ - /** @param name 文件显示名称, 为空则使用文件名 */ - /** @param sceneName 文件存储场景 */ - /** @param width 图片宽度 */ - /** @param height 图片高度 */ - /** @return V2NIMMessage */ - static createImageMessage(imagePath: string, name: string, sceneName: string, width: number, height: number): V2NIMMessage | null { - return utilities.createImageMessage(imagePath, name, sceneName, width, height) - } - createImageMessage(imagePath: string, name: string, sceneName: string, width: number, height: number): V2NIMMessage | null { - return utilities.createImageMessage(imagePath, name, sceneName, width, height) - } - - /** @brief 创建音频消息 */ - /** @param audioPath 音频路径 */ - /** @param name 文件显示名称, 为空则使用文件名 */ - /** @param sceneName 文件存储场景 */ - /** @param duration 音频时长 */ - /** @return V2NIMMessage */ - static createAudioMessage(audioPath: string, name: string, sceneName: string, duration: number): V2NIMMessage | null { - return utilities.createAudioMessage(audioPath, name, sceneName, duration) - } - createAudioMessage(audioPath: string, name: string, sceneName: string, duration: number): V2NIMMessage | null { - return utilities.createAudioMessage(audioPath, name, sceneName, duration) - } - - /** @brief 创建视频消息 */ - /** @param videoPath 视频路径 */ - /** @param name 文件显示名称, 为空则使用文件名 */ - /** @param sceneName 文件存储场景 */ - /** @param duration 视频时长 */ - /** @param width 视频宽度 */ - /** @param height 视频高度 */ - /** @return V2NIMMessage */ - static createVideoMessage(videoPath: string, name: string, sceneName: string, duration: number, width: number, height: number): V2NIMMessage | null { - return utilities.createVideoMessage(videoPath, name, sceneName, duration, width, height) - } - createVideoMessage(videoPath: string, name: string, sceneName: string, duration: number, width: number, height: number): V2NIMMessage | null { - return utilities.createVideoMessage(videoPath, name, sceneName, duration, width, height) - } - - /** @brief 创建文件消息 */ - /** @param filePath 文件路径 */ - /** @param name 文件显示名称, 为空则使用文件名 */ - /** @param sceneName 文件存储场景 */ - /** @return V2NIMMessage */ - static createFileMessage(filePath: string, name: string, sceneName: string): V2NIMMessage | null { - return utilities.createFileMessage(filePath, name, sceneName) - } - createFileMessage(filePath: string, name: string, sceneName: string): V2NIMMessage | null { - return utilities.createFileMessage(filePath, name, sceneName) - } - - /** @brief 创建位置消息 */ - /** @param latitude 纬度 */ - /** @param longitude 经度 */ - /** @param address 详细位置信息 */ - /** @return V2NIMMessage */ - static createLocationMessage(latitude: number, longitude: number, address: string): V2NIMMessage | null { - return utilities.createLocationMessage(latitude, longitude, address) - } - createLocationMessage(latitude: number, longitude: number, address: string): V2NIMMessage | null { - return utilities.createLocationMessage(latitude, longitude, address) - } - - /** @brief 创建自定义消息 */ - /** @param text 文本内容 */ - /** @param rawAttachment 附件 */ - /** @return V2NIMMessage */ - static createCustomMessage(text: string, rawAttachment: string): V2NIMMessage | null { - return utilities.createCustomMessage(text, rawAttachment) - } - createCustomMessage(text: string, rawAttachment: string): V2NIMMessage | null { - return utilities.createCustomMessage(text, rawAttachment) - } - - /** @brief 创建提示消息 */ - /** @param text 文本内容 */ - /** @return V2NIMMessage */ - static createTipsMessage(text: string): V2NIMMessage | null { - return utilities.createTipsMessage(text) - } - createTipsMessage(text: string): V2NIMMessage | null { - return utilities.createTipsMessage(text) - } - - /** @brief 创建转发消息 */ - /** @param message 原消息 */ - /** @return V2NIMMessage */ - static createForwardMessage(message: V2NIMMessage): V2NIMMessage | null { - return utilities.createForwardMessage(message) - } - createForwardMessage(message: V2NIMMessage): V2NIMMessage | null { - return utilities.createForwardMessage(message) - } - - /** @brief 创建话单类消息 */ - /** @param callType 话单类型,业务自定义,内容不校验 */ - /** @param channelId 话单频道 ID,内容不校验 */ - /** @param status 通话状态,业务自定义状态,内容不校验 */ - /** @param durations 通话成员时长列表,内容不校验 */ - /** @param text 话单描述 */ - static createCallMessage(callType: number, channelId: string, status: number, durations: Array, text: string): V2NIMMessage | null { - return utilities.createCallMessage(callType, channelId, status, durations, text) - } - - createCallMessage(callType: number, channelId: string, status: number, durations: Array, text: string): V2NIMMessage { - return utilities.createCallMessage(callType, channelId, status, durations, text) - } + /** + * @brief 创建文本消息 + * @param text 文本内容 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = v2.messageCreator.createTextMessage('Hello, world!') + * ``` + */ + static createTextMessage (text: string): V2NIMMessage | null { + return utilities.createTextMessage(text) + } + + createTextMessage (text: string): V2NIMMessage | null { + return utilities.createTextMessage(text) + } + + /** + * @brief 创建图片消息 + * @param imagePath 图片路径 + * @param name 文件显示名称, 为空则使用文件名 + * @param sceneName 文件存储场景 + * @param width 图片宽度 + * @param height 图片高度 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = v2.messageCreator.createImageMessage(imagePath, name, sceneName, width, height) + * ``` + */ + static createImageMessage (imagePath: string, name: string, sceneName: string, width: number, height: number): V2NIMMessage | null { + return utilities.createImageMessage(imagePath, name, sceneName, width, height) + } + + createImageMessage (imagePath: string, name: string, sceneName: string, width: number, height: number): V2NIMMessage | null { + return utilities.createImageMessage(imagePath, name, sceneName, width, height) + } + + /** + * @brief 创建音频消息 + * @param audioPath 音频路径 + * @param name 文件显示名称, 为空则使用文件名 + * @param sceneName 文件存储场景 + * @param duration 音频时长 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = v2.messageCreator.createAudioMessage(audioPath, name, sceneName, duration) + * ``` + */ + static createAudioMessage (audioPath: string, name: string, sceneName: string, duration: number): V2NIMMessage | null { + return utilities.createAudioMessage(audioPath, name, sceneName, duration) + } + + createAudioMessage (audioPath: string, name: string, sceneName: string, duration: number): V2NIMMessage | null { + return utilities.createAudioMessage(audioPath, name, sceneName, duration) + } + + /** + * @brief 创建视频消息 + * @param videoPath 视频路径 + * @param name 文件显示名称, 为空则使用文件名 + * @param sceneName 文件存储场景 + * @param duration 视频时长 + * @param width 视频宽度 + * @param height 视频高度 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = v2.messageCreator.createVideoMessage(videoPath, name, sceneName, duration, width, height) + * ``` + */ + static createVideoMessage (videoPath: string, name: string, sceneName: string, duration: number, width: number, height: number): V2NIMMessage | null { + return utilities.createVideoMessage(videoPath, name, sceneName, duration, width, height) + } + + createVideoMessage (videoPath: string, name: string, sceneName: string, duration: number, width: number, height: number): V2NIMMessage | null { + return utilities.createVideoMessage(videoPath, name, sceneName, duration, width, height) + } + + /** + * @brief 创建文件消息 + * @param filePath 文件路径 + * @param name 文件显示名称, 为空则使用文件名 + * @param sceneName 文件存储场景 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = v2.messageCreator.createFileMessage(filePath, name, sceneName) + * ``` + */ + static createFileMessage (filePath: string, name: string, sceneName: string): V2NIMMessage | null { + return utilities.createFileMessage(filePath, name, sceneName) + } + + createFileMessage (filePath: string, name: string, sceneName: string): V2NIMMessage | null { + return utilities.createFileMessage(filePath, name, sceneName) + } + + /** + * @brief 创建位置消息 + * @param latitude 纬度 + * @param longitude 经度 + * @param address 详细位置信息 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = v2.messageCreator.createLocationMessage(latitude, longitude, address) + * ``` + */ + static createLocationMessage (latitude: number, longitude: number, address: string): V2NIMMessage | null { + return utilities.createLocationMessage(latitude, longitude, address) + } + + createLocationMessage (latitude: number, longitude: number, address: string): V2NIMMessage | null { + return utilities.createLocationMessage(latitude, longitude, address) + } + + /** + * @brief 创建自定义消息 + * @param text 文本内容 + * @param rawAttachment 附件 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = v2.messageCreator.createCustomMessage(text, rawAttachment) + * ``` + */ + static createCustomMessage (text: string, rawAttachment: string): V2NIMMessage | null { + return utilities.createCustomMessage(text, rawAttachment) + } + + createCustomMessage (text: string, rawAttachment: string): V2NIMMessage | null { + return utilities.createCustomMessage(text, rawAttachment) + } + + /** + * @brief 创建提示消息 + * @param text 文本内容 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = v2.messageCreator.createTipsMessage(text) + * ``` + */ + static createTipsMessage (text: string): V2NIMMessage | null { + return utilities.createTipsMessage(text) + } + + createTipsMessage (text: string): V2NIMMessage | null { + return utilities.createTipsMessage(text) + } + + /** + * @brief 创建转发消息 + * @param message 原消息 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = v2.messageCreator.createForwardMessage(message) + * ``` + */ + static createForwardMessage (message: V2NIMMessage): V2NIMMessage | null { + return utilities.createForwardMessage(message) + } + + createForwardMessage (message: V2NIMMessage): V2NIMMessage | null { + return utilities.createForwardMessage(message) + } + + /** + * @brief 创建话单类消息 + * @param callType 话单类型,业务自定义,内容不校验 + * @param channelId 话单频道 ID,内容不校验 + * @param status 通话状态,业务自定义状态,内容不校验 + * @param durations 通话成员时长列表,内容不校验 + * @param text 话单描述 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = v2.messageCreator.createCallMessage(callType, channelId, status, durations, text) + * ``` + */ + static createCallMessage (callType: number, channelId: string, status: number, durations: Array, text: string): V2NIMMessage | null { + return utilities.createCallMessage(callType, channelId, status, durations, text) + } + + createCallMessage (callType: number, channelId: string, status: number, durations: Array, text: string): V2NIMMessage { + return utilities.createCallMessage(callType, channelId, status, durations, text) + } } /** @brief 消息序列化工具 */ export class V2NIMMessageConverter { - /** - * @brief 将消息序列化为 Json 字符串 - * @param message V2NIMMessage 消息对象 - * @return string - */ - messageSerialization(message: V2NIMMessage): string | null { - return utilities.messageSerialization(message) - } - - /** - * @brief 将 Json 字符串反序列化为消息对象 - * @param message Json 字符串 - * @return V2NIMMessage - */ - messageDeserialization(message: string): V2NIMMessage | null { - return utilities.messageDeserialization(message) - } + /** + * @brief 将消息序列化为 Json 字符串 + * @param message V2NIMMessage 消息对象 + * @returns string + * @example + * ```javascript + * const jsonString = v2.messageConverter.messageSerialization(message) + * ``` + */ + messageSerialization (message: V2NIMMessage): string | null { + return utilities.messageSerialization(message) + } + + /** + * @brief 将 Json 字符串反序列化为消息对象 + * @param message Json 字符串 + * @returns V2NIMMessage + * @example + * ```javascript + * const message = v2.messageConverter.messageDeserialization(jsonString) + * ``` + */ + messageDeserialization (message: string): V2NIMMessage | null { + return utilities.messageDeserialization(message) + } } /** @brief 会话ID工具 */ export class V2NIMConversationIdUtil { - /** @brief 获取点对点会话ID */ - /** @param accountId 账号ID */ - /** @return string */ - static p2pConversationId(accountId: string): string { - return utilities.p2pConversationId(accountId) - } - p2pConversationId(accountId: string): string { - return utilities.p2pConversationId(accountId) - } - - /** @brief 获取群组会话ID */ - /** @param teamId 群组ID */ - /** @return string */ - static teamConversationId(teamId: string): string { - return utilities.teamConversationId(teamId) - } - teamConversationId(teamId: string): string { - return utilities.teamConversationId(teamId) - } - - /** @brief 获取超级群会话ID */ - /** @param superTeamId 超级群ID */ - /** @return string */ - static superTeamConversationId(superTeamId: string): string { - return utilities.superTeamConversationId(superTeamId) - } - superTeamConversationId(superTeamId: string): string { - return utilities.superTeamConversationId(superTeamId) - } - - /** @brief 获取会话ID对应的会话类型 */ - /** @param conversationId 会话ID */ - /** @return V2NIMConversationType */ - static parseConversationType(conversationId: string): V2NIMConversationType { - return utilities.parseConversationType(conversationId) - } - parseConversationType(conversationId: string): V2NIMConversationType { - return utilities.parseConversationType(conversationId) - } - - /** @brief 获取会话ID对应的目标ID */ - /** @param conversationId 会话ID */ - /** @return string */ - static parseConversationTargetId(conversationId: string): string { - return utilities.parseConversationTargetId(conversationId) - } - parseConversationTargetId(conversationId: string): string { - return utilities.parseConversationTargetId(conversationId) - } + /** + * @brief 获取点对点会话ID + * @param accountId 账号ID + * @returns string + * @example + * ```javascript + * const conversationId = v2.conversationIdUtil.p2pConversationId(accountId) + * ``` + */ + static p2pConversationId (accountId: string): string { + return utilities.p2pConversationId(accountId) + } + + p2pConversationId (accountId: string): string { + return utilities.p2pConversationId(accountId) + } + + /** + * @brief 获取群组会话ID + * @param teamId 群组ID + * @returns string + * @example + * ```javascript + * const conversationId = v2.conversationIdUtil.teamConversationId(teamId) + * ``` + */ + static teamConversationId (teamId: string): string { + return utilities.teamConversationId(teamId) + } + + teamConversationId (teamId: string): string { + return utilities.teamConversationId(teamId) + } + + /** + * @brief 获取超级群会话ID + * @param superTeamId 超级群ID + * @returns string + * @example + * ```javascript + * const conversationId = v2.conversationIdUtil.superTeamConversationId(superTeamId) + * ``` + */ + static superTeamConversationId (superTeamId: string): string { + return utilities.superTeamConversationId(superTeamId) + } + + superTeamConversationId (superTeamId: string): string { + return utilities.superTeamConversationId(superTeamId) + } + + /** + * @brief 获取会话ID对应的会话类型 + * @param conversationId 会话ID + * @returns V2NIMConversationType + * @example + * ```javascript + * const conversationType = v2.conversationIdUtil.parseConversationType(conversationId) + * ``` + */ + static parseConversationType (conversationId: string): V2NIMConversationType { + return utilities.parseConversationType(conversationId) + } + + parseConversationType (conversationId: string): V2NIMConversationType { + return utilities.parseConversationType(conversationId) + } + + /** + * @brief 获取会话ID对应的目标ID + * @param conversationId 会话ID + * @returns string + * @example + * ```javascript + * const targetId = v2.conversationIdUtil.parseConversationTargetId(conversationId) + * ``` + */ + static parseConversationTargetId (conversationId: string): string { + return utilities.parseConversationTargetId(conversationId) + } + + parseConversationTargetId (conversationId: string): string { + return utilities.parseConversationTargetId(conversationId) + } } /** @brief 本地反垃圾工具 */ export class V2NIMClientAntispamUtil { - /** @brief 文本本地反垃圾 */ - /** @param text 需要本地反垃圾check的文本 */ - /** @param replace 敏感内容替换词 */ - /** @return V2NIMMessage */ - static checkTextAntispam(text: string, replace: string): V2NIMClientAntispamResult { - return utilities.checkTextAntispam(text, replace) - } - checkTextAntispam(text: string, replace: string): V2NIMClientAntispamResult { - return utilities.checkTextAntispam(text, replace) - } + /** + * @brief 文本本地反垃圾 + * @param text 需要本地反垃圾check的文本 + * @param replace 敏感内容替换词 + * @returns V2NIMClientAntispamResult + * @example + * ```javascript + * const result = v2.clientAntispamUtil.checkTextAntispam(text, replace) + * ``` + */ + static checkTextAntispam (text: string, replace: string): V2NIMClientAntispamResult { + return utilities.checkTextAntispam(text, replace) + } + + checkTextAntispam (text: string, replace: string): V2NIMClientAntispamResult { + return utilities.checkTextAntispam(text, replace) + } } /** @brief 聊天室消息创建器 */ export class V2NIMChatroomMessageCreator extends EventEmitter { - /** @brief 创建文本消息 */ - /** @param text 文本内容 */ - /** @return V2NIMChatroomMessage */ - static createTextMessage(text: string): V2NIMChatroomMessage | null { - return utilities.chatroomCreateTextMessage(text) - } - createTextMessage(text: string): V2NIMChatroomMessage | null { - return utilities.chatroomCreateTextMessage(text) - } - - /** @brief 创建图片消息 */ - /** @param imagePath 图片路径 */ - /** @param name 文件显示名称, 为空则使用文件名 */ - /** @param sceneName 文件存储场景 */ - /** @param width 图片宽度 */ - /** @param height 图片高度 */ - /** @return V2NIMChatroomMessage */ - static createImageMessage(imagePath: string, name: string, sceneName: string, width: number, height: number): V2NIMChatroomMessage | null { - return utilities.chatroomCreateImageMessage(imagePath, name, sceneName, width, height) - } - createImageMessage(imagePath: string, name: string, sceneName: string, width: number, height: number): V2NIMChatroomMessage | null { - return utilities.chatroomCreateImageMessage(imagePath, name, sceneName, width, height) - } - - /** @brief 创建音频消息 */ - /** @param audioPath 音频路径 */ - /** @param name 文件显示名称, 为空则使用文件名 */ - /** @param sceneName 文件存储场景 */ - /** @param duration 音频时长 */ - /** @return V2NIMChatroomMessage */ - static createAudioMessage(audioPath: string, name: string, sceneName: string, duration: number): V2NIMChatroomMessage | null { - return utilities.chatroomCreateAudioMessage(audioPath, name, sceneName, duration) - } - createAudioMessage(audioPath: string, name: string, sceneName: string, duration: number): V2NIMChatroomMessage | null { - return utilities.chatroomCreateAudioMessage(audioPath, name, sceneName, duration) - } - - /** @brief 创建视频消息 */ - /** @param videoPath 视频路径 */ - /** @param name 文件显示名称, 为空则使用文件名 */ - /** @param sceneName 文件存储场景 */ - /** @param duration 视频时长 */ - /** @param width 视频宽度 */ - /** @param height 视频高度 */ - /** @return V2NIMChatroomMessage */ - static createVideoMessage( - videoPath: string, - name: string, - sceneName: string, - duration: number, - width: number, - height: number - ): V2NIMChatroomMessage | null { - return utilities.chatroomCreateVideoMessage(videoPath, name, sceneName, duration, width, height) - } - createVideoMessage(videoPath: string, name: string, sceneName: string, duration: number, width: number, height: number): V2NIMChatroomMessage | null { - return utilities.chatroomCreateVideoMessage(videoPath, name, sceneName, duration, width, height) - } - - /** @brief 创建文件消息 */ - /** @param filePath 文件路径 */ - /** @param name 文件显示名称, 为空则使用文件名 */ - /** @param sceneName 文件存储场景 */ - /** @return V2NIMChatroomMessage */ - static createFileMessage(filePath: string, name: string, sceneName: string): V2NIMChatroomMessage | null { - return utilities.chatroomCreateFileMessage(filePath, name, sceneName) - } - createFileMessage(filePath: string, name: string, sceneName: string): V2NIMChatroomMessage | null { - return utilities.chatroomCreateFileMessage(filePath, name, sceneName) - } - - /** @brief 创建位置消息 */ - /** @param latitude 纬度 */ - /** @param longitude 经度 */ - /** @param address 详细位置信息 */ - /** @return V2NIMChatroomMessage */ - static createLocationMessage(latitude: number, longitude: number, address: string): V2NIMChatroomMessage | null { - return utilities.chatroomCreateLocationMessage(latitude, longitude, address) - } - createLocationMessage(latitude: number, longitude: number, address: string): V2NIMChatroomMessage | null { - return utilities.chatroomCreateLocationMessage(latitude, longitude, address) - } - - /** @brief 创建自定义消息 */ - /** @param rawAttachment 自定义附件 */ - /** @return V2NIMChatroomMessage */ - static createCustomMessage(rawAttachment: string): V2NIMChatroomMessage | null { - return utilities.chatroomCreateCustomMessage(rawAttachment) - } - createCustomMessage(rawAttachment: string): V2NIMChatroomMessage | null { - return utilities.chatroomCreateCustomMessage(rawAttachment) - } - - /** @brief 创建提示消息 */ - /** @param text 文本内容 */ - /** @return V2NIMChatroomMessage */ - static createTipsMessage(text: string): V2NIMChatroomMessage | null { - return utilities.chatroomCreateTipsMessage(text) - } - createTipsMessage(text: string): V2NIMChatroomMessage | null { - return utilities.chatroomCreateTipsMessage(text) - } - - /** @brief 创建转发消息 */ - /** @param message 原消息 */ - /** @return V2NIMChatroomMessage */ - static createForwardMessage(message: V2NIMChatroomMessage): V2NIMChatroomMessage | null { - return utilities.chatroomCreateForwardMessage(message) - } - createForwardMessage(message: V2NIMChatroomMessage): V2NIMChatroomMessage | null { - return utilities.chatroomCreateForwardMessage(message) - } + /** + * @brief 创建文本消息 + * @param text 文本内容 + * @returns V2NIMChatroomMessage + * @example + * ```javascript + * const message = v2.chatroomMessageCreator.createTextMessage(text) + * ``` + */ + static createTextMessage (text: string): V2NIMChatroomMessage | null { + return utilities.chatroomCreateTextMessage(text) + } + + createTextMessage (text: string): V2NIMChatroomMessage | null { + return utilities.chatroomCreateTextMessage(text) + } + + /** + * @brief 创建图片消息 + * @param imagePath 图片路径 + * @param name 文件显示名称, 为空则使用文件名 + * @param sceneName 文件存储场景 + * @param width 图片宽度 + * @param height 图片高度 + * @returns V2NIMChatroomMessage + * @example + * ```javascript + * const message = v2.chatroomMessageCreator.createImageMessage(imagePath, name, sceneName, width, height) + * ``` + */ + static createImageMessage (imagePath: string, name: string, sceneName: string, width: number, height: number): V2NIMChatroomMessage | null { + return utilities.chatroomCreateImageMessage(imagePath, name, sceneName, width, height) + } + + createImageMessage (imagePath: string, name: string, sceneName: string, width: number, height: number): V2NIMChatroomMessage | null { + return utilities.chatroomCreateImageMessage(imagePath, name, sceneName, width, height) + } + + /** + * @brief 创建音频消息 + * @param audioPath 音频路径 + * @param name 文件显示名称, 为空则使用文件名 + * @param sceneName 文件存储场景 + * @param duration 音频时长 + * @returns V2NIMChatroomMessage + * @example + * ```javascript + * const message = v2.chatroomMessageCreator.createAudioMessage(audioPath, name, sceneName, duration) + * ``` + */ + static createAudioMessage (audioPath: string, name: string, sceneName: string, duration: number): V2NIMChatroomMessage | null { + return utilities.chatroomCreateAudioMessage(audioPath, name, sceneName, duration) + } + + createAudioMessage (audioPath: string, name: string, sceneName: string, duration: number): V2NIMChatroomMessage | null { + return utilities.chatroomCreateAudioMessage(audioPath, name, sceneName, duration) + } + + /** + * @brief 创建视频消息 + * @param videoPath 视频路径 + * @param name 文件显示名称, 为空则使用文件名 + * @param sceneName 文件存储场景 + * @param duration 视频时长 + * @param width 视频宽度 + * @param height 视频高度 + * @returns V2NIMChatroomMessage + * @example + * ```javascript + * const message = v2.chatroomMessageCreator.createVideoMessage(videoPath, name, sceneName, duration, width, height) + * ``` + */ + static createVideoMessage ( + videoPath: string, + name: string, + sceneName: string, + duration: number, + width: number, + height: number + ): V2NIMChatroomMessage | null { + return utilities.chatroomCreateVideoMessage(videoPath, name, sceneName, duration, width, height) + } + + createVideoMessage (videoPath: string, name: string, sceneName: string, duration: number, width: number, height: number): V2NIMChatroomMessage | null { + return utilities.chatroomCreateVideoMessage(videoPath, name, sceneName, duration, width, height) + } + + /** + * @brief 创建文件消息 + * @param filePath 文件路径 + * @param name 文件显示名称, 为空则使用文件名 + * @param sceneName 文件存储场景 + * @returns V2NIMChatroomMessage + * @example + * ```javascript + * const message = v2.chatroomMessageCreator.createFileMessage(filePath, name, sceneName) + * ``` + */ + static createFileMessage (filePath: string, name: string, sceneName: string): V2NIMChatroomMessage | null { + return utilities.chatroomCreateFileMessage(filePath, name, sceneName) + } + + createFileMessage (filePath: string, name: string, sceneName: string): V2NIMChatroomMessage | null { + return utilities.chatroomCreateFileMessage(filePath, name, sceneName) + } + + /** + * @brief 创建位置消息 + * @param latitude 纬度 + * @param longitude 经度 + * @param address 详细位置信息 + * @returns V2NIMChatroomMessage + * @example + * ```javascript + * const message = v2.chatroomMessageCreator.createLocationMessage(latitude, longitude, address) + * ``` + */ + static createLocationMessage (latitude: number, longitude: number, address: string): V2NIMChatroomMessage | null { + return utilities.chatroomCreateLocationMessage(latitude, longitude, address) + } + + createLocationMessage (latitude: number, longitude: number, address: string): V2NIMChatroomMessage | null { + return utilities.chatroomCreateLocationMessage(latitude, longitude, address) + } + + /** + * @brief 创建自定义消息 + * @param rawAttachment 自定义附件 + * @returns V2NIMChatroomMessage + * @example + * ```javascript + * const message = v2.chatroomMessageCreator.createCustomMessage(rawAttachment) + * ``` + */ + static createCustomMessage (rawAttachment: string): V2NIMChatroomMessage | null { + return utilities.chatroomCreateCustomMessage(rawAttachment) + } + + createCustomMessage (rawAttachment: string): V2NIMChatroomMessage | null { + return utilities.chatroomCreateCustomMessage(rawAttachment) + } + + /** + * @brief 创建提示消息 + * @param text 文本内容 + * @returns V2NIMChatroomMessage + * @example + * ```javascript + * const message = v2.chatroomMessageCreator.createTipsMessage(text) + * ``` + */ + static createTipsMessage (text: string): V2NIMChatroomMessage | null { + return utilities.chatroomCreateTipsMessage(text) + } + + createTipsMessage (text: string): V2NIMChatroomMessage | null { + return utilities.chatroomCreateTipsMessage(text) + } + + /** + * @brief 创建转发消息 + * @param message 原消息 + * @returns V2NIMChatroomMessage + * @example + * ```javascript + * const message = v2.chatroomMessageCreator.createForwardMessage(message) + * ``` + */ + static createForwardMessage (message: V2NIMChatroomMessage): V2NIMChatroomMessage | null { + return utilities.chatroomCreateForwardMessage(message) + } + + createForwardMessage (message: V2NIMChatroomMessage): V2NIMChatroomMessage | null { + return utilities.chatroomCreateForwardMessage(message) + } } export class V2NIMStorageUtil { - /** @brief 生成图片缩略图链接 */ - /** @param uri 图片原始链接 */ - /** @param thumbSize 缩放的尺寸,如指定为 150,则取 150*150 */ - /** @return string 图片缩略图链接 */ - imageThumbUrl(uri: string, thumbSize: Number): string { - return utilities.imageThumUrl(uri, thumbSize) - } - - /** @brief 生成视频封面链接 */ - /** @param uri 视频原始链接 */ - /** @param offset 截图时间点,单位:秒 */ - /** @param thumbSize 缩放的尺寸,如指定为 150,则取 150*150 */ - /** @param type 截图类型,如:png、jpeg */ - /** @return string 视频封面链接 */ - videoCoverUrl(uri: string, offset: Number, thumbSize: Number, type: string): string { - return utilities.videoCoverUrl(uri, offset, thumbSize, type) - } + /** + * @brief 生成图片缩略图链接 + * @param uri 图片原始链接 + * @param thumbSize 缩放的尺寸,如指定为 150,则取 150*150 + * @returns string 图片缩略图链接 + * @example + * ```javascript + * const url = v2.storageUtil.imageThumbUrl(uri, thumbSize) + * ``` + */ + imageThumbUrl (uri: string, thumbSize: Number): string { + return utilities.imageThumUrl(uri, thumbSize) + } + + /** + * @brief 生成视频封面链接 + * @param uri 视频原始链接 + * @param offset 截图时间点,单位:秒 + * @param thumbSize 缩放的尺寸,如指定为 150,则取 150*150 + * @param type 截图类型,如:png、jpeg + * @returns string 视频封面链接 + * @example + * ```javascript + * const url = v2.storageUtil.videoCoverUrl(uri, offset, thumbSize, type) + * ``` + */ + videoCoverUrl (uri: string, offset: Number, thumbSize: Number, type: string): string { + return utilities.videoCoverUrl(uri, offset, thumbSize, type) + } } export class V2NIMMessageAttachmentCreator { - /** @brief 构造地理位置消息附件 */ - /** @param latitude 纬度 */ - /** @param longitude 经度 */ - /** @param address 详细位置信息 */ - /** @return V2NIMMessageLocationAttachment */ - createLocationMessageAttachment(latitude: number | null, longitude: number | null, address: string): V2NIMMessageLocationAttachment { - return utilities.createLocationMessageAttachment(latitude || 0, longitude || 0, address) - } + /** + * @brief 构造地理位置消息附件 + * @param latitude 纬度 + * @param longitude 经度 + * @param address 详细位置信息 + * @returns V2NIMMessageLocationAttachment + * @example + * ```javascript + * const attachment = v2.messageAttachmentCreator.createLocationMessageAttachment(latitude, longitude, address) + * ``` + */ + createLocationMessageAttachment (latitude: number | null, longitude: number | null, address: string): V2NIMMessageLocationAttachment { + return utilities.createLocationMessageAttachment(latitude || 0, longitude || 0, address) + } } diff --git a/ts/v2_def/v2_nim_enum_def.ts b/ts/v2_def/v2_nim_enum_def.ts index 15aac28..be7d44e 100644 --- a/ts/v2_def/v2_nim_enum_def.ts +++ b/ts/v2_def/v2_nim_enum_def.ts @@ -24,1215 +24,1227 @@ /** | 91 | 接口 | */ /** | 92 | 连接 | */ /** | 93 | 数据库 | */ + /** | 94 | 文件 | */ /** | 95 | 反垃圾 | */ export enum V2NIMErrorCode { - /** 未知错误 / unknown error */ - V2NIM_ERROR_CODE_UNKNOWN = 0, - /** 请求成功 / success */ - V2NIM_ERROR_CODE_SUCCESS = 200, - - // 全局错误 - /** 握手错误 / handshake error */ - V2NIM_ERROR_CODE_HANDSHAKE = 201, - /** 非对称加密算法错误 / asymmetric encryption algorithm error */ - V2NIM_ERROR_CODE_ASYMMETRIC_ENCRYPTION_ALGORITHM = 202, - /** 对称加密算法错误 / symmetric encryption algorithm error */ - V2NIM_ERROR_CODE_SYMMETRIC_ENCRYPTION_ALGORITHM = 203, - /** 握手协议版本需降级 / handshake protocol version need fallback */ - V2NIM_ERROR_CODE_HANDSHAKE_PROTOCOL_VERSION_NEED_FALLBACK = 204, - /** 请求被服务器暂时禁止 / request temporary forbidden */ - V2NIM_ERROR_CODE_REQUEST_TEMPORARY_FORBIDDEN = 398, - /** 服务器单元错误 / server unit error */ - V2NIM_ERROR_CODE_SERVER_UNIT_ERROR = 399, - /** 没有权限 / forbidden */ - V2NIM_ERROR_CODE_FORBIDDEN = 403, - /** 资源不存在 / not found */ - V2NIM_ERROR_CODE_NOT_FOUND = 404, - /** 参数错误 / parameter error */ - V2NIM_ERROR_CODE_PARAMETER_ERROR = 414, - /** 频率超限 / rate limit exceeded */ - V2NIM_ERROR_CODE_RATE_LIMIT = 416, - /** 多端登录被禁止 / multi login forbidden */ - V2NIM_ERROR_CODE_MULTI_LOGIN_FORBIDDEN = 417, - /** 请求需要重试 / need retry */ - V2NIM_ERROR_CODE_NEED_RETRY = 449, - /** 第三方回调被拒绝 / callback forbidden */ - V2NIM_ERROR_CODE_CALLBACK_FORBIDDEN = 463, - /** 服务器内部错误 / internal server error */ - V2NIM_ERROR_CODE_SERVER_INTERNAL_ERROR = 500, - /** 服务器繁忙 / server busy */ - V2NIM_ERROR_CODE_SERVER_BUSY = 503, - /** app 服务不可达 / app server unreachable */ - V2NIM_ERROR_CODE_APP_UNREACHABLE = 511, - /** 服务不可用 / service unavailable */ - V2NIM_ERROR_CODE_SERVICE_UNAVAILABLE = 514, - /** 协议被黑洞规则过滤 / protocol filtered by blackhole rule */ - V2NIM_ERROR_CODE_PROTOCOL_BLACKHOLE_FILTERED = 599, - /** appid 没有权限调用该协议 / appid has no permission to call the protocol */ - V2NIM_ERROR_CODE_NO_PERMISSION = 997, - /** 解包错误 / unpack error */ - V2NIM_ERROR_CODE_UNPACK_ERROR = 998, - /** 打包错误 / pack error */ - V2NIM_ERROR_CODE_PACK_ERROR = 999, - - // 应用 - /** IM 未开通 / IM disabled */ - V2NIM_ERROR_CODE_IM_DISABLED = 101301, - /** 服务地址非法 / service address invalid */ - V2NIM_ERROR_CODE_SERVICE_ADDRESS_INVALID = 101302, - /** appkey 不存在 / appkey not exist */ - V2NIM_ERROR_CODE_APPKEY_NOT_EXIST = 101303, - /** bundleid 校验失败 / bundleid check failed */ - V2NIM_ERROR_CODE_BUNDLEID_CHECK_FAILED = 101304, - /** 非法的鉴权方式 / illegal auth type */ - V2NIM_ERROR_CODE_ILLEGAL_AUTH_TYPE = 101305, - - // 帐号 - /** 用户不存在 / account not exist */ - V2NIM_ERROR_CODE_ACCOUNT_NOT_EXIST = 102404, - /** 用户已存在 / account already exists */ - V2NIM_ERROR_CODE_ACCOUNT_ALREADY_EXIST = 102405, - /** 用户被禁言 / account chat banned */ - V2NIM_ERROR_CODE_ACCOUNT_CHAT_BANNED = 102421, - /** 用户被禁用 / account banned */ - V2NIM_ERROR_CODE_ACCOUNT_BANNED = 102422, - /** 用户被拉黑 / account in block list */ - V2NIM_ERROR_CODE_ACCOUNT_IN_BLOCK_LIST = 102426, - /** 超过最大账号数 / limit of accounts exceeded */ - V2NIM_ERROR_CODE_ACCOUNT_COUNT_LIMIT = 102434, - /** 账号请求需要重试 / account operation need retry */ - V2NIM_ERROR_CODE_ACCOUNT_OPERATION_NEED_RETRY = 102449, - /** 找不到设备登陆记录 / login record not found */ - V2NIM_ERROR_CODE_LOGIN_RECORD_NOT_FOUND = 102301, - /** 无效 token / invalid token */ - V2NIM_ERROR_CODE_INVALID_TOKEN = 102302, - /** 机器人账号不得登录 / robot not allowed */ - V2NIM_ERROR_CODE_ROBOT_NOT_ALLOWED = 102303, - - // 用户资料 - /** 用户资料不存在 / user profile not exist */ - V2NIM_ERROR_CODE_USER_PROFILE_NOT_EXIST = 103404, - /** 用户资料反垃圾 / user profile hit antispam */ - V2NIM_ERROR_CODE_USER_PROFILE_HIT_ANTISPAM = 103451, - - // 好友 - /** 对方好友超限 / peer friend limit exceeded */ - V2NIM_ERROR_CODE_PEER_FRIEND_LIMIT = 104301, - /** 好友申请不存在 / friend application not exist */ - V2NIM_ERROR_CODE_FRIEND_APPLICATION_NOT_EXIST = 104302, - /** 好友不存在 / friend not exist */ - V2NIM_ERROR_CODE_FRIEND_NOT_EXIST = 104404, - /** 好友已存在 / friend already exist */ - V2NIM_ERROR_CODE_FRIEND_ALREADY_EXIST = 104405, - /** 不允许对自己进行好友操作 / self friend operation not allowed */ - V2NIM_ERROR_CODE_SELF_FRIEND_OPERATION_NOT_ALLOWED = 104429, - /** 好友超限 / friend accounts limit exceeded */ - V2NIM_ERROR_CODE_FRIEND_LIMIT = 104435, - /** 好友操作频率超限 / friend operation rate limit exceeded */ - V2NIM_ERROR_CODE_FRIEND_OPERATION_RATE_LIMIT = 104449, - /** 好友反垃圾 / friend hit antispam */ - V2NIM_ERROR_CODE_FRIEND_HIT_ANTISPAM = 104451, - - // 静音 - /** 静音列表超限 / mute list limit exceeded */ - V2NIM_ERROR_CODE_MUTE_LIST_LIMIT = 105435, - /** 不允许对自己进行静音操作 / self mute operation not allowed */ - V2NIM_ERROR_CODE_SELF_MUTE_OPERATION_NOT_ALLOWED = 105429, - - // 黑名单 - /** 黑名单超限 / blocklist limit exceeded */ - V2NIM_ERROR_CODE_BLOCKLIST_LIMIT = 106435, - /** 不允许对自己进行黑名单操作 / self blocklist operation not allowed */ - V2NIM_ERROR_CODE_SELF_BLOCKLIST_OPERATION_NOT_ALLOWED = 106429, - - // 消息 - /** 该app未开启发消息功能 / messaging function disabled */ - V2NIM_ERROR_CODE_MESSAGING_FUNCTION_DISABLED = 107410, - /** 消息命中反垃圾 / message hit antispam */ - V2NIM_ERROR_CODE_MESSAGE_HIT_ANTISPAM = 107451, - /** 消息不存在 / message not exist */ - V2NIM_ERROR_CODE_MESSAGE_NOT_EXIST = 107404, - /** 不允许撤回发给自己的消息 / revoke message to self not allowed */ - V2NIM_ERROR_CODE_REVOKE_MESSAGE_TO_SELF_NOT_ALLOWED = 107429, - /** 无效的时间范围 / invalid time range */ - V2NIM_ERROR_CODE_INVALID_TIME_RANGE = 107439, - /** 不允许撤回第三方业务消息 / revoke third party message not allowed */ - V2NIM_ERROR_CODE_REVOKE_THIRD_PARTY_MESSAGE_NOT_ALLOWED = 107301, - /** 由于群成员过多导致标记已读失败,消息发送失败 / sending message failed for marking message read failed for too many team members */ - V2NIM_ERROR_CODE_TEAM_MARK_READ_FAILED = 107302, - /** 仅允许发送者或管理员撤回消息 / only sender or manager can revoke message */ - V2NIM_ERROR_CODE_SENDER_OR_MANAGER_PERMISSION_ONLY_REVOKE = 107303, - /** 高优消息超过频控限制 / rate limit of high-priority messages exceeded */ - V2NIM_ERROR_CODE_HIGH_PRIORITY_MESSAGE_RATE_LIMIT = 107304, - /** ack消息必须是高优消息 / ack message should be high-priority */ - V2NIM_ERROR_CODE_ACK_MESSAGE_BE_HIGH_PRIORITY = 107305, - /** 消息ID重复 / duplicate client message ID */ - V2NIM_ERROR_CODE_DUPLICATE_CLIENT_MESSAGE_ID = 107306, - /** 短链转长链失败 / short to long URL failed */ - V2NIM_ERROR_CODE_SHORT_TO_LONG_URL_FAILED = 107307, - /** 无效 URL / URL invalid */ - V2NIM_ERROR_CODE_URL_INVALID = 107308, - /** duration 超出范围 / duration out of range */ - V2NIM_ERROR_CODE_DURATION_OUT_OF_RANGE = 107309, - /** 获取文件 meta 信息失败 / get file meta info failed */ - V2NIM_ERROR_CODE_GET_FILE_META_INFO_FAILED = 107310, - /** 音频文件大小超限 / audio file size limit exceeded */ - V2NIM_ERROR_CODE_AUDIO_FILE_SIZE_LIMIT = 107311, - /** 语音转文字超时 / voice to text timeout */ - V2NIM_ERROR_CODE_VOICE_TO_TEXT_TIMEOUT = 107312, - /** 语音转文字失败 / voice to text failed */ - V2NIM_ERROR_CODE_VOICE_TO_TEXT_FAILED = 107313, - /** 撤回消息超过时间限制 / revoke message exceeded time limit */ - V2NIM_ERROR_CODE_REVOKE_EXCEED_TIME_LIMIT = 107314, - /** 不允许撤回指定消息 / revoke message not allowed, not sender or manager */ - V2NIM_ERROR_CODE_REVOKE_MESSAGE_NOT_ALLOWED = 107315, - /** 强推列表超过上限 / force push list limit exceeded */ - V2NIM_ERROR_CODE_FORCE_PUSH_LIST_LIMIT = 107316, - /** 群消息已读操作超频 / team message receipt rate limit exceeded */ - V2NIM_ERROR_CODE_TEAM_MESSAGE_RECEIPT_RATE_LIMIT = 107317, - /** 快照不存在 / snapshot not exist */ - V2NIM_ERROR_CODE_SNAPSHOT_NOT_EXIST = 107318, - /** PIN 数量超限 / PIN limit exceeded */ - V2NIM_ERROR_CODE_PIN_LIMIT = 107319, - /** PIN 不存在 / PIN not exist */ - V2NIM_ERROR_CODE_PIN_NOT_EXIST = 107320, - /** 快捷评论数量超限 / quick comment limit exceeded */ - V2NIM_ERROR_CODE_QUICK_COMMENT_LIMIT = 107321, - /** PIN 已存在 / PIN already exist */ - V2NIM_ERROR_CODE_PIN_ALREADY_EXIST = 107322, - /** 消息被流控 / rate limit for messaging exceeded */ - V2NIM_ERROR_CODE_RATE_LIMIT_FOR_MESSAGING_REACHED = 107323, - /** 该app未开启群消息已读功能 / read receipt for team messages function disabled */ - V2NIM_ERROR_CODE_TEAM_READ_RECEIPT_FUNCTION_DISABLED = 107324, - /** 该app未开启单聊消息已读功能 / read receipt for p2p messages function disabled */ - V2NIM_ERROR_CODE_P2P_READ_RECEIPT_FUNCTION_DISABLED = 107325, - /** 该app未开启快捷评论功能 / quick comment function disabled */ - V2NIM_ERROR_CODE_QUICK_COMMENT_FUNCTION_DISABLED = 107326, - /** 该app未开启消息PIN功能 / PIN function disabled */ - V2NIM_ERROR_CODE_PIN_FUNCTION_DISABLED = 107327, - /** 不允许删除发给自己的消息 / delete self message not allowed */ - V2NIM_ERROR_CODE_DELETE_SELF_MESSAGE_NOT_ALLOWED = 107328, - /** 不是机器人账号 / %s is not chatbot account */ - V2NIM_ERROR_CODE_NOT_CHATBOT_ACCOUNT = 107329, - /** 不允许发送方和接收方均无感知 / sender or receiver must sense message */ - V2NIM_ERROR_CODE_MESSAGE_SENSE_REQUIRED = 107330, - /** 群消息已读功能未开启 / read receipt for team messages function disabled */ - V2NIM_ERROR_CODE_TEAM_MESSAGE_READ_RECEIPT_DISABLED = 107331, - /** 群消息已读记录未找到 / read receipt record for the team message not found */ - V2NIM_ERROR_CODE_TEAM_READ_RECEIPT_RECORD_NOT_FOUND = 107332, - /** 语音转文字功能未开通 / voice to text function disabled */ - V2NIM_ERROR_CODE_VOICE_TO_TEXT_FUNCTION_DISABLED = 107333, - /** 云端搜索功能未开通 / server search function disabled */ - V2NIM_ERROR_CODE_SERVER_SEARCH_FUNCTION_DISABLED = 107334, - /** 单向删除功能未开通 / one-way delete function disabled */ - V2NIM_ERROR_CODE_ONEWAY_DELETE_FUNCTION_DISABLED = 107335, - - // 群 - /** 群不存在 / team not exist */ - V2NIM_ERROR_CODE_TEAM_NOT_EXIST = 108404, - /** 获取在线人数功能未开启 / get online users count disabled */ - V2NIM_ERROR_CODE_GET_ONLINE_USERS_COUNT_DISABLED = 108406, - /** 群全体禁言 / all team members chat banned */ - V2NIM_ERROR_CODE_ALL_TEAM_MEMBERS_CHAT_BANNED = 108423, - /** 不允许添加群主为管理员 / assign team owner manager role not allowed */ - V2NIM_ERROR_CODE_ASSIGN_TEAM_OWNER_MANAGER_ROLE_NOT_ALLOWED = 108430, - /** 大容量超大群数量超限 / extended super team limit */ - V2NIM_ERROR_CODE_EXTENDED_SUPER_TEAM_LIMIT = 108434, - /** 创建群组超过上限 / created team limit */ - V2NIM_ERROR_CODE_CREATED_TEAM_LIMIT = 108435, - /** 群人数超过上限 / team invitation limit */ - V2NIM_ERROR_CODE_TEAM_INVITATION_LIMIT = 108437, - /** 群组反垃圾 / team hit antispam */ - V2NIM_ERROR_CODE_TEAM_HIT_ANTISPAM = 108451, - /** 群组请求需要重试 / team operation need retry */ - V2NIM_ERROR_CODE_TEAM_OPERATION_NEED_RETRY = 108449, - /** 非高级群 / not advanced team */ - V2NIM_ERROR_CODE_NOT_ADVANCED_TEAM = 108302, - /** 管理员超限 / team manager limit exceeded */ - V2NIM_ERROR_CODE_TEAM_MANAGER_LIMIT = 108303, - /** 未配置大容量超大群的数量 / extended super team limit not configured */ - V2NIM_ERROR_CODE_EXTENDED_SUPER_TEAM_LIMIT_NOT_CONFIGURED = 108304, - /** 加入群组超过上限 / joined team limit exceeded */ - V2NIM_ERROR_CODE_JOINED_TEAM_LIMIT = 108305, - /** 群普通成员禁言 / team normal member chat banned */ - V2NIM_ERROR_CODE_TEAM_NORMAL_MEMBER_CHAT_BANNED = 108306, - /** 被邀请者非好友关系 / invited account not friend */ - V2NIM_ERROR_CODE_INVITED_ACCOUNT_NOT_FRIEND = 108307, - /** 拒绝所有入群申请 / reject all team applications */ - V2NIM_ERROR_CODE_REJECT_ALL_TEAM_APPLICATIONS = 108308, - /** 不允许创建超出 %s 人的群 / create team with more than %s users not allowed */ - V2NIM_ERROR_CODE_TEAM_MEMBERS_COUNT_LIMIT = 108309, - /** 当前操作者已是群主 / operator is already team owner */ - V2NIM_ERROR_CODE_OPERATOR_ALREADY_OWN_TEAM = 108310, - /** 超大群服务未开通 / super team service disabled */ - V2NIM_ERROR_CODE_SUPER_TEAM_SERVICE_DISABLED = 108311, - /** 不允许创建大容量超大群 / create extended super team not allowed */ - V2NIM_ERROR_CODE_CREATE_EXTENDED_SUPER_TEAM_NOT_ALLOWED = 108313, - /** 查询群的数量超限 / team limit per query exceeded */ - V2NIM_ERROR_CODE_TEAM_PER_QUERY_LIMIT = 108314, - - // 群成员 - /** 禁言列表包含非群成员 / list of chat banned users contains non team members */ - V2NIM_ERROR_CODE_CHAT_BAN_LIST_CONTAIN_NOT_TEAM_MEMBER = 109301, - /** 禁言列表包含操作人 / list of chat banned users contains the operator */ - V2NIM_ERROR_CODE_CHAT_BAN_LIST_CONTAIN_OPERATOR = 109303, - /** 禁言列表包含群主 / list of chat banned users contains the team owner */ - V2NIM_ERROR_CODE_CHAT_BAN_LIST_CONTAIN_TEAM_OWNER = 109304, - /** 不允许操作管理员 / operation on team manager not allowed */ - V2NIM_ERROR_CODE_OPERATION_ON_TEAM_MANAGER_NOT_ALLOWED = 109305, - /** 没有群邀请权限 / no team invite permission */ - V2NIM_ERROR_CODE_NO_TEAM_INVITE_PERMISSION = 109306, - /** 群主不允许退群 / team owner quit not allowed */ - V2NIM_ERROR_CODE_TEAM_OWNER_QUIT_NOT_ALLOWED = 109307, - /** 群被踢列表包含群主 / list of kicked user contains the team owner */ - V2NIM_ERROR_CODE_TEAM_OWNER_IN_KICK_LIST = 109308, - /** 不允许邀请机器人账号进群 / invite robot account not allowed */ - V2NIM_ERROR_CODE_INVITE_ROBOT_ACCOUNT_NOT_ALLOWED = 109309, - /** 被踢的群成员列表中包含操作者 / kick operator not allowed */ - V2NIM_ERROR_CODE_KICK_OPERATOR_NOT_ALLOWED = 109310, - /** 群成员已存在 / team member already exist */ - V2NIM_ERROR_CODE_TEAM_MEMBER_ALREADY_EXIST = 109311, - /** 不允许操作自己 / operation on self not allowed */ - V2NIM_ERROR_CODE_TEAM_MEMBER_CAN_NOT_MODIFY_SELF = 109312, - /** 群邀请或申请记录不存在 / team invitation or application not exist */ - V2NIM_ERROR_CODE_TEAM_INVITATION_OR_APPLICATION_NOT_EXIST = 109313, - /** 不允许操作群主 / operation on team owner not allowed */ - V2NIM_ERROR_CODE_OPERATION_ON_TEAM_OWNER_NOT_ALLOWED = 109314, - /** 群成员不存在 / team member not exist */ - V2NIM_ERROR_CODE_TEAM_MEMBER_NOT_EXIST = 109404, - /** 群成员被禁言 / team member chat banned */ - V2NIM_ERROR_CODE_TEAM_MEMBER_CHAT_BANNED = 109424, - /** 仅允许群主操作 / team owner operation permission required */ - V2NIM_ERROR_CODE_TEAM_OWNER_OPERATION_PERMISSION_REQUIRED = 109427, - /** 仅允许群主或管理员操作 / team owner or manager operation permission required */ - V2NIM_ERROR_CODE_TEAM_OWNER_OR_MANAGER_OPERATION_PERMISSION_REQUIRED = 109432, - /** 并发操作群成员失败 / team member concurrent operation failed */ - V2NIM_ERROR_CODE_TEAM_MEMBER_CONCURRENT_OPERATION_FAILED = 109449, - /** 群成员反垃圾 / team member hit antispam */ - V2NIM_ERROR_CODE_TEAM_MEMBER_HIT_ANTISPAM = 109451, - - // 会话 - /** 会话所属账号不唯一 / accounts for conversations not unique */ - V2NIM_ERROR_CODE_ACCOUNTS_FOR_CONVERSATIONS_NOT_UNIQUE = 110301, - /** 会话和账号不匹配 / conversation and account mismatch */ - V2NIM_ERROR_CODE_CONVERSATION_AND_ACCOUNT_MISMATCH = 110302, - /** 会话置顶数量超限 / conversation stick top limit */ - V2NIM_ERROR_CODE_CONVERSATION_STICK_TOP_LIMIT = 110303, - /** 会话所属会话分组数量超限 / conversation belonged group limit */ - V2NIM_ERROR_CODE_CONVERSATION_BELONGED_GROUP_LIMIT = 110304, - /** 会话不存在 / conversation not exist */ - V2NIM_ERROR_CODE_CONVERSATION_NOT_EXIST = 110404, - /** 会话请求需要重试 / conversation operation need retry */ - V2NIM_ERROR_CODE_CONVERSATION_OPERATION_NEED_RETRY = 110449, - - /** 广播通知 */ - /** 广播通知未开启 / broadcasting notification service disabled */ - V2NIM_ERROR_CODE_BROADCASTING_NOTIFICATION_DISABLED = 111410, - /** 广播通知不存在 / broadcasting notification not exist */ - V2NIM_ERROR_CODE_BROADCASTING_NOTIFICATION_NOT_EXIST = 111404, - - /** 自定义通知 */ - - /** 聊天室 */ - /** 获取有效的聊天室连接地址失败 / failed to get chatroom link */ - V2NIM_ERROR_CODE_GET_CHATROOM_LINK_FAILED = 113304, - /** IM 连接状态异常 / IM connection abnormal */ - V2NIM_ERROR_CODE_IM_CONNECTION_ABNORMAL = 113305, - /** 聊天室不存在 / chatroom not exist */ - V2NIM_ERROR_CODE_CHATROOM_NOT_EXIST = 113404, - /** 聊天室已关闭 / chatroom closed */ - V2NIM_ERROR_CODE_CHATROOM_CLOSED = 113406, - /** 聊天室重复操作 / operation on chatroom repeated */ - V2NIM_ERROR_CODE_CHATROOM_REPEATED_OPERATION = 113409, - /** 聊天室服务未开通 / chatroom service disabled */ - V2NIM_ERROR_CODE_CHATROOM_SERVICE_DISABLED = 113410, - /** 聊天室全体禁言 / all chatroom members chat banned */ - V2NIM_ERROR_CODE_ALL_CHATROOM_MEMBERS_CHAT_BANNED = 113423, - /** 聊天室信息命中反垃圾 / chatroom info hit antispam */ - V2NIM_ERROR_CODE_CHATROOM_INFO_HIT_ANTISPAM = 113451, - /** 非法的聊天室鉴权方式 / chatroom illegal auth type */ - V2NIM_ERROR_CODE_CHATROOM_ILLEGAL_AUTH_TYPE = 113306, - /** 参数与现有聊天室属性一致,无需更新 / identical field values */ - V2NIM_ERROR_CODE_IDENTICAL_FIELD_VALUES = 113307, - /** 仅允许聊天室管理员操作 / chatroom manager operation permission required */ - V2NIM_ERROR_CODE_CHATROOM_MANAGER_OPERATION_REQUIRED = 113428, - /** 聊天室数量超过限制 / chatroom count limit exceeded */ - V2NIM_ERROR_CODE_CHATROOM_COUNT_LIMIT = 113434, - /** 聊天室成员进出通知功能未开启 / notification for joining or leaving chatrooms disabled */ - V2NIM_ERROR_CODE_NOTIFICATION_FOR_MEMBER_IN_OUT_CHATROOM_DISALED = 113308, - /** 聊天室被临时禁言 / chatroom temporarily chat banned */ - V2NIM_ERROR_CODE_CHATROOM_TEMP_CHAT_BANNED = 113301, - /** 聊天室标签成员被禁言 / chatroom tagged members chat banned */ - V2NIM_ERROR_CODE_CHATROOM_TAGGED_MEMBERS_CHAT_BANNED = 113302, - /** 聊天室正在关闭,禁止开启 / chat room closing, reopen not allowed */ - V2NIM_ERROR_CODE_CHATROOM_CLOSING = 113303, - /** 广播通知命中反垃圾 / chatroom broadcasting notification hit antispam */ - V2NIM_ERROR_CODE_CHATROOM_BROADCASTING_NOTIFICATION_HIT_ANTISPAM = 113309, - /** 广播通知服务未开启 / broadcasting notification service disabled */ - V2NIM_ERROR_CODE_CHATROOM_BROADCASTING_NOTIFICATION_DISABLED = 113310, - - // 聊天室成员 - /** 聊天室成员不存在 / chatroom member not exist */ - V2NIM_ERROR_CODE_CHATROOM_MEMBER_NOT_EXIST = 114404, - /** 聊天室成员重复操作 / chatroom member repeated operation */ - V2NIM_ERROR_CODE_CHATROOM_MEMBER_REPEATED_OPERATION = 114405, - /** 聊天室成员禁言 / chatroom member chat banned */ - V2NIM_ERROR_CODE_CHATROOM_MEMBER_CHAT_BANNED = 114421, - /** 账号在聊天室黑名单中 / account in chatroom block list */ - V2NIM_ERROR_CODE_ACCOUNT_IN_CHATROOM_BLOCK_LIST = 114426, - /** 仅允许聊天室所有者操作 / chatroom owner operation permission required */ - V2NIM_ERROR_CODE_CHATROOM_OWNER_OPERATION_PERMISSION_REQUIRED = 114427, - /** 聊天室成员操作列表包含操作者 / operator in chatroom member operation list */ - V2NIM_ERROR_CODE_OPERATOR_IN_CHATROOM_MEMBER_OPERATION_LIST = 114429, - /** 仅允许聊天室所有者或管理员操作 / chatroom owner or manager operation permission required */ - V2NIM_ERROR_CODE_CHATROOM_OWNER_OR_MANAGER_OPERATION_PERMISSION_REQUIRED = 114432, - /** 聊天室成员数量超限 / chatroom member limit */ - V2NIM_ERROR_CODE_CHATROOM_MEMBER_LIMIT = 114437, - /** 并发操作聊天室成员失败 / chatroom member concurrent operation failed */ - V2NIM_ERROR_CODE_CHATROOM_MEMBER_CONCURRENT_OPERATION_FAILED = 114449, - /** 聊天室成员命中反垃圾 / chatroom member info hit antispam */ - V2NIM_ERROR_CODE_CHATROOM_MEMBER_INFO_HIT_ANTISPAM = 114451, - /** 聊天室成员已删除 / Member: %s was already deleted */ - V2NIM_ERROR_CODE_CHATROOM_MEMBER_ALREADY_DELETED = 114408, - /** 目标账号在禁言或黑名单列表中 / target account in blocklist or chat banned list of chatroom */ - V2NIM_ERROR_CODE_CHATROOM_MEMBER_IN_BLOCKLIST_CHAT_BANNED_LIST = 114301, - /** 匿名成员禁止操作 / anonymous member operation forbidden */ - V2NIM_ERROR_CODE_ANONYMOUS_MEMBER_OPERATION_FORBIDDEN = 114303, - /** 目标成员帐号不在线 / Target chatroom member offline */ - V2NIM_ERROR_CODE_CHATROOM_TARGET_MEMBER_OFFLINE = 114304, - - // 会话分组 - /** 会话分组不存在 / conversation group not exist */ - V2NIM_ERROR_CODE_CONVERSATION_GROUP_NOT_EXIST = 116404, - /** 会话分组数量超限 / conversation group limit */ - V2NIM_ERROR_CODE_CONVERSATION_GROUP_LIMIT = 116435, - /** 会话分组中的会话数量超限 / conversations in group limit */ - V2NIM_ERROR_CODE_CONVERSATIONS_IN_GROUP_LIMIT = 116437, - - // 聊天室队列 - - // 其他 - /** 收藏数量超限 / collection limit exceeded */ - V2NIM_ERROR_CODE_COLLECTION_LIMIT = 189301, - /** 收藏不存在 / collection not exist */ - V2NIM_ERROR_CODE_COLLECTION_NOT_EXIST = 189302, - /** 并发操作收藏失败 / collection concurrent operation failed */ - V2NIM_ERROR_CODE_COLLECTION_CONCURRENT_OPERATION_FAILED = 189449, - /** 客户端反垃圾文件没有发生变化 / client antispam file has no change */ - V2NIM_ERROR_CODE_CLIENT_ANTISPAM_FILE_NO_CHANGE = 189303, - /** 客户端反垃圾文件大小超限 / client antispam file size limit exceeded */ - V2NIM_ERROR_CODE_CLIENT_ANTISPAM_FILE_SIZE_LIMIT = 189304, - - // 通用 - /** 内部错误 / internal error */ - V2NIM_ERROR_CODE_INTERNAL = 190001, - /** 非法状态 / illegal state */ - V2NIM_ERROR_CODE_ILLEGAL_STATE = 190002, - - // 接口 - /** 使用姿势错误 / misuse */ - V2NIM_ERROR_CODE_MISUSE = 191001, - /** 操作取消 / operation cancelled */ - V2NIM_ERROR_CODE_CANCELLED = 191002, - /** 回调失败 / callback failed */ - V2NIM_ERROR_CODE_CALLBACK_FAILED = 191003, - /** 参数错误 / invalid parameter */ - V2NIM_ERROR_CODE_INVALID_PARAMETER = 191004, - /** 超时 / timeout */ - V2NIM_ERROR_CODE_TIMEOUT = 191005, - /** 资源不存在 / resource not exist */ - V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST = 191006, - /** 资源已存在 / resource already exist */ - V2NIM_ERROR_CODE_RESOURCE_ALREADY_EXIST = 191007, - - // 连接 - /** 连接错误 / connect failed */ - V2NIM_ERROR_CODE_CONNECT_FAILED = 192001, - /** 连接超时 / connect timeout */ - V2NIM_ERROR_CODE_CONNECT_TIMEOUT = 192002, - /** 连接断开 / disconnected */ - V2NIM_ERROR_CODE_DISCONNECTED = 192003, - /** 协议超时 / protocol timeout */ - V2NIM_ERROR_CODE_PROTOCOL_TIMEOUT = 192004, - /** 协议发送失败 / protocol send failed */ - V2NIM_ERROR_CODE_PROTOCOL_SEND_FAILED = 192005, - /** 请求失败 / request failed */ - V2NIM_ERROR_CODE_REQUEST_FAILED = 192006, - - // 数据库 - /** 数据库打开失败 / database open failed */ - V2NIM_ERROR_CODE_DATABASE_OPEN_FAILED = 193001, - /** 数据库升级失败 / database upgrade failed */ - V2NIM_ERROR_CODE_DATABASE_UPGRADE_FAILED = 193002, - /** 数据库写入失败 / database write failed */ - V2NIM_ERROR_CODE_DATABASE_WRITE_FAILED = 193003, - /** 数据库读取失败 / database read failed */ - V2NIM_ERROR_CODE_DATABASE_READ_FAILED = 193004, - - // 文件 - /** 文件不存在 / file not found */ - V2NIM_ERROR_CODE_FILE_NOT_FOUND = 194001, - /** 文件创建失败 / file create failed */ - V2NIM_ERROR_CODE_FILE_CREATE_FAILED = 194002, - /** 文件打开失败 / file open failed */ - V2NIM_ERROR_CODE_FILE_OPEN_FAILED = 194003, - /** 文件写入失败 / file write failed */ - V2NIM_ERROR_CODE_FILE_WRITE_FAILED = 194004, - /** 文件读取失败 / file read failed */ - V2NIM_ERROR_CODE_FILE_READ_FAILED = 194005, - /** 文件上传失败 / file upload failed */ - V2NIM_ERROR_CODE_FILE_UPLOAD_FAILED = 194006, - /** 文件下载失败 / file download failed */ - V2NIM_ERROR_CODE_FILE_DOWNLOAD_FAILED = 194007, - - // 反垃圾 - /** 客户端反垃圾 / client anti-spam */ - V2NIM_ERROR_CODE_CLIENT_ANTISPAM = 195001, - /** 云端反垃圾 / server anti-spam */ - V2NIM_ERROR_CODE_SERVER_ANTISPAM = 195002, - - // 信令 - /** 信令房间已存在 */ - V2NIM_ERROR_CODE_SIGNALLING_ROOM_EXIST = 118301, - /** 邀请已经被接受 */ - V2NIM_ERROR_CODE_SIGNALLING_INVITE_ACCEPTED = 118302, - /** 信令成员不存在 */ - V2NIM_ERROR_CODE_SIGNALLING_MEMBER_NOT_EXIST = 118303, - /** 信令成员已存在 */ - V2NIM_ERROR_CODE_SIGNALLING_MEMBER_ALREADY_EXIST = 118304, - /** 信令成员已存在且设备 ID 不一致 */ - V2NIM_ERROR_CODE_SIGNALLING_MEMBER_ALREADY_EXIST_AND_DEVICE_ID_NOT_UNIQUE = 118305, - /** UID 不唯一 */ - V2NIM_ERROR_CODE_SIGNALLING_UID_NOT_UNIQUE = 118306, - /** 邀请已经被拒绝 */ - V2NIM_ERROR_CODE_SIGNALLING_INVITE_REJECTED = 118307, - /** 信令成员不在线,但推送可达 */ - V2NIM_ERROR_CODE_SIGNALLING_MEMBER_OFFLINE_BUT_PUSH_REACHABLE = 118308, - /** 信令成员不在线,且推送不可达 */ - V2NIM_ERROR_CODE_SIGNALLING_MEMBER_OFFLINE_AND_PUSH_NOT_REACHABLE = 118309, - /** 邀请不存在 */ - V2NIM_ERROR_CODE_SIGNALLING_INVITE_NOT_EXIST = 118310, - /** 房间不存在 */ - V2NIM_ERROR_CODE_SIGNALLING_ROOM_NOT_EXIST = 118404, - /** 房间成员数量超限 */ - V2NIM_ERROR_CODE_SIGNALLING_ROOM_MEMBER_LIMIT = 118437, - /** 信令服务未开通 */ - V2NIM_ERROR_CODE_SIGNALLING_SERVICE_DISABLED = 118410 + /** 未知错误 / unknown error */ + V2NIM_ERROR_CODE_UNKNOWN = 0, + /** 请求成功 / success */ + V2NIM_ERROR_CODE_SUCCESS = 200, + + // 全局错误 + /** 握手错误 / handshake error */ + V2NIM_ERROR_CODE_HANDSHAKE = 201, + /** 非对称加密算法错误 / asymmetric encryption algorithm error */ + V2NIM_ERROR_CODE_ASYMMETRIC_ENCRYPTION_ALGORITHM = 202, + /** 对称加密算法错误 / symmetric encryption algorithm error */ + V2NIM_ERROR_CODE_SYMMETRIC_ENCRYPTION_ALGORITHM = 203, + /** 握手协议版本需降级 / handshake protocol version need fallback */ + V2NIM_ERROR_CODE_HANDSHAKE_PROTOCOL_VERSION_NEED_FALLBACK = 204, + /** 请求被服务器暂时禁止 / request temporary forbidden */ + V2NIM_ERROR_CODE_REQUEST_TEMPORARY_FORBIDDEN = 398, + /** 服务器单元错误 / server unit error */ + V2NIM_ERROR_CODE_SERVER_UNIT_ERROR = 399, + /** 没有权限 / forbidden */ + V2NIM_ERROR_CODE_FORBIDDEN = 403, + /** 资源不存在 / not found */ + V2NIM_ERROR_CODE_NOT_FOUND = 404, + /** 参数错误 / parameter error */ + V2NIM_ERROR_CODE_PARAMETER_ERROR = 414, + /** 频率超限 / rate limit exceeded */ + V2NIM_ERROR_CODE_RATE_LIMIT = 416, + /** 多端登录被禁止 / multi login forbidden */ + V2NIM_ERROR_CODE_MULTI_LOGIN_FORBIDDEN = 417, + /** 请求需要重试 / need retry */ + V2NIM_ERROR_CODE_NEED_RETRY = 449, + /** 第三方回调被拒绝 / callback forbidden */ + V2NIM_ERROR_CODE_CALLBACK_FORBIDDEN = 463, + /** 服务器内部错误 / internal server error */ + V2NIM_ERROR_CODE_SERVER_INTERNAL_ERROR = 500, + /** 服务器繁忙 / server busy */ + V2NIM_ERROR_CODE_SERVER_BUSY = 503, + /** app 服务不可达 / app server unreachable */ + V2NIM_ERROR_CODE_APP_UNREACHABLE = 511, + /** 服务不可用 / service unavailable */ + V2NIM_ERROR_CODE_SERVICE_UNAVAILABLE = 514, + /** 协议被黑洞规则过滤 / protocol filtered by blackhole rule */ + V2NIM_ERROR_CODE_PROTOCOL_BLACKHOLE_FILTERED = 599, + /** appid 没有权限调用该协议 / appid has no permission to call the protocol */ + V2NIM_ERROR_CODE_NO_PERMISSION = 997, + /** 解包错误 / unpack error */ + V2NIM_ERROR_CODE_UNPACK_ERROR = 998, + /** 打包错误 / pack error */ + V2NIM_ERROR_CODE_PACK_ERROR = 999, + + // 应用 + /** IM 未开通 / IM disabled */ + V2NIM_ERROR_CODE_IM_DISABLED = 101301, + /** 服务地址非法 / service address invalid */ + V2NIM_ERROR_CODE_SERVICE_ADDRESS_INVALID = 101302, + /** appkey 不存在 / appkey not exist */ + V2NIM_ERROR_CODE_APPKEY_NOT_EXIST = 101303, + /** bundleid 校验失败 / bundleid check failed */ + V2NIM_ERROR_CODE_BUNDLEID_CHECK_FAILED = 101304, + /** 非法的鉴权方式 / illegal auth type */ + V2NIM_ERROR_CODE_ILLEGAL_AUTH_TYPE = 101305, + + // 帐号 + /** 用户不存在 / account not exist */ + V2NIM_ERROR_CODE_ACCOUNT_NOT_EXIST = 102404, + /** 用户已存在 / account already exists */ + V2NIM_ERROR_CODE_ACCOUNT_ALREADY_EXIST = 102405, + /** 用户被禁言 / account chat banned */ + V2NIM_ERROR_CODE_ACCOUNT_CHAT_BANNED = 102421, + /** 用户被禁用 / account banned */ + V2NIM_ERROR_CODE_ACCOUNT_BANNED = 102422, + /** 用户被拉黑 / account in block list */ + V2NIM_ERROR_CODE_ACCOUNT_IN_BLOCK_LIST = 102426, + /** 超过最大账号数 / limit of accounts exceeded */ + V2NIM_ERROR_CODE_ACCOUNT_COUNT_LIMIT = 102434, + /** 账号请求需要重试 / account operation need retry */ + V2NIM_ERROR_CODE_ACCOUNT_OPERATION_NEED_RETRY = 102449, + /** 找不到设备登陆记录 / login record not found */ + V2NIM_ERROR_CODE_LOGIN_RECORD_NOT_FOUND = 102301, + /** 无效 token / invalid token */ + V2NIM_ERROR_CODE_INVALID_TOKEN = 102302, + /** 机器人账号不得登录 / robot not allowed */ + V2NIM_ERROR_CODE_ROBOT_NOT_ALLOWED = 102303, + + // 用户资料 + /** 用户资料不存在 / user profile not exist */ + V2NIM_ERROR_CODE_USER_PROFILE_NOT_EXIST = 103404, + /** 用户资料反垃圾 / user profile hit antispam */ + V2NIM_ERROR_CODE_USER_PROFILE_HIT_ANTISPAM = 103451, + + // 好友 + /** 对方好友超限 / peer friend limit exceeded */ + V2NIM_ERROR_CODE_PEER_FRIEND_LIMIT = 104301, + /** 好友申请不存在 / friend application not exist */ + V2NIM_ERROR_CODE_FRIEND_APPLICATION_NOT_EXIST = 104302, + /** 好友不存在 / friend not exist */ + V2NIM_ERROR_CODE_FRIEND_NOT_EXIST = 104404, + /** 好友已存在 / friend already exist */ + V2NIM_ERROR_CODE_FRIEND_ALREADY_EXIST = 104405, + /** 不允许对自己进行好友操作 / self friend operation not allowed */ + V2NIM_ERROR_CODE_SELF_FRIEND_OPERATION_NOT_ALLOWED = 104429, + /** 好友超限 / friend accounts limit exceeded */ + V2NIM_ERROR_CODE_FRIEND_LIMIT = 104435, + /** 好友操作频率超限 / friend operation rate limit exceeded */ + V2NIM_ERROR_CODE_FRIEND_OPERATION_RATE_LIMIT = 104449, + /** 好友反垃圾 / friend hit antispam */ + V2NIM_ERROR_CODE_FRIEND_HIT_ANTISPAM = 104451, + + // 静音 + /** 静音列表超限 / mute list limit exceeded */ + V2NIM_ERROR_CODE_MUTE_LIST_LIMIT = 105435, + /** 不允许对自己进行静音操作 / self mute operation not allowed */ + V2NIM_ERROR_CODE_SELF_MUTE_OPERATION_NOT_ALLOWED = 105429, + + // 黑名单 + /** 黑名单超限 / blocklist limit exceeded */ + V2NIM_ERROR_CODE_BLOCKLIST_LIMIT = 106435, + /** 不允许对自己进行黑名单操作 / self blocklist operation not allowed */ + V2NIM_ERROR_CODE_SELF_BLOCKLIST_OPERATION_NOT_ALLOWED = 106429, + + // 消息 + /** 该app未开启发消息功能 / messaging function disabled */ + V2NIM_ERROR_CODE_MESSAGING_FUNCTION_DISABLED = 107410, + /** 消息命中反垃圾 / message hit antispam */ + V2NIM_ERROR_CODE_MESSAGE_HIT_ANTISPAM = 107451, + /** 消息不存在 / message not exist */ + V2NIM_ERROR_CODE_MESSAGE_NOT_EXIST = 107404, + /** 不允许撤回发给自己的消息 / revoke message to self not allowed */ + V2NIM_ERROR_CODE_REVOKE_MESSAGE_TO_SELF_NOT_ALLOWED = 107429, + /** 无效的时间范围 / invalid time range */ + V2NIM_ERROR_CODE_INVALID_TIME_RANGE = 107439, + /** 不允许撤回第三方业务消息 / revoke third party message not allowed */ + V2NIM_ERROR_CODE_REVOKE_THIRD_PARTY_MESSAGE_NOT_ALLOWED = 107301, + /** 由于群成员过多导致标记已读失败,消息发送失败 / sending message failed for marking message read failed for too many team members */ + V2NIM_ERROR_CODE_TEAM_MARK_READ_FAILED = 107302, + /** 仅允许发送者或管理员撤回消息 / only sender or manager can revoke message */ + V2NIM_ERROR_CODE_SENDER_OR_MANAGER_PERMISSION_ONLY_REVOKE = 107303, + /** 高优消息超过频控限制 / rate limit of high-priority messages exceeded */ + V2NIM_ERROR_CODE_HIGH_PRIORITY_MESSAGE_RATE_LIMIT = 107304, + /** ack消息必须是高优消息 / ack message should be high-priority */ + V2NIM_ERROR_CODE_ACK_MESSAGE_BE_HIGH_PRIORITY = 107305, + /** 消息ID重复 / duplicate client message ID */ + V2NIM_ERROR_CODE_DUPLICATE_CLIENT_MESSAGE_ID = 107306, + /** 短链转长链失败 / short to long URL failed */ + V2NIM_ERROR_CODE_SHORT_TO_LONG_URL_FAILED = 107307, + /** 无效 URL / URL invalid */ + V2NIM_ERROR_CODE_URL_INVALID = 107308, + /** duration 超出范围 / duration out of range */ + V2NIM_ERROR_CODE_DURATION_OUT_OF_RANGE = 107309, + /** 获取文件 meta 信息失败 / get file meta info failed */ + V2NIM_ERROR_CODE_GET_FILE_META_INFO_FAILED = 107310, + /** 音频文件大小超限 / audio file size limit exceeded */ + V2NIM_ERROR_CODE_AUDIO_FILE_SIZE_LIMIT = 107311, + /** 语音转文字超时 / voice to text timeout */ + V2NIM_ERROR_CODE_VOICE_TO_TEXT_TIMEOUT = 107312, + /** 语音转文字失败 / voice to text failed */ + V2NIM_ERROR_CODE_VOICE_TO_TEXT_FAILED = 107313, + /** 撤回消息超过时间限制 / revoke message exceeded time limit */ + V2NIM_ERROR_CODE_REVOKE_EXCEED_TIME_LIMIT = 107314, + /** 不允许撤回指定消息 / revoke message not allowed, not sender or manager */ + V2NIM_ERROR_CODE_REVOKE_MESSAGE_NOT_ALLOWED = 107315, + /** 强推列表超过上限 / force push list limit exceeded */ + V2NIM_ERROR_CODE_FORCE_PUSH_LIST_LIMIT = 107316, + /** 群消息已读操作超频 / team message receipt rate limit exceeded */ + V2NIM_ERROR_CODE_TEAM_MESSAGE_RECEIPT_RATE_LIMIT = 107317, + /** 快照不存在 / snapshot not exist */ + V2NIM_ERROR_CODE_SNAPSHOT_NOT_EXIST = 107318, + /** PIN 数量超限 / PIN limit exceeded */ + V2NIM_ERROR_CODE_PIN_LIMIT = 107319, + /** PIN 不存在 / PIN not exist */ + V2NIM_ERROR_CODE_PIN_NOT_EXIST = 107320, + /** 快捷评论数量超限 / quick comment limit exceeded */ + V2NIM_ERROR_CODE_QUICK_COMMENT_LIMIT = 107321, + /** PIN 已存在 / PIN already exist */ + V2NIM_ERROR_CODE_PIN_ALREADY_EXIST = 107322, + /** 消息被流控 / rate limit for messaging exceeded */ + V2NIM_ERROR_CODE_RATE_LIMIT_FOR_MESSAGING_REACHED = 107323, + /** 该app未开启群消息已读功能 / read receipt for team messages function disabled */ + V2NIM_ERROR_CODE_TEAM_READ_RECEIPT_FUNCTION_DISABLED = 107324, + /** 该app未开启单聊消息已读功能 / read receipt for p2p messages function disabled */ + V2NIM_ERROR_CODE_P2P_READ_RECEIPT_FUNCTION_DISABLED = 107325, + /** 该app未开启快捷评论功能 / quick comment function disabled */ + V2NIM_ERROR_CODE_QUICK_COMMENT_FUNCTION_DISABLED = 107326, + /** 该app未开启消息PIN功能 / PIN function disabled */ + V2NIM_ERROR_CODE_PIN_FUNCTION_DISABLED = 107327, + /** 不允许删除发给自己的消息 / delete self message not allowed */ + V2NIM_ERROR_CODE_DELETE_SELF_MESSAGE_NOT_ALLOWED = 107328, + /** 不是机器人账号 / %s is not chatbot account */ + V2NIM_ERROR_CODE_NOT_CHATBOT_ACCOUNT = 107329, + /** 不允许发送方和接收方均无感知 / sender or receiver must sense message */ + V2NIM_ERROR_CODE_MESSAGE_SENSE_REQUIRED = 107330, + /** 群消息已读功能未开启 / read receipt for team messages function disabled */ + V2NIM_ERROR_CODE_TEAM_MESSAGE_READ_RECEIPT_DISABLED = 107331, + /** 群消息已读记录未找到 / read receipt record for the team message not found */ + V2NIM_ERROR_CODE_TEAM_READ_RECEIPT_RECORD_NOT_FOUND = 107332, + /** 语音转文字功能未开通 / voice to text function disabled */ + V2NIM_ERROR_CODE_VOICE_TO_TEXT_FUNCTION_DISABLED = 107333, + /** 云端搜索功能未开通 / server search function disabled */ + V2NIM_ERROR_CODE_SERVER_SEARCH_FUNCTION_DISABLED = 107334, + /** 单向删除功能未开通 / one-way delete function disabled */ + V2NIM_ERROR_CODE_ONEWAY_DELETE_FUNCTION_DISABLED = 107335, + + // 群 + /** 群不存在 / team not exist */ + V2NIM_ERROR_CODE_TEAM_NOT_EXIST = 108404, + /** 获取在线人数功能未开启 / get online users count disabled */ + V2NIM_ERROR_CODE_GET_ONLINE_USERS_COUNT_DISABLED = 108406, + /** 群全体禁言 / all team members chat banned */ + V2NIM_ERROR_CODE_ALL_TEAM_MEMBERS_CHAT_BANNED = 108423, + /** 不允许添加群主为管理员 / assign team owner manager role not allowed */ + V2NIM_ERROR_CODE_ASSIGN_TEAM_OWNER_MANAGER_ROLE_NOT_ALLOWED = 108430, + /** 大容量超大群数量超限 / extended super team limit */ + V2NIM_ERROR_CODE_EXTENDED_SUPER_TEAM_LIMIT = 108434, + /** 创建群组超过上限 / created team limit */ + V2NIM_ERROR_CODE_CREATED_TEAM_LIMIT = 108435, + /** 群人数超过上限 / team invitation limit */ + V2NIM_ERROR_CODE_TEAM_INVITATION_LIMIT = 108437, + /** 群组反垃圾 / team hit antispam */ + V2NIM_ERROR_CODE_TEAM_HIT_ANTISPAM = 108451, + /** 群组请求需要重试 / team operation need retry */ + V2NIM_ERROR_CODE_TEAM_OPERATION_NEED_RETRY = 108449, + /** 非高级群 / not advanced team */ + V2NIM_ERROR_CODE_NOT_ADVANCED_TEAM = 108302, + /** 管理员超限 / team manager limit exceeded */ + V2NIM_ERROR_CODE_TEAM_MANAGER_LIMIT = 108303, + /** 未配置大容量超大群的数量 / extended super team limit not configured */ + V2NIM_ERROR_CODE_EXTENDED_SUPER_TEAM_LIMIT_NOT_CONFIGURED = 108304, + /** 加入群组超过上限 / joined team limit exceeded */ + V2NIM_ERROR_CODE_JOINED_TEAM_LIMIT = 108305, + /** 群普通成员禁言 / team normal member chat banned */ + V2NIM_ERROR_CODE_TEAM_NORMAL_MEMBER_CHAT_BANNED = 108306, + /** 被邀请者非好友关系 / invited account not friend */ + V2NIM_ERROR_CODE_INVITED_ACCOUNT_NOT_FRIEND = 108307, + /** 拒绝所有入群申请 / reject all team applications */ + V2NIM_ERROR_CODE_REJECT_ALL_TEAM_APPLICATIONS = 108308, + /** 不允许创建超出 %s 人的群 / create team with more than %s users not allowed */ + V2NIM_ERROR_CODE_TEAM_MEMBERS_COUNT_LIMIT = 108309, + /** 当前操作者已是群主 / operator is already team owner */ + V2NIM_ERROR_CODE_OPERATOR_ALREADY_OWN_TEAM = 108310, + /** 超大群服务未开通 / super team service disabled */ + V2NIM_ERROR_CODE_SUPER_TEAM_SERVICE_DISABLED = 108311, + /** 不允许创建大容量超大群 / create extended super team not allowed */ + V2NIM_ERROR_CODE_CREATE_EXTENDED_SUPER_TEAM_NOT_ALLOWED = 108313, + /** 查询群的数量超限 / team limit per query exceeded */ + V2NIM_ERROR_CODE_TEAM_PER_QUERY_LIMIT = 108314, + + // 群成员 + /** 禁言列表包含非群成员 / list of chat banned users contains non team members */ + V2NIM_ERROR_CODE_CHAT_BAN_LIST_CONTAIN_NOT_TEAM_MEMBER = 109301, + /** 禁言列表包含操作人 / list of chat banned users contains the operator */ + V2NIM_ERROR_CODE_CHAT_BAN_LIST_CONTAIN_OPERATOR = 109303, + /** 禁言列表包含群主 / list of chat banned users contains the team owner */ + V2NIM_ERROR_CODE_CHAT_BAN_LIST_CONTAIN_TEAM_OWNER = 109304, + /** 不允许操作管理员 / operation on team manager not allowed */ + V2NIM_ERROR_CODE_OPERATION_ON_TEAM_MANAGER_NOT_ALLOWED = 109305, + /** 没有群邀请权限 / no team invite permission */ + V2NIM_ERROR_CODE_NO_TEAM_INVITE_PERMISSION = 109306, + /** 群主不允许退群 / team owner quit not allowed */ + V2NIM_ERROR_CODE_TEAM_OWNER_QUIT_NOT_ALLOWED = 109307, + /** 群被踢列表包含群主 / list of kicked user contains the team owner */ + V2NIM_ERROR_CODE_TEAM_OWNER_IN_KICK_LIST = 109308, + /** 不允许邀请机器人账号进群 / invite robot account not allowed */ + V2NIM_ERROR_CODE_INVITE_ROBOT_ACCOUNT_NOT_ALLOWED = 109309, + /** 被踢的群成员列表中包含操作者 / kick operator not allowed */ + V2NIM_ERROR_CODE_KICK_OPERATOR_NOT_ALLOWED = 109310, + /** 群成员已存在 / team member already exist */ + V2NIM_ERROR_CODE_TEAM_MEMBER_ALREADY_EXIST = 109311, + /** 不允许操作自己 / operation on self not allowed */ + V2NIM_ERROR_CODE_TEAM_MEMBER_CAN_NOT_MODIFY_SELF = 109312, + /** 群邀请或申请记录不存在 / team invitation or application not exist */ + V2NIM_ERROR_CODE_TEAM_INVITATION_OR_APPLICATION_NOT_EXIST = 109313, + /** 不允许操作群主 / operation on team owner not allowed */ + V2NIM_ERROR_CODE_OPERATION_ON_TEAM_OWNER_NOT_ALLOWED = 109314, + /** 群成员不存在 / team member not exist */ + V2NIM_ERROR_CODE_TEAM_MEMBER_NOT_EXIST = 109404, + /** 群成员被禁言 / team member chat banned */ + V2NIM_ERROR_CODE_TEAM_MEMBER_CHAT_BANNED = 109424, + /** 仅允许群主操作 / team owner operation permission required */ + V2NIM_ERROR_CODE_TEAM_OWNER_OPERATION_PERMISSION_REQUIRED = 109427, + /** 仅允许群主或管理员操作 / team owner or manager operation permission required */ + V2NIM_ERROR_CODE_TEAM_OWNER_OR_MANAGER_OPERATION_PERMISSION_REQUIRED = 109432, + /** 并发操作群成员失败 / team member concurrent operation failed */ + V2NIM_ERROR_CODE_TEAM_MEMBER_CONCURRENT_OPERATION_FAILED = 109449, + /** 群成员反垃圾 / team member hit antispam */ + V2NIM_ERROR_CODE_TEAM_MEMBER_HIT_ANTISPAM = 109451, + + // 会话 + /** 会话所属账号不唯一 / accounts for conversations not unique */ + V2NIM_ERROR_CODE_ACCOUNTS_FOR_CONVERSATIONS_NOT_UNIQUE = 110301, + /** 会话和账号不匹配 / conversation and account mismatch */ + V2NIM_ERROR_CODE_CONVERSATION_AND_ACCOUNT_MISMATCH = 110302, + /** 会话置顶数量超限 / conversation stick top limit */ + V2NIM_ERROR_CODE_CONVERSATION_STICK_TOP_LIMIT = 110303, + /** 会话所属会话分组数量超限 / conversation belonged group limit */ + V2NIM_ERROR_CODE_CONVERSATION_BELONGED_GROUP_LIMIT = 110304, + /** 会话不存在 / conversation not exist */ + V2NIM_ERROR_CODE_CONVERSATION_NOT_EXIST = 110404, + /** 会话请求需要重试 / conversation operation need retry */ + V2NIM_ERROR_CODE_CONVERSATION_OPERATION_NEED_RETRY = 110449, + + /** 广播通知 */ + /** 广播通知未开启 / broadcasting notification service disabled */ + V2NIM_ERROR_CODE_BROADCASTING_NOTIFICATION_DISABLED = 111410, + /** 广播通知不存在 / broadcasting notification not exist */ + V2NIM_ERROR_CODE_BROADCASTING_NOTIFICATION_NOT_EXIST = 111404, + + /** 自定义通知 */ + + /** 聊天室 */ + /** 获取有效的聊天室连接地址失败 / failed to get chatroom link */ + V2NIM_ERROR_CODE_GET_CHATROOM_LINK_FAILED = 113304, + /** IM 连接状态异常 / IM connection abnormal */ + V2NIM_ERROR_CODE_IM_CONNECTION_ABNORMAL = 113305, + /** 聊天室不存在 / chatroom not exist */ + V2NIM_ERROR_CODE_CHATROOM_NOT_EXIST = 113404, + /** 聊天室已关闭 / chatroom closed */ + V2NIM_ERROR_CODE_CHATROOM_CLOSED = 113406, + /** 聊天室重复操作 / operation on chatroom repeated */ + V2NIM_ERROR_CODE_CHATROOM_REPEATED_OPERATION = 113409, + /** 聊天室服务未开通 / chatroom service disabled */ + V2NIM_ERROR_CODE_CHATROOM_SERVICE_DISABLED = 113410, + /** 聊天室全体禁言 / all chatroom members chat banned */ + V2NIM_ERROR_CODE_ALL_CHATROOM_MEMBERS_CHAT_BANNED = 113423, + /** 聊天室信息命中反垃圾 / chatroom info hit antispam */ + V2NIM_ERROR_CODE_CHATROOM_INFO_HIT_ANTISPAM = 113451, + /** 非法的聊天室鉴权方式 / chatroom illegal auth type */ + V2NIM_ERROR_CODE_CHATROOM_ILLEGAL_AUTH_TYPE = 113306, + /** 参数与现有聊天室属性一致,无需更新 / identical field values */ + V2NIM_ERROR_CODE_IDENTICAL_FIELD_VALUES = 113307, + /** 仅允许聊天室管理员操作 / chatroom manager operation permission required */ + V2NIM_ERROR_CODE_CHATROOM_MANAGER_OPERATION_REQUIRED = 113428, + /** 聊天室数量超过限制 / chatroom count limit exceeded */ + V2NIM_ERROR_CODE_CHATROOM_COUNT_LIMIT = 113434, + /** 聊天室成员进出通知功能未开启 / notification for joining or leaving chatrooms disabled */ + V2NIM_ERROR_CODE_NOTIFICATION_FOR_MEMBER_IN_OUT_CHATROOM_DISALED = 113308, + /** 聊天室被临时禁言 / chatroom temporarily chat banned */ + V2NIM_ERROR_CODE_CHATROOM_TEMP_CHAT_BANNED = 113301, + /** 聊天室标签成员被禁言 / chatroom tagged members chat banned */ + V2NIM_ERROR_CODE_CHATROOM_TAGGED_MEMBERS_CHAT_BANNED = 113302, + /** 聊天室正在关闭,禁止开启 / chat room closing, reopen not allowed */ + V2NIM_ERROR_CODE_CHATROOM_CLOSING = 113303, + /** 广播通知命中反垃圾 / chatroom broadcasting notification hit antispam */ + V2NIM_ERROR_CODE_CHATROOM_BROADCASTING_NOTIFICATION_HIT_ANTISPAM = 113309, + /** 广播通知服务未开启 / broadcasting notification service disabled */ + V2NIM_ERROR_CODE_CHATROOM_BROADCASTING_NOTIFICATION_DISABLED = 113310, + + // 聊天室成员 + /** 聊天室成员不存在 / chatroom member not exist */ + V2NIM_ERROR_CODE_CHATROOM_MEMBER_NOT_EXIST = 114404, + /** 聊天室成员重复操作 / chatroom member repeated operation */ + V2NIM_ERROR_CODE_CHATROOM_MEMBER_REPEATED_OPERATION = 114405, + /** 聊天室成员禁言 / chatroom member chat banned */ + V2NIM_ERROR_CODE_CHATROOM_MEMBER_CHAT_BANNED = 114421, + /** 账号在聊天室黑名单中 / account in chatroom block list */ + V2NIM_ERROR_CODE_ACCOUNT_IN_CHATROOM_BLOCK_LIST = 114426, + /** 仅允许聊天室所有者操作 / chatroom owner operation permission required */ + V2NIM_ERROR_CODE_CHATROOM_OWNER_OPERATION_PERMISSION_REQUIRED = 114427, + /** 聊天室成员操作列表包含操作者 / operator in chatroom member operation list */ + V2NIM_ERROR_CODE_OPERATOR_IN_CHATROOM_MEMBER_OPERATION_LIST = 114429, + /** 仅允许聊天室所有者或管理员操作 / chatroom owner or manager operation permission required */ + V2NIM_ERROR_CODE_CHATROOM_OWNER_OR_MANAGER_OPERATION_PERMISSION_REQUIRED = 114432, + /** 聊天室成员数量超限 / chatroom member limit */ + V2NIM_ERROR_CODE_CHATROOM_MEMBER_LIMIT = 114437, + /** 并发操作聊天室成员失败 / chatroom member concurrent operation failed */ + V2NIM_ERROR_CODE_CHATROOM_MEMBER_CONCURRENT_OPERATION_FAILED = 114449, + /** 聊天室成员命中反垃圾 / chatroom member info hit antispam */ + V2NIM_ERROR_CODE_CHATROOM_MEMBER_INFO_HIT_ANTISPAM = 114451, + /** 聊天室成员已删除 / Member: %s was already deleted */ + V2NIM_ERROR_CODE_CHATROOM_MEMBER_ALREADY_DELETED = 114408, + /** 目标账号在禁言或黑名单列表中 / target account in blocklist or chat banned list of chatroom */ + V2NIM_ERROR_CODE_CHATROOM_MEMBER_IN_BLOCKLIST_CHAT_BANNED_LIST = 114301, + /** 匿名成员禁止操作 / anonymous member operation forbidden */ + V2NIM_ERROR_CODE_ANONYMOUS_MEMBER_OPERATION_FORBIDDEN = 114303, + /** 目标成员帐号不在线 / Target chatroom member offline */ + V2NIM_ERROR_CODE_CHATROOM_TARGET_MEMBER_OFFLINE = 114304, + + // 会话分组 + /** 会话分组不存在 / conversation group not exist */ + V2NIM_ERROR_CODE_CONVERSATION_GROUP_NOT_EXIST = 116404, + /** 会话分组数量超限 / conversation group limit */ + V2NIM_ERROR_CODE_CONVERSATION_GROUP_LIMIT = 116435, + /** 会话分组中的会话数量超限 / conversations in group limit */ + V2NIM_ERROR_CODE_CONVERSATIONS_IN_GROUP_LIMIT = 116437, + + // 聊天室队列 + + // 其他 + /** 收藏数量超限 / collection limit exceeded */ + V2NIM_ERROR_CODE_COLLECTION_LIMIT = 189301, + /** 收藏不存在 / collection not exist */ + V2NIM_ERROR_CODE_COLLECTION_NOT_EXIST = 189302, + /** 并发操作收藏失败 / collection concurrent operation failed */ + V2NIM_ERROR_CODE_COLLECTION_CONCURRENT_OPERATION_FAILED = 189449, + /** 客户端反垃圾文件没有发生变化 / client antispam file has no change */ + V2NIM_ERROR_CODE_CLIENT_ANTISPAM_FILE_NO_CHANGE = 189303, + /** 客户端反垃圾文件大小超限 / client antispam file size limit exceeded */ + V2NIM_ERROR_CODE_CLIENT_ANTISPAM_FILE_SIZE_LIMIT = 189304, + + // 通用 + /** 内部错误 / internal error */ + V2NIM_ERROR_CODE_INTERNAL = 190001, + /** 非法状态 / illegal state */ + V2NIM_ERROR_CODE_ILLEGAL_STATE = 190002, + + // 接口 + /** 使用姿势错误 / misuse */ + V2NIM_ERROR_CODE_MISUSE = 191001, + /** 操作取消 / operation cancelled */ + V2NIM_ERROR_CODE_CANCELLED = 191002, + /** 回调失败 / callback failed */ + V2NIM_ERROR_CODE_CALLBACK_FAILED = 191003, + /** 参数错误 / invalid parameter */ + V2NIM_ERROR_CODE_INVALID_PARAMETER = 191004, + /** 超时 / timeout */ + V2NIM_ERROR_CODE_TIMEOUT = 191005, + /** 资源不存在 / resource not exist */ + V2NIM_ERROR_CODE_RESOURCE_NOT_EXIST = 191006, + /** 资源已存在 / resource already exist */ + V2NIM_ERROR_CODE_RESOURCE_ALREADY_EXIST = 191007, + + // 连接 + /** 连接错误 / connect failed */ + V2NIM_ERROR_CODE_CONNECT_FAILED = 192001, + /** 连接超时 / connect timeout */ + V2NIM_ERROR_CODE_CONNECT_TIMEOUT = 192002, + /** 连接断开 / disconnected */ + V2NIM_ERROR_CODE_DISCONNECTED = 192003, + /** 协议超时 / protocol timeout */ + V2NIM_ERROR_CODE_PROTOCOL_TIMEOUT = 192004, + /** 协议发送失败 / protocol send failed */ + V2NIM_ERROR_CODE_PROTOCOL_SEND_FAILED = 192005, + /** 请求失败 / request failed */ + V2NIM_ERROR_CODE_REQUEST_FAILED = 192006, + + // 数据库 + /** 数据库打开失败 / database open failed */ + V2NIM_ERROR_CODE_DATABASE_OPEN_FAILED = 193001, + /** 数据库升级失败 / database upgrade failed */ + V2NIM_ERROR_CODE_DATABASE_UPGRADE_FAILED = 193002, + /** 数据库写入失败 / database write failed */ + V2NIM_ERROR_CODE_DATABASE_WRITE_FAILED = 193003, + /** 数据库读取失败 / database read failed */ + V2NIM_ERROR_CODE_DATABASE_READ_FAILED = 193004, + + // 文件 + /** 文件不存在 / file not found */ + V2NIM_ERROR_CODE_FILE_NOT_FOUND = 194001, + /** 文件创建失败 / file create failed */ + V2NIM_ERROR_CODE_FILE_CREATE_FAILED = 194002, + /** 文件打开失败 / file open failed */ + V2NIM_ERROR_CODE_FILE_OPEN_FAILED = 194003, + /** 文件写入失败 / file write failed */ + V2NIM_ERROR_CODE_FILE_WRITE_FAILED = 194004, + /** 文件读取失败 / file read failed */ + V2NIM_ERROR_CODE_FILE_READ_FAILED = 194005, + /** 文件上传失败 / file upload failed */ + V2NIM_ERROR_CODE_FILE_UPLOAD_FAILED = 194006, + /** 文件下载失败 / file download failed */ + V2NIM_ERROR_CODE_FILE_DOWNLOAD_FAILED = 194007, + + // 反垃圾 + /** 客户端反垃圾 / client anti-spam */ + V2NIM_ERROR_CODE_CLIENT_ANTISPAM = 195001, + /** 云端反垃圾 / server anti-spam */ + V2NIM_ERROR_CODE_SERVER_ANTISPAM = 195002, + + // 信令 + /** 信令房间已存在 */ + V2NIM_ERROR_CODE_SIGNALLING_ROOM_EXIST = 118301, + /** 邀请已经被接受 */ + V2NIM_ERROR_CODE_SIGNALLING_INVITE_ACCEPTED = 118302, + /** 信令成员不存在 */ + V2NIM_ERROR_CODE_SIGNALLING_MEMBER_NOT_EXIST = 118303, + /** 信令成员已存在 */ + V2NIM_ERROR_CODE_SIGNALLING_MEMBER_ALREADY_EXIST = 118304, + /** 信令成员已存在且设备 ID 不一致 */ + V2NIM_ERROR_CODE_SIGNALLING_MEMBER_ALREADY_EXIST_AND_DEVICE_ID_NOT_UNIQUE = 118305, + /** UID 不唯一 */ + V2NIM_ERROR_CODE_SIGNALLING_UID_NOT_UNIQUE = 118306, + /** 邀请已经被拒绝 */ + V2NIM_ERROR_CODE_SIGNALLING_INVITE_REJECTED = 118307, + /** 信令成员不在线,但推送可达 */ + V2NIM_ERROR_CODE_SIGNALLING_MEMBER_OFFLINE_BUT_PUSH_REACHABLE = 118308, + /** 信令成员不在线,且推送不可达 */ + V2NIM_ERROR_CODE_SIGNALLING_MEMBER_OFFLINE_AND_PUSH_NOT_REACHABLE = 118309, + /** 邀请不存在 */ + V2NIM_ERROR_CODE_SIGNALLING_INVITE_NOT_EXIST = 118310, + /** 房间不存在 */ + V2NIM_ERROR_CODE_SIGNALLING_ROOM_NOT_EXIST = 118404, + /** 房间成员数量超限 */ + V2NIM_ERROR_CODE_SIGNALLING_ROOM_MEMBER_LIMIT = 118437, + /** 信令服务未开通 */ + V2NIM_ERROR_CODE_SIGNALLING_SERVICE_DISABLED = 118410 } export enum V2NIMIPProtocolVersion { - /** 未指定, 自动判断 */ - V2NIM_IP_PROTOCOL_VERSION_UNSPECIFIED = 0, - /** IPv4 */ - V2NIM_IP_PROTOCOL_VERSION_IPV4 = 1, - /** IPv6 */ - V2NIM_IP_PROTOCOL_VERSION_IPV6 = 2 + /** 未指定, 自动判断 */ + V2NIM_IP_PROTOCOL_VERSION_UNSPECIFIED = 0, + /** IPv4 */ + V2NIM_IP_PROTOCOL_VERSION_IPV4 = 1, + /** IPv6 */ + V2NIM_IP_PROTOCOL_VERSION_IPV6 = 2 } export enum V2NIMAsymmetricEncryptionAlgorithm { - /** RSA */ - V2NIM_ASYMMETRIC_ENCRYPTION_ALGORITHM_RSA = 1, - /** SM2 */ - V2NIM_ASYMMETRIC_ENCRYPTION_ALGORITHM_SM2 = 2 + /** RSA */ + V2NIM_ASYMMETRIC_ENCRYPTION_ALGORITHM_RSA = 1, + /** SM2 */ + V2NIM_ASYMMETRIC_ENCRYPTION_ALGORITHM_SM2 = 2 } export enum V2NIMSymmetricEncryptionAlgorithm { - /** RC4 */ - V2NIM_SYMMETRIC_ENCRYPTION_ALGORITHM_RC4 = 1, - /** AES128 */ - V2NIM_SYMMETRIC_ENCRYPTION_ALGORITHM_AES128 = 2, - /** SM4 */ - V2NIM_SYMMETRIC_ENCRYPTION_ALGORITHM_SM4 = 4 + /** RC4 */ + V2NIM_SYMMETRIC_ENCRYPTION_ALGORITHM_RC4 = 1, + /** AES128 */ + V2NIM_SYMMETRIC_ENCRYPTION_ALGORITHM_AES128 = 2, + /** SM4 */ + V2NIM_SYMMETRIC_ENCRYPTION_ALGORITHM_SM4 = 4 } export enum V2NIMSQLCipherVersion { - /** SQLCipher 3 */ - V2NIM_SQLCIPHER_VERSION_3 = 3, - /** SQLCipher 4 */ - V2NIM_SQLCIPHER_VERSION_4 = 4 + /** SQLCipher 3 */ + V2NIM_SQLCIPHER_VERSION_3 = 3, + /** SQLCipher 4 */ + V2NIM_SQLCIPHER_VERSION_4 = 4 } export enum V2NIMSDKLogLevel { - /** 致命 */ - V2NIM_SDK_LOG_LEVEL_FATAL = 1, - /** 错误 */ - V2NIM_SDK_LOG_LEVEL_ERROR = 2, - /** 警告 */ - V2NIM_SDK_LOG_LEVEL_WARN = 3, - /** 应用 */ - V2NIM_SDK_LOG_LEVEL_APP = 5, - /** 调试 */ - V2NIM_SDK_LOG_LEVEL_PRO = 6 + /** 致命 */ + V2NIM_SDK_LOG_LEVEL_FATAL = 1, + /** 错误 */ + V2NIM_SDK_LOG_LEVEL_ERROR = 2, + /** 警告 */ + V2NIM_SDK_LOG_LEVEL_WARN = 3, + /** 应用 */ + V2NIM_SDK_LOG_LEVEL_APP = 5, + /** 调试 */ + V2NIM_SDK_LOG_LEVEL_PRO = 6 } export enum V2NIMFCSAuthType { - /** 无鉴权 */ - V2NIM_FCS_AUTH_TYPE_NONE = 0, - /** refer 鉴权 */ - V2NIM_FCS_AUTH_TYPE_REFER = 1, - /** 基于时间的 token 鉴权 */ - V2NIM_FCS_AUTH_TYPE_TIME_TOKEN = 2, - /** 基于 url 的 token 鉴权 */ - V2NIM_FCS_AUTH_TYPE_URL_TOKEN = 3, - /** custom 鉴权 */ - V2NIM_FCS_AUTH_TYPE_CUSTOM = 4 + /** 无鉴权 */ + V2NIM_FCS_AUTH_TYPE_NONE = 0, + /** refer 鉴权 */ + V2NIM_FCS_AUTH_TYPE_REFER = 1, + /** 基于时间的 token 鉴权 */ + V2NIM_FCS_AUTH_TYPE_TIME_TOKEN = 2, + /** 基于 url 的 token 鉴权 */ + V2NIM_FCS_AUTH_TYPE_URL_TOKEN = 3, + /** custom 鉴权 */ + V2NIM_FCS_AUTH_TYPE_CUSTOM = 4 } export enum V2NIMConversationType { - /** 未知 */ - V2NIM_CONVERSATION_TYPE_UNKNOWN = 0, - /** 单聊 */ - V2NIM_CONVERSATION_TYPE_P2P = 1, - /** 群聊 */ - V2NIM_CONVERSATION_TYPE_TEAM = 2, - /** 超大群 */ - V2NIM_CONVERSATION_TYPE_SUPER_TEAM = 3 + /** 未知 */ + V2NIM_CONVERSATION_TYPE_UNKNOWN = 0, + /** 单聊 */ + V2NIM_CONVERSATION_TYPE_P2P = 1, + /** 群聊 */ + V2NIM_CONVERSATION_TYPE_TEAM = 2, + /** 超大群 */ + V2NIM_CONVERSATION_TYPE_SUPER_TEAM = 3 } export enum V2NIMMessageType { - /** 文本 */ - V2NIM_MESSAGE_TYPE_TEXT = 0, - /** 图片 */ - V2NIM_MESSAGE_TYPE_IMAGE = 1, - /** 语音 */ - V2NIM_MESSAGE_TYPE_AUDIO = 2, - /** 视频 */ - V2NIM_MESSAGE_TYPE_VIDEO = 3, - /** 位置 */ - V2NIM_MESSAGE_TYPE_LOCATION = 4, - /** 通知 */ - V2NIM_MESSAGE_TYPE_NOTIFICATION = 5, - /** 文件 */ - V2NIM_MESSAGE_TYPE_FILE = 6, - /** 提醒 */ - V2NIM_MESSAGE_TYPE_TIP = 10, - /** 机器人 */ - V2NIM_MESSAGE_TYPE_ROBOT = 11, - /** 话单 */ - V2NIM_MESSAGE_TYPE_CALL = 12, - /** 自定义 */ - V2NIM_MESSAGE_TYPE_CUSTOM = 100 + /** 文本 */ + V2NIM_MESSAGE_TYPE_TEXT = 0, + /** 图片 */ + V2NIM_MESSAGE_TYPE_IMAGE = 1, + /** 语音 */ + V2NIM_MESSAGE_TYPE_AUDIO = 2, + /** 视频 */ + V2NIM_MESSAGE_TYPE_VIDEO = 3, + /** 位置 */ + V2NIM_MESSAGE_TYPE_LOCATION = 4, + /** 通知 */ + V2NIM_MESSAGE_TYPE_NOTIFICATION = 5, + /** 文件 */ + V2NIM_MESSAGE_TYPE_FILE = 6, + /** 提醒 */ + V2NIM_MESSAGE_TYPE_TIP = 10, + /** 机器人 */ + V2NIM_MESSAGE_TYPE_ROBOT = 11, + /** 话单 */ + V2NIM_MESSAGE_TYPE_CALL = 12, + /** 自定义 */ + V2NIM_MESSAGE_TYPE_CUSTOM = 100 } export enum V2NIMMessageSendingState { - /** 未知, 如果消息不是从这个端发送的 */ - V2NIM_MESSAGE_SENDING_STATE_UNKNOWN = 0, - /** 已发送 */ - V2NIM_MESSAGE_SENDING_STATE_SUCCEEDED = 1, - /** 发送失败 */ - V2NIM_MESSAGE_SENDING_STATE_FAILED = 2, - /** 发送中 */ - V2NIM_MESSAGE_SENDING_STATE_SENDING = 3 + /** 未知, 如果消息不是从这个端发送的 */ + V2NIM_MESSAGE_SENDING_STATE_UNKNOWN = 0, + /** 已发送 */ + V2NIM_MESSAGE_SENDING_STATE_SUCCEEDED = 1, + /** 发送失败 */ + V2NIM_MESSAGE_SENDING_STATE_FAILED = 2, + /** 发送中 */ + V2NIM_MESSAGE_SENDING_STATE_SENDING = 3 } export enum V2NIMLastMessageState { - /** 默认 */ - V2NIM_MESSAGE_STATE_DEFAULT = 0, - /** 已撤回 */ - V2NIM_MESSAGE_STATE_REVOKED = 1, - /** 客户端回填 */ - V2NIM_MESSAGE_STATE_CLIENTFILL = 2 + /** 默认 */ + V2NIM_MESSAGE_STATE_DEFAULT = 0, + /** 已撤回 */ + V2NIM_MESSAGE_STATE_REVOKED = 1, + /** 客户端回填 */ + V2NIM_MESSAGE_STATE_CLIENTFILL = 2 } export enum V2NIMMessageAttachmentUploadState { - /** 未知, 不存在附件或不需要上传的附件 */ - V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UNKNOWN = 0, - /** 上传成功, 存在存储地址 */ - V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_SUCCEEDED = 1, - /** 上传失败 */ - V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_FAILED = 2, - /** 上传中 */ - V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UPLOADING = 3 + /** 未知, 不存在附件或不需要上传的附件 */ + V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UNKNOWN = 0, + /** 上传成功, 存在存储地址 */ + V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_SUCCEEDED = 1, + /** 上传失败 */ + V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_FAILED = 2, + /** 上传中 */ + V2NIM_MESSAGE_ATTACHMENT_UPLOAD_STATE_UPLOADING = 3 } export enum V2NIMMessageNotificationType { - /** 群拉人 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE = 0, - /** 群踢人 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_KICK = 1, - /** 退出群 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_LEAVE = 2, - /** 更新群信息 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_UPDATE_TINFO = 3, - /** 群解散 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_DISMISS = 4, - /** 群申请加入通过 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_APPLY_PASS = 5, - /** 移交群主 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_OWNER_TRANSFER = 6, - /** 添加管理员 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_ADD_MANAGER = 7, - /** 移除管理员 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_REMOVE_MANAGER = 8, - /** 接受邀请进群 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE_ACCEPT = 9, - /** 禁言群成员 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_BANNED_TEAM_MEMBER = 10, - /** 超大群群拉人 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_INVITE = 401, - /** 超大群 V2NIM_M 群踢人 */ - SSAGE_NOTIFICATION_TYPE_SUPER_TEAM_KICK = 402, - /** 超大群退出群 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_LAVE = 403, - /** 超大群更新群信息 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_UPDATE_TINFO = 404, - /** 超大群群解散 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_DISMISS = 405, - /** 超大群移交群主 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_OWNER_TRANSFER = 406, - /** 超大群添加管理员 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_ADD_MANAGER = 407, - /** 超大群移除管理员 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_REMOVE_MANAGER = 408, - /** 超大群禁言群成员 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_BANNED_TEAM_MEMBER = 409, - /** 超大群群申请加入通过 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_APPLY_PASS = 410, - /** 超大群接受邀请进群 */ - V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_INVITE_ACCEPT = 411 + /** 群拉人 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE = 0, + /** 群踢人 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_KICK = 1, + /** 退出群 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_LEAVE = 2, + /** 更新群信息 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_UPDATE_TINFO = 3, + /** 群解散 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_DISMISS = 4, + /** 群申请加入通过 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_APPLY_PASS = 5, + /** 移交群主 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_OWNER_TRANSFER = 6, + /** 添加管理员 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_ADD_MANAGER = 7, + /** 移除管理员 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_REMOVE_MANAGER = 8, + /** 接受邀请进群 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_INVITE_ACCEPT = 9, + /** 禁言群成员 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_TEAM_BANNED_TEAM_MEMBER = 10, + /** 超大群群拉人 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_INVITE = 401, + /** 超大群 V2NIM_M 群踢人 */ + SSAGE_NOTIFICATION_TYPE_SUPER_TEAM_KICK = 402, + /** 超大群退出群 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_LAVE = 403, + /** 超大群更新群信息 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_UPDATE_TINFO = 404, + /** 超大群群解散 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_DISMISS = 405, + /** 超大群移交群主 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_OWNER_TRANSFER = 406, + /** 超大群添加管理员 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_ADD_MANAGER = 407, + /** 超大群移除管理员 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_REMOVE_MANAGER = 408, + /** 超大群禁言群成员 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_BANNED_TEAM_MEMBER = 409, + /** 超大群群申请加入通过 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_APPLY_PASS = 410, + /** 超大群接受邀请进群 */ + V2NIM_MESSAGE_NOTIFICATION_TYPE_SUPER_TEAM_INVITE_ACCEPT = 411 } export enum V2NIMChatroomMessageNotificationType { - /** 成员进入聊天室 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_ENTER = 0, - /** 成员退出聊天室 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_EXIT = 1, - /** 成员被加入黑名单 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_BLOCK_ADDED = 2, - /** 成员被移除黑名单 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_BLOCK_REMOVED = 3, - /** 成员被禁言 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_CHAT_BANNED_ADDED = 4, - /** 成员取消禁言 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_CHAT_BANNED_REMOVED = 5, - /** 聊天室信息更新 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_ROOM_INFO_UPDATED = 6, - /** 成员被踢 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_KICKED = 7, - /** 成员临时禁言 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_TEMP_CHAT_BANNED_ADDED = 8, - /** 成员解除临时禁言 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_TEMP_CHAT_BANNED_REMOVED = 9, - /** 成员信息更新 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_INFO_UPDATED = 10, - /** 队列有变更 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_QUEUE_CHANGE = 11, - /** 聊天室被禁言 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_CHAT_BANNED = 12, - /** 聊天室解除禁言 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_CHAT_BANNED_REMOVED = 13, - /** 聊天室新增标签禁言 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_TAG_TEMP_CHAT_BANNED_ADDED = 14, - /** 聊天室移除标签禁言 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_TAG_TEMP_CHAT_BANNED_REMOVED = 15, - /** 聊天室消息撤回 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MESSAGE_REVOKE = 16, - /** 聊天室标签更新 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_TAGS_UPDATE = 17, - /** 聊天室成员角色更新 */ - V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_ROLE_UPDATE = 18 + /** 成员进入聊天室 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_ENTER = 0, + /** 成员退出聊天室 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_EXIT = 1, + /** 成员被加入黑名单 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_BLOCK_ADDED = 2, + /** 成员被移除黑名单 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_BLOCK_REMOVED = 3, + /** 成员被禁言 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_CHAT_BANNED_ADDED = 4, + /** 成员取消禁言 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_CHAT_BANNED_REMOVED = 5, + /** 聊天室信息更新 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_ROOM_INFO_UPDATED = 6, + /** 成员被踢 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_KICKED = 7, + /** 成员临时禁言 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_TEMP_CHAT_BANNED_ADDED = 8, + /** 成员解除临时禁言 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_TEMP_CHAT_BANNED_REMOVED = 9, + /** 成员信息更新 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_INFO_UPDATED = 10, + /** 队列有变更 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_QUEUE_CHANGE = 11, + /** 聊天室被禁言 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_CHAT_BANNED = 12, + /** 聊天室解除禁言 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_CHAT_BANNED_REMOVED = 13, + /** 聊天室新增标签禁言 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_TAG_TEMP_CHAT_BANNED_ADDED = 14, + /** 聊天室移除标签禁言 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_TAG_TEMP_CHAT_BANNED_REMOVED = 15, + /** 聊天室消息撤回 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MESSAGE_REVOKE = 16, + /** 聊天室标签更新 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_TAGS_UPDATE = 17, + /** 聊天室成员角色更新 */ + V2NIM_CHATROOM_MESSAGE_NOTIFICATION_TYPE_MEMBER_ROLE_UPDATE = 18 } export enum V2NIMChatroomQueueChangeType { - /** 未知 */ - V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_UNKNOWN = 0, - /** 新增队列元素 */ - V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_OFFER = 1, - /** 移除队列元素 */ - V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_POLL = 2, - /** 清空所有元素 */ - V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_DROP = 3, - /** 部分清理 */ - V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_PARTCLEAR = 4, - /** 批量更新 */ - V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_BATCH_UPDATE = 5, - /** 批量添加 */ - V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_BATCH_OFFER = 6 + /** 未知 */ + V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_UNKNOWN = 0, + /** 新增队列元素 */ + V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_OFFER = 1, + /** 移除队列元素 */ + V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_POLL = 2, + /** 清空所有元素 */ + V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_DROP = 3, + /** 部分清理 */ + V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_PARTCLEAR = 4, + /** 批量更新 */ + V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_BATCH_UPDATE = 5, + /** 批量添加 */ + V2NIM_CHATROOM_QUEUE_CHANGE_TYPE_BATCH_OFFER = 6 } export enum V2NIMMessagePinState { - /** 未 pin */ - V2NIM_MESSAGE_PIN_STEATE_NOT_PINNED = 0, - /** 已 PIN */ - V2NIM_MESSAGE_PIN_STEATE_PINNED = 1, - /** 已 PIN 状态更新 */ - V2NIM_MESSAGE_PIN_STEATE_UPDATED = 2 + /** 未 pin */ + V2NIM_MESSAGE_PIN_STEATE_NOT_PINNED = 0, + /** 已 PIN */ + V2NIM_MESSAGE_PIN_STEATE_PINNED = 1, + /** 已 PIN 状态更新 */ + V2NIM_MESSAGE_PIN_STEATE_UPDATED = 2 } export enum V2NIMQueryDirection { - /** 按时间降序查询 */ - V2NIM_QUERY_DIRECTION_DESC = 0, - /** 按时间升序查询 */ - V2NIM_QUERY_DIRECTION_ASC = 1 + /** 按时间降序查询 */ + V2NIM_QUERY_DIRECTION_DESC = 0, + /** 按时间升序查询 */ + V2NIM_QUERY_DIRECTION_ASC = 1 } export enum V2NIMMessageQuickCommentType { - /** 添加快捷评论 */ - V2NIM_MESSAGE_QUICK_COMMENT_TYPE_ADD = 1, - /** 删除快捷评论 */ - V2NIM_MESSAGE_QUICK_COMMENT_TYPE_REMOVE = 2 + /** 添加快捷评论 */ + V2NIM_MESSAGE_QUICK_COMMENT_TYPE_ADD = 1, + /** 删除快捷评论 */ + V2NIM_MESSAGE_QUICK_COMMENT_TYPE_REMOVE = 2 } export enum V2NIMSortOrder { - /** 按时间降序排序 */ - V2NIM_SORT_ORDER_DESC = 0, - /** 按时间升序排序 */ - V2NIM_SORT_ORDER_ASC = 1 + /** 按时间降序排序 */ + V2NIM_SORT_ORDER_DESC = 0, + /** 按时间升序排序 */ + V2NIM_SORT_ORDER_ASC = 1 } export enum V2NIMMessageRevokeType { - /** 未定义 */ - V2NIM_MESSAGE_REVOKE_TYPE_UNDEFINED = 0, - /** 点对点双向撤回 */ - V2NIM_MESSAGE_REVOKE_TYPE_P2P_BOTHWAY = 1, - /** 群双向撤回 */ - V2NIM_MESSAGE_REVOKE_TYPE_TEAM_BOTHWAY = 2, - /** 超大群双向撤回 */ - V2NIM_MESSAGE_REVOKE_TYPE_SUPER_TEAM_BOTHWAY = 3, - /** 点对点单向撤回 */ - V2NIM_MESSAGE_REVOKE_TYPE_P2P_ONEWAY = 4, - /** 群单向撤回 */ - V2NIM_MESSAGE_REVOKE_TYPE_TEAM_ONEWAY = 5 + /** 未定义 */ + V2NIM_MESSAGE_REVOKE_TYPE_UNDEFINED = 0, + /** 点对点双向撤回 */ + V2NIM_MESSAGE_REVOKE_TYPE_P2P_BOTHWAY = 1, + /** 群双向撤回 */ + V2NIM_MESSAGE_REVOKE_TYPE_TEAM_BOTHWAY = 2, + /** 超大群双向撤回 */ + V2NIM_MESSAGE_REVOKE_TYPE_SUPER_TEAM_BOTHWAY = 3, + /** 点对点单向撤回 */ + V2NIM_MESSAGE_REVOKE_TYPE_P2P_ONEWAY = 4, + /** 群单向撤回 */ + V2NIM_MESSAGE_REVOKE_TYPE_TEAM_ONEWAY = 5 } export enum V2NIMMessageClientAntispamOperatorType { - /** 无操作 */ - V2NIM_MESSAGE_CLIENT_ANTISPAM_OPERATOR_NONE = 0, - /** 命中后, 本地替换 */ - V2NIM_MESSAGE_CLIENT_ANTISPAM_OPERATOR_REPLACE, - /** 命中后, 本地屏蔽, 该消息拒绝发送 */ - V2NIM_MESSAGE_CLIENT_ANTISPAM_OPERATOR_CLIENT_SHIELD, - /** 命中后, 消息可以发送, 由服务器屏蔽 */ - V2NIM_MESSAGE_CLIENT_ANTISPAM_OPERATOR_SERVER_SHIELD + /** 无操作 */ + V2NIM_MESSAGE_CLIENT_ANTISPAM_OPERATOR_NONE = 0, + /** 命中后, 本地替换 */ + V2NIM_MESSAGE_CLIENT_ANTISPAM_OPERATOR_REPLACE, + /** 命中后, 本地屏蔽, 该消息拒绝发送 */ + V2NIM_MESSAGE_CLIENT_ANTISPAM_OPERATOR_CLIENT_SHIELD, + /** 命中后, 消息可以发送, 由服务器屏蔽 */ + V2NIM_MESSAGE_CLIENT_ANTISPAM_OPERATOR_SERVER_SHIELD } export enum V2NIMLoginAuthType { - /** 默认 */ - V2NIM_LOGIN_AUTH_TYPE_DEFAULT = 0, - /** 动态token */ - V2NIM_LOGIN_AUTH_TYPE_DYNAMIC_TOKEN = 1, - /** 第三方 */ - V2NIM_LOGIN_AUTH_TYPE_THIRD_PARTY = 2 + /** 默认 */ + V2NIM_LOGIN_AUTH_TYPE_DEFAULT = 0, + /** 动态token */ + V2NIM_LOGIN_AUTH_TYPE_DYNAMIC_TOKEN = 1, + /** 第三方 */ + V2NIM_LOGIN_AUTH_TYPE_THIRD_PARTY = 2 } export enum V2NIMLoginClientType { - /** 未知类型 */ - V2NIM_LOGIN_CLIENT_TYPE_UNKNOWN = 0, - /** Android */ - V2NIM_LOGIN_CLIENT_TYPE_ANDROID = 1, - /** iOS */ - V2NIM_LOGIN_CLIENT_TYPE_IOS = 2, - /** PC */ - V2NIM_LOGIN_CLIENT_TYPE_PC = 4, - /** Windows Phone */ - V2NIM_LOGIN_CLIENT_TYPE_WINPHONE = 8, - /** WEB */ - V2NIM_LOGIN_CLIENT_TYPE_WEB = 16, - /** REST API */ - V2NIM_LOGIN_CLIENT_TYPE_RESTFUL = 32, - /** macOS */ - V2NIM_LOGIN_CLIENT_TYPE_MAC_OS = 64, - /** HarmonyOS */ - V2NIM_LOGIN_CLIENT_TYPE_HARMONY_OS = 65 + /** 未知类型 */ + V2NIM_LOGIN_CLIENT_TYPE_UNKNOWN = 0, + /** Android */ + V2NIM_LOGIN_CLIENT_TYPE_ANDROID = 1, + /** iOS */ + V2NIM_LOGIN_CLIENT_TYPE_IOS = 2, + /** PC */ + V2NIM_LOGIN_CLIENT_TYPE_PC = 4, + /** Windows Phone */ + V2NIM_LOGIN_CLIENT_TYPE_WINPHONE = 8, + /** WEB */ + V2NIM_LOGIN_CLIENT_TYPE_WEB = 16, + /** REST API */ + V2NIM_LOGIN_CLIENT_TYPE_RESTFUL = 32, + /** macOS */ + V2NIM_LOGIN_CLIENT_TYPE_MAC_OS = 64, + /** HarmonyOS */ + V2NIM_LOGIN_CLIENT_TYPE_HARMONY_OS = 65 } export enum V2NIMLoginStatus { - /** 未登录 */ - V2NIM_LOGIN_STATUS_LOGOUT = 0, - /** 已登录 */ - V2NIM_LOGIN_STATUS_LOGINED = 1, - /** 登录中 */ - V2NIM_LOGIN_STATUS_LOGINING = 2 + /** 未登录 */ + V2NIM_LOGIN_STATUS_LOGOUT = 0, + /** 已登录 */ + V2NIM_LOGIN_STATUS_LOGINED = 1, + /** 登录中 */ + V2NIM_LOGIN_STATUS_LOGINING = 2 } export enum V2NIMKickedOfflineReason { - /** 多端登录互踢 */ - V2NIM_KICKED_OFFLINE_REASON_CLIENT_EXCLUSIVE = 1, - /** 被服务器踢下线 */ - V2NIM_KICKED_OFFLINE_REASON_SERVER = 2, - /** 被客户端踢下线 */ - V2NIM_KICKED_OFFLINE_REASON_CLIENT = 3 + /** 多端登录互踢 */ + V2NIM_KICKED_OFFLINE_REASON_CLIENT_EXCLUSIVE = 1, + /** 被服务器踢下线 */ + V2NIM_KICKED_OFFLINE_REASON_SERVER = 2, + /** 被客户端踢下线 */ + V2NIM_KICKED_OFFLINE_REASON_CLIENT = 3 } export enum V2NIMLoginClientChange { - /** 端列表刷新 */ - V2NIM_LOGIN_CLIENT_CHANGE_LIST = 1, - /** 端登录 */ - V2NIM_LOGIN_CLIENT_CHANGE_LOGIN = 2, - /** 端登出 */ - V2NIM_LOGIN_CLIENT_CHANGE_LOGOUT = 3 + /** 端列表刷新 */ + V2NIM_LOGIN_CLIENT_CHANGE_LIST = 1, + /** 端登录 */ + V2NIM_LOGIN_CLIENT_CHANGE_LOGIN = 2, + /** 端登出 */ + V2NIM_LOGIN_CLIENT_CHANGE_LOGOUT = 3 } export enum V2NIMConnectStatus { - /** 未连接 */ - V2NIM_CONNECT_STATUS_DISCONNECTED = 0, - /** 已连接 */ - V2NIM_CONNECT_STATUS_CONNECTED = 1, - /** 连接中 */ - V2NIM_CONNECT_STATUS_CONNECTING = 2, - /** 等待重连 */ - V2NIM_CONNECT_STATUS_WAITING = 3 + /** 未连接 */ + V2NIM_CONNECT_STATUS_DISCONNECTED = 0, + /** 已连接 */ + V2NIM_CONNECT_STATUS_CONNECTED = 1, + /** 连接中 */ + V2NIM_CONNECT_STATUS_CONNECTING = 2, + /** 等待重连 */ + V2NIM_CONNECT_STATUS_WAITING = 3 } export enum V2NIMDataSyncLevel { - /** 完全同步 */ - V2NIM_DATA_SYNC_LEVEL_FULL = 0, - /** 只同步基础数据 */ - V2NIM_DATA_SYNC_LEVEL_BASIC = 1 + /** 完全同步 */ + V2NIM_DATA_SYNC_LEVEL_FULL = 0, + /** 只同步基础数据 */ + V2NIM_DATA_SYNC_LEVEL_BASIC = 1 } export enum V2NIMDataSyncType { - /** 同步主数据 */ - V2NIM_DATA_SYNC_MAIN = 1, - /** 同步群组成员 */ - V2NIM_DATA_SYNC_TEAM_MEMBER = 2, - /** 同步超大群组成员 */ - V2NIM_DATA_SYNC_SUPER_TEAM_MEMBER = 3 + /** 同步主数据 */ + V2NIM_DATA_SYNC_MAIN = 1, + /** 同步群组成员 */ + V2NIM_DATA_SYNC_TEAM_MEMBER = 2, + /** 同步超大群组成员 */ + V2NIM_DATA_SYNC_SUPER_TEAM_MEMBER = 3 } export enum V2NIMDataSyncState { - /** 等待同步 */ - V2NIM_DATA_SYNC_STATE_WAITING = 1, - /** 开始同步 */ - V2NIM_DATA_SYNC_STATE_SYNCING = 2, - /** 同步完成 */ - V2NIM_DATA_SYNC_STATE_COMPLETED = 3 + /** 等待同步 */ + V2NIM_DATA_SYNC_STATE_WAITING = 1, + /** 开始同步 */ + V2NIM_DATA_SYNC_STATE_SYNCING = 2, + /** 同步完成 */ + V2NIM_DATA_SYNC_STATE_COMPLETED = 3 } export enum V2NIMLoginType { - /** IM 业务登录 */ - V2NIM_LOGIN_TYPE_IM = 1, - /** QChat 业务登录 */ - V2NIM_LOGIN_TYPE_QCHAT = 2, - /** IM 和 QChat 业务融合登录 */ - V2NIM_LOGIN_TYPE_IM_AND_QCHAT = 3 + /** IM 业务登录 */ + V2NIM_LOGIN_TYPE_IM = 1, + /** QChat 业务登录 */ + V2NIM_LOGIN_TYPE_QCHAT = 2, + /** IM 和 QChat 业务融合登录 */ + V2NIM_LOGIN_TYPE_IM_AND_QCHAT = 3 } export enum V2NIMClientAntispamOperateType { - /** 无操作 */ - V2NIM_CLIENT_ANTISPAM_OPERATE_NONE = 0, - /** 本地替换 */ - V2NIM_CLIENT_ANTISPAM_OPERATE_REPLACE = 1, - /** 本地屏蔽 */ - V2NIM_CLIENT_ANTISPAM_OPERATE_CLIENT_SHIELD = 2, - /** 服务器屏蔽 */ - V2NIM_CLIENT_ANTISPAM_OPERATE_SERVER_SHIELD = 3 + /** 无操作 */ + V2NIM_CLIENT_ANTISPAM_OPERATE_NONE = 0, + /** 本地替换 */ + V2NIM_CLIENT_ANTISPAM_OPERATE_REPLACE = 1, + /** 本地屏蔽 */ + V2NIM_CLIENT_ANTISPAM_OPERATE_CLIENT_SHIELD = 2, + /** 服务器屏蔽 */ + V2NIM_CLIENT_ANTISPAM_OPERATE_SERVER_SHIELD = 3 } export enum V2NIMClientAntispamThesaurusMatchType { - V2NIM_CLIENT_ANTISPAM_THESAURUS_MATCH_TYPE_WORD = 1, - V2NIM_CLIENT_ANTISPAM_THESAURUS_MATCH_TYPE_REGEX = 2 + V2NIM_CLIENT_ANTISPAM_THESAURUS_MATCH_TYPE_WORD = 1, + V2NIM_CLIENT_ANTISPAM_THESAURUS_MATCH_TYPE_REGEX = 2 } export enum V2NIMTeamType { - /** 无效 */ - V2NIM_TEAM_TYPE_INVALID = 0, - /** 高级群 */ - V2NIM_TEAM_TYPE_NORMAL = 1, - /** 超大群 */ - V2NIM_TEAM_TYPE_SUPER = 2 + /** 无效 */ + V2NIM_TEAM_TYPE_INVALID = 0, + /** 高级群 */ + V2NIM_TEAM_TYPE_NORMAL = 1, + /** 超大群 */ + V2NIM_TEAM_TYPE_SUPER = 2 } export enum V2NIMTeamJoinMode { - /** 自由加入, 无须验证 */ - V2NIM_TEAM_JOIN_MODE_FREE = 0, - /** 需申请, 群主或管理同意后加入 */ - V2NIM_TEAM_JOIN_MODE_APPLY = 1, - /** 私有群, 不接受申请, 仅能通过邀请方式入群 */ - V2NIM_TEAM_JOIN_MODE_PRIVATE = 2 + /** 自由加入, 无须验证 */ + V2NIM_TEAM_JOIN_MODE_FREE = 0, + /** 需申请, 群主或管理同意后加入 */ + V2NIM_TEAM_JOIN_MODE_APPLY = 1, + /** 私有群, 不接受申请, 仅能通过邀请方式入群 */ + V2NIM_TEAM_JOIN_MODE_PRIVATE = 2 } export enum V2NIMTeamAgreeMode { - /** 需要被邀请人同意 */ - V2NIM_TEAM_AGREE_MODE_AUTH = 0, - /** 不需要被邀请人同意 */ - V2NIM_TEAM_AGREE_MODE_NO_AUTH = 1 + /** 需要被邀请人同意 */ + V2NIM_TEAM_AGREE_MODE_AUTH = 0, + /** 不需要被邀请人同意 */ + V2NIM_TEAM_AGREE_MODE_NO_AUTH = 1 } export enum V2NIMTeamInviteMode { - /** 群主, 管理员可以邀请其他人入群 */ - V2NIM_TEAM_INVITE_MODE_MANAGER = 0, - /** 所有人都可以邀请其他人入群 */ - V2NIM_TEAM_INVITE_MODE_ALL = 1 + /** 群主, 管理员可以邀请其他人入群 */ + V2NIM_TEAM_INVITE_MODE_MANAGER = 0, + /** 所有人都可以邀请其他人入群 */ + V2NIM_TEAM_INVITE_MODE_ALL = 1 } export enum V2NIMTeamUpdateInfoMode { - /** 群主/管理员可以修改群组资料 */ - V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER = 0, - /** 所有人都可以修改群组资料 */ - V2NIM_TEAM_UPDATE_INFO_MODE_ALL = 1 + /** 群主/管理员可以修改群组资料 */ + V2NIM_TEAM_UPDATE_INFO_MODE_MANAGER = 0, + /** 所有人都可以修改群组资料 */ + V2NIM_TEAM_UPDATE_INFO_MODE_ALL = 1 } export enum V2NIMTeamChatBannedMode { - /** 不禁言, 群组成员可以自由发言 */ - V2NIM_TEAM_CHAT_BANNED_MODE_NONE = 0, - /** 普通成员禁言, 不包括管理员,群主 */ - V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_NORMAL = 1, - /** 全员禁言, 群组所有成员都被禁言,该状态只能 OpenApi 发起 */ - V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_ALL = 2 + /** 不禁言, 群组成员可以自由发言 */ + V2NIM_TEAM_CHAT_BANNED_MODE_NONE = 0, + /** 普通成员禁言, 不包括管理员,群主 */ + V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_NORMAL = 1, + /** 全员禁言, 群组所有成员都被禁言,该状态只能 OpenApi 发起 */ + V2NIM_TEAM_CHAT_BANNED_MODE_BANNED_ALL = 2 } export enum V2NIMTeamUpdateExtensionMode { - /** 群主/管理员可以修改群组扩展字段 */ - V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER = 0, - /** 所有人均可以修改群组扩展字段 */ - V2NIM_TEAM_UPDATE_EXTENSION_MODE_ALL = 1 + /** 群主/管理员可以修改群组扩展字段 */ + V2NIM_TEAM_UPDATE_EXTENSION_MODE_MANAGER = 0, + /** 所有人均可以修改群组扩展字段 */ + V2NIM_TEAM_UPDATE_EXTENSION_MODE_ALL = 1 } export enum V2NIMTeamMemberRole { - /** 普通成员 */ - V2NIM_TEAM_MEMBER_ROLE_NORMAL = 0, - /** 群组拥有者 */ - V2NIM_TEAM_MEMBER_ROLE_OWNER = 1, - /** 群组管理员 */ - V2NIM_TEAM_MEMBER_ROLE_MANAGER = 2 + /** 普通成员 */ + V2NIM_TEAM_MEMBER_ROLE_NORMAL = 0, + /** 群组拥有者 */ + V2NIM_TEAM_MEMBER_ROLE_OWNER = 1, + /** 群组管理员 */ + V2NIM_TEAM_MEMBER_ROLE_MANAGER = 2 } export enum V2NIMTeamMemberRoleQueryType { - /** 所有成员 */ - V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_ALL = 0, - /** 群组管理员(包括群主) */ - V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_MANAGER = 1, - /** 普通成员 */ - V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_NORMAL = 2 + /** 所有成员 */ + V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_ALL = 0, + /** 群组管理员(包括群主) */ + V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_MANAGER = 1, + /** 普通成员 */ + V2NIM_TEAM_MEMBER_ROLE_QUERY_TYPE_NORMAL = 2 } export enum V2NIMTeamJoinActionType { - /** 申请入群 */ - V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION = 0, - /** 管理拒绝申请入群 */ - V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_APPLICATION = 1, - /** 邀请入群 */ - V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION = 2, - /** 成员拒绝邀请入群 */ - V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_INVITATION = 3 + /** 申请入群 */ + V2NIM_TEAM_JOIN_ACTION_TYPE_APPLICATION = 0, + /** 管理拒绝申请入群 */ + V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_APPLICATION = 1, + /** 邀请入群 */ + V2NIM_TEAM_JOIN_ACTION_TYPE_INVITATION = 2, + /** 成员拒绝邀请入群 */ + V2NIM_TEAM_JOIN_ACTION_TYPE_REJECT_INVITATION = 3 } export enum V2NIMTeamMessageMuteMode { - /** 群消息免打扰关闭 */ - V2NIM_TEAM_MESSAGE_MUTE_MODE_OFF = 0, - /** 群消息免打扰开启 */ - V2NIM_TEAM_MESSAGE_MUTE_MODE_ON = 1, - /** 群主/管理员消息免打扰关闭 */ - V2NIM_TEAM_MESSAGE_MUTE_MODE_NORMAL_ON = 2 + /** 群消息免打扰关闭 */ + V2NIM_TEAM_MESSAGE_MUTE_MODE_OFF = 0, + /** 群消息免打扰开启 */ + V2NIM_TEAM_MESSAGE_MUTE_MODE_ON = 1, + /** 群主/管理员消息免打扰关闭 */ + V2NIM_TEAM_MESSAGE_MUTE_MODE_NORMAL_ON = 2 } export enum V2NIMP2PMessageMuteMode { - /** 点对点消息免打扰关闭 */ - V2NIM_P2P_MESSAGE_MUTE_MODE_OFF = 0, - /** 点对点消息免打扰开启 */ - V2NIM_P2P_MESSAGE_MUTE_MODE_ON = 1 + /** 点对点消息免打扰关闭 */ + V2NIM_P2P_MESSAGE_MUTE_MODE_OFF = 0, + /** 点对点消息免打扰开启 */ + V2NIM_P2P_MESSAGE_MUTE_MODE_ON = 1 } export enum V2NIMFriendAddMode { - /** 直接添加对方为好友 */ - V2NIM_FRIEND_MODE_TYPE_ADD = 1, - /** 请求添加对方为好友, 对方需要验证 */ - V2NIM_FRIEND_MODE_TYPE_APPLY = 2 + /** 直接添加对方为好友 */ + V2NIM_FRIEND_MODE_TYPE_ADD = 1, + /** 请求添加对方为好友, 对方需要验证 */ + V2NIM_FRIEND_MODE_TYPE_APPLY = 2 } export enum V2NIMTeamJoinActionStatus { - /** 未处理 */ - V2NIM_TEAM_JOIN_ACTION_STATUS_INIT = 0, - /** 已同意 */ - V2NIM_TEAM_JOIN_ACTION_STATUS_AGREED = 1, - /** 已拒绝 */ - V2NIM_TEAM_JOIN_ACTION_STATUS_REJECTED = 2, - /** 已过期 */ - V2NIM_TEAM_JOIN_ACTION_STATUS_EXPIRED = 3 + /** 未处理 */ + V2NIM_TEAM_JOIN_ACTION_STATUS_INIT = 0, + /** 已同意 */ + V2NIM_TEAM_JOIN_ACTION_STATUS_AGREED = 1, + /** 已拒绝 */ + V2NIM_TEAM_JOIN_ACTION_STATUS_REJECTED = 2, + /** 已过期 */ + V2NIM_TEAM_JOIN_ACTION_STATUS_EXPIRED = 3 } export enum V2NIMFriendAddApplicationStatus { - /** 未处理 */ - V2NIM_FRIEND_ADD_APPLICATION_STATUS_INIT = 0, - /** 已同意 */ - V2NIM_FRIEND_ADD_APPLICATION_STATUS_AGREED = 1, - /** 已拒绝 */ - V2NIM_FRIEND_ADD_APPLICATION_STATUS_REJECTED = 2, - /** 已过期 */ - V2NIM_FRIEND_ADD_APPLICATION_STATUS_EXPIRED = 3, - /** 直接加为好友 @since v10.3.0 */ - V2NIM_FRIEND_ADD_APPLICATION_STATUS_DIRECT_ADD = 4 + /** 未处理 */ + V2NIM_FRIEND_ADD_APPLICATION_STATUS_INIT = 0, + /** 已同意 */ + V2NIM_FRIEND_ADD_APPLICATION_STATUS_AGREED = 1, + /** 已拒绝 */ + V2NIM_FRIEND_ADD_APPLICATION_STATUS_REJECTED = 2, + /** 已过期 */ + V2NIM_FRIEND_ADD_APPLICATION_STATUS_EXPIRED = 3, + /** 直接加为好友 @since v10.3.0 */ + V2NIM_FRIEND_ADD_APPLICATION_STATUS_DIRECT_ADD = 4 } export enum V2NIMFriendDeletionType { - /** 自己删除好友 */ - V2NIM_FRIEND_DELETION_TYPE_BY_SELF = 1, - /** 对方删除好友 */ - V2NIM_FRIEND_DELETION_TYPE_BY_PEER = 2 + /** 自己删除好友 */ + V2NIM_FRIEND_DELETION_TYPE_BY_SELF = 1, + /** 对方删除好友 */ + V2NIM_FRIEND_DELETION_TYPE_BY_PEER = 2 } export enum V2NIMChatroomQueueLevelMode { - /** 所有人都有权限操作 */ - V2NIM_CHATROOM_QUEUE_LEVEL_MODE_ANY = 0, - /** 只有创建者/管理员才能操作 */ - V2NIM_CHATROOM_QUEUE_LEVEL_MODE_MANAGER = 1 + /** 所有人都有权限操作 */ + V2NIM_CHATROOM_QUEUE_LEVEL_MODE_ANY = 0, + /** 只有创建者/管理员才能操作 */ + V2NIM_CHATROOM_QUEUE_LEVEL_MODE_MANAGER = 1 } export enum V2NIMChatroomMemberRole { - /** 普通成员 */ - V2NIM_CHATROOM_MEMBER_ROLE_NORMAL = 0, - /** 创建者 */ - V2NIM_CHATROOM_MEMBER_ROLE_CREATOR = 1, - /** 管理员 */ - V2NIM_CHATROOM_MEMBER_ROLE_MANAGER = 2, - /** 普通游客 */ - V2NIM_CHATROOM_MEMBER_ROLE_NORMAL_GUEST = 3, - /** 匿名游客 */ - V2NIM_CHATROOM_MEMBER_ROLE_ANONYMOUS_GUEST = 4, - /** 虚构用户 */ - V2NIM_CHATROOM_MEMBER_ROLE_VIRTUAL = 5 + /** 普通成员 */ + V2NIM_CHATROOM_MEMBER_ROLE_NORMAL = 0, + /** 创建者 */ + V2NIM_CHATROOM_MEMBER_ROLE_CREATOR = 1, + /** 管理员 */ + V2NIM_CHATROOM_MEMBER_ROLE_MANAGER = 2, + /** 普通游客 */ + V2NIM_CHATROOM_MEMBER_ROLE_NORMAL_GUEST = 3, + /** 匿名游客 */ + V2NIM_CHATROOM_MEMBER_ROLE_ANONYMOUS_GUEST = 4, + /** 虚构用户 */ + V2NIM_CHATROOM_MEMBER_ROLE_VIRTUAL = 5 } export enum V2NIMChatroomKickedReason { - /** 未知 */ - V2NIM_CHATROOM_KICKED_REASON_UNKNOWN = -1, - /** 聊天室解散 */ - V2NIM_CHATROOM_KICKED_REASON_CHATROOM_INVALID = 1, - /** 被管理员踢出 */ - V2NIM_CHATROOM_KICKED_REASON_BY_MANAGER = 2, - /** 多端被踢 */ - V2NIM_CHATROOM_KICKED_REASON_BY_CONFLICT_LOGIN = 3, - /** 静默被踢 */ - V2NIM_CHATROOM_KICKED_REASON_SILENTLY = 4, - /** 加黑被踢 */ - V2NIM_CHATROOM_KICKED_REASON_BE_BLOCKED = 5 + /** 未知 */ + V2NIM_CHATROOM_KICKED_REASON_UNKNOWN = -1, + /** 聊天室解散 */ + V2NIM_CHATROOM_KICKED_REASON_CHATROOM_INVALID = 1, + /** 被管理员踢出 */ + V2NIM_CHATROOM_KICKED_REASON_BY_MANAGER = 2, + /** 多端被踢 */ + V2NIM_CHATROOM_KICKED_REASON_BY_CONFLICT_LOGIN = 3, + /** 静默被踢 */ + V2NIM_CHATROOM_KICKED_REASON_SILENTLY = 4, + /** 加黑被踢 */ + V2NIM_CHATROOM_KICKED_REASON_BE_BLOCKED = 5 } export enum V2NIMChatroomAsymmetricType { - /** RSA */ - V2NIM_CHATROOM_ASYMMETRIC_TYPE_RSA = 1, - /** SM2 */ - V2NIM_CHATROOM_ASYMMETRIC_TYPE_SM2 = 2, - /** RSA_OAEP_1 */ - V2NIM_CHATROOM_ASYMMETRIC_TYPE_RSA_OAEP_1 = 4, - /** RSA_OAEP_256 */ - V2NIM_CHATROOM_ASYMMETRIC_TYPE_RSA_OAEP_256 = 8 + /** RSA */ + V2NIM_CHATROOM_ASYMMETRIC_TYPE_RSA = 1, + /** SM2 */ + V2NIM_CHATROOM_ASYMMETRIC_TYPE_SM2 = 2, + /** RSA_OAEP_1 */ + V2NIM_CHATROOM_ASYMMETRIC_TYPE_RSA_OAEP_1 = 4, + /** RSA_OAEP_256 */ + V2NIM_CHATROOM_ASYMMETRIC_TYPE_RSA_OAEP_256 = 8 } export enum V2NIMChatroomSymmetricType { - /** RC4 */ - V2NIM_CHATROOM_SYMMETRIC_TYPE_RC4 = 1, - /** AES */ - V2NIM_CHATROOM_SYMMETRIC_TYPE_AES = 2, - /** SM4 */ - V2NIM_CHATROOM_SYMMETRIC_TYPE_SM4 = 4 + /** RC4 */ + V2NIM_CHATROOM_SYMMETRIC_TYPE_RC4 = 1, + /** AES */ + V2NIM_CHATROOM_SYMMETRIC_TYPE_AES = 2, + /** SM4 */ + V2NIM_CHATROOM_SYMMETRIC_TYPE_SM4 = 4 } export enum V2NIMChatroomStatus { - /** 聊天室断开连接 */ - V2NIM_CHATROOM_STATUS_DISCONNECTED = 0, - /** 聊天室等待重连 */ - V2NIM_CHATROOM_STATUS_WAITING = 1, - /** 聊天室连接过程中 */ - V2NIM_CHATROOM_STATUS_CONNECTING = 2, - /** 聊天室已连接 */ - V2NIM_CHATROOM_STATUS_CONNECTED = 3, - /** 聊天室进入中 */ - V2NIM_CHATROOM_STATUS_ENTERING = 4, - /** 聊天室已进入 */ - V2NIM_CHATROOM_STATUS_ENTERED = 5, - /** 聊天室已退出 */ - V2NIM_CHATROOM_STATUS_EXITED = 6 + /** 聊天室断开连接 */ + V2NIM_CHATROOM_STATUS_DISCONNECTED = 0, + /** 聊天室等待重连 */ + V2NIM_CHATROOM_STATUS_WAITING = 1, + /** 聊天室连接过程中 */ + V2NIM_CHATROOM_STATUS_CONNECTING = 2, + /** 聊天室已连接 */ + V2NIM_CHATROOM_STATUS_CONNECTED = 3, + /** 聊天室进入中 */ + V2NIM_CHATROOM_STATUS_ENTERING = 4, + /** 聊天室已进入 */ + V2NIM_CHATROOM_STATUS_ENTERED = 5, + /** 聊天室已退出 */ + V2NIM_CHATROOM_STATUS_EXITED = 6 } export enum V2NIMMessageAttachmentType { - /** 通用 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_UNIVERSAL = 0, - /** 图片 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_IMAGE = 1, - /** 语音 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_AUDIO = 2, - /** 视频 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_VIDEO = 3, - /** 位置 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_LOCATION = 4, - /** 群通知 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_TEAM_NOTIFICATION = 5, - /** 文件 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_FILE = 6, - /** 聊天室通知 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_NOTIFICATION = 7, - /** 聊天室消息撤回 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_MESSAGE_REVOKE_NOTIFICATION = 8, - /** 聊天室队列变更 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_QUEUE_NOTIFICATION = 9, - /** 聊天室禁言 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_CHAT_BANNED_NOTIFICATION = 10, - /** 聊天室成员进入 */ - V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_MEMBER_ENTER_NOTIFICATION = 11 + /** 通用 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_UNIVERSAL = 0, + /** 图片 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_IMAGE = 1, + /** 语音 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_AUDIO = 2, + /** 视频 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_VIDEO = 3, + /** 位置 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_LOCATION = 4, + /** 群通知 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_TEAM_NOTIFICATION = 5, + /** 文件 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_FILE = 6, + /** 聊天室通知 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_NOTIFICATION = 7, + /** 聊天室消息撤回 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_MESSAGE_REVOKE_NOTIFICATION = 8, + /** 聊天室队列变更 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_QUEUE_NOTIFICATION = 9, + /** 聊天室禁言 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_CHAT_BANNED_NOTIFICATION = 10, + /** 聊天室成员进入 */ + V2NIM_MESSAGE_ATTACHMENT_TYPE_CHATROOM_MEMBER_ENTER_NOTIFICATION = 11 } export enum V2NIMAIModelRoleType { - /** 系统 */ - V2NIM_AI_MODEL_ROLE_TYPE_SYSTEM, - /** 用户 */ - V2NIM_AI_MODEL_ROLE_TYPE_USER, - /** 助手 */ - V2NIM_AI_MODEL_ROLE_TYPE_ASSISTANT, + /** 系统 */ + V2NIM_AI_MODEL_ROLE_TYPE_SYSTEM, + /** 用户 */ + V2NIM_AI_MODEL_ROLE_TYPE_USER, + /** 助手 */ + V2NIM_AI_MODEL_ROLE_TYPE_ASSISTANT, } export enum V2NIMAIModelType { - /** 未知 */ - V2NIM_AI_MODEL_TYPE_UNKNOW = 0, - /** 通义千问大模型 */ - V2NIM_AI_MODEL_TYPE_QWEN = 1, - /** 微软Azure */ - V2NIM_AI_MODEL_TYPE_AZURE = 2, - /** 私有本地大模型 */ - V2NIM_AI_MODEL_TYPE_PRIVATE = 3, + /** 未知 */ + V2NIM_AI_MODEL_TYPE_UNKNOW = 0, + /** 通义千问大模型 */ + V2NIM_AI_MODEL_TYPE_QWEN = 1, + /** 微软Azure */ + V2NIM_AI_MODEL_TYPE_AZURE = 2, + /** 私有本地大模型 */ + V2NIM_AI_MODEL_TYPE_PRIVATE = 3, } export enum V2NIMDownloadAttachmentType { - /** 原始资源,支持全部有附件的类型 */ - V2NIM_DOWNLOAD_ATTACHMENT_TYPE_SOURCE, - /** 图片缩略图,仅支持图片类附件 */ - V2NIM_DOWNLOAD_ATTACHMENT_TYPE_THUMBNAIL, - /** 视频封面,仅支持视频类附件 */ - V2NIM_DOWNLOAD_ATTACHMENT_TYPE_VIDEO_COVER, + /** 原始资源,支持全部有附件的类型 */ + V2NIM_DOWNLOAD_ATTACHMENT_TYPE_SOURCE, + /** 图片缩略图,仅支持图片类附件 */ + V2NIM_DOWNLOAD_ATTACHMENT_TYPE_THUMBNAIL, + /** 视频封面,仅支持视频类附件 */ + V2NIM_DOWNLOAD_ATTACHMENT_TYPE_VIDEO_COVER, } export enum V2NIMSignallingChannelType { - /** 未知频道类型 */ - V2NIM_SIGNALLING_CHANNEL_TYPE_UNKNOWN = 0, - /** 音频频道 */ - V2NIM_SIGNALLING_CHANNEL_TYPE_AUDIO = 1, - /** 视频频道 */ - V2NIM_SIGNALLING_CHANNEL_TYPE_VIDEO, - /** 自定义频道 */ - V2NIM_SIGNALLING_CHANNEL_TYPE_CUSTOM + /** 未知频道类型 */ + V2NIM_SIGNALLING_CHANNEL_TYPE_UNKNOWN = 0, + /** 音频频道 */ + V2NIM_SIGNALLING_CHANNEL_TYPE_AUDIO = 1, + /** 视频频道 */ + V2NIM_SIGNALLING_CHANNEL_TYPE_VIDEO, + /** 自定义频道 */ + V2NIM_SIGNALLING_CHANNEL_TYPE_CUSTOM } /** @brief 信令频道事件类型 */ export enum V2NIMSignallingEventType { - /** 未知 */ - V2NIM_SIGNALLING_EVENT_TYPE_UNKNOWN, - /** 关闭信令频道房间 */ - V2NIM_SIGNALLING_EVENT_TYPE_CLOSE, - /** 加入信令频道房间 */ - V2NIM_SIGNALLING_EVENT_TYPE_JOIN, - /** 邀请加入信令频道房间 */ - V2NIM_SIGNALLING_EVENT_TYPE_INVITE, - /** 取消邀请加入信令频道房间 */ - V2NIM_SIGNALLING_EVENT_TYPE_CANCEL_INVITE, - /** 拒绝邀请 */ - V2NIM_SIGNALLING_EVENT_TYPE_REJECT, - /** 接受邀请 */ - V2NIM_SIGNALLING_EVENT_TYPE_ACCEPT, - /** 离开信令频道房间 */ - V2NIM_SIGNALLING_EVENT_TYPE_LEAVE, - /** 自定义控制命令 */ - V2NIM_SIGNALLING_EVENT_TYPE_CONTROL + /** 未知 */ + V2NIM_SIGNALLING_EVENT_TYPE_UNKNOWN, + /** 关闭信令频道房间 */ + V2NIM_SIGNALLING_EVENT_TYPE_CLOSE, + /** 加入信令频道房间 */ + V2NIM_SIGNALLING_EVENT_TYPE_JOIN, + /** 邀请加入信令频道房间 */ + V2NIM_SIGNALLING_EVENT_TYPE_INVITE, + /** 取消邀请加入信令频道房间 */ + V2NIM_SIGNALLING_EVENT_TYPE_CANCEL_INVITE, + /** 拒绝邀请 */ + V2NIM_SIGNALLING_EVENT_TYPE_REJECT, + /** 接受邀请 */ + V2NIM_SIGNALLING_EVENT_TYPE_ACCEPT, + /** 离开信令频道房间 */ + V2NIM_SIGNALLING_EVENT_TYPE_LEAVE, + /** 自定义控制命令 */ + V2NIM_SIGNALLING_EVENT_TYPE_CONTROL } export enum V2NIMUserStatusType { - /** 未知 */ - V2NIM_USER_STATUS_TYPE_UNKNOWN, - /** 登录 */ - V2NIM_USER_STATUS_TYPE_LOGIN, - /** 登出 */ - V2NIM_USER_STATUS_TYPE_LOGOUT, - /** 断开连接 */ - V2NIM_USER_STATUS_TYPE_DISCONNECT + /** 未知 */ + V2NIM_USER_STATUS_TYPE_UNKNOWN, + /** 登录 */ + V2NIM_USER_STATUS_TYPE_LOGIN, + /** 登出 */ + V2NIM_USER_STATUS_TYPE_LOGOUT, + /** 断开连接 */ + V2NIM_USER_STATUS_TYPE_DISCONNECT +} + +export enum V2NIMProxyRequestMethod { + /** GET 请求 */ + V2NIM_PROXY_REQUEST_METHOD_GET = 1, + /** POST 请求 */ + V2NIM_PROXY_REQUEST_METHOD_POST, + /** PUT 请求 */ + V2NIM_PROXY_REQUEST_METHOD_PUT, + /** DELETE 请求 */ + V2NIM_PROXY_REQUEST_METHOD_DELETE } diff --git a/ts/v2_def/v2_nim_struct_def.ts b/ts/v2_def/v2_nim_struct_def.ts index 6a86589..5b481e4 100644 --- a/ts/v2_def/v2_nim_struct_def.ts +++ b/ts/v2_def/v2_nim_struct_def.ts @@ -1,909 +1,954 @@ -import { V2NIMAIModelType, V2NIMAsymmetricEncryptionAlgorithm, V2NIMChatroomKickedReason, V2NIMChatroomMemberRole, V2NIMChatroomMessageNotificationType, V2NIMChatroomQueueChangeType, V2NIMChatroomQueueLevelMode, V2NIMClientAntispamOperateType, V2NIMClientAntispamThesaurusMatchType, V2NIMConversationType, V2NIMDataSyncLevel, V2NIMDataSyncState, V2NIMDataSyncType, V2NIMDownloadAttachmentType, V2NIMFCSAuthType, V2NIMFriendAddApplicationStatus, V2NIMFriendAddMode, V2NIMIPProtocolVersion, V2NIMKickedOfflineReason, V2NIMLastMessageState, V2NIMLoginAuthType, V2NIMLoginClientType, V2NIMMessageAttachmentUploadState, V2NIMMessageClientAntispamOperatorType, V2NIMMessageNotificationType, V2NIMMessagePinState, V2NIMMessageQuickCommentType, V2NIMMessageRevokeType, V2NIMMessageSendingState, V2NIMMessageType, V2NIMQueryDirection, V2NIMSDKLogLevel, V2NIMSignallingChannelType, V2NIMSignallingEventType, V2NIMSortOrder, V2NIMSQLCipherVersion, V2NIMSymmetricEncryptionAlgorithm, V2NIMTeamAgreeMode, V2NIMTeamChatBannedMode, V2NIMTeamInviteMode, V2NIMTeamJoinActionStatus, V2NIMTeamJoinActionType, V2NIMTeamJoinMode, V2NIMTeamMemberRole, V2NIMTeamMemberRoleQueryType, V2NIMTeamType, V2NIMTeamUpdateExtensionMode, V2NIMTeamUpdateInfoMode } from "./v2_nim_enum_def" +import { + V2NIMAIModelType, + V2NIMAsymmetricEncryptionAlgorithm, + V2NIMChatroomKickedReason, + V2NIMChatroomMemberRole, + V2NIMChatroomMessageNotificationType, + V2NIMChatroomQueueChangeType, + V2NIMChatroomQueueLevelMode, + V2NIMClientAntispamOperateType, + V2NIMClientAntispamThesaurusMatchType, + V2NIMConversationType, + V2NIMDataSyncType, + V2NIMDownloadAttachmentType, + V2NIMFCSAuthType, + V2NIMFriendAddApplicationStatus, + V2NIMFriendAddMode, + V2NIMIPProtocolVersion, + V2NIMLoginAuthType, + V2NIMLoginClientType, + V2NIMMessageAttachmentUploadState, + V2NIMMessageClientAntispamOperatorType, + V2NIMMessageNotificationType, + V2NIMMessagePinState, + V2NIMMessageRevokeType, + V2NIMMessageSendingState, + V2NIMMessageType, + V2NIMProxyRequestMethod, + V2NIMQueryDirection, + V2NIMSDKLogLevel, + V2NIMSignallingChannelType, + V2NIMSignallingEventType, + V2NIMSortOrder, + V2NIMSQLCipherVersion, + V2NIMSymmetricEncryptionAlgorithm, + V2NIMTeamAgreeMode, + V2NIMTeamChatBannedMode, + V2NIMTeamInviteMode, + V2NIMTeamJoinActionStatus, + V2NIMTeamJoinActionType, + V2NIMTeamJoinMode, + V2NIMTeamMemberRole, + V2NIMTeamMemberRoleQueryType, + V2NIMTeamType, + V2NIMTeamUpdateExtensionMode, + V2NIMTeamUpdateInfoMode +} from './v2_nim_enum_def' export interface V2NIMError { - /** 错误码, 详见 V2NIMErrorCode */ - code?: number - /** 错误描述 */ - desc?: string - /** 错误详情 */ - detail?: Map + /** 错误码, 详见 V2NIMErrorCode */ + code?: number + /** 错误描述 */ + desc?: string + /** 错误详情 */ + detail?: Map } export interface V2NIMSize { - /** 宽度 */ - width: number - /** 高度 */ - height: number + /** 宽度 */ + width: number + /** 高度 */ + height: number } export interface V2NIMLinkOption { - /** 连接超时, 单位毫秒 */ - linkTimeout?: number - /** 协议超时, 单位毫秒 */ - protocolTimeout?: number - /** 非对称加密"交换密钥"协议加密算法 */ - asymmetricEncryptionAlgorithm?: V2NIMAsymmetricEncryptionAlgorithm - /** 对称加密通信加密算法 */ - symmetricEncryptionAlgorithm?: V2NIMSymmetricEncryptionAlgorithm + /** 连接超时, 单位毫秒 */ + linkTimeout?: number + /** 协议超时, 单位毫秒 */ + protocolTimeout?: number + /** 非对称加密"交换密钥"协议加密算法 */ + asymmetricEncryptionAlgorithm?: V2NIMAsymmetricEncryptionAlgorithm + /** 对称加密通信加密算法 */ + symmetricEncryptionAlgorithm?: V2NIMSymmetricEncryptionAlgorithm } export interface V2NIMFCSOption { - /** 融合存储认证类型 */ - fcsAuthType?: V2NIMFCSAuthType - /** mock refer */ - mockRefer?: string - /** mock ua */ - mockUa?: string + /** 融合存储认证类型 */ + fcsAuthType?: V2NIMFCSAuthType + /** mock refer */ + mockRefer?: string + /** mock ua */ + mockUa?: string } export interface V2NIMPrivateServerOption { - /** IP 协议版本 */ - ipProtocolVersion?: V2NIMIPProtocolVersion - /** lbs 地址 */ - lbsAddresses?: Array - /** nos lbs 地址 */ - nosLbsAddress?: string - /** 默认 link 地址 */ - defaultLinkAddress?: string - /** 默认 ipv6 link 地址 */ - defaultLinkAddressIpv6?: string - /** 默认 nos 上传地址 */ - defaultNosUploadAddress?: string - /** 默认 nos 上传主机地址 */ - defaultNosUploadHost?: string - /** nos 下载地址拼接模板, 用于拼接最终得到的下载地址 */ - nosDownloadAddress?: string - /** nos 加速域名列表 */ - nosAccelerateHosts?: Array - /** nos 加速地址拼接模板, 用于获得加速后的下载地址 */ - nosAccelerateAddress?: string - /** 探测 ipv4 地址类型使用的 url */ - probeIpv4Url?: string - /** 探测 ipv6 地址类型使用的 url */ - probeIpv6Url?: string - /** 非对称加密密钥 A, RSA: module, SM2: X */ - asymmetricEncryptionKeyA?: string - /** 非对称加密密钥 B, RSA: EXP, SM2: SM2Y */ - asymmetricEncryptionKeyB?: string - /** 非对称加密算法 key 版本号 */ - asymmetricEncryptionKeyVersion?: number + /** IP 协议版本 */ + ipProtocolVersion?: V2NIMIPProtocolVersion + /** lbs 地址 */ + lbsAddresses?: Array + /** nos lbs 地址 */ + nosLbsAddress?: string + /** 默认 link 地址 */ + defaultLinkAddress?: string + /** 默认 ipv6 link 地址 */ + defaultLinkAddressIpv6?: string + /** 默认 nos 上传地址 */ + defaultNosUploadAddress?: string + /** 默认 nos 上传主机地址 */ + defaultNosUploadHost?: string + /** nos 下载地址拼接模板, 用于拼接最终得到的下载地址 */ + nosDownloadAddress?: string + /** nos 加速域名列表 */ + nosAccelerateHosts?: Array + /** nos 加速地址拼接模板, 用于获得加速后的下载地址 */ + nosAccelerateAddress?: string + /** 探测 ipv4 地址类型使用的 url */ + probeIpv4Url?: string + /** 探测 ipv6 地址类型使用的 url */ + probeIpv6Url?: string + /** 非对称加密密钥 A, RSA: module, SM2: X */ + asymmetricEncryptionKeyA?: string + /** 非对称加密密钥 B, RSA: EXP, SM2: SM2Y */ + asymmetricEncryptionKeyB?: string + /** 非对称加密算法 key 版本号 */ + asymmetricEncryptionKeyVersion?: number } export interface V2NIMDatabaseOption { - /** 数据库加密密钥 */ - encryptionKey?: string - /** 是否开启用户数据备份(本地)功能 */ - enableBackup?: boolean - /** 是否开启用户数据恢复(本地)功能 */ - enableRestore?: boolean - /** 用户数据备份(本地)目录, 缺省在数据文件所在目录创建一个dbFile.back目录 */ - backupFolder?: string - /** SQLCipher 版本, 仅 macOS / Linux 平台有效 */ - sqlcipherVersion?: V2NIMSQLCipherVersion + /** 数据库加密密钥 */ + encryptionKey?: string + /** 是否开启用户数据备份(本地)功能 */ + enableBackup?: boolean + /** 是否开启用户数据恢复(本地)功能 */ + enableRestore?: boolean + /** 用户数据备份(本地)目录, 缺省在数据文件所在目录创建一个dbFile.back目录 */ + backupFolder?: string + /** SQLCipher 版本, 仅 macOS / Linux 平台有效 */ + sqlcipherVersion?: V2NIMSQLCipherVersion } export interface V2NIMBasicOption { - /** 是否使用 https */ - useHttps?: boolean - /** 是否使用 httpdns */ - useHttpdns?: boolean - /** 自定义客户端类型 */ - customClientType?: number - /** 登录自定义信息, 最大 32 个字符 */ - customTag?: string - /** 日志保留天数 */ - logReserveDays?: number - /** SDK日志级别 */ - sdkLogLevel?: V2NIMSDKLogLevel - /** 是否禁用 macOS 下的 App Nap 功能 */ - disableAppNap?: boolean - /** 云信指南针数据上报开关 */ - enableCompass?: boolean - /** 云信指南针数据上报地址,为空则使用默认地址 */ - compassDataEndpoint?: string + /** 是否使用 https */ + useHttps?: boolean + /** 是否使用 httpdns */ + useHttpdns?: boolean + /** 自定义客户端类型 */ + customClientType?: number + /** 登录自定义信息, 最大 32 个字符 */ + customTag?: string + /** 日志保留天数 */ + logReserveDays?: number + /** SDK日志级别 */ + sdkLogLevel?: V2NIMSDKLogLevel + /** 是否禁用 macOS 下的 App Nap 功能 */ + disableAppNap?: boolean + /** 云信指南针数据上报开关 */ + enableCompass?: boolean + /** 云信指南针数据上报地址,为空则使用默认地址 */ + compassDataEndpoint?: string } export interface V2NIMInitOption { - /** app key */ - appkey?: string - /** app 数据目录, 为空则使用默认目录 */ - appDataPath?: string - /** 基础配置 */ - basicOption?: V2NIMBasicOption - /** 连接相关配置 */ - linkOption?: V2NIMLinkOption - /** 数据库配置 */ - databaseOption?: V2NIMDatabaseOption - /** 融合存储配置 */ - fcsOption?: V2NIMFCSOption - /** 私有化配置 */ - privateServerOption?: V2NIMPrivateServerOption + /** app key */ + appkey?: string + /** app 数据目录, 为空则使用默认目录 */ + appDataPath?: string + /** 基础配置 */ + basicOption?: V2NIMBasicOption + /** 连接相关配置 */ + linkOption?: V2NIMLinkOption + /** 数据库配置 */ + databaseOption?: V2NIMDatabaseOption + /** 融合存储配置 */ + fcsOption?: V2NIMFCSOption + /** 私有化配置 */ + privateServerOption?: V2NIMPrivateServerOption } export interface V2NIMStorageScene { - /** 场景名 */ - sceneName?: string - /** 过期时间, 单位秒, 0 表示不过期 */ - expireTime?: number + /** 场景名 */ + sceneName?: string + /** 过期时间, 单位秒, 0 表示不过期 */ + expireTime?: number } /** @brief 话单消息通话时长描述信息 */ export interface V2NIMMessageCallDuration { - /** 话单对应成员的账号 ID */ - accountId: string - /** 通话时长, 单位秒 */ - duration: number + /** 话单对应成员的账号 ID */ + accountId: string + /** 通话时长, 单位秒 */ + duration: number } // noreflection export interface V2NIMMessageAttachment { - /** 附件内容 */ - raw?: string + /** 附件内容 */ + raw?: string } // noreflection export interface V2NIMMessageFileAttachment extends V2NIMMessageAttachment { - /** 文件大小 */ - size?: number - /** 文件 md5 */ - md5?: string - /** 文件 url */ - url?: string - /** 文件显示名称 */ - name?: string - /** 文件本地路径 */ - path?: string - /** 文件扩展名 */ - ext?: string - /** 文件存储场景 */ - sceneName?: string - /** 附件上传状态 */ - uploadState?: V2NIMMessageAttachmentUploadState + /** 文件大小 */ + size?: number + /** 文件 md5 */ + md5?: string + /** 文件 url */ + url?: string + /** 文件显示名称 */ + name?: string + /** 文件本地路径 */ + path?: string + /** 文件扩展名 */ + ext?: string + /** 文件存储场景 */ + sceneName?: string + /** 附件上传状态 */ + uploadState?: V2NIMMessageAttachmentUploadState } // noreflection export interface V2NIMMessageImageAttachment extends V2NIMMessageFileAttachment { - /** 图片宽度 */ - width?: number - /** 图片高度 */ - height?: number + /** 图片宽度 */ + width?: number + /** 图片高度 */ + height?: number } // noreflection export interface V2NIMMessageAudioAttachment extends V2NIMMessageFileAttachment { - /** 语音文件播放时长 */ - duration?: number + /** 语音文件播放时长 */ + duration?: number } // noreflection export interface V2NIMMessageVideoAttachment extends V2NIMMessageFileAttachment { - /** 视频文件播放时长 */ - duration?: number - /** 图片宽度 */ - width?: number - /** 图片高度 */ - height?: number + /** 视频文件播放时长 */ + duration?: number + /** 图片宽度 */ + width?: number + /** 图片高度 */ + height?: number } // noreflection export interface V2NIMMessageLocationAttachment extends V2NIMMessageAttachment { - /** 纬度 */ - latitude?: number - /** 经度 */ - longitude?: number - /** 详细位置信息 */ - address?: string + /** 纬度 */ + latitude?: number + /** 经度 */ + longitude?: number + /** 详细位置信息 */ + address?: string } export interface V2NIMMessageCallAttachment extends V2NIMMessageAttachment { - /** 话单类型, 业务自定义 */ - type: number - /** 话单频道 ID */ - channelId: string - /** 通话状态,业务自定义状态 */ - status: number - /** 通话成员时长列表 */ - durations: Array - /** 话单描述 */ - text: string + /** 话单类型, 业务自定义 */ + type: number + /** 话单频道 ID */ + channelId: string + /** 通话状态,业务自定义状态 */ + status: number + /** 通话成员时长列表 */ + durations: Array + /** 话单描述 */ + text: string } // noreflection export interface V2NIMMessageTeamNotificationAttachment extends V2NIMMessageAttachment { - /** 通知类型 */ - type?: V2NIMMessageNotificationType - /** 扩展字段 */ - serverExtension?: string - /** 被操作者 ID 列表 */ - targetIds?: Array - /** 群成员是否被禁言 */ - chatBanned?: boolean - /** 群信息更新字段,有相应字段信息,则表示对应字段被修改 */ - updatedTeamInfo?: V2NIMUpdatedTeamInfo + /** 通知类型 */ + type?: V2NIMMessageNotificationType + /** 扩展字段 */ + serverExtension?: string + /** 被操作者 ID 列表 */ + targetIds?: Array + /** 群成员是否被禁言 */ + chatBanned?: boolean + /** 群信息更新字段,有相应字段信息,则表示对应字段被修改 */ + updatedTeamInfo?: V2NIMUpdatedTeamInfo } // noreflection export interface V2NIMChatroomNotificationAttachment extends V2NIMMessageAttachment { - /** 通知类型 */ - type?: V2NIMChatroomMessageNotificationType - /** 被操作的成员账号列表 */ - targetIds?: Array - /** 被操作成员的昵称列表 */ - targetNicks?: Array - /** 被操作的标签 */ - targetTag?: string - /** 操作者 */ - operatorId?: string - /** 操作者昵称 */ - operatorNick?: string - /** 扩展字段 */ - notificationExtension?: string - /** 更新后的标签 */ - tags?: Array + /** 通知类型 */ + type?: V2NIMChatroomMessageNotificationType + /** 被操作的成员账号列表 */ + targetIds?: Array + /** 被操作成员的昵称列表 */ + targetNicks?: Array + /** 被操作的标签 */ + targetTag?: string + /** 操作者 */ + operatorId?: string + /** 操作者昵称 */ + operatorNick?: string + /** 扩展字段 */ + notificationExtension?: string + /** 更新后的标签 */ + tags?: Array } // noreflection export interface V2NIMChatroomMessageRevokeNotificationAttachment extends V2NIMChatroomNotificationAttachment { - /** 消息撤回 ID */ - messageClientId?: string - /** 消息撤回时间 */ - messageTime?: number + /** 消息撤回 ID */ + messageClientId?: string + /** 消息撤回时间 */ + messageTime?: number } // noreflection export interface V2NIMChatroomQueueNotificationAttachment extends V2NIMChatroomNotificationAttachment { - /** 队列变更的内容 */ - keyValues?: Array> - /** 队列更新类型 */ - queueChangeType?: V2NIMChatroomQueueChangeType + /** 队列变更的内容 */ + keyValues?: Array> + /** 队列更新类型 */ + queueChangeType?: V2NIMChatroomQueueChangeType } // noreflection export interface V2NIMChatroomChatBannedNotificationAttachment extends V2NIMChatroomNotificationAttachment { - /** 成员是否被禁言 */ - chatBanned?: boolean - /** 成员是否被临时禁言 */ - tempChatBanned?: boolean - /** 成员临时禁言时长 */ - tempChatBannedDuration?: number + /** 成员是否被禁言 */ + chatBanned?: boolean + /** 成员是否被临时禁言 */ + tempChatBanned?: boolean + /** 成员临时禁言时长 */ + tempChatBannedDuration?: number } // noreflection export interface V2NIMChatroomMemberEnterNotificationAttachment extends V2NIMChatroomNotificationAttachment { - /** 成员是否被禁言 */ - chatBanned?: boolean - /** 成员是否被临时禁言 */ - tempChatBanned?: boolean - /** 成员临时禁言时长 */ - tempChatBannedDuration?: number + /** 成员是否被禁言 */ + chatBanned?: boolean + /** 成员是否被临时禁言 */ + tempChatBanned?: boolean + /** 成员临时禁言时长 */ + tempChatBannedDuration?: number } // noreflection export interface V2NIMChatroomMemberRoleUpdateAttachment extends V2NIMChatroomNotificationAttachment { - /** 之前的角色类型 */ - previousRole?: V2NIMChatroomMemberRole - /** 当前的成员信息 */ - currentMember?: V2NIMChatroomMember + /** 之前的角色类型 */ + previousRole?: V2NIMChatroomMemberRole + /** 当前的成员信息 */ + currentMember?: V2NIMChatroomMember } export interface V2NIMMessagePushConfig { - /** 是否需要推送消息 */ - pushEnabled?: boolean - /** 是否需要推送消息发送者昵称 */ - pushNickEnabled?: boolean - /** 推送文本 */ - pushContent?: string - /** 推送数据 */ - pushPayload?: string - /** 是否强制推送, 忽略用户提醒相关设置 */ - forcePush?: boolean - /** 强制推送文案 */ - forcePushContent?: string - /** 强制推送目标账号列表 */ - forcePushAccountIds?: Array + /** 是否需要推送消息 */ + pushEnabled?: boolean + /** 是否需要推送消息发送者昵称 */ + pushNickEnabled?: boolean + /** 推送文本 */ + pushContent?: string + /** 推送数据 */ + pushPayload?: string + /** 是否强制推送, 忽略用户提醒相关设置 */ + forcePush?: boolean + /** 强制推送文案 */ + forcePushContent?: string + /** 强制推送目标账号列表 */ + forcePushAccountIds?: Array } export interface V2NIMNotificationPushConfig { - /** 是否需要推送通知 */ - pushEnabled?: boolean - /** 是否需要推送消息发送者昵称 */ - pushNickEnabled?: boolean - /** 推送文本 */ - pushContent?: string - /** 推送数据 */ - pushPayload?: string - /** 是否强制推送, 忽略用户提醒相关设置 */ - forcePush?: boolean - /** 强制推送文案 */ - forcePushContent?: string - /** 强制推送目标账号列表 */ - forcePushAccountIds?: Array + /** 是否需要推送通知 */ + pushEnabled?: boolean + /** 是否需要推送消息发送者昵称 */ + pushNickEnabled?: boolean + /** 推送文本 */ + pushContent?: string + /** 推送数据 */ + pushPayload?: string + /** 是否强制推送, 忽略用户提醒相关设置 */ + forcePush?: boolean + /** 强制推送文案 */ + forcePushContent?: string + /** 强制推送目标账号列表 */ + forcePushAccountIds?: Array } export interface V2NIMMessageAntispamConfig { - /** 指定是否需要过安全通 */ - antispamEnabled?: boolean - /** 指定易盾业务id, 而不使用云信后台配置的 */ - antispamBusinessId?: string - /** 自定义消息中需要反垃圾的内容(仅当消息类型为自定义消息时有效), json 格式, 长度不超过 5000 字节, 字段如下 */ - /** type: int, 1: 文本, 2: 图片, 3: 视频 */ - /** data: string, 文本内容/图片地址/视频地址 */ - antispamCustomMessage?: string - /** 易盾反作弊(辅助检测数据), json格式, 限制长度 1024 字节 */ - antispamCheating?: string - /** 易盾反垃圾(增强检测数据), json格式, 限制长度 1024 字节 */ - antispamExtension?: string + /** 指定是否需要过安全通 */ + antispamEnabled?: boolean + /** 指定易盾业务id, 而不使用云信后台配置的 */ + antispamBusinessId?: string + /** 自定义消息中需要反垃圾的内容(仅当消息类型为自定义消息时有效), json 格式, 长度不超过 5000 字节, 字段如下 */ + /** type: int, 1: 文本, 2: 图片, 3: 视频 */ + /** data: string, 文本内容/图片地址/视频地址 */ + antispamCustomMessage?: string + /** 易盾反作弊(辅助检测数据), json格式, 限制长度 1024 字节 */ + antispamCheating?: string + /** 易盾反垃圾(增强检测数据), json格式, 限制长度 1024 字节 */ + antispamExtension?: string } export interface V2NIMNotificationAntispamConfig { - /** 指定是否需要过安全通 */ - antispamEnabled?: boolean - /** 自定义消息中需要反垃圾的内容(仅当消息类型为自定义消息时有效), json 格式, 长度不超过 5000 字节, 字段如下 */ - /** type: int, 1: 文本, 2: 图片, 3: 视频 */ - /** data: string, 文本内容/图片地址/视频地址 */ - antispamCustomMessage?: string + /** 指定是否需要过安全通 */ + antispamEnabled?: boolean + /** 自定义消息中需要反垃圾的内容(仅当消息类型为自定义消息时有效), json 格式, 长度不超过 5000 字节, 字段如下 */ + /** type: int, 1: 文本, 2: 图片, 3: 视频 */ + /** data: string, 文本内容/图片地址/视频地址 */ + antispamCustomMessage?: string } export interface V2NIMMessageRobotConfig { - /** 机器人账号, 仅群聊有效 */ - accountId?: string - /** 机器人消息话题 */ - topic?: string - /** 机器人具体功能, 用户可以自定义输入 */ - function?: string - /** 机器人自定义内容 */ - customContent?: string + /** 机器人账号, 仅群聊有效 */ + accountId?: string + /** 机器人消息话题 */ + topic?: string + /** 机器人具体功能, 用户可以自定义输入 */ + function?: string + /** 机器人自定义内容 */ + customContent?: string } export interface V2NIMMessageRouteConfig { - /** 是否需要路由消息 */ - routeEnabled?: boolean - /** 路由环境变量, 用于指向不同的抄送, 第三方回调等配置 */ - routeEnvironment?: string + /** 是否需要路由消息 */ + routeEnabled?: boolean + /** 路由环境变量, 用于指向不同的抄送, 第三方回调等配置 */ + routeEnvironment?: string } export interface V2NIMNotificationRouteConfig { - /** 是否需要路由通知 */ - routeEnabled?: boolean - /** 路由环境变量, 用于指向不同的抄送, 第三方回调等配置 */ - routeEnvironment?: string + /** 是否需要路由通知 */ + routeEnabled?: boolean + /** 路由环境变量, 用于指向不同的抄送, 第三方回调等配置 */ + routeEnvironment?: string } export interface V2NIMMessageStatus { - /** 消息发送失败后的错误码信息 */ - errorCode?: number, - /** 群消息开启已读回执配置,当 V2NIMMessageConfig::readReceiptEnabled 为 true 时,其他端收到消息后需要发送已读回执请求,该字段记录是否已经发送过已读回执请求,避免重复发送 */ - readReceiptSent?: boolean + /** 消息发送失败后的错误码信息 */ + errorCode?: number, + /** 群消息开启已读回执配置,当 V2NIMMessageConfig::readReceiptEnabled 为 true 时,其他端收到消息后需要发送已读回执请求,该字段记录是否已经发送过已读回执请求,避免重复发送 */ + readReceiptSent?: boolean } export interface V2NIMMessageConfig { - /** 是否需要消息已读回执信息 */ - readReceiptEnabled?: boolean - /** 是否需要更新消息所属的会话信息 */ - lastMessageUpdateEnabled?: boolean - /** 是否需要存历史消息 */ - historyEnabled?: boolean - /** 是否需要存漫游消息 */ - roamingEnabled?: boolean - /** 是否需要发送方多端在线同步消息 */ - onlineSyncEnabled?: boolean - /** 是否需要存离线消息 */ - offlineEnabled?: boolean - /** 是否需要计未读 */ - unreadEnabled?: boolean + /** 是否需要消息已读回执信息 */ + readReceiptEnabled?: boolean + /** 是否需要更新消息所属的会话信息 */ + lastMessageUpdateEnabled?: boolean + /** 是否需要存历史消息 */ + historyEnabled?: boolean + /** 是否需要存漫游消息 */ + roamingEnabled?: boolean + /** 是否需要发送方多端在线同步消息 */ + onlineSyncEnabled?: boolean + /** 是否需要存离线消息 */ + offlineEnabled?: boolean + /** 是否需要计未读 */ + unreadEnabled?: boolean } export interface V2NIMNotificationConfig { - /** 是否需要存离线消息 */ - offlineEnabled?: boolean - /** 是否需要计未读 */ - unreadEnabled?: boolean + /** 是否需要存离线消息 */ + offlineEnabled?: boolean + /** 是否需要计未读 */ + unreadEnabled?: boolean } export interface V2NIMMessageRefer { - /** 发送方账号 */ - senderId?: string - /** 接收方账号 */ - receiverId?: string - /** 客户端消息 id */ - messageClientId?: string - /** 服务端消息 id */ - messageServerId?: string - /** 会话类型 */ - conversationType?: V2NIMConversationType - /** 会话 ID */ - conversationId?: string - /** 消息时间 */ - createTime?: number + /** 发送方账号 */ + senderId?: string + /** 接收方账号 */ + receiverId?: string + /** 客户端消息 id */ + messageClientId?: string + /** 服务端消息 id */ + messageServerId?: string + /** 会话类型 */ + conversationType?: V2NIMConversationType + /** 会话 ID */ + conversationId?: string + /** 消息时间 */ + createTime?: number } export interface V2NIMThreadMessageListOption { - /** 需要查询的消息引用,如果该消息为根消息,则参数为当前消息 */ - messageRefer?: V2NIMMessageRefer - /** 查询开始时间,小于等于 endTime */ - begin?: number - /** 查询结束时间 */ - end?: number - /** 锚点消息ServerId,该消息必须处于端点,暨消息时间必须等于 beginTime 或 endTime */ - excludeMessageServerId?: string - /** 每次查询条数,默认50 */ - limit?: number - /** 消息查询方向,如果其它参数都不填 */ - direction?: V2NIMQueryDirection + /** 需要查询的消息引用,如果该消息为根消息,则参数为当前消息 */ + messageRefer?: V2NIMMessageRefer + /** 查询开始时间,小于等于 endTime */ + begin?: number + /** 查询结束时间 */ + end?: number + /** 锚点消息ServerId,该消息必须处于端点,暨消息时间必须等于 beginTime 或 endTime */ + excludeMessageServerId?: string + /** 每次查询条数,默认50 */ + limit?: number + /** 消息查询方向,如果其它参数都不填 */ + direction?: V2NIMQueryDirection } export interface V2NIMThreadMessageListResult { - /** 根消息 */ - message?: V2NIMMessage - /** thread 聊天里最后一条消息的时间戳 */ - timestamp?: number - /** 获取 thread 聊天里的总回复数 */ - replyCount?: number - /** 消息回复列表 */ - replyList?: Array + /** 根消息 */ + message?: V2NIMMessage + /** thread 聊天里最后一条消息的时间戳 */ + timestamp?: number + /** 获取 thread 聊天里的总回复数 */ + replyCount?: number + /** 消息回复列表 */ + replyList?: Array } export interface V2NIMMessageQueryTime { - /** 起始时间 */ - begin?: number - /** 结束时间 */ - end?: number - /** 包含起始时间 */ - includeBegin?: boolean - /** 包含结束时间 */ - includeEnd?: boolean + /** 起始时间 */ + begin?: number + /** 结束时间 */ + end?: number + /** 包含起始时间 */ + includeBegin?: boolean + /** 包含结束时间 */ + includeEnd?: boolean } export interface V2NIMAIModelConfig { - /** 具体大模型版本模型名 */ - model?: string - /** 提示词 */ - prompt?: string - /** 模型最大tokens数量 */ - maxTokens?: number - /** 取值范围(0,1),生成时,核采样方法的概率阈值。 */ - topP?: number - /** 取值范围(0,2),用于控制随机性和多样性的程度。 */ - temperature?: number + /** 具体大模型版本模型名 */ + model?: string + /** 提示词 */ + prompt?: string + /** 模型最大tokens数量 */ + maxTokens?: number + /** 取值范围(0,1),生成时,核采样方法的概率阈值。 */ + topP?: number + /** 取值范围(0,2),用于控制随机性和多样性的程度。 */ + temperature?: number } export interface V2NIMAIUser extends V2NIMUser { - /** 模型选择 */ - modelType?: V2NIMAIModelType - /** 模型相关配置文件 */ - modelConfig?: V2NIMAIModelConfig + /** 模型选择 */ + modelType?: V2NIMAIModelType + /** 模型相关配置文件 */ + modelConfig?: V2NIMAIModelConfig } export interface V2NIMAIModelCallContent { - /** 请求/响应的文本内容 */ - msg?: string - /** 类型, 暂时只有 0, 代表文本,预留扩展能力 */ - type?: number + /** 请求/响应的文本内容 */ + msg?: string + /** 类型, 暂时只有 0, 代表文本,预留扩展能力 */ + type?: number } export interface V2NIMAIModelConfigParams { - /** 提示词 */ - prompt?: string - /** 模型最大tokens数量 */ - maxTokens?: number - /** 取值范围(0,1),生成时,核采样方法的概率阈值。 */ - topP?: number - /** 取值范围(0,2),用于控制随机性和多样性的程度。 */ - temperature?: number + /** 提示词 */ + prompt?: string + /** 模型最大tokens数量 */ + maxTokens?: number + /** 取值范围(0,1),生成时,核采样方法的概率阈值。 */ + topP?: number + /** 取值范围(0,2),用于控制随机性和多样性的程度。 */ + temperature?: number } export interface V2NIMAIModelCallResponse { - /** AI 响应的状态码 */ - code?: number - /** 数字人的账户 ID */ - accountId?: string - /** 本次响应的标识 */ - requestId?: string - /** 请求 AI 的回复 */ - content?: V2NIMAIModelCallContent + /** AI 响应的状态码 */ + code?: number + /** 数字人的账户 ID */ + accountId?: string + /** 本次响应的标识 */ + requestId?: string + /** 请求 AI 的回复 */ + content?: V2NIMAIModelCallContent } export interface V2NIMProxyAIModelCallParams { - /** 机器人账号 ID */ - accountId?: string - /** 请求 ID */ - requestId?: string - /** 请求大模型的内容 */ - content?: V2NIMAIModelCallContent - /** 上下文内容 */ - messages?: Array - /** 提示词变量占位符替换, 如果 V2NIMAIUser 中的 modelConfig.prompt 定义了变量,则必填. 端测不校验 */ - promptVariables?: string - /** 请求接口模型相关参数配置, 如果参数不为空,则默认覆盖控制相关配置 */ - modelConfigParams?: V2NIMAIModelConfigParams + /** 机器人账号 ID */ + accountId?: string + /** 请求 ID */ + requestId?: string + /** 请求大模型的内容 */ + content?: V2NIMAIModelCallContent + /** 上下文内容 */ + messages?: Array + /** 提示词变量占位符替换, 如果 V2NIMAIUser 中的 modelConfig.prompt 定义了变量,则必填. 端测不校验 */ + promptVariables?: string + /** 请求接口模型相关参数配置, 如果参数不为空,则默认覆盖控制相关配置 */ + modelConfigParams?: V2NIMAIModelConfigParams } export interface V2NIMMessage { - /** 客户端消息 id */ - messageClientId?: string - /** 服务端消息 id */ - messageServerId?: string - /** 消息时间 */ - createTime?: number - /** 消息发送者账号 */ - senderId?: string - /** 消息接收者账号 */ - receiverId?: string - /** 消息所属会话类型 */ - conversationType?: V2NIMConversationType - /** 消息所属会话 ID */ - conversationId?: string - /** 消息类型 */ - messageType?: V2NIMMessageType - /** 消息内容 */ - subType?: number - /** 消息文本 */ - text?: string - /** 消息附属附件 */ - attachment?: V2NIMMessageAttachment - /** 服务端扩展 */ - serverExtension?: string - /** 本地扩展 */ - localExtension?: string - /** 回调扩展 */ - callbackExtension?: string - /** 消息发送状态 */ - sendingState?: V2NIMMessageSendingState - /** 附件上传状态 */ - attachmentUploadState?: V2NIMMessageAttachmentUploadState - /** 消息状态 */ - messageStatus?: V2NIMMessageStatus - /** 消息相关配置 */ - messageConfig?: V2NIMMessageConfig - /** 推送相关配置 */ - pushConfig?: V2NIMMessagePushConfig - /** 路由抄送相关配置 */ - routeConfig?: V2NIMMessageRouteConfig - /** 反垃圾相关配置 */ - antispamConfig?: V2NIMMessageAntispamConfig - /** 机器人相关配置 */ - robotConfig?: V2NIMMessageRobotConfig - /** Thread 消息引用 */ - threadRoot?: V2NIMMessageRefer - /** 回复消息引用 */ - threadReply?: V2NIMMessageRefer - /** 消息发送者是否是自己 */ - isSelf?: boolean - /** AI 数字人相关信息 */ - aiConfig?: V2NIMAIModelConfig - /** 消息更新时间 */ - modifyTime?: number - /** 消息更新者账号 */ - modifyAccountId?: string + /** 客户端消息 id */ + messageClientId?: string + /** 服务端消息 id */ + messageServerId?: string + /** 消息时间 */ + createTime?: number + /** 消息发送者账号 */ + senderId?: string + /** 消息接收者账号 */ + receiverId?: string + /** 消息所属会话类型 */ + conversationType?: V2NIMConversationType + /** 消息所属会话 ID */ + conversationId?: string + /** 消息类型 */ + messageType?: V2NIMMessageType + /** 消息内容 */ + subType?: number + /** 消息文本 */ + text?: string + /** 消息附属附件 */ + attachment?: V2NIMMessageAttachment + /** 服务端扩展 */ + serverExtension?: string + /** 本地扩展 */ + localExtension?: string + /** 回调扩展 */ + callbackExtension?: string + /** 消息发送状态 */ + sendingState?: V2NIMMessageSendingState + /** 附件上传状态 */ + attachmentUploadState?: V2NIMMessageAttachmentUploadState + /** 消息状态 */ + messageStatus?: V2NIMMessageStatus + /** 消息相关配置 */ + messageConfig?: V2NIMMessageConfig + /** 推送相关配置 */ + pushConfig?: V2NIMMessagePushConfig + /** 路由抄送相关配置 */ + routeConfig?: V2NIMMessageRouteConfig + /** 反垃圾相关配置 */ + antispamConfig?: V2NIMMessageAntispamConfig + /** 机器人相关配置 */ + robotConfig?: V2NIMMessageRobotConfig + /** Thread 消息引用 */ + threadRoot?: V2NIMMessageRefer + /** 回复消息引用 */ + threadReply?: V2NIMMessageRefer + /** 消息发送者是否是自己 */ + isSelf?: boolean + /** AI 数字人相关信息 */ + aiConfig?: V2NIMAIModelConfig + /** 消息更新时间 */ + modifyTime?: number + /** 消息更新者账号 */ + modifyAccountId?: string } export interface V2NIMModifyMessageResult { - /** 修改成功后的消息体 */ - message: V2NIMMessage - /** 返回错误码 */ - errorCode: number - /** 云端反垃圾返回的结果 */ - antispamResult: string - /** 客户端本地反垃圾结果 */ - clientAntispamResult: V2NIMClientAntispamResult -} - -export interface V2NIMModifyMessageParams{ - /** 消息子类型 */ - subType?: number - /** 消息内容 */ - text?: string - /** 消息附属附件 */ - attachment?: V2NIMMessageAttachment - /** 消息服务端扩展 */ - serverExtension?: string - /** 反垃圾相关配置 */ - antispamConfig?: V2NIMMessageAntispamConfig - /** 路由抄送相关配置 */ - routeConfig?: V2NIMMessageRouteConfig - /** 是否启用本地反垃圾 */ - clientAntispamEnabled?: boolean - /** 反垃圾命中后替换的文本 */ - clientAntispamReplace?: string + /** 修改成功后的消息体 */ + message: V2NIMMessage + /** 返回错误码 */ + errorCode: number + /** 云端反垃圾返回的结果 */ + antispamResult: string + /** 客户端本地反垃圾结果 */ + clientAntispamResult: V2NIMClientAntispamResult +} + +export interface V2NIMModifyMessageParams { + /** 消息子类型 */ + subType?: number + /** 消息内容 */ + text?: string + /** 消息附属附件 */ + attachment?: V2NIMMessageAttachment + /** 消息服务端扩展 */ + serverExtension?: string + /** 反垃圾相关配置 */ + antispamConfig?: V2NIMMessageAntispamConfig + /** 路由抄送相关配置 */ + routeConfig?: V2NIMMessageRouteConfig + /** 是否启用本地反垃圾 */ + clientAntispamEnabled?: boolean + /** 反垃圾命中后替换的文本 */ + clientAntispamReplace?: string } export interface V2NIMCustomNotification { - /** 通知发送者账号 */ - senderId?: string - /** 通知接收者账号 */ - receiverId?: string - /** 通知所属会话类型 */ - conversationType?: V2NIMConversationType - /** 客户设置时间戳 */ - timestamp?: number - /** 通知内容 */ - content?: string - /** 通知相关配置 */ - notificationConfig?: V2NIMNotificationConfig - /** 离线推送配置相关 */ - pushConfig?: V2NIMNotificationPushConfig - /** 反垃圾相关配置 */ - antispamConfig?: V2NIMNotificationAntispamConfig - /** 路由抄送相关配置 */ - routeConfig?: V2NIMNotificationRouteConfig + /** 通知发送者账号 */ + senderId?: string + /** 通知接收者账号 */ + receiverId?: string + /** 通知所属会话类型 */ + conversationType?: V2NIMConversationType + /** 客户设置时间戳 */ + timestamp?: number + /** 通知内容 */ + content?: string + /** 通知相关配置 */ + notificationConfig?: V2NIMNotificationConfig + /** 离线推送配置相关 */ + pushConfig?: V2NIMNotificationPushConfig + /** 反垃圾相关配置 */ + antispamConfig?: V2NIMNotificationAntispamConfig + /** 路由抄送相关配置 */ + routeConfig?: V2NIMNotificationRouteConfig } export interface V2NIMBroadcastNotification { - /** 广播通知 ID */ - id?: number - /** 广播通知发送者账号 */ - senderId?: string - /** 广播通知时间戳 */ - timestamp?: number - /** 广播通知内容 */ - content?: string + /** 广播通知 ID */ + id?: number + /** 广播通知发送者账号 */ + senderId?: string + /** 广播通知时间戳 */ + timestamp?: number + /** 广播通知内容 */ + content?: string } export interface V2NIMMessageTargetConfig { - /** 为 true 时表示消息发送到群组中 receiverIds 对应的成员,为 false 时表示消息发送到群组中排除 receiverIds 以外的所有成员 */ - inclusive: boolean - /** 接收者 ID 列表 */ - receiverIds: Array - /** 新成员是否可以查看该定向消息 */ - newMemberVisible?: boolean -}; + /** 为 true 时表示消息发送到群组中 receiverIds 对应的成员,为 false 时表示消息发送到群组中排除 receiverIds 以外的所有成员 */ + inclusive: boolean + /** 接收者 ID 列表 */ + receiverIds: Array + /** 新成员是否可以查看该定向消息 */ + newMemberVisible?: boolean +} export interface V2NIMSendMessageParams { - /** 消息相关配置 */ - messageConfig?: V2NIMMessageConfig - /** 路由抄送相关配置 */ - routeConfig?: V2NIMMessageRouteConfig - /** 推送相关配置 */ - pushConfig?: V2NIMMessagePushConfig - /** 反垃圾相关配置 */ - antispamConfig?: V2NIMMessageAntispamConfig - /** 机器人相关配置 */ - robotConfig?: V2NIMMessageRobotConfig - /** 用以控制在发送群组消息时,消息是否发送给指定的群组成员 */ - targetConfig?: V2NIMMessageTargetConfig - /** 是否启用本地反垃圾 */ - clientAntispamEnabled?: boolean - /** 本地反垃圾命中后替换的文本 */ - clientAntispamReplace?: string + /** 消息相关配置 */ + messageConfig?: V2NIMMessageConfig + /** 路由抄送相关配置 */ + routeConfig?: V2NIMMessageRouteConfig + /** 推送相关配置 */ + pushConfig?: V2NIMMessagePushConfig + /** 反垃圾相关配置 */ + antispamConfig?: V2NIMMessageAntispamConfig + /** 机器人相关配置 */ + robotConfig?: V2NIMMessageRobotConfig + /** 用以控制在发送群组消息时,消息是否发送给指定的群组成员 */ + targetConfig?: V2NIMMessageTargetConfig + /** 是否启用本地反垃圾 */ + clientAntispamEnabled?: boolean + /** 本地反垃圾命中后替换的文本 */ + clientAntispamReplace?: string } export interface V2NIMMessageRevokeParams { - /** 附言 */ - postscript?: string - /** 扩展信息 */ - serverExtension?: string - /** 推送文案 */ - pushContent?: string - /** 推送数据 */ - pushPayload?: string - /** 路由抄送地址 */ - env?: string + /** 附言 */ + postscript?: string + /** 扩展信息 */ + serverExtension?: string + /** 推送文案 */ + pushContent?: string + /** 推送数据 */ + pushPayload?: string + /** 路由抄送地址 */ + env?: string } export interface V2NIMMessageRevokeNotification { - /** 被撤回的消息引用 */ - messageRefer?: V2NIMMessageRefer - /** 扩展信息 */ - serverExtension?: string - /** 附言 */ - postscript?: string - /** 消息撤回者账号 */ - revokeAccountId?: string - /** 消息撤回类型 */ - revokeType?: V2NIMMessageRevokeType - /** 第三方回调传入的自定义扩展字段 */ - callbackExtension?: string + /** 被撤回的消息引用 */ + messageRefer?: V2NIMMessageRefer + /** 扩展信息 */ + serverExtension?: string + /** 附言 */ + postscript?: string + /** 消息撤回者账号 */ + revokeAccountId?: string + /** 消息撤回类型 */ + revokeType?: V2NIMMessageRevokeType + /** 第三方回调传入的自定义扩展字段 */ + callbackExtension?: string } export interface V2NIMMessagePin { - /** pin 消息引用 */ - messageRefer?: V2NIMMessageRefer - /** 操作者 ID */ - operatorId?: string - /** 扩展字段 */ - serverExtension?: string - /** 创建时间 */ - createTime?: number - /** 更新时间 */ - updateTime?: number + /** pin 消息引用 */ + messageRefer?: V2NIMMessageRefer + /** 操作者 ID */ + operatorId?: string + /** 扩展字段 */ + serverExtension?: string + /** 创建时间 */ + createTime?: number + /** 更新时间 */ + updateTime?: number } export interface V2NIMMessagePinNotification { - /** 消息 PIN 状态 */ - pinState?: V2NIMMessagePinState - /** 消息相关的PIN信息 */ - pin?: V2NIMMessagePin + /** 消息 PIN 状态 */ + pinState?: V2NIMMessagePinState + /** 消息相关的PIN信息 */ + pin?: V2NIMMessagePin } export interface V2NIMSendCustomNotificationParams { - /** 通知相关配置 */ - notificationConfig?: V2NIMNotificationConfig - /** 离线推送配置相关 */ - pushConfig?: V2NIMNotificationPushConfig - /** 反垃圾相关配置 */ - antispamConfig?: V2NIMNotificationAntispamConfig - /** 路由抄送相关配置 */ - routeConfig?: V2NIMNotificationRouteConfig + /** 通知相关配置 */ + notificationConfig?: V2NIMNotificationConfig + /** 离线推送配置相关 */ + pushConfig?: V2NIMNotificationPushConfig + /** 反垃圾相关配置 */ + antispamConfig?: V2NIMNotificationAntispamConfig + /** 路由抄送相关配置 */ + routeConfig?: V2NIMNotificationRouteConfig } export interface V2NIMClientAntispamResult { - /** 客户端反垃圾文本命中后操作类型 */ - operateType?: V2NIMClientAntispamOperateType - /** 处理后的文本内容 */ - replacedText?: string + /** 客户端反垃圾文本命中后操作类型 */ + operateType?: V2NIMClientAntispamOperateType + /** 处理后的文本内容 */ + replacedText?: string } export interface V2NIMSendMessageResult { - /** 发送成功后的消息体 */ - message?: V2NIMMessage - /** 反垃圾返回的结果 */ - antispamResult?: string - /** 客户端本地反垃圾结果 */ - clientAntispamResult?: V2NIMClientAntispamResult + /** 发送成功后的消息体 */ + message?: V2NIMMessage + /** 反垃圾返回的结果 */ + antispamResult?: string + /** 客户端本地反垃圾结果 */ + clientAntispamResult?: V2NIMClientAntispamResult } export interface V2NIMTeamMessageReadReceipt { - /** 会话 ID */ - conversationId?: string - /** 消息服务器 ID */ - messageServerId?: string - /** 消息客户端 ID */ - messageClientId?: string - /** 群消息已读人数 */ - readCount?: number - /** 群消息未读人数 */ - unreadCount?: number - /** 群消息最新已读账号 */ - latestReadAccount?: string + /** 会话 ID */ + conversationId?: string + /** 消息服务器 ID */ + messageServerId?: string + /** 消息客户端 ID */ + messageClientId?: string + /** 群消息已读人数 */ + readCount?: number + /** 群消息未读人数 */ + unreadCount?: number + /** 群消息最新已读账号 */ + latestReadAccount?: string } export interface V2NIMTeamMessageReadReceiptDetail { - /** 群消息已读回执 */ - readReceipt?: V2NIMTeamMessageReadReceipt - /** 已读账号列表 */ - readAccountList?: Array - /** 未读账号列表 */ - unreadAccountList?: Array + /** 群消息已读回执 */ + readReceipt?: V2NIMTeamMessageReadReceipt + /** 已读账号列表 */ + readAccountList?: Array + /** 未读账号列表 */ + unreadAccountList?: Array } export interface V2NIMP2PMessageReadReceipt { - /** 会话 ID */ - conversationId?: string - /** 最后一条已读消息时间, 比该时间早的消息都可以认为已读 */ - timestamp?: number + /** 会话 ID */ + conversationId?: string + /** 最后一条已读消息时间, 比该时间早的消息都可以认为已读 */ + timestamp?: number } export interface V2NIMMessageClientAntispamResult { - /** 客户端反垃圾文本命中后操作类型 */ - operateType?: V2NIMMessageClientAntispamOperatorType - /** 处理后的文本内容 */ - replaceContent?: string + /** 客户端反垃圾文本命中后操作类型 */ + operateType?: V2NIMMessageClientAntispamOperatorType + /** 处理后的文本内容 */ + replaceContent?: string } export interface V2NIMMessageListOption { - /** 根据消息类型查询会话, 为空表示查询所有消息类型 */ - messageTypes?: Array - /** 会话 ID */ - conversationId?: string - /** 消息查询开始时间, 闭区间 */ - beginTime?: number - /** 消息查询结束时间, 闭区间 */ - endTime?: number - /** 查询条数 */ - limit?: number - /** 锚点消息, 根据锚点消息查询, 不包含该消息 */ - anchorMessage?: V2NIMMessage - /** 是否反向排序 */ - reverse?: boolean - /** 消息查询方向 */ - direction?: V2NIMQueryDirection - /** 严格模式, 无法确定消息完整性则返回错误 */ - strictMode?: boolean + /** 根据消息类型查询会话, 为空表示查询所有消息类型 */ + messageTypes?: Array + /** 会话 ID */ + conversationId?: string + /** 消息查询开始时间, 闭区间 */ + beginTime?: number + /** 消息查询结束时间, 闭区间 */ + endTime?: number + /** 查询条数 */ + limit?: number + /** 锚点消息, 根据锚点消息查询, 不包含该消息 */ + anchorMessage?: V2NIMMessage + /** 是否反向排序 */ + reverse?: boolean + /** 消息查询方向 */ + direction?: V2NIMQueryDirection + /** 严格模式, 无法确定消息完整性则返回错误 */ + strictMode?: boolean } export interface V2NIMClearHistoryMessageOption { - /** 需要清空消息的对应的会话 ID */ - conversationId?: string - /** 是否同步删除漫游消息, 默认删除, 该字段只 P2P 时有效 */ - deleteRoam?: boolean - /** 是否多端同步, 默认不同步 */ - onlineSync?: boolean - /** 扩展字段, 多端同步时会同步到其它端 */ - serverExtension?: string + /** 需要清空消息的对应的会话 ID */ + conversationId?: string + /** 是否同步删除漫游消息, 默认删除, 该字段只 P2P 时有效 */ + deleteRoam?: boolean + /** 是否多端同步, 默认不同步 */ + onlineSync?: boolean + /** 扩展字段, 多端同步时会同步到其它端 */ + serverExtension?: string } export interface V2NIMMessageQuickCommentPushConfig { - /** 是否需要推送 */ - needPush?: boolean - /** 是否需要角标 */ - needBadge?: boolean - /** 推送标题 */ - pushTitle?: string - /** 推送内容 */ - pushContent?: string - /** 推送自定义字段 */ - pushPayload?: string + /** 是否需要推送 */ + needPush?: boolean + /** 是否需要角标 */ + needBadge?: boolean + /** 推送标题 */ + pushTitle?: string + /** 推送内容 */ + pushContent?: string + /** 推送自定义字段 */ + pushPayload?: string } export interface V2NIMMessageQuickComment { - /** 消息引用 */ - messageRefer?: V2NIMMessageRefer - /** 操作者 ID */ - operatorId?: string - /** 评论索引 */ - index?: number - /** 扩展字段 */ - serverExtension?: string - /** 创建时间 */ - createTime?: number + /** 消息引用 */ + messageRefer?: V2NIMMessageRefer + /** 操作者 ID */ + operatorId?: string + /** 评论索引 */ + index?: number + /** 扩展字段 */ + serverExtension?: string + /** 创建时间 */ + createTime?: number } export interface V2NIMMessageQuickCommentNotification { - /** 快捷评论操作类型 */ - operationType?: V2NIMMessageQuickCommentType - /** 快捷评论 */ - quickComment?: V2NIMMessageQuickComment + /** 快捷评论操作类型 */ + operationType?: V2NIMMessageQuickComment + /** 快捷评论 */ + quickComment?: V2NIMMessageQuickComment } export interface V2NIMMessageDeletedNotification { - /** 被删除的消息引用 */ - messageRefer?: V2NIMMessageRefer - /** 被删除的时间 */ - deleteTime?: number - /** 被删除时填入的扩展字段 */ - serverExtension?: string + /** 被删除的消息引用 */ + messageRefer?: V2NIMMessageRefer + /** 被删除的时间 */ + deleteTime?: number + /** 被删除时填入的扩展字段 */ + serverExtension?: string } export interface V2NIMClearHistoryNotification { - /** 会话 ID */ - conversationId?: string - /** 被删除的时间 */ - deleteTime?: number - /** 被删除时填入的扩展字段 */ - serverExtension?: string + /** 会话 ID */ + conversationId?: string + /** 被删除的时间 */ + deleteTime?: number + /** 被删除时填入的扩展字段 */ + serverExtension?: string } export interface V2NIMCollection { - /** 收藏信息服务端 ID */ - collectionId?: string - /** 收藏索引 */ - collectionType?: number - /** 收藏数据 */ - collectionData?: string - /** 扩展字段 */ - serverExtension?: string - /** 去重唯一 ID */ - uniqueId?: string - /** 创建时间 */ - createTime?: number - /** 更新时间 */ - updateTime?: number + /** 收藏信息服务端 ID */ + collectionId?: string + /** 收藏索引 */ + collectionType?: number + /** 收藏数据 */ + collectionData?: string + /** 扩展字段 */ + serverExtension?: string + /** 去重唯一 ID */ + uniqueId?: string + /** 创建时间 */ + createTime?: number + /** 更新时间 */ + updateTime?: number } export interface V2NIMAddCollectionParams { - /** 收藏类型 */ - collectionType?: number - /** 收藏数据 */ - collectionData?: string - /** 扩展字段 */ - serverExtension?: string - /** 去重唯一ID, 如果ID相同, 则不会新增收藏,只更新之前的收藏内容 */ - uniqueId?: string + /** 收藏类型 */ + collectionType?: number + /** 收藏数据 */ + collectionData?: string + /** 扩展字段 */ + serverExtension?: string + /** 去重唯一ID, 如果ID相同, 则不会新增收藏,只更新之前的收藏内容 */ + uniqueId?: string } export interface V2NIMCollectionOption { - /** 查询开始时间区间, 闭区间 */ - beginTime?: number - /** 查询结束时间区间, 闭区间, 0 表示当前时间 */ - endTime?: number - /** 查询锚点 */ - anchorCollection?: V2NIMCollection - /** 查询方向 */ - direction?: V2NIMQueryDirection - /** 每次查询收藏条数 */ - limit?: number - /** 收藏类型 */ - collectionType?: number + /** 查询开始时间区间, 闭区间 */ + beginTime?: number + /** 查询结束时间区间, 闭区间, 0 表示当前时间 */ + endTime?: number + /** 查询锚点 */ + anchorCollection?: V2NIMCollection + /** 查询方向 */ + direction?: V2NIMQueryDirection + /** 每次查询收藏条数 */ + limit?: number + /** 收藏类型 */ + collectionType?: number } /** @brief 动态 token 获取回调 */ @@ -937,1324 +982,1369 @@ export type V2NIMChatroomLoginExtensionProvider = (roomId: string, account: stri export type V2NIMChatroomLinkProvider = (roomId: string, account: string) => Array export interface V2NIMLoginOption { - /** 重试次数 */ - retryCount?: number - /** 登录超时, 单位毫秒 */ - timeout?: number - /** 强制登录模式 */ - forceMode?: boolean - /** 认证类型 */ - authType?: V2NIMLoginAuthType - /** 动态 token 获取回调 */ - tokenProvider?: V2NIMTokenProvider - /** 登陆扩展信息获取回调 */ - loginExtensionProvider?: V2NIMLoginExtensionProvider - /** 数据同步等级 */ - syncLevel?: V2NIMDataSyncLevel + /** 重试次数 */ + retryCount?: number + /** 登录超时, 单位毫秒 */ + timeout?: number + /** 强制登录模式 */ + forceMode?: boolean + /** 认证类型 */ + authType?: V2NIMLoginAuthType + /** 动态 token 获取回调 */ + tokenProvider?: V2NIMTokenProvider + /** 登陆扩展信息获取回调 */ + loginExtensionProvider?: V2NIMLoginExtensionProvider + /** 数据同步等级 */ + syncLevel?: V2NIMDataSyncDetail } export interface V2NIMLoginClient { - /** 客户端类型 */ - type?: V2NIMLoginClientType - /** 操作系统 */ - os?: string - /** 登录时间 */ - timestamp?: number - /** 自定义信息 */ - customTag?: string - /** 自定义类型 */ - customClientType?: number - /** 客户端 ID */ - clientId?: string - /** 客户端 IP */ - clientIP?: string + /** 客户端类型 */ + type?: V2NIMLoginClient + /** 操作系统 */ + os?: string + /** 登录时间 */ + timestamp?: number + /** 自定义信息 */ + customTag?: string + /** 自定义类型 */ + customClientType?: number + /** 客户端 ID */ + clientId?: string + /** 客户端 IP */ + clientIP?: string } export interface V2NIMKickedOfflineDetail { - /** 原因 */ - reason?: V2NIMKickedOfflineReason - /** 说明 */ - reasonDesc?: string - /** 客户端类型 */ - clientType?: V2NIMLoginClientType - /** 自定义客户端类型 */ - customClientType?: number + /** 原因 */ + reason?: V2NIMKickedOfflineDetail + /** 说明 */ + reasonDesc?: string + /** 客户端类型 */ + clientType?: V2NIMLoginClient + /** 自定义客户端类型 */ + customClientType?: number } export interface V2NIMDataSyncDetail { - /** 数据同步类型 */ - type?: V2NIMDataSyncType - /** 数据同步状态 */ - state?: V2NIMDataSyncState + /** 数据同步类型 */ + type?: V2NIMDataSyncType + /** 数据同步状态 */ + state?: V2NIMDataSyncDetail } export interface V2NIMLastMessage { - /** 最后一条消息状态 */ - lastMessageState?: V2NIMLastMessageState - /** 最后一条消息引用 */ - messageRefer?: V2NIMMessageRefer - /** 最后一条消息类型 */ - messageType?: V2NIMMessageType - /** 消息子类型 */ - subType?: number - /** 消息发送状态 */ - sendingState?: V2NIMMessageSendingState - /** 消息文本内容或撤回附言 */ - text?: string - /** 消息附件 */ - attachment?: V2NIMMessageAttachment - /** 消息撤回者账号 */ - revokeAccountId?: string - /** 消息撤回类型 */ - revokeType?: V2NIMMessageRevokeType - /** 消息发送者 */ - senderName?: string - /** 扩展信息 */ - serverExtension?: string - /** 第三方扩展字段 */ - callbackExtension?: string + /** 最后一条消息状态 */ + lastMessageState?: V2NIMMessagePinState + /** 最后一条消息引用 */ + messageRefer?: V2NIMMessageRefer + /** 最后一条消息类型 */ + messageType?: V2NIMMessageType + /** 消息子类型 */ + subType?: number + /** 消息发送状态 */ + sendingState?: V2NIMMessageSendingState + /** 消息文本内容或撤回附言 */ + text?: string + /** 消息附件 */ + attachment?: V2NIMMessageAttachment + /** 消息撤回者账号 */ + revokeAccountId?: string + /** 消息撤回类型 */ + revokeType?: V2NIMMessageRevokeType + /** 消息发送者 */ + senderName?: string + /** 扩展信息 */ + serverExtension?: string + /** 第三方扩展字段 */ + callbackExtension?: string } export interface V2NIMConversation { - /** 会话标识 */ - conversationId?: string - /** 会话类型 */ - type?: V2NIMConversationType - /** 会话名称 */ - name?: string - /** 会话头像 */ - avatar?: string - /** 免打扰 */ - mute?: boolean - /** 置顶 */ - stickTop?: boolean - /** 会话分组 ID 列表 */ - groupIds?: Array - /** 本地扩展信息 */ - localExtension?: string - /** 服务端扩展信息 */ - serverExtension?: string - /** 最后一条消息 */ - lastMessage?: V2NIMLastMessage - /** 未读计数 */ - unreadCount?: number - /** 会话排序时间 */ - sortOrder?: number - /** 会话创建时间 */ - createTime?: number - /** 会话更新时间 */ - updateTime?: number + /** 会话标识 */ + conversationId?: string + /** 会话类型 */ + type?: V2NIMConversationType + /** 会话名称 */ + name?: string + /** 会话头像 */ + avatar?: string + /** 免打扰 */ + mute?: boolean + /** 置顶 */ + stickTop?: boolean + /** 会话分组 ID 列表 */ + groupIds?: Array + /** 本地扩展信息 */ + localExtension?: string + /** 服务端扩展信息 */ + serverExtension?: string + /** 最后一条消息 */ + lastMessage?: V2NIMLastMessage + /** 未读计数 */ + unreadCount?: number + /** 会话排序时间 */ + sortOrder?: number + /** 会话创建时间 */ + createTime?: number + /** 会话更新时间 */ + updateTime?: number } export interface V2NIMConversationResult { - /** 下一次拉取的偏移 */ - offset?: number - /** 数据是否拉取完毕 */ - finished?: boolean - /** 会话列表 */ - conversationList?: Array + /** 下一次拉取的偏移 */ + offset?: number + /** 数据是否拉取完毕 */ + finished?: boolean + /** 会话列表 */ + conversationList?: Array } export interface V2NIMConversationOperationResult { - /** 会话标识 */ - conversationId?: string - /** 错误 */ - error?: V2NIMError + /** 会话标识 */ + conversationId?: string + /** 错误 */ + error?: V2NIMError } export interface V2NIMConversationUpdate { - /** 服务端扩展字段 */ - serverExtension?: string + /** 服务端扩展字段 */ + serverExtension?: string } export interface V2NIMConversationOption { - /** 查询指定会话类型, empty: 不限制会话类型 */ - conversationTypes?: Array - /** 查询指定分组的会话, null: 查询所有分组, empty: 查询未分组的会话 */ - conversationGroupIds?: Array - /** false: 查询所有会话, true: 查询包含未读的会话 */ - onlyUnread?: boolean + /** 查询指定会话类型, empty: 不限制会话类型 */ + conversationTypes?: Array + /** 查询指定分组的会话, null: 查询所有分组, empty: 查询未分组的会话 */ + conversationGroupIds?: Array + /** false: 查询所有会话, true: 查询包含未读的会话 */ + onlyUnread?: boolean } export interface V2NIMConversationFilter { - /** 过滤指定对话类型, empty: 不限制会话类型 */ - conversationTypes?: Array - /** 过滤指定分组的会话, nullopt: 不过滤会话分组 */ - conversationGroupId?: string - /** 过滤免打扰会话 */ - ignoreMuted?: boolean + /** 过滤指定对话类型, empty: 不限制会话类型 */ + conversationTypes?: Array + /** 过滤指定分组的会话, nullopt: 不过滤会话分组 */ + conversationGroupId?: string + /** 过滤免打扰会话 */ + ignoreMuted?: boolean } export interface V2NIMConversationGroup { - /** 会话分组 ID */ - groupId?: string - /** 会话分组名称 */ - name?: string - /** 扩展字段 */ - serverExtension?: string - /** 创建时间 */ - createTime?: number - /** 更新时间 */ - updateTime?: number + /** 会话分组 ID */ + groupId?: string + /** 会话分组名称 */ + name?: string + /** 扩展字段 */ + serverExtension?: string + /** 创建时间 */ + createTime?: number + /** 更新时间 */ + updateTime?: number } export interface V2NIMConversationGroupResult { - /** 会话分组信息 */ - group?: V2NIMConversationGroup - /** 失败的会话列表 */ - failedList?: Array + /** 会话分组信息 */ + group?: V2NIMConversationGroup + /** 失败的会话列表 */ + failedList?: Array } export interface V2NIMMessageSearchParams { - /** 关键字 */ - keyword?: string - /** 查询起始时间 */ - beginTime?: number - /** 查询结束时间, 0 表示当前时间 */ - endTime?: number - /** 检索会话数量 */ - conversationLimit?: number - /** 返回消息数量 */ - messageLimit?: number - /** 消息排序规则 */ - sortOrder?: V2NIMSortOrder - /** P2P 账号列表 */ - p2pAccountIds?: Array - /** 高级群账号列表 */ - teamIds?: Array - /** 发送账号列表 */ - senderAccountIds?: Array - /** 要检索的消息类型, 为空表示查询所有消息类型 */ - messageTypes?: Array - /** 要检索的消息子类型, 为空表示查询所有消息子类型 */ - messageSubTypes?: Array + /** 关键字 */ + keyword?: string + /** 查询起始时间 */ + beginTime?: number + /** 查询结束时间, 0 表示当前时间 */ + endTime?: number + /** 检索会话数量 */ + conversationLimit?: number + /** 返回消息数量 */ + messageLimit?: number + /** 消息排序规则 */ + sortOrder?: V2NIMSortOrder + /** P2P 账号列表 */ + p2pAccountIds?: Array + /** 高级群账号列表 */ + teamIds?: Array + /** 发送账号列表 */ + senderAccountIds?: Array + /** 要检索的消息类型, 为空表示查询所有消息类型 */ + messageTypes?: Array + /** 要检索的消息子类型, 为空表示查询所有消息子类型 */ + messageSubTypes?: Array } export interface V2NIMVoiceToTextParams { - /** 本地语音文件路径, 若为空则使用 url */ - voicePath?: string - /** 语音 url, 若为空则根据 voicePath 自动上传 */ - voiceUrl?: string - /** 音频类型, aac, wav, mp3, amr等 */ - mimeType?: string - /** 采样率 */ - sampleRate?: string - /** 语音时长, 单位毫秒 */ - duration?: number - /** 文件存储场景 */ - sceneName?: string + /** 本地语音文件路径, 若为空则使用 url */ + voicePath?: string + /** 语音 url, 若为空则根据 voicePath 自动上传 */ + voiceUrl?: string + /** 音频类型, aac, wav, mp3, amr等 */ + mimeType?: string + /** 采样率 */ + sampleRate?: string + /** 语音时长, 单位毫秒 */ + duration?: number + /** 文件存储场景 */ + sceneName?: string } export interface V2NIMTeam { - /** 群组ID */ - teamId?: string - /** 群组类型 */ - teamType?: V2NIMTeamType - /** 群组名称 */ - name?: string - /** 群组创建者/拥有者 ID */ - ownerAccountId?: string - /** 群组人数上限 */ - memberLimit?: number - /** 群组当前人数 */ - memberCount?: number - /** 群组创建时间 */ - createTime?: number - /** 群组更新时间 */ - updateTime?: number - /** 群组介绍 */ - intro?: string - /** 群组公告 */ - announcement?: string - /** 群组头像 */ - avatar?: string - /** 服务端扩展字段 */ - serverExtension?: string - /** 客户自定义扩展, 由openApi设置 */ - customerExtension?: string - /** 申请入群模式, 入群验证方式 */ - joinMode?: V2NIMTeamJoinMode - /** 被邀请人入群模式, 被邀请人的同意方式 */ - agreeMode?: V2NIMTeamAgreeMode - /** 群组邀请模式, 谁可以邀请他人入群 */ - inviteMode?: V2NIMTeamInviteMode - /** 群组资料修改模式, 谁可以修改群组资料 */ - updateInfoMode?: V2NIMTeamUpdateInfoMode - /** 群组扩展字段修改模式, 谁可以修改群组扩展 */ - updateExtensionMode?: V2NIMTeamUpdateExtensionMode - /** 群禁言状态 */ - chatBannedMode?: V2NIMTeamChatBannedMode - /** 是否为自己所在且有效的群, 群存在且我在群组中 */ - isValidTeam?: boolean + /** 群组ID */ + teamId?: string + /** 群组类型 */ + teamType?: V2NIMTeamType + /** 群组名称 */ + name?: string + /** 群组创建者/拥有者 ID */ + ownerAccountId?: string + /** 群组人数上限 */ + memberLimit?: number + /** 群组当前人数 */ + memberCount?: number + /** 群组创建时间 */ + createTime?: number + /** 群组更新时间 */ + updateTime?: number + /** 群组介绍 */ + intro?: string + /** 群组公告 */ + announcement?: string + /** 群组头像 */ + avatar?: string + /** 服务端扩展字段 */ + serverExtension?: string + /** 客户自定义扩展, 由openApi设置 */ + customerExtension?: string + /** 申请入群模式, 入群验证方式 */ + joinMode?: V2NIMTeamJoinMode + /** 被邀请人入群模式, 被邀请人的同意方式 */ + agreeMode?: V2NIMTeamAgreeMode + /** 群组邀请模式, 谁可以邀请他人入群 */ + inviteMode?: V2NIMTeamInviteMode + /** 群组资料修改模式, 谁可以修改群组资料 */ + updateInfoMode?: V2NIMTeamUpdateInfoMode + /** 群组扩展字段修改模式, 谁可以修改群组扩展 */ + updateExtensionMode?: V2NIMTeamUpdateExtensionMode + /** 群禁言状态 */ + chatBannedMode?: V2NIMTeamChatBannedMode + /** 是否为自己所在且有效的群, 群存在且我在群组中 */ + isValidTeam?: boolean } export interface V2NIMTeamMember { - /** 群组ID */ - teamId?: string - /** 群组类型 */ - teamType?: V2NIMTeamType - /** 群组成员账号 */ - accountId?: string - /** 群组成员类型 */ - memberRole?: V2NIMTeamMemberRole - /** 群组昵称 */ - teamNick?: string - /** 服务端扩展字段 */ - serverExtension?: string - /** 入群时间 */ - joinTime?: number - /** 更新时间 */ - updateTime?: number - /** 入群邀请人 */ - invitorAccountId?: string - /** 是否在群中 */ - inTeam?: boolean - /** 聊天是否被禁言 */ - chatBanned?: boolean - /** 特别关注群成员 account ID 列表 */ - followAccountIds?: Array + /** 群组ID */ + teamId?: string + /** 群组类型 */ + teamType?: V2NIMTeamType + /** 群组成员账号 */ + accountId?: string + /** 群组成员类型 */ + memberRole?: V2NIMTeamMemberRole + /** 群组昵称 */ + teamNick?: string + /** 服务端扩展字段 */ + serverExtension?: string + /** 入群时间 */ + joinTime?: number + /** 更新时间 */ + updateTime?: number + /** 入群邀请人 */ + invitorAccountId?: string + /** 是否在群中 */ + inTeam?: boolean + /** 聊天是否被禁言 */ + chatBanned?: boolean + /** 特别关注群成员 account ID 列表 */ + followAccountIds?: Array } // @internal export interface V2NIMTeamMemberUpdateParams { - /** 群组ID */ - teamId?: string - /** 群组类型 */ - teamType?: V2NIMTeamType - /** 群组成员账号 */ - accountId?: string - /** 群组成员类型 */ - memberRole?: V2NIMTeamMemberRole - /** 群组昵称 */ - teamNick?: string - /** 内部使用字段 */ - bits?: number - /** 服务端扩展字段 */ - serverExtension?: string - /** 入群时间 */ - joinTime?: number - /** 更新时间 */ - updateTime?: number - /** 入群邀请人 */ - invitorAccountId?: string - /** 是否在群中 */ - inTeam?: boolean - /** 聊天是否被禁言 */ - chatBanned?: boolean + /** 群组ID */ + teamId?: string + /** 群组类型 */ + teamType?: V2NIMTeamType + /** 群组成员账号 */ + accountId?: string + /** 群组成员类型 */ + memberRole?: V2NIMTeamMemberRole + /** 群组昵称 */ + teamNick?: string + /** 内部使用字段 */ + bits?: number + /** 服务端扩展字段 */ + serverExtension?: string + /** 入群时间 */ + joinTime?: number + /** 更新时间 */ + updateTime?: number + /** 入群邀请人 */ + invitorAccountId?: string + /** 是否在群中 */ + inTeam?: boolean + /** 聊天是否被禁言 */ + chatBanned?: boolean } export interface V2NIMCreateTeamParams { - /** 群组名称 */ - name?: string - /** 群组类型 */ - teamType?: V2NIMTeamType - /** 群组人数上限 */ - memberLimit?: number - /** 群组介绍 */ - intro?: string - /** 群组公告 */ - announcement?: string - /** 群组头像 */ - avatar?: string - /** 服务端扩展字段 */ - serverExtension?: string - /** 申请入群模式, 入群验证方式 */ - joinMode?: V2NIMTeamJoinMode - /** 被邀请人入群模式, 被邀请人的同意方式 */ - agreeMode?: V2NIMTeamAgreeMode - /** 群组邀请模式, 谁可以邀请他人入群 */ - inviteMode?: V2NIMTeamInviteMode - /** 群组资料修改模式, 谁可以修改群组资料 */ - updateInfoMode?: V2NIMTeamUpdateInfoMode - /** 群组扩展字段修改模式, 谁可以修改群组扩展 */ - updateExtensionMode?: V2NIMTeamUpdateExtensionMode - /** 群禁言状态 */ - chatBannedMode?: V2NIMTeamChatBannedMode + /** 群组名称 */ + name?: string + /** 群组类型 */ + teamType?: V2NIMTeamType + /** 群组人数上限 */ + memberLimit?: number + /** 群组介绍 */ + intro?: string + /** 群组公告 */ + announcement?: string + /** 群组头像 */ + avatar?: string + /** 服务端扩展字段 */ + serverExtension?: string + /** 申请入群模式, 入群验证方式 */ + joinMode?: V2NIMTeamJoinMode + /** 被邀请人入群模式, 被邀请人的同意方式 */ + agreeMode?: V2NIMTeamAgreeMode + /** 群组邀请模式, 谁可以邀请他人入群 */ + inviteMode?: V2NIMTeamInviteMode + /** 群组资料修改模式, 谁可以修改群组资料 */ + updateInfoMode?: V2NIMTeamUpdateInfoMode + /** 群组扩展字段修改模式, 谁可以修改群组扩展 */ + updateExtensionMode?: V2NIMTeamUpdateExtensionMode + /** 群禁言状态 */ + chatBannedMode?: V2NIMTeamChatBannedMode } export interface V2NIMTeamMemberQueryOption { - /** 群成员类型 */ - roleQueryType?: V2NIMTeamMemberRoleQueryType - /** 是否只返回聊天禁言成员列表 */ - onlyChatBanned?: boolean - /** 消息查询方向 */ - direction?: V2NIMQueryDirection - /** 分页偏移, 首次传空, 后续拉取采用上一次返回的 nextToken */ - nextToken?: string - /** 分页拉取数量 */ - limit?: number + /** 群成员类型 */ + roleQueryType?: V2NIMTeamMemberRoleQueryType + /** 是否只返回聊天禁言成员列表 */ + onlyChatBanned?: boolean + /** 消息查询方向 */ + direction?: V2NIMQueryDirection + /** 分页偏移, 首次传空, 后续拉取采用上一次返回的 nextToken */ + nextToken?: string + /** 分页拉取数量 */ + limit?: number } export interface V2NIMUpdateTeamInfoParams { - /** 新修改群组名称 */ - name?: string - /** 群组人数上限 */ - memberLimit?: number - /** 群组介绍 */ - intro?: string - /** 群组公告 */ - announcement?: string - /** 群组头像 */ - avatar?: string - /** 服务端扩展字段 */ - serverExtension?: string - /** 申请入群模式 */ - joinMode?: V2NIMTeamJoinMode - /** 被邀请人入群模式 */ - agreeMode?: V2NIMTeamAgreeMode - /** 群组邀请模式 */ - inviteMode?: V2NIMTeamInviteMode - /** 群组资料修改模式 */ - updateInfoMode?: V2NIMTeamUpdateInfoMode - /** 群组扩展字段修改模式 */ - updateExtensionMode?: V2NIMTeamUpdateExtensionMode + /** 新修改群组名称 */ + name?: string + /** 群组人数上限 */ + memberLimit?: number + /** 群组介绍 */ + intro?: string + /** 群组公告 */ + announcement?: string + /** 群组头像 */ + avatar?: string + /** 服务端扩展字段 */ + serverExtension?: string + /** 申请入群模式 */ + joinMode?: V2NIMTeamJoinMode + /** 被邀请人入群模式 */ + agreeMode?: V2NIMTeamAgreeMode + /** 群组邀请模式 */ + inviteMode?: V2NIMTeamInviteMode + /** 群组资料修改模式 */ + updateInfoMode?: V2NIMTeamUpdateInfoMode + /** 群组扩展字段修改模式 */ + updateExtensionMode?: V2NIMTeamUpdateExtensionMode } export interface V2NIMUpdatedTeamInfo extends V2NIMUpdateTeamInfoParams { - chatBannedMode?: V2NIMTeamChatBannedMode + chatBannedMode?: V2NIMTeamChatBannedMode } export interface V2NIMCreateTeamResult { - /** 被创建的群组信息 */ - team?: V2NIMTeam - /** 被邀请成员失败列表 */ - failedList?: Array + /** 被创建的群组信息 */ + team?: V2NIMTeam + /** 被邀请成员失败列表 */ + failedList?: Array } export interface V2NIMUpdateSelfMemberInfoParams { - /** 设置的群昵称 */ - teamNick?: string - /** 设置的群成员扩展字段 */ - serverExtension?: string + /** 设置的群昵称 */ + teamNick?: string + /** 设置的群成员扩展字段 */ + serverExtension?: string } export interface V2NIMTeamMemberListResult { - /** 数据是否拉取完毕 */ - finished?: boolean - /** 下一次查询的偏移量 */ - nextToken?: string - /** 拉取的成员列表 */ - memberList?: Array + /** 数据是否拉取完毕 */ + finished?: boolean + /** 下一次查询的偏移量 */ + nextToken?: string + /** 拉取的成员列表 */ + memberList?: Array } export interface V2NIMTeamJoinActionInfo { - /** 入群操作类型 */ - actionType?: V2NIMTeamJoinActionType - /** 群组ID */ - teamId?: string - /** 群组类型 */ - teamType?: V2NIMTeamType - /** 申请者账号 */ - operatorAccountId?: string - /** 申请入群的附言 */ - postscript?: string - /** 申请时间 */ - timestamp?: number - /** 操作状态 */ - actionStatus?: V2NIMTeamJoinActionStatus + /** 入群操作类型 */ + actionType?: V2NIMTeamJoinActionType + /** 群组ID */ + teamId?: string + /** 群组类型 */ + teamType?: V2NIMTeamType + /** 申请者账号 */ + operatorAccountId?: string + /** 申请入群的附言 */ + postscript?: string + /** 申请时间 */ + timestamp?: number + /** 操作状态 */ + actionStatus?: V2NIMTeamJoinActionStatus } export interface V2NIMAntispamConfig { - /** 易盾业务 ID */ - antispamBusinessId?: string + /** 易盾业务 ID */ + antispamBusinessId?: string } export interface V2NIMUser { - /** 账号 ID */ - accountId?: string - /** 用户昵称 */ - name?: string - /** 用户头像 */ - avatar?: string - /** 用户签名 */ - sign?: string - /** 用户邮箱 */ - email?: string - /** 用户生日 */ - birthday?: string - /** 用户手机号 */ - mobile?: string - /** 用户性别 */ - gender?: number - /** 用户扩展字段 */ - serverExtension?: string - /** 用户资料创建时间 */ - createTime?: number - /** 用户资料更新时间 */ - updateTime?: number + /** 账号 ID */ + accountId?: string + /** 用户昵称 */ + name?: string + /** 用户头像 */ + avatar?: string + /** 用户签名 */ + sign?: string + /** 用户邮箱 */ + email?: string + /** 用户生日 */ + birthday?: string + /** 用户手机号 */ + mobile?: string + /** 用户性别 */ + gender?: number + /** 用户扩展字段 */ + serverExtension?: string + /** 用户资料创建时间 */ + createTime?: number + /** 用户资料更新时间 */ + updateTime?: number } export interface V2NIMUserUpdateParams { - /** 用户昵称 */ - name?: string - /** 用户头像 */ - avatar?: string - /** 用户签名 */ - sign?: string - /** 用户邮箱 */ - email?: string - /** 用户生日 */ - birthday?: string - /** 用户手机号 */ - mobile?: string - /** 用户性别 */ - gender?: number - /** 用户扩展字段 */ - serverExtension?: string + /** 用户昵称 */ + name?: string + /** 用户头像 */ + avatar?: string + /** 用户签名 */ + sign?: string + /** 用户邮箱 */ + email?: string + /** 用户生日 */ + birthday?: string + /** 用户手机号 */ + mobile?: string + /** 用户性别 */ + gender?: number + /** 用户扩展字段 */ + serverExtension?: string } export interface V2NIMUserSearchOption { - /** 搜索关键字 */ - keyword?: string - /** 是否搜索用户昵称,默认为 true */ - searchName?: boolean - /** 是否搜索用户账号 */ - searchAccountId?: boolean - /** 是否搜索手机号 */ - searchMobile?: boolean + /** 搜索关键字 */ + keyword?: string + /** 是否搜索用户昵称,默认为 true */ + searchName?: boolean + /** 是否搜索用户账号 */ + searchAccountId?: boolean + /** 是否搜索手机号 */ + searchMobile?: boolean } export interface V2NIMFriend { - /** 好友账号 */ - accountId?: string - /** 好友备注 */ - alias?: string - /** 好友扩展字段 */ - serverExtension?: string - /** 用户扩展字段 */ - customerExtension?: string - /** 创建时间 */ - createTime?: number - /** 更新时间 */ - updateTime?: number - /** 好友对应的用户信息 */ - userProfile: V2NIMUser + /** 好友账号 */ + accountId?: string + /** 好友备注 */ + alias?: string + /** 好友扩展字段 */ + serverExtension?: string + /** 用户扩展字段 */ + customerExtension?: string + /** 创建时间 */ + createTime?: number + /** 更新时间 */ + updateTime?: number + /** 好友对应的用户信息 */ + userProfile: V2NIMUser } export interface V2NIMFriendAddParams { - /** 添加好友模式 */ - addMode?: V2NIMFriendAddMode - /** 添加/申请添加好友的附言 */ - postscript?: string + /** 添加好友模式 */ + addMode?: V2NIMFriendAddMode + /** 添加/申请添加好友的附言 */ + postscript?: string } export interface V2NIMFriendAddApplication { - /** 申请者账号 */ - applicantAccountId: string - /** 被申请者账号 */ - recipientAccountId: string - /** 操作者账号 */ - operatorAccountId?: string - /** 附言 */ - postscript?: string - /** 状态 */ - status?: V2NIMFriendAddApplicationStatus - /** 时间 */ - timestamp?: number - /** 是否已读 */ - read?: boolean; + /** 申请者账号 */ + applicantAccountId: string + /** 被申请者账号 */ + recipientAccountId: string + /** 操作者账号 */ + operatorAccountId?: string + /** 附言 */ + postscript?: string + /** 状态 */ + status?: V2NIMFriendAddApplicationStatus + /** 时间 */ + timestamp?: number + /** 是否已读 */ + read?: boolean; } export interface V2NIMFriendDeleteParams { - /** 是否删除备注 */ - deleteAlias?: boolean + /** 是否删除备注 */ + deleteAlias?: boolean } export interface V2NIMFriendSetParams { - /** 别名 */ - alias?: string - /** 扩展字段 */ - serverExtension?: string + /** 别名 */ + alias?: string + /** 扩展字段 */ + serverExtension?: string } export interface V2NIMFriendSearchOption { - /** 搜索关键字,默认搜索好友备注,可以指定是否同时搜索用户账号 */ - keyword?: string - /** 是否搜索好友备注,默认为 true */ - searchAlias?: boolean - /** 查询账号,默认为 false */ - searchAccountId?: boolean + /** 搜索关键字,默认搜索好友备注,可以指定是否同时搜索用户账号 */ + keyword?: string + /** 是否搜索好友备注,默认为 true */ + searchAlias?: boolean + /** 查询账号,默认为 false */ + searchAccountId?: boolean } export interface V2NIMTeamJoinActionInfoQueryOption { - /** 查询类型 */ - types?: Array - /** 分页偏移 */ - offset?: number - /** 查询数量 */ - limit?: number - /** 查询状态 */ - status?: Array + /** 查询类型 */ + types?: Array + /** 分页偏移 */ + offset?: number + /** 查询数量 */ + limit?: number + /** 查询状态 */ + status?: Array } export interface V2NIMTeamJoinActionInfoResult { - /** 查询返回的列表 */ - infos?: Array - /** 下一次的偏移量 */ - offset?: number - /** 分页结束 */ - finished?: boolean + /** 查询返回的列表 */ + infos?: Array + /** 下一次的偏移量 */ + offset?: number + /** 分页结束 */ + finished?: boolean } export interface V2NIMTeamMemberSearchOption { - /** 搜索关键词,不为空 */ - keyword: string - /** 群组类型 */ - teamType: V2NIMTeamType - /** 群组ID,如果不传则检索所有群,如果需要检索特定的群,则需要同时传入 teamId + teamType */ - teamId?: string - // 起始位置,首次传空, 后续传上次返回的 nextToken - nextToken: string - /** 按照 joinTime 排序,默认时间降序排列 */ - order: V2NIMSortOrder - /** 查询成员的个数,默认 10 */ - limit: number + /** 搜索关键词,不为空 */ + keyword: string + /** 群组类型 */ + teamType: V2NIMTeamType + /** 群组ID,如果不传则检索所有群,如果需要检索特定的群,则需要同时传入 teamId + teamType */ + teamId?: string + // 起始位置,首次传空, 后续传上次返回的 nextToken + nextToken: string + /** 按照 joinTime 排序,默认时间降序排列 */ + order: V2NIMSortOrder + /** 查询成员的个数,默认 10 */ + limit: number } export interface V2NIMFriendAddApplicationQueryOption { - /** 分页偏移 */ - offset?: number - /** 查询数量 */ - limit?: number - /** 查询状态 */ - status?: Array + /** 分页偏移 */ + offset?: number + /** 查询数量 */ + limit?: number + /** 查询状态 */ + status?: Array } export interface V2NIMFriendAddApplicationResult { - /** 查询返回的列表 */ - infos?: Array - /** 下一次的偏移量 */ - offset?: number - /** 分页结束 */ - finished?: boolean + /** 查询返回的列表 */ + infos?: Array + /** 下一次的偏移量 */ + offset?: number + /** 分页结束 */ + finished?: boolean } export interface V2NIMChatroomLoginOption { - [x: string]: any + [x: string]: any - /** 认证模式 */ - authType?: V2NIMLoginAuthType - /** token 获取回调 */ - tokenProvider?: V2NIMChatroomTokenProvider - /** 登陆扩展回调 */ - loginExtensionProvider?: V2NIMChatroomLoginExtensionProvider + /** 认证模式 */ + authType?: V2NIMLoginAuthType + /** token 获取回调 */ + tokenProvider?: V2NIMChatroomTokenProvider + /** 登陆扩展回调 */ + loginExtensionProvider?: V2NIMChatroomLoginExtensionProvider } export interface V2NIMChatroomTagConfig { - /** 登陆标签 */ - tags?: Array - /** 登录登出通知标签 */ - notifyTargetTags?: string + /** 登陆标签 */ + tags?: Array + /** 登录登出通知标签 */ + notifyTargetTags?: string } export interface V2NIMLocationInfo { - /** 空间坐标 X */ - x?: number - /** 空间坐标 Y */ - y?: number - /** 空间坐标 Z */ - z?: number + /** 空间坐标 X */ + x?: number + /** 空间坐标 Y */ + y?: number + /** 空间坐标 Z */ + z?: number } export interface V2NIMChatroomLocationConfig { - /** 空间坐标信息 */ - locationInfo?: V2NIMLocationInfo - /** 订阅的消息的距离 */ - distance?: number + /** 空间坐标信息 */ + locationInfo?: V2NIMLocationInfo + /** 订阅的消息的距离 */ + distance?: number } export interface V2NIMChatroomEnterParams { - [x: string]: any - - /** 账号 ID */ - accountId?: string - /** 静态 token */ - token?: string - /** 进入聊天室后显示的昵称 */ - roomNick?: string - /** 进入聊天室后显示的头像 */ - roomAvatar?: string - /** 登录超时, 单位毫秒 */ - timeout?: number - /** 聊天室登录相关信息 */ - loginOption?: V2NIMChatroomLoginOption - /** 匿名模式 */ - anonymousMode?: boolean - /** 获取聊天室 link 链接地址 */ - linkProvider?: V2NIMChatroomLinkProvider - /** 用户扩展字段 */ - serverExtension?: string - /** 通知扩展字段 */ - notificationExtension?: string - /** 进入聊天室标签信息配置 */ - tagConfig?: V2NIMChatroomTagConfig - /** 进入聊天室空间位置信息配置 */ - locationConfig?: V2NIMChatroomLocationConfig - /** 反垃圾配置信息 */ - antispamConfig?: V2NIMAntispamConfig + [x: string]: any + + /** 账号 ID */ + accountId?: string + /** 静态 token */ + token?: string + /** 进入聊天室后显示的昵称 */ + roomNick?: string + /** 进入聊天室后显示的头像 */ + roomAvatar?: string + /** 登录超时, 单位毫秒 */ + timeout?: number + /** 聊天室登录相关信息 */ + loginOption?: V2NIMChatroomLoginOption + /** 匿名模式 */ + anonymousMode?: boolean + /** 获取聊天室 link 链接地址 */ + linkProvider?: V2NIMChatroomLinkProvider + /** 用户扩展字段 */ + serverExtension?: string + /** 通知扩展字段 */ + notificationExtension?: string + /** 进入聊天室标签信息配置 */ + tagConfig?: V2NIMChatroomTagConfig + /** 进入聊天室空间位置信息配置 */ + locationConfig?: V2NIMChatroomLocationConfig + /** 反垃圾配置信息 */ + antispamConfig?: V2NIMAntispamConfig } export interface V2NIMChatroomInfo { - /** 聊天室 ID */ - roomId?: string - /** 聊天室名称 */ - roomName?: string - /** 聊天室公告 */ - announcement?: string - /** 视频直播拉流地址 */ - liveUrl?: string - /** 聊天室是否有效 */ - isValidRoom?: boolean - /** 聊天室扩展字段 */ - serverExtension?: string - /** 聊天室队列操作权限模式 */ - queueLevelMode?: V2NIMChatroomQueueLevelMode - /** 聊天室创建者账号 ID */ - creatorAccountId?: string - /** 聊天室当前在线用户数量 */ - onlineUserCount?: number - /** 聊天室禁言状态 */ - chatBanned?: boolean + /** 聊天室 ID */ + roomId?: string + /** 聊天室名称 */ + roomName?: string + /** 聊天室公告 */ + announcement?: string + /** 视频直播拉流地址 */ + liveUrl?: string + /** 聊天室是否有效 */ + isValidRoom?: boolean + /** 聊天室扩展字段 */ + serverExtension?: string + /** 聊天室队列操作权限模式 */ + queueLevelMode?: V2NIMChatroomQueueLevelMode + /** 聊天室创建者账号 ID */ + creatorAccountId?: string + /** 聊天室当前在线用户数量 */ + onlineUserCount?: number + /** 聊天室禁言状态 */ + chatBanned?: boolean } export interface V2NIMChatroomEnterInfo { - /** 进入聊天室后显示的昵称 */ - roomNick?: string - /** 进入聊天室后显示的头像 */ - roomAvatar?: string - /** 用户进入聊天室的时间点 */ - enterTime?: number - /** 进入的终端类型 */ - clientType?: number + /** 进入聊天室后显示的昵称 */ + roomNick?: string + /** 进入聊天室后显示的头像 */ + roomAvatar?: string + /** 用户进入聊天室的时间点 */ + enterTime?: number + /** 进入的终端类型 */ + clientType?: number } export interface V2NIMChatroomMember { - /** 聊天室 ID */ - roomId?: string - /** 成员账号 ID */ - accountId?: string - /** 聊天室成员角色 */ - memberRole?: V2NIMChatroomMemberRole - /** 成员等级, 0 表示未设置 */ - memberLevel?: number - /** 进入聊天室后显示的昵称 */ - roomNick?: string - /** 进入聊天室后显示的头像 */ - roomAvatar?: string - /** 聊天室成员扩展字段 */ - serverExtension?: string - /** 用户是否在线 */ - isOnline?: boolean - /** 是否在黑名单中 */ - blocked?: boolean - /** 是否禁言 */ - chatBanned?: boolean - /** 是否临时禁言 */ - tempChatBanned?: boolean - /** 临时禁言时长, 单位秒 */ - tempChatBannedDuration?: number - /** 登录标签 */ - tags?: Array - /** 登录登出通知标签 */ - notifyTargetTags?: string - /** 用户进入聊天室的时间点 */ - enterTime?: number - /** 更新时间 */ - updateTime?: number - /** 是否有效 */ - valid?: boolean - /** 多端登录信息 */ - multiEnterInfo?: Array + /** 聊天室 ID */ + roomId?: string + /** 成员账号 ID */ + accountId?: string + /** 聊天室成员角色 */ + memberRole?: V2NIMChatroomMemberRole + /** 成员等级, 0 表示未设置 */ + memberLevel?: number + /** 进入聊天室后显示的昵称 */ + roomNick?: string + /** 进入聊天室后显示的头像 */ + roomAvatar?: string + /** 聊天室成员扩展字段 */ + serverExtension?: string + /** 用户是否在线 */ + isOnline?: boolean + /** 是否在黑名单中 */ + blocked?: boolean + /** 是否禁言 */ + chatBanned?: boolean + /** 是否临时禁言 */ + tempChatBanned?: boolean + /** 临时禁言时长, 单位秒 */ + tempChatBannedDuration?: number + /** 登录标签 */ + tags?: Array + /** 登录登出通知标签 */ + notifyTargetTags?: string + /** 用户进入聊天室的时间点 */ + enterTime?: number + /** 更新时间 */ + updateTime?: number + /** 是否有效 */ + valid?: boolean + /** 多端登录信息 */ + multiEnterInfo?: Array } export interface V2NIMChatroomCdnInfo { - enabled?: boolean - cdnUrls?: Array - timestamp?: number - pollingInterval?: number // seconds - decryptType?: number - decryptKey?: string - pollingTimeout?: number // milliseconds + enabled?: boolean + cdnUrls?: Array + timestamp?: number + pollingInterval?: number // seconds + decryptType?: number + decryptKey?: string + pollingTimeout?: number // milliseconds } export interface V2NIMChatroomEnterResult { - /** 聊天室信息 */ - chatroom?: V2NIMChatroomInfo - /** 用户信息 */ - selfMember?: V2NIMChatroomMember + /** 聊天室信息 */ + chatroom?: V2NIMChatroomInfo + /** 用户信息 */ + selfMember?: V2NIMChatroomMember } export interface V2NIMChatroomKickedInfo { - /** 被踢原因 */ - kickedReason?: V2NIMChatroomKickedReason - /** 被踢扩展字段 */ - serverExtension?: string + /** 被踢原因 */ + kickedReason?: V2NIMChatroomKickedReason + /** 被踢扩展字段 */ + serverExtension?: string } export interface V2NIMUserInfoConfig { - /** 消息发送者 uinfo 的最后更新时间 */ - userInfoTimestamp?: number - /** 发送方昵称 */ - senderNick?: string - /** 发送方头像 */ - senderAvatar?: string - /** 发送方扩展字段 */ - senderExtension?: string + /** 消息发送者 uinfo 的最后更新时间 */ + userInfoTimestamp?: number + /** 发送方昵称 */ + senderNick?: string + /** 发送方头像 */ + senderAvatar?: string + /** 发送方扩展字段 */ + senderExtension?: string } export interface V2NIMChatroomMessageConfig { - /** 是否需要在服务端保存历史消息 */ - historyEnabled?: boolean - /** 是否是高优先级消息 */ - highPriority?: boolean + /** 是否需要在服务端保存历史消息 */ + historyEnabled?: boolean + /** 是否是高优先级消息 */ + highPriority?: boolean } export interface V2NIMChatroomMessage { - /** 客户端消息 ID */ - messageClientId?: string - /** 消息发送方客户端类型 */ - senderClientType?: V2NIMLoginClientType - /** 消息时间, 单位毫秒 */ - createTime?: number - /** 消息发送者账号 */ - senderId?: string - /** 聊天室 ID */ - roomId?: string - /** 消息发送者是否是自己 */ - isSelf?: boolean - /** 附件上传状态 */ - attachmentUploadState?: V2NIMMessageAttachmentUploadState - /** 消息发送状态 */ - sendingState?: V2NIMMessageSendingState - /** 消息类型 */ - messageType?: V2NIMMessageType - /** 消息子类型 */ - subType?: number - /** 消息内容 */ - text?: string - /** 消息附属附件 */ - attachment?: V2NIMMessageAttachment - /** 服务端扩展 */ - serverExtension?: string - /** 第三方扩展字段 */ - callbackExtension?: string - /** 路由抄送相关配置 */ - routeConfig?: V2NIMMessageRouteConfig - /** 反垃圾相关配置 */ - antispamConfig?: V2NIMMessageAntispamConfig - /** 消息的目标标签表达式 */ - notifyTargetTags?: string - /** 聊天室消息配置 */ - messageConfig?: V2NIMChatroomMessageConfig - /** 消息发送时的用户信息 */ - userInfoConfig?: V2NIMUserInfoConfig - /** 消息空间坐标信息配置 */ - locationInfo?: V2NIMLocationInfo + /** 客户端消息 ID */ + messageClientId?: string + /** 消息发送方客户端类型 */ + senderClientType?: V2NIMLoginClientType + /** 消息时间, 单位毫秒 */ + createTime?: number + /** 消息发送者账号 */ + senderId?: string + /** 聊天室 ID */ + roomId?: string + /** 消息发送者是否是自己 */ + isSelf?: boolean + /** 附件上传状态 */ + attachmentUploadState?: V2NIMMessageAttachmentUploadState + /** 消息发送状态 */ + sendingState?: V2NIMMessageSendingState + /** 消息类型 */ + messageType?: V2NIMMessageType + /** 消息子类型 */ + subType?: number + /** 消息内容 */ + text?: string + /** 消息附属附件 */ + attachment?: V2NIMMessageAttachment + /** 服务端扩展 */ + serverExtension?: string + /** 第三方扩展字段 */ + callbackExtension?: string + /** 路由抄送相关配置 */ + routeConfig?: V2NIMMessageRouteConfig + /** 反垃圾相关配置 */ + antispamConfig?: V2NIMMessageAntispamConfig + /** 消息的目标标签表达式 */ + notifyTargetTags?: string + /** 聊天室消息配置 */ + messageConfig?: V2NIMChatroomMessageConfig + /** 消息发送时的用户信息 */ + userInfoConfig?: V2NIMUserInfoConfig + /** 消息空间坐标信息配置 */ + locationInfo?: V2NIMLocationInfo } export interface V2NIMSendChatroomMessageParams { - /** 消息相关配置 */ - messageConfig?: V2NIMChatroomMessageConfig - /** 路由抄送相关配置 */ - routeConfig?: V2NIMMessageRouteConfig - /** 反垃圾相关配置 */ - antispamConfig?: V2NIMMessageAntispamConfig - /** 是否启用本地反垃圾 */ - clientAntispamEnabled?: boolean - /** 反垃圾命中后替换的文本 */ - clientAntispamReplace?: string - /** 定向消息接收者账号列表, 为空表示不定向, 定向消息不存历史 */ - receiverIds?: Array - /** 消息的目标标签表达式 */ - notifyTargetTags?: string - /** 消息空间坐标信息配置 */ - locationInfo?: V2NIMLocationInfo + /** 消息相关配置 */ + messageConfig?: V2NIMChatroomMessageConfig + /** 路由抄送相关配置 */ + routeConfig?: V2NIMMessageRouteConfig + /** 反垃圾相关配置 */ + antispamConfig?: V2NIMMessageAntispamConfig + /** 是否启用本地反垃圾 */ + clientAntispamEnabled?: boolean + /** 反垃圾命中后替换的文本 */ + clientAntispamReplace?: string + /** 定向消息接收者账号列表, 为空表示不定向, 定向消息不存历史 */ + receiverIds?: Array + /** 消息的目标标签表达式 */ + notifyTargetTags?: string + /** 消息空间坐标信息配置 */ + locationInfo?: V2NIMLocationInfo } export interface V2NIMSendChatroomMessageResult { - /** 发送成功后的消息体 */ - message?: V2NIMChatroomMessage - /** 云端反垃圾返回的结果 */ - antispamResult?: string - /** 客户端本地反垃圾结果 */ - clientAntispamResult?: V2NIMClientAntispamResult + /** 发送成功后的消息体 */ + message?: V2NIMChatroomMessage + /** 云端反垃圾返回的结果 */ + antispamResult?: string + /** 客户端本地反垃圾结果 */ + clientAntispamResult?: V2NIMClientAntispamResult } export interface V2NIMChatroomMemberQueryOption { - /** 需要查询的成员类型 */ - memberRoles?: Array - /** 是否只返回黑名单成员 */ - onlyBlocked?: boolean - /** 是否只返回禁言用户 */ - onlyChatBanned?: boolean - /** 是否只查询在线成员 */ - onlyOnline?: boolean - /** 偏移量 */ - pageToken?: string - /** 查询数量 */ - limit?: number + /** 需要查询的成员类型 */ + memberRoles?: Array + /** 是否只返回黑名单成员 */ + onlyBlocked?: boolean + /** 是否只返回禁言用户 */ + onlyChatBanned?: boolean + /** 是否只查询在线成员 */ + onlyOnline?: boolean + /** 偏移量 */ + pageToken?: string + /** 查询数量 */ + limit?: number } export interface V2NIMChatroomMemberListResult { - /** 下一次查询的偏移量 */ - pageToken?: string - /** 数据是否拉取完毕 */ - finished?: boolean - /** 拉取的成员列表 */ - memberList?: Array + /** 下一次查询的偏移量 */ + pageToken?: string + /** 数据是否拉取完毕 */ + finished?: boolean + /** 拉取的成员列表 */ + memberList?: Array } export interface V2NIMChatroomMessageListOption { - /** 消息查询方向 */ - direction?: V2NIMQueryDirection - /** 消息类型 */ - messageTypes?: Array - /** 开始时间 */ - beginTime?: number - /** 查询数量 */ - limit?: number + /** 消息查询方向 */ + direction?: V2NIMQueryDirection + /** 消息类型 */ + messageTypes?: Array + /** 开始时间 */ + beginTime?: number + /** 查询数量 */ + limit?: number } export interface V2NIMChatroomMemberRoleUpdateParams { - /** 设置的成员角色 */ - memberRole?: V2NIMChatroomMemberRole - /** 设置用户等级 */ - memberLevel?: number - /** 通知扩展字段 */ - notificationExtension?: string + /** 设置的成员角色 */ + memberRole?: V2NIMChatroomMemberRole + /** 设置用户等级 */ + memberLevel?: number + /** 通知扩展字段 */ + notificationExtension?: string } export interface V2NIMChatroomUpdateParams { - /** 聊天室名称 */ - roomName?: string - /** 聊天室公告 */ - announcement?: string - /** 聊天室直播地址 */ - liveUrl?: string - /** 聊天室扩展字段 */ - serverExtension?: string - /** 是否需要通知 */ - notificationEnabled?: boolean - /** 本次操作生成的通知中的扩展字段 */ - notificationExtension?: string + /** 聊天室名称 */ + roomName?: string + /** 聊天室公告 */ + announcement?: string + /** 聊天室直播地址 */ + liveUrl?: string + /** 聊天室扩展字段 */ + serverExtension?: string + /** 是否需要通知 */ + notificationEnabled?: boolean + /** 本次操作生成的通知中的扩展字段 */ + notificationExtension?: string } export interface V2NIMChatroomSelfMemberUpdateParams { - /** 聊天室显示的昵称 */ - roomNick?: string - /** 聊天室显示的头像 */ - roomAvatar?: string - /** 成员扩展字段 */ - serverExtension?: string - /** 是否需要通知 */ - notificationEnabled?: boolean - /** 本次操作生成的通知中的扩展字段 */ - notificationExtension?: string - /** 更新信息持久化 */ - persistence?: boolean + /** 聊天室显示的昵称 */ + roomNick?: string + /** 聊天室显示的头像 */ + roomAvatar?: string + /** 成员扩展字段 */ + serverExtension?: string + /** 是否需要通知 */ + notificationEnabled?: boolean + /** 本次操作生成的通知中的扩展字段 */ + notificationExtension?: string + /** 更新信息持久化 */ + persistence?: boolean } export interface V2NIMChatroomTagTempChatBannedParams { - /** 禁言的 tag */ - targetTag?: string - /** 消息的目标标签表达式 */ - notifyTargetTags?: string - /** 禁言时长, 单位秒 */ - duration?: number - /** 是否需要通知 */ - notificationEnabled?: boolean - /** 本次操作生成的通知中的扩展字段 */ - notificationExtension?: string + /** 禁言的 tag */ + targetTag?: string + /** 消息的目标标签表达式 */ + notifyTargetTags?: string + /** 禁言时长, 单位秒 */ + duration?: number + /** 是否需要通知 */ + notificationEnabled?: boolean + /** 本次操作生成的通知中的扩展字段 */ + notificationExtension?: string } export interface V2NIMChatroomTagsUpdateParams { - /** 标签 */ - tags?: Array - /** 消息的目标标签表达式 */ - notifyTargetTags?: string - /** 是否需要通知 */ - notificationEnabled?: boolean - /** 本次操作生成的通知中的扩展字段 */ - notificationExtension?: string + /** 标签 */ + tags?: Array + /** 消息的目标标签表达式 */ + notifyTargetTags?: string + /** 是否需要通知 */ + notificationEnabled?: boolean + /** 本次操作生成的通知中的扩展字段 */ + notificationExtension?: string } export interface V2NIMChatroomTagMemberOption { - /** 标签 */ - tag?: string - /** 偏移量 */ - pageToken?: string - /** 查询条数 */ - limit?: number + /** 标签 */ + tag?: string + /** 偏移量 */ + pageToken?: string + /** 查询条数 */ + limit?: number } export interface V2NIMChatroomTagMessageOption { - /** 查询的标签 */ - tags?: Array - /** 消息类型 */ - messageTypes?: Array - /** 查询起始时间 */ - beginTime?: number - /** 查询结束时间 */ - endTime?: number - /** 查询条数 */ - limit?: number - /** 查询方向 */ - direction?: V2NIMQueryDirection + /** 查询的标签 */ + tags?: Array + /** 消息类型 */ + messageTypes?: Array + /** 查询起始时间 */ + beginTime?: number + /** 查询结束时间 */ + endTime?: number + /** 查询条数 */ + limit?: number + /** 查询方向 */ + direction?: V2NIMQueryDirection } export interface V2NIMClientAntispamThesaurusItem { - key?: string - matchType?: V2NIMClientAntispamThesaurusMatchType - operateType?: V2NIMClientAntispamOperateType - config?: string + key?: string + matchType?: V2NIMClientAntispamThesaurusMatchType + operateType?: V2NIMClientAntispamOperateType + config?: string } export interface V2NIMClientAntispamThesaurus { - name?: string - config?: string - items?: Array + name?: string + config?: string + items?: Array } export interface V2NIMChatroomQueueOfferParams { - /** 元素的唯一key */ - elementKey?: string - /** 元素的值 */ - elementValue?: string - /** 元素是否瞬态的 */ - transient?: boolean - /** 元素属于的账号 */ - elementOwnerAccountId?: string + /** 元素的唯一key */ + elementKey?: string + /** 元素的值 */ + elementValue?: string + /** 元素是否瞬态的 */ + transient?: boolean + /** 元素属于的账号 */ + elementOwnerAccountId?: string +} + +export interface V2NIMChatroomQueueElement { + /** 元素的唯一 key */ + key: string + /** 元素的值 */ + value: string + /** 该元素所属于的账号 */ + accountId?: string + /** 该元素所属于的账号的昵称 */ + nick?: string + /** 其他的扩展字段 JSON String */ + extension?: string } export interface V2NIMUploadFileParams { - /** 文件地址 */ - filePath?: string - /** 场景名 */ - sceneName?: string + /** 文件地址 */ + filePath?: string + /** 场景名 */ + sceneName?: string } export interface V2NIMUploadFileTask { - /** 上传任务 ID */ - taskId?: string - /** 上传任务参数 */ - uploadParams?: V2NIMUploadFileParams + /** 上传任务 ID */ + taskId?: string + /** 上传任务参数 */ + uploadParams?: V2NIMUploadFileParams } export interface V2NIMDownloadMessageAttachmentParams { - /** 消息附件信息 */ - attachment: V2NIMMessageAttachment - /** 要下载附件的类型 */ - type: V2NIMDownloadAttachmentType - /** 如果下载的是缩略图或者视频封面,通过该参数指定缩略图大小或视频封面大小 */ - thumbSize?: V2NIMSize - /** 消息客户端 ID,如果指定了该参数将下载完成后的本地附件保存路径更新到消息数据库中,下一次查询时将直接返回对应的路径 */ - messageClientId?: string - /** 附件保存路径,如未指定 SDK 将下载到登录用户缓存目录,如指定该参数则以指定的路径为准 */ - saveAs?: string + /** 消息附件信息 */ + attachment: V2NIMMessageAttachment + /** 要下载附件的类型 */ + type: V2NIMDownloadAttachmentType + /** 如果下载的是缩略图或者视频封面,通过该参数指定缩略图大小或视频封面大小 */ + thumbSize?: V2NIMSize + /** 消息客户端 ID,如果指定了该参数将下载完成后的本地附件保存路径更新到消息数据库中,下一次查询时将直接返回对应的路径 */ + messageClientId?: string + /** 附件保存路径,如未指定 SDK 将下载到登录用户缓存目录,如指定该参数则以指定的路径为准 */ + saveAs?: string } export interface V2NIMGetMediaResourceInfoResult { - /** 附件资源完整下载地址 */ - url: string - /** 下载该资源所需的鉴权信息,当列表为空时则代表不需要鉴权,若不为空则需要将该列表添加到请求时的 Header 中 */ - authHeaders: Array + /** 附件资源完整下载地址 */ + url: string + /** 下载该资源所需的鉴权信息,当列表为空时则代表不需要鉴权,若不为空则需要将该列表添加到请求时的 Header 中 */ + authHeaders: Array } export interface V2NIMDndConfig { - /** 是否显示详情 */ - showDetail: boolean - /** 免打扰是否开启 */ - dndOn: boolean - /** 如果开启免打扰,开始小时数 (Integer) */ - fromH: number - /** 如果开启免打扰,开始分钟数 (Integer) */ - fromM: number - /** 如果开启免打扰,截止小时数 (Integer) */ - toH: number - /** 如果开启免打扰,截止分钟数 (Integer) */ - toM: number + /** 是否显示详情 */ + showDetail: boolean + /** 免打扰是否开启 */ + dndOn: boolean + /** 如果开启免打扰,开始小时数 (Integer) */ + fromH: number + /** 如果开启免打扰,开始分钟数 (Integer) */ + fromM: number + /** 如果开启免打扰,截止小时数 (Integer) */ + toH: number + /** 如果开启免打扰,截止分钟数 (Integer) */ + toM: number } export interface V2NIMSignallingConfig { - /** 是否需要存离线消息 */ - offlineEnabled?: boolean - /** 是否需要计未读 */ - unreadEnabled?: boolean - /** 用户 UID */ - selfUid?: number + /** 是否需要存离线消息 */ + offlineEnabled?: boolean + /** 是否需要计未读 */ + unreadEnabled?: boolean + /** 用户 UID */ + selfUid?: number } export interface V2NIMSignallingPushConfig { - /** 是否需要推送 */ - pushEnabled?: boolean - /** 推送标题 */ - pushTitle?: string - /** 推送文案 */ - pushContent?: string - /** 推送数据 */ - pushPayload?: string + /** 是否需要推送 */ + pushEnabled?: boolean + /** 推送标题 */ + pushTitle?: string + /** 推送文案 */ + pushContent?: string + /** 推送数据 */ + pushPayload?: string } export interface V2NIMSignallingRtcConfig { - /** 云信音视频房间频道名称 */ - rtcChannelName?: string - /** 音视频房间 token 过期时间 */ - rtcTokenTtl?: number - /** JSON 格式字符串,音视频 SDK 相关参数,IM 信令仅透传相关参数 */ - rtcParams?: string + /** 云信音视频房间频道名称 */ + rtcChannelName?: string + /** 音视频房间 token 过期时间 */ + rtcTokenTtl?: number + /** JSON 格式字符串,音视频 SDK 相关参数,IM 信令仅透传相关参数 */ + rtcParams?: string } export interface V2NIMSignallingCallParams { - /** 被呼叫者账号 ID */ - calleeAccountId: string - /** 请求 ID,可以用 UUID 实现 */ - requestId: string - /** 频道类型 */ - channelType: V2NIMSignallingChannelType - /** 频道名称,建议使用与业务有相关场景的名称,便于页面显示 */ - channelName?: string - /** 频道相关扩展字段,长度限制 4096,跟频道绑定,JSON 格式 */ - channelExtension?: string - /** 服务器扩展字段,长度限制 4096,JSON 格式 */ - serverExtension?: string - /** 信令相关配置 */ - signallingConfig?: V2NIMSignallingConfig - /** 推送相关配置 */ - pushConfig?: V2NIMSignallingPushConfig - /** 音视频相关参数配置 */ - rtcConfig?: V2NIMSignallingRtcConfig + /** 被呼叫者账号 ID */ + calleeAccountId: string + /** 请求 ID,可以用 UUID 实现 */ + requestId: string + /** 频道类型 */ + channelType: V2NIMSignallingChannelType + /** 频道名称,建议使用与业务有相关场景的名称,便于页面显示 */ + channelName?: string + /** 频道相关扩展字段,长度限制 4096,跟频道绑定,JSON 格式 */ + channelExtension?: string + /** 服务器扩展字段,长度限制 4096,JSON 格式 */ + serverExtension?: string + /** 信令相关配置 */ + signallingConfig?: V2NIMSignallingConfig + /** 推送相关配置 */ + pushConfig?: V2NIMSignallingPushConfig + /** 音视频相关参数配置 */ + rtcConfig?: V2NIMSignallingRtcConfig } export interface V2NIMSignallingChannelInfo { - /** 信令频道 ID,唯一标识了该频道房间,后续主要以该字段作为请求标识 */ - channelId: string - /** 频道类型 */ - channelType: V2NIMSignallingChannelType - /** 信令频道名称,如果请求时不传,则该字段为空 */ - channelName?: string - /** 频道相关扩展字段,长度限制 4096,JSON 格式 */ - channelExtension?: string - /** 频道房间创建时间 */ - createTime: number - /** 频道房间过期时间 */ - expireTime: number - /** 创建者账号 ID */ - creatorAccountId: string + /** 信令频道 ID,唯一标识了该频道房间,后续主要以该字段作为请求标识 */ + channelId: string + /** 频道类型 */ + channelType: V2NIMSignallingChannelType + /** 信令频道名称,如果请求时不传,则该字段为空 */ + channelName?: string + /** 频道相关扩展字段,长度限制 4096,JSON 格式 */ + channelExtension?: string + /** 频道房间创建时间 */ + createTime: number + /** 频道房间过期时间 */ + expireTime: number + /** 创建者账号 ID */ + creatorAccountId: string } export interface V2NIMSignallingMember { - /** 成员账号 ID */ - accountId: string - /** 成员 UID */ - uid: number - /** 用户加入信令频道房间时间 */ - joinTime: number - /** 用户信令频道房间过期时间 */ - expireTime: number - /** 成员操作的设备 ID */ - deviceId: string + /** 成员账号 ID */ + accountId: string + /** 成员 UID */ + uid: number + /** 用户加入信令频道房间时间 */ + joinTime: number + /** 用户信令频道房间过期时间 */ + expireTime: number + /** 成员操作的设备 ID */ + deviceId: string } export interface V2NIMSignallingRoomInfo { - /** 频道房间相关信息 */ - channelInfo: V2NIMSignallingChannelInfo - /** 成员列表信息 */ - members: Array + /** 频道房间相关信息 */ + channelInfo: V2NIMSignallingChannelInfo + /** 成员列表信息 */ + members: Array } export interface V2NIMSignallingRtcInfo { - /** 进入音视频对应的 token */ - rtcToken?: string - /** 音视频房间 token 过期时间 */ - rtcTokenTtl?: number - /** JSON 格式字符串,音视频SDK相关参数,IM 信令仅透传相关参数 */ - rtcParams?: string + /** 进入音视频对应的 token */ + rtcToken?: string + /** 音视频房间 token 过期时间 */ + rtcTokenTtl?: number + /** JSON 格式字符串,音视频SDK相关参数,IM 信令仅透传相关参数 */ + rtcParams?: string } export interface V2NIMSignallingCallResult { - /** 频道房间相关信息 */ - roomInfo: V2NIMSignallingRoomInfo - /** 音视频房间相关信息 */ - rtcInfo?: V2NIMSignallingRtcInfo - /** 呼叫状态 */ - callStatus: number + /** 频道房间相关信息 */ + roomInfo: V2NIMSignallingRoomInfo + /** 音视频房间相关信息 */ + rtcInfo?: V2NIMSignallingRtcInfo + /** 呼叫状态 */ + callStatus: number } export interface V2NIMSignallingCallSetupParams { - /** 信令频道 ID,唯一标识了该频道房间 */ - channelId: string - /** 接受的呼叫者账号 ID */ - callerAccountId: string - /** 请求 ID,可以用 UUID 实现 */ - requestId: string - /** 服务器扩展字段,长度限制 4096,JSON 格式 */ - serverExtension?: string - /** 信令相关配置 */ - signallingConfig?: V2NIMSignallingConfig - /** 音视频相关参数配置 */ - rtcConfig?: V2NIMSignallingRtcConfig + /** 信令频道 ID,唯一标识了该频道房间 */ + channelId: string + /** 接受的呼叫者账号 ID */ + callerAccountId: string + /** 请求 ID,可以用 UUID 实现 */ + requestId: string + /** 服务器扩展字段,长度限制 4096,JSON 格式 */ + serverExtension?: string + /** 信令相关配置 */ + signallingConfig?: V2NIMSignallingConfig + /** 音视频相关参数配置 */ + rtcConfig?: V2NIMSignallingRtcConfig } export interface V2NIMSignallingCallSetupResult { - /** 频道房间相关信息 */ - roomInfo: V2NIMSignallingRoomInfo - /** 音视频房间相关信息 */ - rtcInfo?: V2NIMSignallingRtcInfo - /** 呼叫状态 */ - callStatus?: number + /** 频道房间相关信息 */ + roomInfo: V2NIMSignallingRoomInfo + /** 音视频房间相关信息 */ + rtcInfo?: V2NIMSignallingRtcInfo + /** 呼叫状态 */ + callStatus?: number } export interface V2NIMSignallingJoinParams { - /** 信令频道 ID,唯一标识了该频道房间 */ - channelId: string - /** 服务器扩展字段,长度限制 4096 */ - serverExtension?: string - /** 信令相关配置 */ - signallingConfig?: V2NIMSignallingConfig - /** 音视频相关参数配置 */ - rtcConfig?: V2NIMSignallingRtcConfig + /** 信令频道 ID,唯一标识了该频道房间 */ + channelId: string + /** 服务器扩展字段,长度限制 4096 */ + serverExtension?: string + /** 信令相关配置 */ + signallingConfig?: V2NIMSignallingConfig + /** 音视频相关参数配置 */ + rtcConfig?: V2NIMSignallingRtcConfig } export interface V2NIMSignallingInviteParams { - /** 信令频道 ID,唯一标识了该频道房间 */ - channelId: string - /** 被邀请者账号 ID */ - inviteeAccountId: string - /** 请求 ID,可以用 UUID 实现 */ - requestId: string - /** 服务器扩展字段,长度限制 4096,JSON 格式 */ - serverExtension?: string - /** 信令相关配置 */ - signallingConfig?: V2NIMSignallingConfig - /** 推送相关配置 */ - pushConfig?: V2NIMSignallingPushConfig + /** 信令频道 ID,唯一标识了该频道房间 */ + channelId: string + /** 被邀请者账号 ID */ + inviteeAccountId: string + /** 请求 ID,可以用 UUID 实现 */ + requestId: string + /** 服务器扩展字段,长度限制 4096,JSON 格式 */ + serverExtension?: string + /** 信令相关配置 */ + signallingConfig?: V2NIMSignallingConfig + /** 推送相关配置 */ + pushConfig?: V2NIMSignallingPushConfig } export interface V2NIMSignallingCancelInviteParams { - /** 信令频道 ID,唯一标识了该频道房间 */ - channelId: string - /** 被邀请者账号 ID */ - inviteeAccountId: string - /** 请求 ID,可以用 UUID 实现 */ - requestId: string - /** 服务器扩展字段,长度限制 4096 */ - serverExtension?: string - /** 是否存离线,true 表示存离线,false 表示不存离线 */ - offlineEnabled?: boolean + /** 信令频道 ID,唯一标识了该频道房间 */ + channelId: string + /** 被邀请者账号 ID */ + inviteeAccountId: string + /** 请求 ID,可以用 UUID 实现 */ + requestId: string + /** 服务器扩展字段,长度限制 4096 */ + serverExtension?: string + /** 是否存离线,true 表示存离线,false 表示不存离线 */ + offlineEnabled?: boolean } export interface V2NIMSignallingRejectInviteParams { - /** 信令频道 ID,唯一标识了该频道房间 */ - channelId: string - /** 邀请者账号 ID */ - inviterAccountId: string - /** 请求 ID,可以用 UUID 实现 */ - requestId: string - /** 服务器扩展字段,长度限制 4096 */ - serverExtension?: string - /** 是否存离线,true 表示存离线,false 表示不存离线 */ - offlineEnabled?: boolean + /** 信令频道 ID,唯一标识了该频道房间 */ + channelId: string + /** 邀请者账号 ID */ + inviterAccountId: string + /** 请求 ID,可以用 UUID 实现 */ + requestId: string + /** 服务器扩展字段,长度限制 4096 */ + serverExtension?: string + /** 是否存离线,true 表示存离线,false 表示不存离线 */ + offlineEnabled?: boolean } export interface V2NIMSignallingAcceptInviteParams { - /** 信令频道 ID,唯一标识了该频道房间 */ - channelId: string - /** 邀请者账号 ID */ - inviterAccountId: string - /** 请求 ID,可以用 UUID 实现 */ - requestId: string - /** 服务器扩展字段,长度限制 4096 */ - serverExtension?: string - /** 是否存离线,true 表示存离线,false 表示不存离线 */ - offlineEnabled?: boolean + /** 信令频道 ID,唯一标识了该频道房间 */ + channelId: string + /** 邀请者账号 ID */ + inviterAccountId: string + /** 请求 ID,可以用 UUID 实现 */ + requestId: string + /** 服务器扩展字段,长度限制 4096 */ + serverExtension?: string + /** 是否存离线,true 表示存离线,false 表示不存离线 */ + offlineEnabled?: boolean } export interface V2NIMSignallingEvent { - /** 信令频道事件类型 */ - eventType: V2NIMSignallingEventType - /** 信令频道房间相关信息 */ - channelInfo: V2NIMSignallingChannelInfo - /** 操作者 ID */ - operatorAccountId: string - /** 服务器扩展字段,长度限制 4096 */ - serverExtension?: string - /** 操作的时间点 */ - time: number - /** 被邀请者账号 ID,以下场景包含该字段 */ - inviteeAccountId?: string - /** 邀请者账号 ID,以下场景包含该字段 */ - inviterAccountId?: string - /** 本次请求发起产生的请求 ID, 以下场景包含该字段 */ - requestId: string - /** 推送相关配置,以下场景包含该字段,可能为空,依赖于发起方 */ - pushConfig?: V2NIMSignallingPushConfig - /** 是否需要计未读 */ - unreadEnabled?: boolean - /** 成员信息 */ - member?: V2NIMSignallingMember + /** 信令频道事件类型 */ + eventType: V2NIMSignallingEventType + /** 信令频道房间相关信息 */ + channelInfo: V2NIMSignallingChannelInfo + /** 操作者 ID */ + operatorAccountId: string + /** 服务器扩展字段,长度限制 4096 */ + serverExtension?: string + /** 操作的时间点 */ + time: number + /** 被邀请者账号 ID,以下场景包含该字段 */ + inviteeAccountId?: string + /** 邀请者账号 ID,以下场景包含该字段 */ + inviterAccountId?: string + /** 本次请求发起产生的请求 ID, 以下场景包含该字段 */ + requestId: string + /** 推送相关配置,以下场景包含该字段,可能为空,依赖于发起方 */ + pushConfig?: V2NIMSignallingPushConfig + /** 是否需要计未读 */ + unreadEnabled?: boolean + /** 成员信息 */ + member?: V2NIMSignallingMember } export interface V2NIMSubscribeUserStatusOption { - /** 订阅的成员列表,为空返回参数错误,单次数量不超过 100,列表数量如果超限,默认截取前 100 个账号 */ - accountIds: Array - /** 订阅的有效期,时间范围为 60~2592000,单位:秒,过期后需要重新订阅。如果未过期的情况下重复订阅,新设置的有效期会覆盖之前的有效期 */ - duration?: number - /** 订阅后是否立即同步事件状态值,默认为 false,为 true 表示立即同步当前状态值。但为了性能考虑,30s 内重复订阅会忽略该参数 */ - immediateSync?: boolean + /** 订阅的成员列表,为空返回参数错误,单次数量不超过 100,列表数量如果超限,默认截取前 100 个账号 */ + accountIds: Array + /** 订阅的有效期,时间范围为 60~2592000,单位:秒,过期后需要重新订阅。如果未过期的情况下重复订阅,新设置的有效期会覆盖之前的有效期 */ + duration?: number + /** 订阅后是否立即同步事件状态值,默认为 false,为 true 表示立即同步当前状态值。但为了性能考虑,30s 内重复订阅会忽略该参数 */ + immediateSync?: boolean } export interface V2NIMUnsubscribeUserStatusOption { - /** 取消订阅的成员列表,为空则表示取消所有订阅的成员,否则取消指定的成员。单次数量不超过 100,超过默认截取前 100 */ - accountIds?: Array + /** 取消订阅的成员列表,为空则表示取消所有订阅的成员,否则取消指定的成员。单次数量不超过 100,超过默认截取前 100 */ + accountIds?: Array } export interface V2NIMCustomUserStatusParams { - /** 自定义设置值 10000 以上,不包括 10000,10000 以内为内部预定义值。小于 10000 将返回参数错误 */ - statusType: number - /** 状态的有效期,单位秒,范围为 60s 到 7 天 */ - duration?: number - /** 用户发布状态时设置的扩展字段 */ - extension?: string - /** 用户发布状态时是否只广播给在线的订阅者 */ - onlineOnly?: boolean - /** 用户发布状态时是否需要多端同步 */ - multiSync?: boolean + /** 自定义设置值 10000 以上,不包括 10000,10000 以内为内部预定义值。小于 10000 将返回参数错误 */ + statusType: number + /** 状态的有效期,单位秒,范围为 60s 到 7 天 */ + duration?: number + /** 用户发布状态时设置的扩展字段 */ + extension?: string + /** 用户发布状态时是否只广播给在线的订阅者 */ + onlineOnly?: boolean + /** 用户发布状态时是否需要多端同步 */ + multiSync?: boolean } export interface V2NIMCustomUserStatusPublishResult { - /** 发布自定义用户状态时,内部生成的唯一 ID */ - uniqueId: string - /** 服务器针对该状态事件生成的 ID */ - serverId: string - /** 用户状态发布时的时间 */ - publishTime: number + /** 发布自定义用户状态时,内部生成的唯一 ID */ + uniqueId: string + /** 服务器针对该状态事件生成的 ID */ + serverId: string + /** 用户状态发布时的时间 */ + publishTime: number } /// @brief 用户状态订阅结果 export interface V2NIMUserStatusSubscribeResult { - /** 查询的用户账号 */ - accountId: string - /** 状态的有效期,单位秒,范围为 60s 到 30 天 */ - duration: number - /** 用户状态发布时的时间 */ - subscribeTime: number; -}; + /** 查询的用户账号 */ + accountId: string + /** 状态的有效期,单位秒,范围为 60s 到 30 天 */ + duration: number + /** 用户状态发布时的时间 */ + subscribeTime: number; +} export interface V2NIMUserStatus { - /** 用户账号 ID */ - accountId: string - /** 用户状态类型 */ - statusType: number - /** 用户发布状态对应的终端 */ - clientType: V2NIMLoginClientType - /** 用户发布状态的发布时间(服务器时间) */ - publishTime: number - /** 每次发布时会生成一个唯一 ID,发布自定义事件时会生成该参数,如果 ID 相同则表示同一个事件 */ - uniqueId?: string - /** 事件的有效期 */ - duration?: number - /** 用户发布状态时设置的扩展字段 */ - extension?: string - /** 获取预留状态中的配置信息,由服务端填入 JSON array 格式 */ - serverExtension?: string + /** 用户账号 ID */ + accountId: string + /** 用户状态类型 */ + statusType: number + /** 用户发布状态对应的终端 */ + clientType: V2NIMLoginClientType + /** 用户发布状态的发布时间(服务器时间) */ + publishTime: number + /** 每次发布时会生成一个唯一 ID,发布自定义事件时会生成该参数,如果 ID 相同则表示同一个事件 */ + uniqueId?: string + /** 事件的有效期 */ + duration?: number + /** 用户发布状态时设置的扩展字段 */ + extension?: string + /** 获取预留状态中的配置信息,由服务端填入 JSON array 格式 */ + serverExtension?: string +} + +/** @brief HTTP 代理请求参数 */ +export interface V2NIMProxyRequest { + /** 请求路径 */ + path: string; + /** 请求方法 */ + method: V2NIMProxyRequestMethod + /** 映射一个请求地址,不传使用服务器默认的配置 */ + zone?: string + /** 请求头 */ + header?: string + /** 请求体 */ + body?: string +} + +/** @brief HTTP 代理响应 */ +export interface V2NIMProxyResponse { + /** 响应头 */ + header: string + /** 响应体 */ + body: string +} + +/// @brief 代理请求回调 +export interface V2NIMProxyNotify { + /** 发送方账号 */ + fromAccountId: string + /** 通知体 */ + body: string + /** 发送时间,毫秒 */ + time: number }