diff --git a/src/client/puppet-service.ts b/src/client/puppet-service.ts index 8d2bcce9..b6375533 100644 --- a/src/client/puppet-service.ts +++ b/src/client/puppet-service.ts @@ -744,12 +744,20 @@ class PuppetService extends PUPPET.Puppet { * Conversation * */ - override conversationReadMark ( + override async conversationReadMark ( conversationId: string, hasRead = true, ) : Promise { log.verbose('PuppetService', 'conversationMarkRead(%s, %s)', conversationId, hasRead) - return PUPPET.throwUnsupportedError('not implemented. See https://github.com/wechaty/wechaty-puppet/pull/132') + + const request = new grpcPuppet.ConversationReadRequest() + request.setConversationId(conversationId) + request.setHasRead(hasRead) + await util.promisify( + this.grpcManager.client.conversationRead + .bind(this.grpcManager.client), + )(request) + } /** diff --git a/src/server/puppet-implementation.ts b/src/server/puppet-implementation.ts index 02f7312a..7ee55449 100644 --- a/src/server/puppet-implementation.ts +++ b/src/server/puppet-implementation.ts @@ -94,6 +94,21 @@ function puppetImplementation ( const puppetServerImpl: grpcPuppet.IPuppetServer = { + conversationRead: async (call, callback) => { + log.verbose('PuppetServiceImpl', 'conversationRead()') + + try { + const conversationId = call.request.getConversationId() + const hasRead = call.request.getHasRead() + await puppet.conversationReadMark(conversationId, hasRead) + + const response = new grpcPuppet.ConversationReadResponse() + return callback(null, response) + } catch (e) { + return grpcError('currentUser', e, callback) + } + }, + contactAlias: async (call, callback) => { log.verbose('PuppetServiceImpl', 'contactAlias()')