node-nim 9.14.2 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +7 -1
  2. package/dist/loader.js +35 -35
  3. package/dist/nim/client.js +184 -184
  4. package/dist/nim/client.js.map +1 -1
  5. package/dist/nim/data_sync.js +19 -19
  6. package/dist/nim/friend.js +150 -150
  7. package/dist/nim/global.js +131 -131
  8. package/dist/nim/msglog.js +687 -687
  9. package/dist/nim/nos.js +216 -180
  10. package/dist/nim/nos.js.map +1 -1
  11. package/dist/nim/online_session.js +85 -85
  12. package/dist/nim/pass_through_proxy.js +39 -39
  13. package/dist/nim/plugin.js +65 -65
  14. package/dist/nim/session.js +392 -392
  15. package/dist/nim/subscribe_event.js +142 -142
  16. package/dist/nim/super_team.js +592 -592
  17. package/dist/nim/sysmsg.js +194 -194
  18. package/dist/nim/talk.js +209 -209
  19. package/dist/nim/talk.js.map +1 -1
  20. package/dist/nim/talkex.js +191 -191
  21. package/dist/nim/team.js +818 -818
  22. package/dist/nim/tool.js +119 -119
  23. package/dist/nim/user.js +201 -201
  24. package/dist/nim_def/client_def.js +245 -245
  25. package/dist/nim_def/client_def.js.map +1 -1
  26. package/dist/nim_def/data_sync_def.js +20 -20
  27. package/dist/nim_def/doc_trans_def.js +16 -16
  28. package/dist/nim_def/friend_def.js +37 -37
  29. package/dist/nim_def/global_def.js +39 -39
  30. package/dist/nim_def/msglog_def.js +148 -148
  31. package/dist/nim_def/nos_def.js +16 -16
  32. package/dist/nim_def/online_session_def.js +2 -2
  33. package/dist/nim_def/pass_through_proxy_def.js +10 -10
  34. package/dist/nim_def/plugin_def.js +2 -2
  35. package/dist/nim_def/session_def.js +26 -26
  36. package/dist/nim_def/subscribe_event_def.js +52 -52
  37. package/dist/nim_def/super_team_def.js +64 -64
  38. package/dist/nim_def/sysmsg_def.js +28 -28
  39. package/dist/nim_def/talk_def.js +2 -2
  40. package/dist/nim_def/talkex_def.js +2 -2
  41. package/dist/nim_def/team_def.js +69 -69
  42. package/dist/nim_def/tool_def.js +11 -11
  43. package/dist/nim_def/user_def.js +22 -22
  44. package/dist/node-nim.js +171 -171
  45. package/dist/node-nim.js.map +1 -1
  46. package/dist/qchat/attachment.js +63 -63
  47. package/dist/qchat/channel.js +314 -314
  48. package/dist/qchat/channel_category.js +187 -187
  49. package/dist/qchat/instance.js +77 -77
  50. package/dist/qchat/message.js +285 -285
  51. package/dist/qchat/role.js +423 -423
  52. package/dist/qchat/server.js +453 -453
  53. package/dist/qchat/system_notification.js +74 -74
  54. package/dist/qchat_def/attachment_def.js +2 -2
  55. package/dist/qchat_def/channel_def.js +2 -2
  56. package/dist/qchat_def/instance_def.js +2 -2
  57. package/dist/qchat_def/message_def.js +2 -2
  58. package/dist/qchat_def/public_def.js +649 -649
  59. package/dist/qchat_def/public_def.js.map +1 -1
  60. package/dist/qchat_def/role_def.js +2 -2
  61. package/dist/qchat_def/server_def.js +2 -2
  62. package/dist/qchat_def/system_notification_def.js +2 -2
  63. package/dist/v2/v2_nim_chatroom_client.js +135 -0
  64. package/dist/v2/v2_nim_chatroom_client.js.map +1 -0
  65. package/dist/v2/v2_nim_chatroom_service.js +244 -0
  66. package/dist/v2/v2_nim_chatroom_service.js.map +1 -0
  67. package/dist/v2/v2_nim_client.js +138 -0
  68. package/dist/v2/v2_nim_client.js.map +1 -0
  69. package/dist/v2/v2_nim_conversation_group_service.js +116 -0
  70. package/dist/v2/v2_nim_conversation_group_service.js.map +1 -0
  71. package/dist/v2/v2_nim_conversation_service.js +236 -0
  72. package/dist/v2/v2_nim_conversation_service.js.map +1 -0
  73. package/dist/v2/v2_nim_friend_service.js +128 -0
  74. package/dist/v2/v2_nim_friend_service.js.map +1 -0
  75. package/dist/v2/v2_nim_login_service.js +119 -123
  76. package/dist/v2/v2_nim_login_service.js.map +1 -1
  77. package/dist/v2/v2_nim_message_service.js +382 -0
  78. package/dist/v2/v2_nim_message_service.js.map +1 -0
  79. package/dist/v2/v2_nim_notification_service.js +30 -0
  80. package/dist/v2/v2_nim_notification_service.js.map +1 -0
  81. package/dist/v2/v2_nim_setting_service.js +86 -0
  82. package/dist/v2/v2_nim_setting_service.js.map +1 -0
  83. package/dist/v2/v2_nim_storage_service.js +58 -0
  84. package/dist/v2/v2_nim_storage_service.js.map +1 -0
  85. package/dist/v2/v2_nim_team_service.js +360 -0
  86. package/dist/v2/v2_nim_team_service.js.map +1 -0
  87. package/dist/v2/v2_nim_user_service.js +76 -0
  88. package/dist/v2/v2_nim_user_service.js.map +1 -0
  89. package/dist/v2/v2_nim_utilities.js +276 -0
  90. package/dist/v2/v2_nim_utilities.js.map +1 -0
  91. package/dist/v2_def/v2_nim_callback_def.js +2 -2
  92. package/dist/v2_def/v2_nim_enum_def.js +1087 -325
  93. package/dist/v2_def/v2_nim_enum_def.js.map +1 -1
  94. package/dist/v2_def/v2_nim_struct_def.js +2 -2
  95. package/package.json +74 -74
  96. package/script/download-sdk.js +78 -78
  97. package/script/exec-node-nim-tester.js +17 -17
  98. package/script/publish-to-netease-npm.js +3 -2
  99. package/types/loader.d.ts +2 -2
  100. package/types/nim/client.d.ts +123 -123
  101. package/types/nim/data_sync.d.ts +12 -12
  102. package/types/nim/friend.d.ts +82 -82
  103. package/types/nim/global.d.ts +69 -69
  104. package/types/nim/msglog.d.ts +392 -392
  105. package/types/nim/nos.d.ts +118 -118
  106. package/types/nim/online_session.d.ts +44 -44
  107. package/types/nim/pass_through_proxy.d.ts +24 -24
  108. package/types/nim/plugin.d.ts +39 -39
  109. package/types/nim/session.d.ts +212 -212
  110. package/types/nim/subscribe_event.d.ts +87 -87
  111. package/types/nim/super_team.d.ts +331 -331
  112. package/types/nim/sysmsg.d.ts +105 -105
  113. package/types/nim/talk.d.ts +94 -94
  114. package/types/nim/talkex.d.ts +95 -95
  115. package/types/nim/team.d.ts +461 -461
  116. package/types/nim/tool.d.ts +77 -77
  117. package/types/nim/user.d.ts +111 -111
  118. package/types/nim_def/client_def.d.ts +284 -284
  119. package/types/nim_def/data_sync_def.d.ts +19 -19
  120. package/types/nim_def/doc_trans_def.d.ts +11 -11
  121. package/types/nim_def/friend_def.d.ts +65 -65
  122. package/types/nim_def/global_def.d.ts +62 -62
  123. package/types/nim_def/msglog_def.d.ts +373 -373
  124. package/types/nim_def/nos_def.d.ts +72 -72
  125. package/types/nim_def/online_session_def.d.ts +34 -34
  126. package/types/nim_def/pass_through_proxy_def.d.ts +13 -13
  127. package/types/nim_def/plugin_def.d.ts +8 -8
  128. package/types/nim_def/session_def.d.ts +114 -114
  129. package/types/nim_def/subscribe_event_def.d.ts +83 -83
  130. package/types/nim_def/super_team_def.d.ts +144 -137
  131. package/types/nim_def/sysmsg_def.d.ts +70 -70
  132. package/types/nim_def/talk_def.d.ts +96 -96
  133. package/types/nim_def/talkex_def.d.ts +112 -112
  134. package/types/nim_def/team_def.d.ts +167 -167
  135. package/types/nim_def/tool_def.d.ts +28 -28
  136. package/types/nim_def/user_def.d.ts +59 -59
  137. package/types/node-nim.d.ts +90 -93
  138. package/types/qchat/attachment.d.ts +40 -40
  139. package/types/qchat/channel.d.ts +139 -139
  140. package/types/qchat/channel_category.d.ts +82 -82
  141. package/types/qchat/instance.d.ts +46 -46
  142. package/types/qchat/message.d.ts +128 -128
  143. package/types/qchat/role.d.ts +166 -166
  144. package/types/qchat/server.d.ts +198 -198
  145. package/types/qchat/system_notification.d.ts +39 -39
  146. package/types/qchat_def/attachment_def.d.ts +71 -71
  147. package/types/qchat_def/channel_def.d.ts +643 -643
  148. package/types/qchat_def/instance_def.d.ts +214 -214
  149. package/types/qchat_def/message_def.d.ts +565 -565
  150. package/types/qchat_def/public_def.d.ts +754 -754
  151. package/types/qchat_def/role_def.d.ts +413 -413
  152. package/types/qchat_def/server_def.d.ts +529 -529
  153. package/types/qchat_def/system_notification_def.d.ts +172 -172
  154. package/types/v2/v2_nim_chatroom_client.d.ts +73 -0
  155. package/types/v2/v2_nim_chatroom_service.d.ts +114 -0
  156. package/types/v2/v2_nim_client.d.ts +75 -0
  157. package/types/v2/v2_nim_conversation_group_service.d.ts +54 -0
  158. package/types/v2/v2_nim_conversation_service.d.ts +110 -0
  159. package/types/v2/v2_nim_friend_service.d.ts +58 -0
  160. package/types/v2/v2_nim_login_service.d.ts +80 -96
  161. package/types/v2/v2_nim_message_service.d.ts +143 -0
  162. package/types/v2/v2_nim_notification_service.d.ts +18 -0
  163. package/types/v2/v2_nim_setting_service.d.ts +43 -0
  164. package/types/v2/v2_nim_storage_service.d.ts +28 -0
  165. package/types/v2/v2_nim_team_service.d.ts +184 -0
  166. package/types/v2/v2_nim_user_service.d.ts +34 -0
  167. package/types/v2/v2_nim_utilities.d.ts +168 -0
  168. package/types/v2_def/v2_nim_callback_def.d.ts +7 -20
  169. package/types/v2_def/v2_nim_enum_def.d.ts +1009 -300
  170. package/types/v2_def/v2_nim_struct_def.d.ts +1539 -338
  171. package/dist/chatroom/chatroom.js +0 -263
  172. package/dist/chatroom/chatroom.js.map +0 -1
  173. package/dist/chatroom_def/chatroom_def.js +0 -120
  174. package/dist/chatroom_def/chatroom_def.js.map +0 -1
  175. package/dist/v2/v2_nim_instance.js +0 -44
  176. package/dist/v2/v2_nim_instance.js.map +0 -1
  177. package/types/chatroom/chatroom.d.ts +0 -55
  178. package/types/chatroom_def/chatroom_def.d.ts +0 -448
  179. package/types/v2/v2_nim_instance.d.ts +0 -25
@@ -1,688 +1,688 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NIMMsgLog = void 0;
7
- const loader_1 = __importDefault(require("../loader"));
8
- const eventemitter3_1 = require("eventemitter3");
9
- class NIMMsgLog extends eventemitter3_1.EventEmitter {
10
- constructor() {
11
- super();
12
- this.msglog = new loader_1.default.NIMMsgLog({ emit: this.emit.bind(this) });
13
- }
14
- /** 注册全局回调 */
15
- initEventHandlers() {
16
- return this.msglog.InitEventHandlers();
17
- }
18
- /** 根据消息ID查询本地(单条)消息
19
- * @param clientMsgId 客户端消息ID
20
- * @param jsonExtension json扩展参数(备用,目前不需要)
21
- * @param cb 查询本地消息的回调函数
22
- * @return boolean 检查参数如果不符合要求则返回失败
23
- * @note
24
- * <pre>
25
- * 200:成功
26
- * </pre>
27
- */
28
- queryMsgByIDAysnc(clientMsgId, cb, jsonExtension) {
29
- return new Promise((resolve) => {
30
- if (!this.msglog.QueryMsgByIDAysnc(clientMsgId, (rescode, id, msg) => {
31
- if (cb) {
32
- cb(rescode, id, msg);
33
- }
34
- resolve([rescode, id, msg]);
35
- }, jsonExtension)) {
36
- resolve(null);
37
- }
38
- });
39
- }
40
- /** 查询本地消息
41
- * @param accid 查询id,account_id/uid或者tid
42
- * @param to_type 会话类型,双人0,群组1 (见nim_msglog_def.h)
43
- * @param limit_count 一次查询数量,建议20
44
- * @param anchor_msg_time
45
- * 作为此次查询的定位点的消息历史的消息时间戳(上次查询最后一条消息的时间戳,按指定的时间的顺序起查,默认为逆序,2.4.0之前命名为last_name)
46
- * @param jsonExtension json扩展参数(备用,目前不需要)
47
- * @param cb 查询本地消息的回调函数
48
- * @return boolean 检查参数如果不符合要求则返回失败
49
- * @note
50
- * <pre>
51
- * 200:成功
52
- * </pre>
53
- */
54
- queryMsgAsync(accid, to_type, limit_count, anchor_msg_time, cb, jsonExtension) {
55
- return new Promise((resolve) => {
56
- if (!this.msglog.QueryMsgAsync(accid, to_type, limit_count, anchor_msg_time, (rescode, id, to_type, result) => {
57
- if (cb) {
58
- cb(rescode, id, to_type, result);
59
- }
60
- resolve([rescode, id, to_type, result]);
61
- }, jsonExtension)) {
62
- resolve(null);
63
- }
64
- });
65
- }
66
- /** 查询历史消息,基于本地可信时间段信息来动态判断获取消息的途径
67
- * @param session_id 会话id
68
- * @param to_type 会话类型, 双人0,群组1, 超大群5
69
- * @param from_time 开始时间, 包含
70
- * @param to_time 结束时间, 大于from_time, 0表示当前时间; 只有在direction为kForward且anchor_client_msg_id不为空时才包含
71
- * @param limit_count 查询数量
72
- * @param anchor_client_msg_id 查询起始的客户端消息id, 查询结果不包括这条消息
73
- * @param anchor_server_msg_id 查询起始的服务器消息id, 查询结果不包括这条消息
74
- * @param direction 查询方向
75
- * @param cb 查询消息的回调函数
76
- * @param json_extension json扩展参数(备用,目前不需要)
77
- * @return void
78
- * @note 错误码 200:成功
79
- */
80
- getMessagesDynamically(session_id, to_type, from_time, to_time, limit_count, anchor_client_msg_id, anchor_server_msg_id, direction, cb, jsonExtension) {
81
- return new Promise((resolve) => {
82
- this.msglog.GetMessagesDynamically(session_id, to_type, from_time, to_time, limit_count, anchor_client_msg_id, anchor_server_msg_id, direction, (result) => {
83
- if (cb) {
84
- cb(result);
85
- }
86
- resolve([result]);
87
- }, jsonExtension);
88
- });
89
- }
90
- /** 在线查询消息(不包括系统消息)
91
- * @param param 查询参数
92
- * @param cb 在线查询消息的回调函数
93
- * @return boolean 检查参数如果不符合要求则返回失败
94
- * @note
95
- * <pre>
96
- * 200:成功
97
- * 403:禁止访问(不在该群,只针对群组会话)
98
- * 414:参数错误
99
- * </pre>
100
- */
101
- queryMsgOnlineAsync(param, cb) {
102
- return new Promise((resolve) => {
103
- if (!this.msglog.QueryMsgOnlineAsync(param, (rescode, id, to_type, result) => {
104
- if (cb) {
105
- cb(rescode, id, to_type, result);
106
- }
107
- resolve([rescode, id, to_type, result]);
108
- })) {
109
- resolve(null);
110
- }
111
- });
112
- }
113
- /** 在线查询消息(不包括系统消息)
114
- * @param param 查询参数
115
- * @param cb 在线查询消息的回调函数
116
- * @return boolean 检查参数如果不符合要求则返回失败
117
- * @note
118
- * <pre>
119
- * 200:成功
120
- * 403:禁止访问(不在该群,只针对群组会话)
121
- * 414:参数错误
122
- * </pre>
123
- */
124
- queryMsgByKeywordOnlineAsync(param, cb) {
125
- return new Promise((resolve) => {
126
- if (!this.msglog.QueryMsgByKeywordOnlineAsync(param, (rescode, id, to_type, result) => {
127
- if (cb) {
128
- cb(rescode, id, to_type, result);
129
- }
130
- resolve([rescode, id, to_type, result]);
131
- })) {
132
- resolve(null);
133
- }
134
- });
135
- }
136
- /** 根据指定条件在一个会话中查询指定单个或多个类型的本地消息
137
- * @param to_type 会话类型,双人0,群组1 (nim_msglog_def.h)
138
- * @param id 查询id,对方的account id或者群组tid。
139
- * @param limit_count 本次查询的消息条数上限(最多100条)
140
- * @param fromTime 起始时间点,单位:毫秒
141
- * @param endTime 结束时间点,单位:毫秒
142
- * @param endClientMsgId 结束查询的最后一条消息的end_client_msg_id(不包含在查询结果中)
143
- * @param reverse true:反向查询(按时间正序起查,正序排列),false:按时间逆序起查,逆序排列(建议默认为false)
144
- * @param msgType 检索的消息类型
145
- * @param jsonExtension json扩展参数(备用,目前不需要)
146
- * @param cb 在线查询消息的回调函数
147
- * @return boolean 检查参数如果不符合要求则返回失败
148
- * @note
149
- * <pre>
150
- * 200:成功
151
- * </pre>
152
- */
153
- queryMsgOfSpecifiedTypeInASessionAsync(to_type, id, limit_count, fromTime, endTime, endClientMsgId, reverse, msgType, cb, jsonExtension) {
154
- return new Promise((resolve) => {
155
- if (!this.msglog.QueryMsgOfSpecifiedTypeInASessionAsync(to_type, id, limit_count, fromTime, endTime, endClientMsgId, reverse, msgType, (rescode, id, to_type, result) => {
156
- if (cb) {
157
- cb(rescode, id, to_type, result);
158
- }
159
- resolve([rescode, id, to_type, result]);
160
- }, jsonExtension)) {
161
- resolve(null);
162
- }
163
- });
164
- }
165
- /** 根据指定条件查询本地消息,使用此接口可以完成全局搜索等功能,具体请参阅开发手册
166
- * @param param 查询参数
167
- * @param cb 在线查询消息的回调函数
168
- * @return boolean 检查参数如果不符合要求则返回失败
169
- * @note
170
- * <pre>
171
- * 200:成功
172
- * </pre>
173
- */
174
- queryMsgByOptionsAsync(param, cb) {
175
- return new Promise((resolve) => {
176
- if (!this.msglog.QueryMsgByOptionsAsync(param, (rescode, id, to_type, result) => {
177
- if (cb) {
178
- cb(rescode, id, to_type, result);
179
- }
180
- resolve([rescode, id, to_type, result]);
181
- })) {
182
- resolve(null);
183
- }
184
- });
185
- }
186
- /** 批量设置已读状态
187
- * @param accid 查询id,account_id/uid或者tid
188
- * @param to_type 会话类型,双人0,群组1 (见nim_msglog_def.h)
189
- * @param jsonExtension json扩展参数(备用,目前不需要)
190
- * @param cb 操作结果的回调函数
191
- * @return boolean 检查参数如果不符合要求则返回失败
192
- * @note
193
- * <pre>
194
- * 200:成功
195
- * </pre>
196
- */
197
- batchStatusReadAsync(accid, to_type, cb, jsonExtension) {
198
- return new Promise((resolve) => {
199
- if (!this.msglog.BatchStatusReadAsync(accid, to_type, (rescode, uid, to_type) => {
200
- if (cb) {
201
- cb(rescode, uid, to_type);
202
- }
203
- resolve([rescode, uid, to_type]);
204
- }, jsonExtension)) {
205
- resolve(null);
206
- }
207
- });
208
- }
209
- /** 删除某个会话的全部聊天记录
210
- * @param accid 要删除会话的id,account_id/uid或者tid
211
- * @param to_type 会话类型,双人0,群组1 (见nim_msglog_def.h)
212
- * @param revert_by_query_online 是否可以通过服务端查询消息记录(含入库选项)进行恢复,true:是,false:否
213
- * @param cb 操作结果的回调函数
214
- * @param jsonExtension json扩展参数(备用,目前不需要)
215
- * @return boolean 检查参数如果不符合要求则返回失败
216
- * @note
217
- * <pre>
218
- * 200:成功
219
- * </pre>
220
- */
221
- batchStatusDeleteAsync(accid, to_type, revert_by_query_online, cb, jsonExtension) {
222
- return new Promise((resolve) => {
223
- if (!this.msglog.BatchStatusDeleteAsync(accid, to_type, revert_by_query_online, (rescode, uid, to_type) => {
224
- if (cb) {
225
- cb(rescode, uid, to_type);
226
- }
227
- resolve([rescode, uid, to_type]);
228
- }, jsonExtension)) {
229
- resolve(null);
230
- }
231
- });
232
- }
233
- /** 设置消息状态
234
- * @param msg_id 消息id
235
- * @param status 消息状态枚举值
236
- * @param jsonExtension json扩展参数(备用,目前不需要)
237
- * @param cb 操作结果的回调函数
238
- * @return boolean 检查参数如果不符合要求则返回失败
239
- * @note
240
- * <pre>
241
- * 200:成功
242
- * </pre>
243
- */
244
- setStatusAsync(msg_id, status, cb, jsonExtension) {
245
- return new Promise((resolve) => {
246
- if (!this.msglog.SetStatusAsync(msg_id, status, (rescode, msg_id) => {
247
- if (cb) {
248
- cb(rescode, msg_id);
249
- }
250
- resolve([rescode, msg_id]);
251
- }, jsonExtension)) {
252
- resolve(null);
253
- }
254
- });
255
- }
256
- /** 设置消息子状态
257
- * @param msg_id 消息id
258
- * @param status 消息子状态枚举值
259
- * @param jsonExtension json扩展参数(备用,目前不需要)
260
- * @param cb 操作结果的回调函数
261
- * @return boolean 检查参数如果不符合要求则返回失败
262
- * @note
263
- * <pre>
264
- * 200:成功
265
- * </pre>
266
- */
267
- setSubStatusAsync(msg_id, status, cb, jsonExtension) {
268
- return new Promise((resolve) => {
269
- if (!this.msglog.SetSubStatusAsync(msg_id, status, (rescode, msg_id) => {
270
- if (cb) {
271
- cb(rescode, msg_id);
272
- }
273
- resolve([rescode, msg_id]);
274
- }, jsonExtension)) {
275
- resolve(null);
276
- }
277
- });
278
- }
279
- /** 只往本地消息历史数据库里写入一条消息(如果已存在这条消息,则更新。通常是APP的本地自定义消息,并不会发给服务器)
280
- * @param talkId 会话id,对方的account id或者群组tid
281
- * @param msg 消息内容
282
- * @param needUpdateSession 是否更新会话列表(一般最新一条消息有这个需求)
283
- * @param composeLastMsg 如果消息历史中有该会话的消息,是否将该会话最后一条消息随会话变更上报,true 为携带,否则不携带
284
- * @param excludeMsgType 如果 compose_last_msg = true,则可根据需要排除指定最后一条消息的类型
285
- * @param cb 操作结果的回调函数
286
- * @return boolean 检查参数如果不符合要求则返回失败
287
- * @note
288
- * <pre>
289
- * 200:成功
290
- * </pre>
291
- */
292
- writeMsglogToLocalAsync(talkId, msg, needUpdateSession, composeLastMsg, excludeMsgType, cb) {
293
- return new Promise((resolve) => {
294
- if (!this.msglog.WriteMsglogToLocalAsync(talkId, msg, needUpdateSession, composeLastMsg, excludeMsgType, (rescode, msg_id) => {
295
- if (cb) {
296
- cb(rescode, msg_id);
297
- }
298
- resolve([rescode, msg_id]);
299
- })) {
300
- resolve(null);
301
- }
302
- });
303
- }
304
- /** 删除指定会话类型的所有消息
305
- * @param delSessions 是否删除会话
306
- * @param to_type 会话类型
307
- * @param revert_by_query_online 是否可以通过服务端查询消息记录(含入库选项)进行恢复,true:是,false:否
308
- * @param jsonExtension json扩展参数(备用,目前不需要)
309
- * @param cb 操作结果的回调函数
310
- * @return boolean 检查参数如果不符合要求则返回失败
311
- * @note
312
- * <pre>
313
- * 200:成功
314
- * </pre>
315
- */
316
- deleteBySessionTypeAsync(delSessions, to_type, revert_by_query_online, cb, jsonExtension) {
317
- return new Promise((resolve) => {
318
- if (!this.msglog.DeleteBySessionTypeAsync(delSessions, to_type, revert_by_query_online, (rescode, msg_id, to_type) => {
319
- if (cb) {
320
- cb(rescode, msg_id, to_type);
321
- }
322
- resolve([rescode, msg_id, to_type]);
323
- }, jsonExtension)) {
324
- resolve(null);
325
- }
326
- });
327
- }
328
- /** 删除指定一条消息
329
- * @param session_id 会话id,对方的account id或者群组tid
330
- * @param to_type 会话类型
331
- * @param msg_id 消息id
332
- * @param jsonExtension json扩展参数(备用,目前不需要)
333
- * @param cb 操作结果的回调函数
334
- * @return boolean 检查参数如果不符合要求则返回失败
335
- * @note
336
- * <pre>
337
- * 200:成功
338
- * </pre>
339
- */
340
- deleteAsync(session_id, to_type, msg_id, cb, jsonExtension) {
341
- return new Promise((resolve) => {
342
- if (!this.msglog.DeleteAsync(session_id, to_type, msg_id, (rescode, msg_id) => {
343
- if (cb) {
344
- cb(rescode, msg_id);
345
- }
346
- resolve([rescode, msg_id]);
347
- }, jsonExtension)) {
348
- resolve(null);
349
- }
350
- });
351
- }
352
- /** 删除全部消息历史
353
- * @param del_session 是否删除所有会话列表项(即全部最近联系人)。
354
- ture则删除,并通过nim_session_reg_change_cb注册的回调通知上层kNIMSessionCommandRemoveAll事件(不会触发每个会话项的kNIMSessionCommandRemove事件);
355
- false则不删除,并将所有会话项的最后一条消息的状态kNIMSessionMsgStatus设置为已删除状态,并通过nim_session_reg_change_cb注册的回调通知上层kNIMSession
356
- CommandAllMsgDeleted事件(不会触发每个会话项的kNIMSessionCommandUpdate事件,避免频繁通知上层)。
357
- * @param revert_by_query_online 是否可以通过服务端查询消息记录(含入库选项)进行恢复,true:是,false:否
358
- * @param jsonExtension json扩展参数(备用,目前不需要)
359
- * @param cb 操作结果的回调函数
360
- * @return boolean 检查参数如果不符合要求则返回失败
361
- * @note
362
- * <pre>
363
- * 200:成功
364
- * </pre>
365
- */
366
- deleteAllAsync(del_session, revert_by_query_online, cb, jsonExtension) {
367
- return new Promise((resolve) => {
368
- if (!this.msglog.DeleteAllAsync(del_session, revert_by_query_online, (rescode) => {
369
- if (cb) {
370
- cb(rescode);
371
- }
372
- resolve([rescode]);
373
- }, jsonExtension)) {
374
- resolve(null);
375
- }
376
- });
377
- }
378
- /** 根据时间段删除部分会话的历史消息
379
- * @param session_id 要删除消息的会话ID
380
- * @param to_type 要删除消息的会话类型
381
- * @param revert_by_query_online 是否可以通过服务端查询消息记录(含入库选项)进行恢复,true:是,false:否
382
- * @param timestamp1 单位ms timestamp1 与 timestamp2 组成一个时间段,SDK 内部会判断大小调整入参顺序
383
- * @param timestamp2 单位ms timestamp2 与 timestamp1 组成一个时间段,SDK 内部会判断大小调整入参顺序
384
- * @param jsonExtension json扩展参数(备用,目前不需要)
385
- * @param cb 操作结果的回调函数
386
- * @return boolean 检查参数如果不符合要求则返回失败
387
- * @note
388
- * <pre>
389
- * 200:成功
390
- * </pre>
391
- */
392
- deleteMsgByTimeAsync(session_id, to_type, revert_by_query_online, timestamp1, timestamp2, cb, jsonExtension) {
393
- return new Promise((resolve) => {
394
- if (!this.msglog.DeleteMsgByTimeAsync(session_id, to_type, revert_by_query_online, timestamp1, timestamp2, (rescode) => {
395
- if (cb) {
396
- cb(rescode);
397
- }
398
- resolve([rescode]);
399
- }, jsonExtension)) {
400
- resolve(null);
401
- }
402
- });
403
- }
404
- /** 导出整个消息历史DB文件(不包括系统消息历史)
405
- * @param dst_path 导出时保存的目标全路径(UTF-8编码)。
406
- * @param jsonExtension json扩展参数(备用,目前不需要)
407
- * @param cb 操作结果的回调函数
408
- * @return boolean 检查参数如果不符合要求则返回失败
409
- * @note
410
- * <pre>
411
- * 200:成功
412
- * </pre>
413
- */
414
- exportDbAsync(dst_path, cb, jsonExtension) {
415
- return new Promise((resolve) => {
416
- this.msglog.ExportDbAsync(dst_path, (rescode) => {
417
- if (cb) {
418
- cb(rescode);
419
- }
420
- resolve([rescode]);
421
- }, jsonExtension);
422
- });
423
- }
424
- /** 导入消息历史DB文件(不包括系统消息历史)。先验证是否自己的消息历史文件和DB加密密钥(见nim_client_def.h里的kNIMDataBaseEncryptKey),如果验证不通过,则不导入。
425
- * @param src_path 导入源文件的全路径(UTF-8编码)。
426
- * @param jsonExtension json扩展参数(备用,目前不需要)
427
- * @param cb 操作结果的回调函数
428
- * @param prg_cb 导入进度的回调函数
429
- * @return boolean 检查参数如果不符合要求则返回失败
430
- * @note
431
- * <pre>
432
- * 200:成功
433
- * 10600:导入消息历史时验证身份和加密密钥不通过
434
- * 10601:导入消息历史时写记录失败
435
- * </pre>
436
- */
437
- importDbAsync(src_path, cb, prg_cb, jsonExtension) {
438
- return new Promise((resolve) => {
439
- this.msglog.ImportDbAsync(src_path, (rescode) => {
440
- if (cb) {
441
- cb(rescode);
442
- }
443
- resolve([rescode]);
444
- }, prg_cb, jsonExtension);
445
- });
446
- }
447
- /** 发送消息已读回执
448
- * @param msg 已读消息
449
- * @param cb 操作结果的回调函数
450
- * @return void 无返回值
451
- * @note
452
- * <pre>
453
- * 200:成功
454
- * 403:服务器关闭此功能,或者应用没权限
455
- * 404:请求的目标(用户或对象)不存在
456
- * 10414:本地错误码,参数错误
457
- * </pre>
458
- */
459
- sendReceiptAsync(msg, cb) {
460
- return new Promise((resolve) => {
461
- this.msglog.SendReceiptAsync(msg, (result) => {
462
- if (cb) {
463
- cb(result);
464
- }
465
- resolve([result]);
466
- });
467
- });
468
- }
469
- /** 查询自己发送的消息是否被对方已读
470
- * @param msg 消息。
471
- * @return boolean 是否被已读
472
- */
473
- querySentMessageBeReaded(msg) {
474
- return this.msglog.QuerySentMessageBeReaded(msg);
475
- }
476
- /** 查询收到的消息是否已经发送过已读回执
477
- * @param msg 消息。
478
- * @return boolean 是否已发送过
479
- */
480
- queryReceivedMsgReceiptSent(msg) {
481
- return this.msglog.QueryReceivedMsgReceiptSent(msg);
482
- }
483
- /** 更新本地消息扩展字段内容
484
- * @param msg_id 消息id
485
- * @param local_ext 本地扩展字段内容
486
- * @param jsonExtension json扩展参数(备用,目前不需要)
487
- * @param cb 操作结果的回调函数
488
- * @return boolean 检查参数如果不符合要求则返回失败
489
- * @note
490
- * <pre>
491
- * 200:成功
492
- * </pre>
493
- */
494
- updateLocalExtAsync(msg_id, local_ext, cb, jsonExtension) {
495
- return new Promise((resolve) => {
496
- this.msglog.UpdateLocalExtAsync(msg_id, local_ext, (rescode, local_ext) => {
497
- if (cb) {
498
- cb(rescode, local_ext);
499
- }
500
- resolve([rescode, local_ext]);
501
- }, jsonExtension);
502
- });
503
- }
504
- /** 全部未读消息历史标记为已读
505
- * @param jsonExtension json扩展参数(备用,目前不需要)
506
- * @param cb 操作结果的回调函数
507
- * @return boolean 检查参数如果不符合要求则返回失败
508
- * @note
509
- * <pre>
510
- * 200:成功
511
- * </pre>
512
- */
513
- readAllAsync(cb, jsonExtension) {
514
- return new Promise((resolve) => {
515
- this.msglog.ReadAllAsync((rescode) => {
516
- if (cb) {
517
- cb(rescode);
518
- }
519
- resolve([rescode]);
520
- }, jsonExtension);
521
- });
522
- }
523
- /** 导出本地消息记录到云端
524
- * @param export_info 导出需要的参数参考LogsBackupExportInfo定义
525
- * @return boolean false : 当前有导入/导出操作正在进行中
526
- */
527
- exportBackupToRemote(export_info) {
528
- return this.msglog.ExportBackupToRemote(export_info);
529
- }
530
- /** 导入已备份在云端的消息记录
531
- * @param import_info 导入需要的参数参考LogsBackupImportInfo定义
532
- * @return boolean false : 当前有导入/导出操作正在进行中
533
- */
534
- importBackupToRemote(export_info) {
535
- return this.msglog.ImportBackupToRemote(export_info);
536
- }
537
- /** 取消导入已备份在云端的消息记录
538
- * @return void
539
- */
540
- cancelImportBackupFromRemote() {
541
- return this.msglog.CancelImportBackupFromRemote();
542
- }
543
- /** 取消导出本地消息记录到云端
544
- * @return void
545
- */
546
- cancelExportBackupToRemote() {
547
- return this.msglog.CancelExportBackupToRemote();
548
- }
549
- /** 删除与某账号的所有云端历史记录与漫游消息(p2p)
550
- * @param accid 对方的accid
551
- * @param del_remote 是否同时删除所有的漫游消息 true : 是 false : 否
552
- * @param jsonExtension json扩展参数(备用,目前不需要)
553
- * @param cb 操作结果的回调函数
554
- * @return void
555
- * @note
556
- * <pre>
557
- * 200:成功
558
- * </pre>
559
- */
560
- deleteHistoryOnlineAsync(accid, del_remote, jsonExtension, cb) {
561
- return new Promise((resolve) => {
562
- this.msglog.DeleteHistoryOnlineAsync(accid, del_remote, jsonExtension, (rescode, accid) => {
563
- if (cb) {
564
- cb(rescode, accid);
565
- }
566
- resolve([rescode, accid]);
567
- });
568
- });
569
- }
570
- /** 删除某一会话的云端的历史记录[v8.0.0]
571
- * @param accid 对方的accid(p2p:accid team:tid)
572
- * @param to_type 会话类型,双人0,群组1 (见nim_msglog_def.h)
573
- * @param needs_notify_self 是否通知其它终端
574
- * @param jsonExtension 扩展字段
575
- * @param cb 操作结果的回调函数
576
- * @return void
577
- * @note 错误码 200:成功
578
- */
579
- deleteHistoryOnlineAsyncEx(accid, to_type, needs_notify_self, jsonExtension, cb) {
580
- return new Promise((resolve) => {
581
- this.msglog.DeleteHistoryOnlineAsyncEx(accid, to_type, needs_notify_self, jsonExtension, (rescode, accid, to_type, timestamp, jsonExtension) => {
582
- if (cb) {
583
- cb(rescode, accid, to_type, timestamp, jsonExtension);
584
- }
585
- resolve([rescode, accid, to_type, timestamp, jsonExtension]);
586
- });
587
- });
588
- }
589
- /** 单向删除某条消息记录(同时删除本地与云端)
590
- * @param msg 要删除的消息
591
- * @param exts 用户自定义扩展字段
592
- * @param cb 操作结果的回调函数
593
- * @return void 无返回值
594
- * @note
595
- * <pre>
596
- * 200:成功
597
- * </pre>
598
- */
599
- deleteMessageSelfAsync(msg, ext, cb) {
600
- return new Promise((resolve) => {
601
- this.msglog.DeleteMessageSelfAsync(msg, ext, (rescode) => {
602
- if (cb) {
603
- cb(rescode);
604
- }
605
- resolve([rescode]);
606
- });
607
- });
608
- }
609
- /** 查询某条消息是否为thread聊天的根消息
610
- * @param client_id 要查询的消息的客户端ID
611
- * @param cb 操作结果的回调函数
612
- * @return void 无返回值
613
- * @note
614
- * <pre>
615
- * 200:成功
616
- * </pre>
617
- */
618
- queryMessageIsThreadRoot(client_id, cb) {
619
- return new Promise((resolve) => {
620
- this.msglog.QueryMessageIsThreadRoot(client_id, (rescode, client_id, is_thread_root) => {
621
- if (cb) {
622
- cb(rescode, client_id, is_thread_root);
623
- }
624
- resolve([rescode, client_id, is_thread_root]);
625
- });
626
- });
627
- }
628
- /** 查询某条消息的具体内容一般用在thread talk 场景中
629
- * @param param 要查询的消息的相关参数,可以在msglog.threadinfo中得到
630
- * @param cb 查询结果的回调函数
631
- * @return void 无返回值
632
- * @note
633
- * <pre>
634
- * 200:成功
635
- * </pre>
636
- */
637
- queryMessageOnline(param, cb) {
638
- return new Promise((resolve) => {
639
- this.msglog.QueryMessageOnline(param, (rescode, param, msg) => {
640
- if (cb) {
641
- cb(rescode, param, msg);
642
- }
643
- resolve([rescode, param, msg]);
644
- });
645
- });
646
- }
647
- /** 分页查询thread talk消息历史
648
- * @param msg 要查询的消息
649
- * @param param 要查询的消息的相关参数,可以在msglog.threadinfo中得到
650
- * @param cb 查询结果的回调函数
651
- * @return void 无返回值
652
- * @note
653
- * <pre>
654
- * 200:成功
655
- * </pre>
656
- */
657
- queryThreadHistoryMsg(msg, param, cb) {
658
- return new Promise((resolve) => {
659
- this.msglog.QueryThreadHistoryMsg(msg, param, (rescode, root_msg, total, last_msg_time, msg_array) => {
660
- if (cb) {
661
- cb(rescode, root_msg, total, last_msg_time, msg_array);
662
- }
663
- resolve([rescode, root_msg, total, last_msg_time, msg_array]);
664
- });
665
- });
666
- }
667
- /** 在线全文检索
668
- * @param param 全文检索参数
669
- * @param cb 全文检索结果回调函数
670
- * @return void 无返回值
671
- * @note
672
- * <pre>
673
- * 200:成功
674
- * </pre>
675
- */
676
- fullTextSearchOnlineAsync(param, cb) {
677
- return new Promise((resolve) => {
678
- this.msglog.FullTextSearchOnlineAsync(param, (rescode, result) => {
679
- if (cb) {
680
- cb(rescode, result);
681
- }
682
- resolve([rescode, result]);
683
- });
684
- });
685
- }
686
- }
687
- exports.NIMMsgLog = NIMMsgLog;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NIMMsgLog = void 0;
7
+ const loader_1 = __importDefault(require("../loader"));
8
+ const eventemitter3_1 = require("eventemitter3");
9
+ class NIMMsgLog extends eventemitter3_1.EventEmitter {
10
+ constructor() {
11
+ super();
12
+ this.msglog = new loader_1.default.NIMMsgLog({ emit: this.emit.bind(this) });
13
+ }
14
+ /** 注册全局回调 */
15
+ initEventHandlers() {
16
+ return this.msglog.InitEventHandlers();
17
+ }
18
+ /** 根据消息ID查询本地(单条)消息
19
+ * @param clientMsgId 客户端消息ID
20
+ * @param jsonExtension json扩展参数(备用,目前不需要)
21
+ * @param cb 查询本地消息的回调函数
22
+ * @return boolean 检查参数如果不符合要求则返回失败
23
+ * @note
24
+ * <pre>
25
+ * 200:成功
26
+ * </pre>
27
+ */
28
+ queryMsgByIDAysnc(clientMsgId, cb, jsonExtension) {
29
+ return new Promise((resolve) => {
30
+ if (!this.msglog.QueryMsgByIDAysnc(clientMsgId, (rescode, id, msg) => {
31
+ if (cb) {
32
+ cb(rescode, id, msg);
33
+ }
34
+ resolve([rescode, id, msg]);
35
+ }, jsonExtension)) {
36
+ resolve(null);
37
+ }
38
+ });
39
+ }
40
+ /** 查询本地消息
41
+ * @param accid 查询id,account_id/uid或者tid
42
+ * @param to_type 会话类型,双人0,群组1 (见nim_msglog_def.h)
43
+ * @param limit_count 一次查询数量,建议20
44
+ * @param anchor_msg_time
45
+ * 作为此次查询的定位点的消息历史的消息时间戳(上次查询最后一条消息的时间戳,按指定的时间的顺序起查,默认为逆序,2.4.0之前命名为last_name)
46
+ * @param jsonExtension json扩展参数(备用,目前不需要)
47
+ * @param cb 查询本地消息的回调函数
48
+ * @return boolean 检查参数如果不符合要求则返回失败
49
+ * @note
50
+ * <pre>
51
+ * 200:成功
52
+ * </pre>
53
+ */
54
+ queryMsgAsync(accid, to_type, limit_count, anchor_msg_time, cb, jsonExtension) {
55
+ return new Promise((resolve) => {
56
+ if (!this.msglog.QueryMsgAsync(accid, to_type, limit_count, anchor_msg_time, (rescode, id, to_type, result) => {
57
+ if (cb) {
58
+ cb(rescode, id, to_type, result);
59
+ }
60
+ resolve([rescode, id, to_type, result]);
61
+ }, jsonExtension)) {
62
+ resolve(null);
63
+ }
64
+ });
65
+ }
66
+ /** 查询历史消息,基于本地可信时间段信息来动态判断获取消息的途径
67
+ * @param session_id 会话id
68
+ * @param to_type 会话类型, 双人0,群组1, 超大群5
69
+ * @param from_time 开始时间, 包含
70
+ * @param to_time 结束时间, 大于from_time, 0表示当前时间; 只有在direction为kForward且anchor_client_msg_id不为空时才包含
71
+ * @param limit_count 查询数量
72
+ * @param anchor_client_msg_id 查询起始的客户端消息id, 查询结果不包括这条消息
73
+ * @param anchor_server_msg_id 查询起始的服务器消息id, 查询结果不包括这条消息
74
+ * @param direction 查询方向
75
+ * @param cb 查询消息的回调函数
76
+ * @param json_extension json扩展参数(备用,目前不需要)
77
+ * @return void
78
+ * @note 错误码 200:成功
79
+ */
80
+ getMessagesDynamically(session_id, to_type, from_time, to_time, limit_count, anchor_client_msg_id, anchor_server_msg_id, direction, cb, jsonExtension) {
81
+ return new Promise((resolve) => {
82
+ this.msglog.GetMessagesDynamically(session_id, to_type, from_time, to_time, limit_count, anchor_client_msg_id, anchor_server_msg_id, direction, (result) => {
83
+ if (cb) {
84
+ cb(result);
85
+ }
86
+ resolve([result]);
87
+ }, jsonExtension);
88
+ });
89
+ }
90
+ /** 在线查询消息(不包括系统消息)
91
+ * @param param 查询参数
92
+ * @param cb 在线查询消息的回调函数
93
+ * @return boolean 检查参数如果不符合要求则返回失败
94
+ * @note
95
+ * <pre>
96
+ * 200:成功
97
+ * 403:禁止访问(不在该群,只针对群组会话)
98
+ * 414:参数错误
99
+ * </pre>
100
+ */
101
+ queryMsgOnlineAsync(param, cb) {
102
+ return new Promise((resolve) => {
103
+ if (!this.msglog.QueryMsgOnlineAsync(param, (rescode, id, to_type, result) => {
104
+ if (cb) {
105
+ cb(rescode, id, to_type, result);
106
+ }
107
+ resolve([rescode, id, to_type, result]);
108
+ })) {
109
+ resolve(null);
110
+ }
111
+ });
112
+ }
113
+ /** 在线查询消息(不包括系统消息)
114
+ * @param param 查询参数
115
+ * @param cb 在线查询消息的回调函数
116
+ * @return boolean 检查参数如果不符合要求则返回失败
117
+ * @note
118
+ * <pre>
119
+ * 200:成功
120
+ * 403:禁止访问(不在该群,只针对群组会话)
121
+ * 414:参数错误
122
+ * </pre>
123
+ */
124
+ queryMsgByKeywordOnlineAsync(param, cb) {
125
+ return new Promise((resolve) => {
126
+ if (!this.msglog.QueryMsgByKeywordOnlineAsync(param, (rescode, id, to_type, result) => {
127
+ if (cb) {
128
+ cb(rescode, id, to_type, result);
129
+ }
130
+ resolve([rescode, id, to_type, result]);
131
+ })) {
132
+ resolve(null);
133
+ }
134
+ });
135
+ }
136
+ /** 根据指定条件在一个会话中查询指定单个或多个类型的本地消息
137
+ * @param to_type 会话类型,双人0,群组1 (nim_msglog_def.h)
138
+ * @param id 查询id,对方的account id或者群组tid。
139
+ * @param limit_count 本次查询的消息条数上限(最多100条)
140
+ * @param fromTime 起始时间点,单位:毫秒
141
+ * @param endTime 结束时间点,单位:毫秒
142
+ * @param endClientMsgId 结束查询的最后一条消息的end_client_msg_id(不包含在查询结果中)
143
+ * @param reverse true:反向查询(按时间正序起查,正序排列),false:按时间逆序起查,逆序排列(建议默认为false)
144
+ * @param msgType 检索的消息类型
145
+ * @param jsonExtension json扩展参数(备用,目前不需要)
146
+ * @param cb 在线查询消息的回调函数
147
+ * @return boolean 检查参数如果不符合要求则返回失败
148
+ * @note
149
+ * <pre>
150
+ * 200:成功
151
+ * </pre>
152
+ */
153
+ queryMsgOfSpecifiedTypeInASessionAsync(to_type, id, limit_count, fromTime, endTime, endClientMsgId, reverse, msgType, cb, jsonExtension) {
154
+ return new Promise((resolve) => {
155
+ if (!this.msglog.QueryMsgOfSpecifiedTypeInASessionAsync(to_type, id, limit_count, fromTime, endTime, endClientMsgId, reverse, msgType, (rescode, id, to_type, result) => {
156
+ if (cb) {
157
+ cb(rescode, id, to_type, result);
158
+ }
159
+ resolve([rescode, id, to_type, result]);
160
+ }, jsonExtension)) {
161
+ resolve(null);
162
+ }
163
+ });
164
+ }
165
+ /** 根据指定条件查询本地消息,使用此接口可以完成全局搜索等功能,具体请参阅开发手册
166
+ * @param param 查询参数
167
+ * @param cb 在线查询消息的回调函数
168
+ * @return boolean 检查参数如果不符合要求则返回失败
169
+ * @note
170
+ * <pre>
171
+ * 200:成功
172
+ * </pre>
173
+ */
174
+ queryMsgByOptionsAsync(param, cb) {
175
+ return new Promise((resolve) => {
176
+ if (!this.msglog.QueryMsgByOptionsAsync(param, (rescode, id, to_type, result) => {
177
+ if (cb) {
178
+ cb(rescode, id, to_type, result);
179
+ }
180
+ resolve([rescode, id, to_type, result]);
181
+ })) {
182
+ resolve(null);
183
+ }
184
+ });
185
+ }
186
+ /** 批量设置已读状态
187
+ * @param accid 查询id,account_id/uid或者tid
188
+ * @param to_type 会话类型,双人0,群组1 (见nim_msglog_def.h)
189
+ * @param jsonExtension json扩展参数(备用,目前不需要)
190
+ * @param cb 操作结果的回调函数
191
+ * @return boolean 检查参数如果不符合要求则返回失败
192
+ * @note
193
+ * <pre>
194
+ * 200:成功
195
+ * </pre>
196
+ */
197
+ batchStatusReadAsync(accid, to_type, cb, jsonExtension) {
198
+ return new Promise((resolve) => {
199
+ if (!this.msglog.BatchStatusReadAsync(accid, to_type, (rescode, uid, to_type) => {
200
+ if (cb) {
201
+ cb(rescode, uid, to_type);
202
+ }
203
+ resolve([rescode, uid, to_type]);
204
+ }, jsonExtension)) {
205
+ resolve(null);
206
+ }
207
+ });
208
+ }
209
+ /** 删除某个会话的全部聊天记录
210
+ * @param accid 要删除会话的id,account_id/uid或者tid
211
+ * @param to_type 会话类型,双人0,群组1 (见nim_msglog_def.h)
212
+ * @param revert_by_query_online 是否可以通过服务端查询消息记录(含入库选项)进行恢复,true:是,false:否
213
+ * @param cb 操作结果的回调函数
214
+ * @param jsonExtension json扩展参数(备用,目前不需要)
215
+ * @return boolean 检查参数如果不符合要求则返回失败
216
+ * @note
217
+ * <pre>
218
+ * 200:成功
219
+ * </pre>
220
+ */
221
+ batchStatusDeleteAsync(accid, to_type, revert_by_query_online, cb, jsonExtension) {
222
+ return new Promise((resolve) => {
223
+ if (!this.msglog.BatchStatusDeleteAsync(accid, to_type, revert_by_query_online, (rescode, uid, to_type) => {
224
+ if (cb) {
225
+ cb(rescode, uid, to_type);
226
+ }
227
+ resolve([rescode, uid, to_type]);
228
+ }, jsonExtension)) {
229
+ resolve(null);
230
+ }
231
+ });
232
+ }
233
+ /** 设置消息状态
234
+ * @param msg_id 消息id
235
+ * @param status 消息状态枚举值
236
+ * @param jsonExtension json扩展参数(备用,目前不需要)
237
+ * @param cb 操作结果的回调函数
238
+ * @return boolean 检查参数如果不符合要求则返回失败
239
+ * @note
240
+ * <pre>
241
+ * 200:成功
242
+ * </pre>
243
+ */
244
+ setStatusAsync(msg_id, status, cb, jsonExtension) {
245
+ return new Promise((resolve) => {
246
+ if (!this.msglog.SetStatusAsync(msg_id, status, (rescode, msg_id) => {
247
+ if (cb) {
248
+ cb(rescode, msg_id);
249
+ }
250
+ resolve([rescode, msg_id]);
251
+ }, jsonExtension)) {
252
+ resolve(null);
253
+ }
254
+ });
255
+ }
256
+ /** 设置消息子状态
257
+ * @param msg_id 消息id
258
+ * @param status 消息子状态枚举值
259
+ * @param jsonExtension json扩展参数(备用,目前不需要)
260
+ * @param cb 操作结果的回调函数
261
+ * @return boolean 检查参数如果不符合要求则返回失败
262
+ * @note
263
+ * <pre>
264
+ * 200:成功
265
+ * </pre>
266
+ */
267
+ setSubStatusAsync(msg_id, status, cb, jsonExtension) {
268
+ return new Promise((resolve) => {
269
+ if (!this.msglog.SetSubStatusAsync(msg_id, status, (rescode, msg_id) => {
270
+ if (cb) {
271
+ cb(rescode, msg_id);
272
+ }
273
+ resolve([rescode, msg_id]);
274
+ }, jsonExtension)) {
275
+ resolve(null);
276
+ }
277
+ });
278
+ }
279
+ /** 只往本地消息历史数据库里写入一条消息(如果已存在这条消息,则更新。通常是APP的本地自定义消息,并不会发给服务器)
280
+ * @param talkId 会话id,对方的account id或者群组tid
281
+ * @param msg 消息内容
282
+ * @param needUpdateSession 是否更新会话列表(一般最新一条消息有这个需求)
283
+ * @param composeLastMsg 如果消息历史中有该会话的消息,是否将该会话最后一条消息随会话变更上报,true 为携带,否则不携带
284
+ * @param excludeMsgType 如果 compose_last_msg = true,则可根据需要排除指定最后一条消息的类型
285
+ * @param cb 操作结果的回调函数
286
+ * @return boolean 检查参数如果不符合要求则返回失败
287
+ * @note
288
+ * <pre>
289
+ * 200:成功
290
+ * </pre>
291
+ */
292
+ writeMsglogToLocalAsync(talkId, msg, needUpdateSession, composeLastMsg, excludeMsgType, cb) {
293
+ return new Promise((resolve) => {
294
+ if (!this.msglog.WriteMsglogToLocalAsync(talkId, msg, needUpdateSession, composeLastMsg, excludeMsgType, (rescode, msg_id) => {
295
+ if (cb) {
296
+ cb(rescode, msg_id);
297
+ }
298
+ resolve([rescode, msg_id]);
299
+ })) {
300
+ resolve(null);
301
+ }
302
+ });
303
+ }
304
+ /** 删除指定会话类型的所有消息
305
+ * @param delSessions 是否删除会话
306
+ * @param to_type 会话类型
307
+ * @param revert_by_query_online 是否可以通过服务端查询消息记录(含入库选项)进行恢复,true:是,false:否
308
+ * @param jsonExtension json扩展参数(备用,目前不需要)
309
+ * @param cb 操作结果的回调函数
310
+ * @return boolean 检查参数如果不符合要求则返回失败
311
+ * @note
312
+ * <pre>
313
+ * 200:成功
314
+ * </pre>
315
+ */
316
+ deleteBySessionTypeAsync(delSessions, to_type, revert_by_query_online, cb, jsonExtension) {
317
+ return new Promise((resolve) => {
318
+ if (!this.msglog.DeleteBySessionTypeAsync(delSessions, to_type, revert_by_query_online, (rescode, msg_id, to_type) => {
319
+ if (cb) {
320
+ cb(rescode, msg_id, to_type);
321
+ }
322
+ resolve([rescode, msg_id, to_type]);
323
+ }, jsonExtension)) {
324
+ resolve(null);
325
+ }
326
+ });
327
+ }
328
+ /** 删除指定一条消息
329
+ * @param session_id 会话id,对方的account id或者群组tid
330
+ * @param to_type 会话类型
331
+ * @param msg_id 消息id
332
+ * @param jsonExtension json扩展参数(备用,目前不需要)
333
+ * @param cb 操作结果的回调函数
334
+ * @return boolean 检查参数如果不符合要求则返回失败
335
+ * @note
336
+ * <pre>
337
+ * 200:成功
338
+ * </pre>
339
+ */
340
+ deleteAsync(session_id, to_type, msg_id, cb, jsonExtension) {
341
+ return new Promise((resolve) => {
342
+ if (!this.msglog.DeleteAsync(session_id, to_type, msg_id, (rescode, msg_id) => {
343
+ if (cb) {
344
+ cb(rescode, msg_id);
345
+ }
346
+ resolve([rescode, msg_id]);
347
+ }, jsonExtension)) {
348
+ resolve(null);
349
+ }
350
+ });
351
+ }
352
+ /** 删除全部消息历史
353
+ * @param del_session 是否删除所有会话列表项(即全部最近联系人)。
354
+ ture则删除,并通过nim_session_reg_change_cb注册的回调通知上层kNIMSessionCommandRemoveAll事件(不会触发每个会话项的kNIMSessionCommandRemove事件);
355
+ false则不删除,并将所有会话项的最后一条消息的状态kNIMSessionMsgStatus设置为已删除状态,并通过nim_session_reg_change_cb注册的回调通知上层kNIMSession
356
+ CommandAllMsgDeleted事件(不会触发每个会话项的kNIMSessionCommandUpdate事件,避免频繁通知上层)。
357
+ * @param revert_by_query_online 是否可以通过服务端查询消息记录(含入库选项)进行恢复,true:是,false:否
358
+ * @param jsonExtension json扩展参数(备用,目前不需要)
359
+ * @param cb 操作结果的回调函数
360
+ * @return boolean 检查参数如果不符合要求则返回失败
361
+ * @note
362
+ * <pre>
363
+ * 200:成功
364
+ * </pre>
365
+ */
366
+ deleteAllAsync(del_session, revert_by_query_online, cb, jsonExtension) {
367
+ return new Promise((resolve) => {
368
+ if (!this.msglog.DeleteAllAsync(del_session, revert_by_query_online, (rescode) => {
369
+ if (cb) {
370
+ cb(rescode);
371
+ }
372
+ resolve([rescode]);
373
+ }, jsonExtension)) {
374
+ resolve(null);
375
+ }
376
+ });
377
+ }
378
+ /** 根据时间段删除部分会话的历史消息
379
+ * @param session_id 要删除消息的会话ID
380
+ * @param to_type 要删除消息的会话类型
381
+ * @param revert_by_query_online 是否可以通过服务端查询消息记录(含入库选项)进行恢复,true:是,false:否
382
+ * @param timestamp1 单位ms timestamp1 与 timestamp2 组成一个时间段,SDK 内部会判断大小调整入参顺序
383
+ * @param timestamp2 单位ms timestamp2 与 timestamp1 组成一个时间段,SDK 内部会判断大小调整入参顺序
384
+ * @param jsonExtension json扩展参数(备用,目前不需要)
385
+ * @param cb 操作结果的回调函数
386
+ * @return boolean 检查参数如果不符合要求则返回失败
387
+ * @note
388
+ * <pre>
389
+ * 200:成功
390
+ * </pre>
391
+ */
392
+ deleteMsgByTimeAsync(session_id, to_type, revert_by_query_online, timestamp1, timestamp2, cb, jsonExtension) {
393
+ return new Promise((resolve) => {
394
+ if (!this.msglog.DeleteMsgByTimeAsync(session_id, to_type, revert_by_query_online, timestamp1, timestamp2, (rescode) => {
395
+ if (cb) {
396
+ cb(rescode);
397
+ }
398
+ resolve([rescode]);
399
+ }, jsonExtension)) {
400
+ resolve(null);
401
+ }
402
+ });
403
+ }
404
+ /** 导出整个消息历史DB文件(不包括系统消息历史)
405
+ * @param dst_path 导出时保存的目标全路径(UTF-8编码)。
406
+ * @param jsonExtension json扩展参数(备用,目前不需要)
407
+ * @param cb 操作结果的回调函数
408
+ * @return boolean 检查参数如果不符合要求则返回失败
409
+ * @note
410
+ * <pre>
411
+ * 200:成功
412
+ * </pre>
413
+ */
414
+ exportDbAsync(dst_path, cb, jsonExtension) {
415
+ return new Promise((resolve) => {
416
+ this.msglog.ExportDbAsync(dst_path, (rescode) => {
417
+ if (cb) {
418
+ cb(rescode);
419
+ }
420
+ resolve([rescode]);
421
+ }, jsonExtension);
422
+ });
423
+ }
424
+ /** 导入消息历史DB文件(不包括系统消息历史)。先验证是否自己的消息历史文件和DB加密密钥(见nim_client_def.h里的kNIMDataBaseEncryptKey),如果验证不通过,则不导入。
425
+ * @param src_path 导入源文件的全路径(UTF-8编码)。
426
+ * @param jsonExtension json扩展参数(备用,目前不需要)
427
+ * @param cb 操作结果的回调函数
428
+ * @param prg_cb 导入进度的回调函数
429
+ * @return boolean 检查参数如果不符合要求则返回失败
430
+ * @note
431
+ * <pre>
432
+ * 200:成功
433
+ * 10600:导入消息历史时验证身份和加密密钥不通过
434
+ * 10601:导入消息历史时写记录失败
435
+ * </pre>
436
+ */
437
+ importDbAsync(src_path, cb, prg_cb, jsonExtension) {
438
+ return new Promise((resolve) => {
439
+ this.msglog.ImportDbAsync(src_path, (rescode) => {
440
+ if (cb) {
441
+ cb(rescode);
442
+ }
443
+ resolve([rescode]);
444
+ }, prg_cb, jsonExtension);
445
+ });
446
+ }
447
+ /** 发送消息已读回执
448
+ * @param msg 已读消息
449
+ * @param cb 操作结果的回调函数
450
+ * @return void 无返回值
451
+ * @note
452
+ * <pre>
453
+ * 200:成功
454
+ * 403:服务器关闭此功能,或者应用没权限
455
+ * 404:请求的目标(用户或对象)不存在
456
+ * 10414:本地错误码,参数错误
457
+ * </pre>
458
+ */
459
+ sendReceiptAsync(msg, cb) {
460
+ return new Promise((resolve) => {
461
+ this.msglog.SendReceiptAsync(msg, (result) => {
462
+ if (cb) {
463
+ cb(result);
464
+ }
465
+ resolve([result]);
466
+ });
467
+ });
468
+ }
469
+ /** 查询自己发送的消息是否被对方已读
470
+ * @param msg 消息。
471
+ * @return boolean 是否被已读
472
+ */
473
+ querySentMessageBeReaded(msg) {
474
+ return this.msglog.QuerySentMessageBeReaded(msg);
475
+ }
476
+ /** 查询收到的消息是否已经发送过已读回执
477
+ * @param msg 消息。
478
+ * @return boolean 是否已发送过
479
+ */
480
+ queryReceivedMsgReceiptSent(msg) {
481
+ return this.msglog.QueryReceivedMsgReceiptSent(msg);
482
+ }
483
+ /** 更新本地消息扩展字段内容
484
+ * @param msg_id 消息id
485
+ * @param local_ext 本地扩展字段内容
486
+ * @param jsonExtension json扩展参数(备用,目前不需要)
487
+ * @param cb 操作结果的回调函数
488
+ * @return boolean 检查参数如果不符合要求则返回失败
489
+ * @note
490
+ * <pre>
491
+ * 200:成功
492
+ * </pre>
493
+ */
494
+ updateLocalExtAsync(msg_id, local_ext, cb, jsonExtension) {
495
+ return new Promise((resolve) => {
496
+ this.msglog.UpdateLocalExtAsync(msg_id, local_ext, (rescode, local_ext) => {
497
+ if (cb) {
498
+ cb(rescode, local_ext);
499
+ }
500
+ resolve([rescode, local_ext]);
501
+ }, jsonExtension);
502
+ });
503
+ }
504
+ /** 全部未读消息历史标记为已读
505
+ * @param jsonExtension json扩展参数(备用,目前不需要)
506
+ * @param cb 操作结果的回调函数
507
+ * @return boolean 检查参数如果不符合要求则返回失败
508
+ * @note
509
+ * <pre>
510
+ * 200:成功
511
+ * </pre>
512
+ */
513
+ readAllAsync(cb, jsonExtension) {
514
+ return new Promise((resolve) => {
515
+ this.msglog.ReadAllAsync((rescode) => {
516
+ if (cb) {
517
+ cb(rescode);
518
+ }
519
+ resolve([rescode]);
520
+ }, jsonExtension);
521
+ });
522
+ }
523
+ /** 导出本地消息记录到云端
524
+ * @param export_info 导出需要的参数参考LogsBackupExportInfo定义
525
+ * @return boolean false : 当前有导入/导出操作正在进行中
526
+ */
527
+ exportBackupToRemote(export_info) {
528
+ return this.msglog.ExportBackupToRemote(export_info);
529
+ }
530
+ /** 导入已备份在云端的消息记录
531
+ * @param import_info 导入需要的参数参考LogsBackupImportInfo定义
532
+ * @return boolean false : 当前有导入/导出操作正在进行中
533
+ */
534
+ importBackupToRemote(export_info) {
535
+ return this.msglog.ImportBackupToRemote(export_info);
536
+ }
537
+ /** 取消导入已备份在云端的消息记录
538
+ * @return void
539
+ */
540
+ cancelImportBackupFromRemote() {
541
+ return this.msglog.CancelImportBackupFromRemote();
542
+ }
543
+ /** 取消导出本地消息记录到云端
544
+ * @return void
545
+ */
546
+ cancelExportBackupToRemote() {
547
+ return this.msglog.CancelExportBackupToRemote();
548
+ }
549
+ /** 删除与某账号的所有云端历史记录与漫游消息(p2p)
550
+ * @param accid 对方的accid
551
+ * @param del_remote 是否同时删除所有的漫游消息 true : 是 false : 否
552
+ * @param jsonExtension json扩展参数(备用,目前不需要)
553
+ * @param cb 操作结果的回调函数
554
+ * @return void
555
+ * @note
556
+ * <pre>
557
+ * 200:成功
558
+ * </pre>
559
+ */
560
+ deleteHistoryOnlineAsync(accid, del_remote, jsonExtension, cb) {
561
+ return new Promise((resolve) => {
562
+ this.msglog.DeleteHistoryOnlineAsync(accid, del_remote, jsonExtension, (rescode, accid) => {
563
+ if (cb) {
564
+ cb(rescode, accid);
565
+ }
566
+ resolve([rescode, accid]);
567
+ });
568
+ });
569
+ }
570
+ /** 删除某一会话的云端的历史记录[v8.0.0]
571
+ * @param accid 对方的accid(p2p:accid team:tid)
572
+ * @param to_type 会话类型,双人0,群组1 (见nim_msglog_def.h)
573
+ * @param needs_notify_self 是否通知其它终端
574
+ * @param jsonExtension 扩展字段
575
+ * @param cb 操作结果的回调函数
576
+ * @return void
577
+ * @note 错误码 200:成功
578
+ */
579
+ deleteHistoryOnlineAsyncEx(accid, to_type, needs_notify_self, jsonExtension, cb) {
580
+ return new Promise((resolve) => {
581
+ this.msglog.DeleteHistoryOnlineAsyncEx(accid, to_type, needs_notify_self, jsonExtension, (rescode, accid, to_type, timestamp, jsonExtension) => {
582
+ if (cb) {
583
+ cb(rescode, accid, to_type, timestamp, jsonExtension);
584
+ }
585
+ resolve([rescode, accid, to_type, timestamp, jsonExtension]);
586
+ });
587
+ });
588
+ }
589
+ /** 单向删除某条消息记录(同时删除本地与云端)
590
+ * @param msg 要删除的消息
591
+ * @param exts 用户自定义扩展字段
592
+ * @param cb 操作结果的回调函数
593
+ * @return void 无返回值
594
+ * @note
595
+ * <pre>
596
+ * 200:成功
597
+ * </pre>
598
+ */
599
+ deleteMessageSelfAsync(msg, ext, cb) {
600
+ return new Promise((resolve) => {
601
+ this.msglog.DeleteMessageSelfAsync(msg, ext, (rescode) => {
602
+ if (cb) {
603
+ cb(rescode);
604
+ }
605
+ resolve([rescode]);
606
+ });
607
+ });
608
+ }
609
+ /** 查询某条消息是否为thread聊天的根消息
610
+ * @param client_id 要查询的消息的客户端ID
611
+ * @param cb 操作结果的回调函数
612
+ * @return void 无返回值
613
+ * @note
614
+ * <pre>
615
+ * 200:成功
616
+ * </pre>
617
+ */
618
+ queryMessageIsThreadRoot(client_id, cb) {
619
+ return new Promise((resolve) => {
620
+ this.msglog.QueryMessageIsThreadRoot(client_id, (rescode, client_id, is_thread_root) => {
621
+ if (cb) {
622
+ cb(rescode, client_id, is_thread_root);
623
+ }
624
+ resolve([rescode, client_id, is_thread_root]);
625
+ });
626
+ });
627
+ }
628
+ /** 查询某条消息的具体内容一般用在thread talk 场景中
629
+ * @param param 要查询的消息的相关参数,可以在msglog.threadinfo中得到
630
+ * @param cb 查询结果的回调函数
631
+ * @return void 无返回值
632
+ * @note
633
+ * <pre>
634
+ * 200:成功
635
+ * </pre>
636
+ */
637
+ queryMessageOnline(param, cb) {
638
+ return new Promise((resolve) => {
639
+ this.msglog.QueryMessageOnline(param, (rescode, param, msg) => {
640
+ if (cb) {
641
+ cb(rescode, param, msg);
642
+ }
643
+ resolve([rescode, param, msg]);
644
+ });
645
+ });
646
+ }
647
+ /** 分页查询thread talk消息历史
648
+ * @param msg 要查询的消息
649
+ * @param param 要查询的消息的相关参数,可以在msglog.threadinfo中得到
650
+ * @param cb 查询结果的回调函数
651
+ * @return void 无返回值
652
+ * @note
653
+ * <pre>
654
+ * 200:成功
655
+ * </pre>
656
+ */
657
+ queryThreadHistoryMsg(msg, param, cb) {
658
+ return new Promise((resolve) => {
659
+ this.msglog.QueryThreadHistoryMsg(msg, param, (rescode, root_msg, total, last_msg_time, msg_array) => {
660
+ if (cb) {
661
+ cb(rescode, root_msg, total, last_msg_time, msg_array);
662
+ }
663
+ resolve([rescode, root_msg, total, last_msg_time, msg_array]);
664
+ });
665
+ });
666
+ }
667
+ /** 在线全文检索
668
+ * @param param 全文检索参数
669
+ * @param cb 全文检索结果回调函数
670
+ * @return void 无返回值
671
+ * @note
672
+ * <pre>
673
+ * 200:成功
674
+ * </pre>
675
+ */
676
+ fullTextSearchOnlineAsync(param, cb) {
677
+ return new Promise((resolve) => {
678
+ this.msglog.FullTextSearchOnlineAsync(param, (rescode, result) => {
679
+ if (cb) {
680
+ cb(rescode, result);
681
+ }
682
+ resolve([rescode, result]);
683
+ });
684
+ });
685
+ }
686
+ }
687
+ exports.NIMMsgLog = NIMMsgLog;
688
688
  //# sourceMappingURL=msglog.js.map