Skip to content

Commit 79d7db9

Browse files
committed
chore: bump version 9.16.3
Signed-off-by: Dylan <[email protected]>
1 parent 5e13503 commit 79d7db9

File tree

7 files changed

+283
-76
lines changed

7 files changed

+283
-76
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"printWidth": 160,
3-
"tabWidth": 4,
3+
"tabWidth": 2,
44
"singleQuote": true,
55
"semi": false,
66
"bracketSpacing": true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-nim",
3-
"version": "9.16.2",
3+
"version": "9.16.3",
44
"description": "NetEase IM nodejs wrapper based on NetEase IM C++ SDK",
55
"main": "dist/node-nim.js",
66
"bin": {

src/nim/msglog/nim_node_msglog.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ Napi::Object NIMMsgLog::Init(Napi::Env env, Napi::Object exports) {
4040
RegApi("QueryMessageIsThreadRoot", &MsgLog::QueryMessageIsThreadRoot), RegApi("QueryMessageOnline", &MsgLog::QueryMessageOnline),
4141
RegApi("QueryThreadHistoryMsg", &MsgLog::QueryThreadHistoryMsg),
4242
RegApi("QueryLocalThreadHistoryMsg", &MsgLog::QueryLocalThreadHistoryMsg),
43-
RegApi("FullTextSearchOnlineAsync", &MsgLog::FullTextSearchOnlineAsync)});
43+
RegApi("FullTextSearchOnlineAsync", &MsgLog::FullTextSearchOnlineAsync),
44+
RegApi("QueryMessagesByKeywordAsync", &MsgLog::QueryMessagesByKeywordAsync),
45+
RegApi("IsMessageIndexEstablished", &MsgLog::IsMessageIndexEstablished), RegApi("BuildMsglogIndexes", &MsgLog::BuildMsglogIndexes),
46+
RegApi("CancelMsglogIndexesBuilding", &MsgLog::CancelMsglogIndexesBuilding)});
4447
}
4548

4649
void NIMMsgLog::InitEventHandlers() {

src/reflection/nim_msglog_reflection.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ ReflectionDefinition_O(MsgLog::QueryMsgByOptionsAsyncParam,
126126
msg_type_,
127127
msg_sub_type_,
128128
search_content_);
129+
ReflectionDefinition_O(MsgLog::QueryMsgByKeywordParam,
130+
keyword_,
131+
account_id_,
132+
to_type_,
133+
type_,
134+
limit_count_,
135+
from_time_,
136+
end_time_,
137+
direction_,
138+
segment_engine_,
139+
enable_pinyin_);
129140

130141
// Callback
131142
CallbackSpecialization(MsgLog::QueryMsgCallback);
@@ -140,6 +151,9 @@ CallbackSpecialization(MsgLog::DeleteHistoryOnLineNotifyCallback);
140151
CallbackSpecialization(MsgLog::QueryMessageIsThreadRootAsyncCallback);
141152
CallbackSpecialization(MsgLog::QueryThreadHistoryMsgCallback);
142153
CallbackSpecialization(MsgLog::FullTextSearchOnlineAsyncCallback);
154+
CallbackSpecialization(MsgLog::IsMessageIndexEstablishedCallback);
155+
CallbackSpecialization(MsgLog::BuildMsglogIndexesProgress);
156+
CallbackSpecialization(MsgLog::BuildMsglogIndexesComplete);
143157

144158
// xpack specialization
145159
namespace xpack {

test/test_msglog.js

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const NIM = require('../../dist/node-nim')
1+
const NIM = require('../dist/node-nim')
22
const assert = require('assert')
33

44
const msglog = new NIM.NIMMsgLog()
5+
const talk = new NIM.NIMTalk()
56

67
describe('********************Msglog********************', function () {
78
let signalMsgId = ''
@@ -491,4 +492,69 @@ describe('******************** Msglog thread ********************', function ()
491492
assert.ok(replyCount > 0)
492493
})
493494
})
495+
describe('#queryMessagesByKeywordAsync', () => {
496+
it('Query messages by keyword should return with query keyword', async () => {
497+
const result = await NIM.nim.msgLog.queryMessagesByKeywordAsync({
498+
keyword_: '测试',
499+
type_: [0],
500+
limit_count_: 1000,
501+
})
502+
assert.strictEqual(result[3].msglogs_.length, 1000)
503+
})
504+
it('Query messages by option with content should return with query keyword', async () => {
505+
const result = await NIM.nim.msgLog.queryMsgByOptionsAsync({
506+
query_range_: 100,
507+
ids: [],
508+
from_time_: 0,
509+
end_time_: 0,
510+
limit_count_: 1000,
511+
msg_sub_type_: 0,
512+
msg_type_: 0,
513+
reverse_: true,
514+
search_content_: '测试',
515+
})
516+
assert.strictEqual(result[3].msglogs_.length, 1000)
517+
})
518+
});
519+
describe('#queryMessagesByKeywordAsync', () => {
520+
before(async function () {
521+
for (let i = 0; i < 10; i++) {
522+
let obj = {
523+
session_type_: 0, // p2p
524+
receiver_accid_: 'jiajia02',
525+
timetag_: new Date().getTime(),
526+
type_: 0, // text message
527+
content_: `Test message sent by node-nim, message index ${i}`,
528+
client_msg_id_: new Date().getTime().toString() // use an uuid
529+
}
530+
await talk.sendMsg(obj, '')
531+
}
532+
})
533+
it('Query messages by keyword result should return with Test message', async function () {
534+
const result = await NIM.nim.msgLog.queryMessagesByKeywordAsync({
535+
keyword_: 'Test message',
536+
type_: [0],
537+
limit_count_: 10
538+
})
539+
assert.strictEqual(result[3].msglogs_.length, 10)
540+
result[3].msglogs_.map((message) => {
541+
assert.strictEqual(message.content_.includes('Test message'), true)
542+
})
543+
})
544+
});
545+
describe('#buildMsglogIndexes', () => {
546+
it('buildMsglogIndexes should return with complete', async function () {
547+
const [reason, message] = await NIM.nim.msgLog.buildMsglogIndexes(5000, (total, built) => {
548+
console.log(`Total: ${total}, Built: ${built}`)
549+
})
550+
console.log('reason', reason, message)
551+
assert.strictEqual(reason, 0)
552+
})
553+
})
554+
describe('#isMsglogIndexesEstablished', () => {
555+
it('isMsglogIndexesEstablished should return with true', async function () {
556+
const established = await NIM.nim.msgLog.isMessageIndexEstablished()
557+
assert.strictEqual(established, true)
558+
})
559+
})
494560
})

0 commit comments

Comments
 (0)